Compare commits

...

2 commits

Author SHA1 Message Date
c55d4afa87 Update cgi-bin.php 2015-12-13 23:09:12 +01:00
34f38557c5 Fix unreadable blue color 2015-11-27 21:32:59 +01:00
2 changed files with 13 additions and 23 deletions
conf

View file

@ -1,22 +1,14 @@
<?php
/**
* Run old CGI applications through PHP
* @author Adrian Kousz
* @link https://wiki.archlinux.org/index.php/Awstats Source
*/
// Adapted from https://wiki.archlinux.org/index.php/Awstats
// Prepare environment
$newenv = $_SERVER;
$xScriptFilename = $_SERVER["X_SCRIPT_FILENAME"];
$xScriptName = $_SERVER["X_SCRIPT_NAME"];
$newenv["SCRIPT_FILENAME"] = $xScriptFilename;
$newenv["SCRIPT_NAME"] = $xScriptName;
$newenv["SCRIPT_FILENAME"] = $_SERVER["X_SCRIPT_FILENAME"];
$newenv["SCRIPT_NAME"] = $_SERVER["X_SCRIPT_NAME"];
// Check file
if (!is_executable($xScriptFilename) || is_dir($xScriptFilename))
if (!is_executable($_SERVER["X_SCRIPT_FILENAME"]) || is_dir($_SERVER["X_SCRIPT_FILENAME"]))
error_exit(404, 'Not Found');
// Open process
@ -27,7 +19,7 @@ $descriptorspec = array(
array('pipe', 'w'),
);
$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))
error_exit(500, 'Internal Server Error');
@ -36,29 +28,26 @@ if (!is_resource($process))
while (true) {
$head = fgets($pipes[1]);
if ($head === "\r\n" || $head === "\n") break;
if ($head === false || $head === "\r\n" || $head === "\n") break;
header($head);
}
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
$scriptErrors = trim(stream_get_contents($pipes[2]));
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
function error_exit($code, $msg)
{
$err = "Error executing $_SERVER[X_SCRIPT_FILENAME]: $msg";
header("$_SERVER[SERVER_PROTOCOL] $code $msg");
echo($msg);
trigger_error($err, E_USER_ERROR);
exit;
exit(1);
}

View file

@ -3,6 +3,7 @@ REGEDIT4
[HKEY_CURRENT_USER\Console]
"ColorTable00"=dword:00403010
"ColorTable07"=dword:00d0c8c0
"ColorTable09"=dword:00ff9933
"FaceName"="Oxygen Mono"
"FontFamily"=dword:00000036
"FontSize"=dword:000c0000