Compare commits

..

No commits in common. "c55d4afa87d3a6d708679851adf252ce3e62f8eb" and "c49cecf3a688a5e94bf62d5d438a62a4c58a7b72" have entirely different histories.

2 changed files with 23 additions and 13 deletions

View file

@ -1,14 +1,22 @@
<?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;
$newenv["SCRIPT_FILENAME"] = $_SERVER["X_SCRIPT_FILENAME"]; $xScriptFilename = $_SERVER["X_SCRIPT_FILENAME"];
$newenv["SCRIPT_NAME"] = $_SERVER["X_SCRIPT_NAME"]; $xScriptName = $_SERVER["X_SCRIPT_NAME"];
$newenv["SCRIPT_FILENAME"] = $xScriptFilename;
$newenv["SCRIPT_NAME"] = $xScriptName;
if (!is_executable($_SERVER["X_SCRIPT_FILENAME"]) || is_dir($_SERVER["X_SCRIPT_FILENAME"])) // Check file
if (!is_executable($xScriptFilename) || is_dir($xScriptFilename))
error_exit(404, 'Not Found'); error_exit(404, 'Not Found');
// Open process // Open process
@ -19,7 +27,7 @@ $descriptorspec = array(
array('pipe', 'w'), array('pipe', 'w'),
); );
$pipes = array(); $pipes = array();
$process = proc_open($_SERVER["X_SCRIPT_FILENAME"], $descriptorspec, $pipes, null, $newenv); $process = proc_open($xScriptFilename, $descriptorspec, $pipes, null, $newenv);
if (!is_resource($process)) if (!is_resource($process))
error_exit(500, 'Internal Server Error'); error_exit(500, 'Internal Server Error');
@ -28,26 +36,29 @@ if (!is_resource($process))
while (true) { while (true) {
$head = fgets($pipes[1]); $head = fgets($pipes[1]);
if ($head === false || $head === "\r\n" || $head === "\n") break; if ($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);
$returnValue = proc_close($process); 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(1); exit;
} }

View file

@ -3,7 +3,6 @@ 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