Created
February 1, 2021 20:41
-
-
Save mbirth/b545682583fbe07a4c18044de2e2a15c to your computer and use it in GitHub Desktop.
PHP proxy for AWStats.pl when your host doesn't allow cgi-bin or .pl scripts but PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
# Put this in the same directory where AWStats' cgi-bin dir is! | |
$config = 'your.default.config'; | |
$output = 'main'; | |
$cmd = './awstats.pl'; | |
# Mandatory parameter | |
if (!isset($_GET['config'])) { | |
$_GET['config'] = $config; | |
} | |
# Mandatory parameter | |
if (!isset($_GET['output'])) { | |
$_GET['output'] = $output; | |
} | |
foreach ($_GET as $k=>$v) { | |
$cmd .= ' ' . escapeshellarg($k) . '=' . escapeshellarg($v); | |
} | |
# print("CMD: $cmd"); | |
chdir('cgi-bin'); | |
exec($cmd, $outarr); | |
$awsout = implode("\n", $outarr); | |
$awsout = str_replace('cgi-bin/awstats.pl', 'index.php', $awsout); | |
print($awsout); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment