Hello,
I wonder if anyone can help me with a problem I have. I have some sites
hosted on a Cobalt Raq4 server (not sure if this is relevant). I recently
upgraded PHP from a package at www.pkgmaster.com, and since making this
upgrade I have problems with PHP that I cannot find the solution to.
I have conacted their 'team' who have thus far offered no explanation,
saying it must be something else causing these issues with PHP, but I
haven't made any more changes, just installed the new PHP version.
The problems are with the mail() function taking an AGE to excecute, and
environmental HTTP header information not being sent/recieved by getenv().
Some examples follow..
For example, as an extremely basic example of the mail function going slow,
this simple script:
<?
mail("[EMAIL PROTECTED]", "Test subject", "Test message");
print "finished!";
?>
Which can be found at http://www.clicktolearn.co.uk/test/mail.php in action,
ran (as it should do) extremely fast the week before I made the upgrade from
the packages. Now, as you will see, it runs dog slow.
Secondly, the following script shows the lack of headers:
http://www.clicktolearn.co.uk/test/ (click the link, so there's a referer
to the script page)...
<?
function get_http_headers($url, $proto="HTTP/1.0", $timeout=10) {
$return = false;
if (substr($url,0,7)=="http://") {
$url = substr($url,7);
}
$parts = parse_url("http://".$url);
$ips = gethostbynamel($parts["host"]);
if ($ips[0]) {
$ip = $ips[0];
$host = $parts["host"];
$path = ($parts["path"]) ? $parts["path"] : "/";
$port = ($parts["port"]) ? $parts["port"] : 80;
$start = time();
$timeout = $timeout + $start;
if($sock = fsockopen($host, $port)) {
set_socket_blocking($sock, 0);
switch($proto) {
case "HTTP/1.1":
set_socket_blocking($sock, 1);
fputs($sock, sprintf("HEAD %s %s\n",
$path, $proto));
fputs($sock, sprintf("Host: %s\n\n",
$host));
break;
default:
fputs($sock, sprintf("HEAD %s
%s\n\n", $path, $proto));
}
while(!feof($sock) && $t<$timeout) {
$line .= fgets($sock,1);
$t = time();
}
fclose($sock);
$end = time();
if ($t>=$timeout) {
$http = parse_output($line);
$http["result"] = 502;
$http["message"] = "Timed Out";
$http["time_used"] = $end - $start;
$return = $http;
} elseif($line) {
$http = parse_output($line);
$http["time_used"] = $end - $start;
$return = $http;
}
}
}
return $return;
}
function parse_output($line) {
$lines = explode("\n", $line);
if(substr($lines[0],0,4)=="HTTP") {
list($http["protocol"], $http["result"], $http["message"]) =
split("[[:space:]]+",$lines[0],3);
} else if(substr($lines[0],0,7)=="Server:") {
$http["server"] = substr($lines[0],8);
}
for ($i=1; $i<count($lines); $i++) {
list($key, $val) = split(":[[:space:]]*", $lines[$i],2);
$key = strtolower(trim($key));
if ($key) {
$http[$key] = trim($val);
} else {
break;
}
}
return($http);
};
var_dump(getallheaders());
print "<br><br>";
var_dump(get_http_headers('http://www.clicktolearn.co.uk/test/testheaders.ph
p'));
print "<br><br>";
print $HTTP_REFERER;
print "<br><br>";
print "<a href='Javascript: history.back();'>Back</a>";
print "<br><br>";
var_dump(getenv($HTTP_REFERER));
?>
Under the "Back" link is the output of: var_dump(getenv($HTTP_REFERER));
Now I know that this was working before the upgrade, as a log in script I
use on the main site uses getenv($HTTP_REFERER) to send them back to where
they came from. This again worked 100% fine before PHP upgrade.
Sorry to take up your time, but there is a problem somewhere that has
certainly only begun with PHP since I upgraded to 4.1.2, and I dont know
what it could be!?
Thanks in advance.
Paul Mullett
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php