Skip to content

Instantly share code, notes, and snippets.

@mbirth
Created February 1, 2021 20:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbirth/b545682583fbe07a4c18044de2e2a15c to your computer and use it in GitHub Desktop.
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
<?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