PS: [PHP-WIN] Double Click file to have it open in Windows Explorer
| From: | (Sven Schnitzke) | Date: | Sat, 17 May 2003 16:09:48 +0000 |
| Subject: | PS: [PHP-WIN] Double Click file to have it open in Windows Explorer | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-19983@lists.php.net to get a copy of this message | ||
Straightening a little glitch:
When on WIN98 and using PHP as Apache ISAPI module
the proposed start script will hang Apache and PHP (only
one thread at hand!).
But that can be avoided using popen() instead of system() to
start the browser (thanks diggn aka malte):
<?php
$path_to_browser = "C:\WINDOWS\IEXPLORE.EXE";
// or anything else appropriate; eventually add options too
// here you might need a lookup if you have virtual hosts
$root_as_seen_from_web = 'htdocs/';
$server_name = 'localhost/'; // e.g.; maybe not the only one
if (!isset($argv[1])) {
exit("No path specified.");
} else {
$path = $argv[1];
}
$path = str_replace("\\", "/", $path);
$path = str_replace("//", "/", $path);
// very comfortable would be scanning apaches conf file ... (howto get knowledge using IIS, PWS,
...?)
$pos = strpos($path, $root_as_seen_from_web);
$pos += (strlen($root_as_seen_from_web));
$fp = popen("$path_to_browser http://$server_name$root_as_seen_from_web"
. substr(path, $pos),"w");
fclose($fp);
?>
Sven