Jump to content

Help with register_globals


lew14

Recommended Posts

I have several scripts that require register_globals.  I do not use globals for security reasons.  Is there a way to recode so the script will work without it?

 

The code I am trying to change is:

foreach (array_keys($GLOBALS) as $i) {if(!isset(${$i})) global ${$i};}

and

function brotator($br_rid) {

global $url,$dbhost,$dbuser,$dbpass,$dbname;

$db = mysql_pconnect($dbhost, $dbuser, $dbpass) or die("Could not connect");

 

I have included the actaul file also.

 

Thanks for any help you can give me.

 

 

[attachment deleted by admin]

Link to comment
https://forums.phpfreaks.com/topic/237300-help-with-register_globals/
Share on other sites

The first bit of code imports global variables into a scope (such as function scope). That doesn't need any changing.

 

For the second bit, the four $db variables are probably defined somewhere - not from form input. $url, on the other hand, might be from a form, in which case a simple

$url = $_POST["url"]; // or $_GET["url"]

at the beginning of the function would be enough.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.