...

View Full Version : register_globals Not Functioning Properly!



baaaan
06-09-2006, 05:50 PM
We are currently having quite the dilemma when it comes to register_globals.

We are setting up register_globals on a local, as-needed basis. We have a "test" directory on our server and have register_globals turned on locally for this directory. If you run phpinfo() within this directory, it tells you that register_globals are "On" for the local value and "Off" for the master value.

However .. it seems that register_globals aren't actually enabled, despite what the phpinfo() information says. I run the following script to act as a simple test, as it's clear that I can't rely on the configuration settings themselves:


<form method="post" action="globalstest.php?result=1">
<input type="hidden" name="testvalue" value="true" />
<input type="submit" value="Click to Test" />
</form>

<?php

if($_GET['result']) {
if($testvalue == "true") {
echo "<p>(POST) Register globals are on.</p>";
} else {
echo "<p>(POST) Register globals are <strong>not</strong> on.</p>";
}


}

?>


Can anyone provide any insight? We've tried the same thing on another server (both are running IIS) and we are having the same issue.

Thanks!

marek_mar
06-09-2006, 07:13 PM
register_globals should be off anyways as if you try to develop with it on your code, apart from potential security holes, will stop working with PHP6.
A good way to check if register globals is on is this:


<?php
if (@ini_get('register_globals') == '1' || strtolower(@ini_get('register_globals')) == 'on')
{
// register_globals on
}
?>

baaaan
06-09-2006, 07:47 PM
At this point, it's not any of my concern what the configuration files tell me. It's whether or not a very simple test of register_globals that I run (the script I pasted above) works.. at this point, it does not. My main question is whether or not the script I posted is a sure-fire way to test to see whether or not register_globals are enabled.

dumpfi
06-09-2006, 11:24 PM
I don't know why your test should not work, however this does work:
<html>
<head>

</head>
<body>
<?php
echo (TRUE == isset($_POST['test'])) ?
((TRUE == isset($test)) ?
'register_globals is <strong>enabled</strong>.' :
'register_globals is <strong>disabled</strong>.') :
//'<a href="?test=1">Test if register_globals is enabled</a>';
'<form method="post"><input type="hidden" name="test" value="1"><input type="submit" value="Test if register_globals is enabled"></form>';
?>
</body>
</html>dumpfi



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum