PHP 4.0 Bug #4321: <?php_track_vars?> does not always work
| From: | patrick at spacesurfer dot com | Date: | Thu, 04 May 2000 13:52:18 +0000 |
| Subject: | PHP 4.0 Bug #4321: <?php_track_vars?> does not always work | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-18414@lists.php.net to get a copy of this message | ||
From: patrick@spacesurfer.com
Operating system: linux 2.2
PHP version: 4.0 Release Candidate 1
PHP Bug Type: Scripting Engine problem
Bug description: <?php_track_vars?> does not always work
I am running:
Apache/1.3.12 (Unix) mod_perl/1.21 PHP/4.0RC1 mod_ssl/2.6.2 OpenSSL/0.9.5
and I am getting an intermittent problem with <?php_track_vars?>
I have track_vars off as default but in one script I turn them on by putting
<?php_track_vars?> in the first line of code. Most of the time all works fine but every so
often the relevant variable ($HTTP_GET_VARS or $HTTP_POST_VARS) is not there. I have the following
code in the page to test for the relevant variable:
// DEBUG
$fp=fopen("/tmp/".$Script, "w+");
fputs($fp, "action=".$action." email=".$email."
key=".$key."\n");
$vars=array();
if ($HTTP_GET_VARS) {fputs($fp, "GET\n"); $vars=array_merge($vars, $HTTP_GET_VARS);}
if ($HTTP_POST_VARS) {fputs($fp, "POST\n"); $vars=array_merge($vars, $HTTP_POST_VARS);}
foreach(array_keys($vars) as $vn)
{
fputs($fp, $vn."=".$vars[$vn]." ");
}
fputs($fp, "\n");
fclose($fp);
// END DEBUG
$action, $email, $key are all passed either by GET or POST and are not set within the script. Every
so often the temp file has values for the former three variables, but neither $HTTP_GET_VARS
$HTTP_POST_VARS exist!
I realise it is very hard to fix such a problem (It took me ages to detect it), but I am willing to
help.
You can see the entire script below:
<?php_track_vars?>
<?php
global $SCRIPT_NAME;
global $SCRIPT_FILENAME;
$tmp=split("/", $SCRIPT_FILENAME);
array_pop($tmp);
$RFn=join("/", $tmp);
$tmp=split("/", $SCRIPT_NAME);
$Script=array_pop($tmp);
$Fn=$RFn."/d/gen/SecureTransfer/".$Script;
if (file_exists($Fn))
{
include "$Fn";
unlink("$SCRIPT_FILENAME");
unlink("$Fn");
include "index.php";
}
else
{
include "GlobalVars.phpi";
GlobalInclude("HtmlHead.phpi");
GlobalInclude("AuthComplex.phpi");
$fp=fopen($Fn, "w+");
flock($fp, LOCK_EX);
fputs($fp, "<?php ");
$vars=array();
global $HTTP_GET_VARS;
global $HTTP_POST_VARS;
if ($HTTP_GET_VARS) {$vars=array_merge($vars, $HTTP_GET_VARS);}
if ($HTTP_POST_VARS) {$vars=array_merge($vars, $HTTP_POST_VARS);}
foreach(array_keys($vars) as $vn)
{
fputs($fp, "$".$vn."=\"".$vars[$vn]."\"; ");
}
fputs($fp, "?>");
flock($fp, LOCK_UN);
fclose($fp);
// DEBUG
$fp=fopen("/tmp/".$Script, "w+");
fputs($fp, "action=".$action." email=".$email."
key=".$key."\n");
$vars=array();
if ($HTTP_GET_VARS) {fputs($fp, "GET\n"); $vars=array_merge($vars, $HTTP_GET_VARS);}
if ($HTTP_POST_VARS) {fputs($fp, "POST\n"); $vars=array_merge($vars, $HTTP_POST_VARS);}
foreach(array_keys($vars) as $vn)
{
fputs($fp, $vn."=".$vars[$vn]." ");
}
fputs($fp, "\n");
fclose($fp);
// END DEBUG
global $SERVER_NAME;
$url="http://".$SERVER_NAME.$SCRIPT_NAME;
echo '<META HTTP-EQUIV="Refresh" CONTENT="0;
URL='.$url.'">';
include "i/secure.phpi";
}
?>