note 54003 added to ref.exec
| From: | php-general at lists dot php dot net | Date: | Mon, 20 Jun 2005 17:40:14 +0000 |
| Subject: | note 54003 added to ref.exec | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-90705@lists.php.net to get a copy of this message | ||
Comment to code posted by info at skyco dot de:
On Apache 1 and PHP 5, the code didn't work as expected?
Something like this worked better:
<?
// put this in the calling file:
function callWebsite($strHost, $strPath="/") {
// try opening the connection
$fFile = @fsockopen($strHost, 80, $intError, $strError);
if ($fFile) {
// make a simple GET-command
$strCommand = "GET ".$strPath."\r\n";
// send the command
fwrite($fFile, $strCommand);
// close connection
fclose($fFile);
return true;
} else {
// report error
echo "Could not connect to ".$strHost. " (".$intError.")
".$strError.".");
return false;
}
}
// call like you were outside yourself... (127.0.0.1=your own computer)
callWebsite("127.0.0.1", "/yourpath/yourfile.php?example_variable=24");
?>
<?
// and do this in the file that should run on it's own:
ignore_user_abort(true);
// if it should run longer than timeout, do this:
set_time_limit(0);
// put your code below here
?>
Your last file could be tested in telnet too. To do this, enter this using the command prompt:
telnet www.yourhost.com 80<enter>
GET /thepathtoyourfile/file.php?hello=yes<enter>
----
Manual Page -- http://www.php.net/manual/en/ref.exec.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+54003
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+54003&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+54003&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+54003&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+54003&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+54003&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+54003&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+54003&report=yes
Search -- http://master.php.net/manage/user-notes.php