Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 02-23-2006, 04:52 PM
Learning Learning is offline
 
Join Date: Feb 2006
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default mysql_connect security issue

Hi, (I'll try this again, this time in the right forum :nervous

Please forgive my newbie question, but is using mysql_connect from vb to insert info into a second database a security risk?

Is using the database name, user name and password safe from those viewing the forum?

Thanks,
still Larning.

Is this question too difficult, or too retarded?
Reply With Quote
  #2  
Old 02-24-2006, 12:05 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

hmm, actually i don't really understand where there should be an issue.

vb makes a connecten to a db, but that is totally isolated from a second connection, so if you write your scripts carefully, a second db connection is no security risk
Reply With Quote
  #3  
Old 02-24-2006, 03:11 PM
Learning Learning is offline
 
Join Date: Feb 2006
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you for replying Xenon.

I simply do not know much about database connections, so am unsure as to the correct way of connecting 2 databases.

Would the following constitute a safe connection?

Code:
//connecting to second database
$dbtest = @mysql_connect("host","name","pass",true) or die ("no connection possible");    
mysql_select_db("database",$dbtest) or die ("no db"); 
$a = mysql_query("
				SELECT something
				FROM " . TABLE_PREFIX . "sometable
			 ");
while ($row = mysql_fetch_assoc($a))
{
	foreach ($row as $field_name => $field_value)
	echo $field_name . " : " .$field_value;
}

mysql_close($dbtest);
This must not be a very exciting topic to most people but I would like to know whether I am doing it right. Since this code and related password are in a PHP file, I assume no one visiting my site (viewing the results from that php file) can actualy view the code itself.

Thanks in advance.
Reply With Quote
  #4  
Old 02-24-2006, 03:16 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

from what i see, there is no security problem in the code, just two things to think about:

1) vb3.5 allows a second connection set up from within config.php afaik, which could make things a bit easier for you
2) are you sure you need TABLE_PREFIX in your query, as you are connecting to a second db, no the vb one, that could produce an error.

as for the security again: yep that's ok, as noone could directly view into the php files and see the pw
Reply With Quote
  #5  
Old 02-24-2006, 03:43 PM
filburt1 filburt1 is offline
 
Join Date: Feb 2002
Location: Maryland, US
Posts: 6,144
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It's only a security risk if injection is possible such that the username/password/database/server/query can be read/altered. As for performance, that depends on how MySQL is set up.
Reply With Quote
  #6  
Old 02-24-2006, 03:54 PM
Paul M's Avatar
Paul M Paul M is offline
 
Join Date: Sep 2004
Location: Nottingham, UK
Posts: 23,748
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Xenon
1) vb3.5 allows a second connection set up from within config.php afaik, which could make things a bit easier for you
The dual server settings in vb don't work like he wants, you can have a read server and a write server, but you have to set-up replication from the write server to the read server.
Reply With Quote
  #7  
Old 02-24-2006, 09:01 PM
Learning Learning is offline
 
Join Date: Feb 2006
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This is great stuff.
Thanks guys, I do appreciate your replies and info.
At least I’m on the right track and my learning curve can now continue / expand.
Cheers.
Reply With Quote
  #8  
Old 02-26-2006, 09:12 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Paul M
The dual server settings in vb don't work like he wants, you can have a read server and a write server, but you have to set-up replication from the write server to the read server.

seem si have to look at that feature again.
couldn't test it as locally i just have one and never saw a need for it
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:25 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04450 seconds
  • Memory Usage 2,230KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (8)post_thanks_box
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete