Compare commits
2 commits
c49cecf3a6
...
c55d4afa87
Author | SHA1 | Date | |
---|---|---|---|
c55d4afa87 | |||
34f38557c5 |
2 changed files with 13 additions and 23 deletions
|
@ -1,22 +1,14 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
// Adapted from https://wiki.archlinux.org/index.php/Awstats
|
||||||
* Run old CGI applications through PHP
|
|
||||||
* @author Adrian Kousz
|
|
||||||
* @link https://wiki.archlinux.org/index.php/Awstats Source
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Prepare environment
|
// Prepare environment
|
||||||
|
|
||||||
$newenv = $_SERVER;
|
$newenv = $_SERVER;
|
||||||
$xScriptFilename = $_SERVER["X_SCRIPT_FILENAME"];
|
$newenv["SCRIPT_FILENAME"] = $_SERVER["X_SCRIPT_FILENAME"];
|
||||||
$xScriptName = $_SERVER["X_SCRIPT_NAME"];
|
$newenv["SCRIPT_NAME"] = $_SERVER["X_SCRIPT_NAME"];
|
||||||
$newenv["SCRIPT_FILENAME"] = $xScriptFilename;
|
|
||||||
$newenv["SCRIPT_NAME"] = $xScriptName;
|
|
||||||
|
|
||||||
// Check file
|
if (!is_executable($_SERVER["X_SCRIPT_FILENAME"]) || is_dir($_SERVER["X_SCRIPT_FILENAME"]))
|
||||||
|
|
||||||
if (!is_executable($xScriptFilename) || is_dir($xScriptFilename))
|
|
||||||
error_exit(404, 'Not Found');
|
error_exit(404, 'Not Found');
|
||||||
|
|
||||||
// Open process
|
// Open process
|
||||||
|
@ -27,7 +19,7 @@ $descriptorspec = array(
|
||||||
array('pipe', 'w'),
|
array('pipe', 'w'),
|
||||||
);
|
);
|
||||||
$pipes = array();
|
$pipes = array();
|
||||||
$process = proc_open($xScriptFilename, $descriptorspec, $pipes, null, $newenv);
|
$process = proc_open($_SERVER["X_SCRIPT_FILENAME"], $descriptorspec, $pipes, null, $newenv);
|
||||||
|
|
||||||
if (!is_resource($process))
|
if (!is_resource($process))
|
||||||
error_exit(500, 'Internal Server Error');
|
error_exit(500, 'Internal Server Error');
|
||||||
|
@ -36,29 +28,26 @@ if (!is_resource($process))
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
$head = fgets($pipes[1]);
|
$head = fgets($pipes[1]);
|
||||||
if ($head === "\r\n" || $head === "\n") break;
|
if ($head === false || $head === "\r\n" || $head === "\n") break;
|
||||||
header($head);
|
header($head);
|
||||||
}
|
}
|
||||||
fpassthru($pipes[1]);
|
fpassthru($pipes[1]);
|
||||||
|
|
||||||
// Log errors
|
|
||||||
|
|
||||||
$scriptErrors = '';
|
|
||||||
while ($line = fgets($pipes[2])) $scriptErrors .= $line;
|
|
||||||
$scriptErrors = trim($scriptErrors);
|
|
||||||
if ($scriptErrors) trigger_error($scriptErrors, E_USER_NOTICE);
|
|
||||||
|
|
||||||
// Close
|
// Close
|
||||||
|
|
||||||
|
$scriptErrors = trim(stream_get_contents($pipes[2]));
|
||||||
foreach ($pipes as $fh) fclose($fh);
|
foreach ($pipes as $fh) fclose($fh);
|
||||||
proc_close($process);
|
$returnValue = proc_close($process);
|
||||||
|
if ($scriptErrors) trigger_error("Status=$returnValue Error=$scriptErrors", E_USER_ERROR);
|
||||||
|
exit;
|
||||||
|
|
||||||
// Exit helper
|
// Exit helper
|
||||||
|
|
||||||
function error_exit($code, $msg)
|
function error_exit($code, $msg)
|
||||||
{
|
{
|
||||||
|
$err = "Error executing $_SERVER[X_SCRIPT_FILENAME]: $msg";
|
||||||
header("$_SERVER[SERVER_PROTOCOL] $code $msg");
|
header("$_SERVER[SERVER_PROTOCOL] $code $msg");
|
||||||
echo($msg);
|
echo($msg);
|
||||||
trigger_error($err, E_USER_ERROR);
|
trigger_error($err, E_USER_ERROR);
|
||||||
exit;
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ REGEDIT4
|
||||||
[HKEY_CURRENT_USER\Console]
|
[HKEY_CURRENT_USER\Console]
|
||||||
"ColorTable00"=dword:00403010
|
"ColorTable00"=dword:00403010
|
||||||
"ColorTable07"=dword:00d0c8c0
|
"ColorTable07"=dword:00d0c8c0
|
||||||
|
"ColorTable09"=dword:00ff9933
|
||||||
"FaceName"="Oxygen Mono"
|
"FaceName"="Oxygen Mono"
|
||||||
"FontFamily"=dword:00000036
|
"FontFamily"=dword:00000036
|
||||||
"FontSize"=dword:000c0000
|
"FontSize"=dword:000c0000
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue