$user = 'cpusername';//your cpanel username
$pass = 'pass';//your cpanel password
$domain = 'onebuckdirectory.com';//do not include 'http://' or 'www.'
$config_domain = 'onebuckdirectory.com'; //The Domain You want the Awstats to show (can be altered in browser)
$dynamic_images = true; //Ignore at the moment
$image_directory = './awstats_images/'; //Ignore at the moment!
?>
Then create a second file called index.php
Put This code in (no need to edit anything)
PHP Code:
<?
require ('awconfig.php');
//retrieves the file, either .pl or .png
function get_file($fileQuery)
{
global $user, $pass, $domain;
return file_get_contents("http://$user:$pass@$domain:2082/".$fileQuery);
}
if($requesting_image) //it's a .png file...
{
if(!$dynamic_images && !is_dir($image_directory))
{
exit;
}
$fileQuery = $_SERVER['QUERY_STRING'];
}
elseif(empty($_SERVER['QUERY_STRING']))//probably first time to access page...
{
if(empty($config_domain))
{
$config_domain = $domain;
}
$fileQuery = "awstats.pl?config=$config_domain";
}
else //otherwise, all other accesses
{
$fileQuery = 'awstats.pl?'.$_SERVER['QUERY_STRING'];
}
$file = get_file($fileQuery);
//check again to see if it was a .png file
//if it's not, replace the links
if(!$requesting_image)
{
$file = str_replace('awstats.pl', basename($_SERVER['PHP_SELF']), $file);
$file = str_replace($imgsrc_search, $imgsrc_replace, $file);
$file = str_replace($spam_words, 'SPAM', $file);
}
else //if it is a png, output appropriate header
{
header("Content-type: image/png");
}
//output the file
echo $file;
?>
Then upload both to your webserver in an awstats directory and away you go, i will soon do a version where the config is outside the public_html folder.
Warning: Cannot modify header information - headers already sent by (output started at /home/user/public_html/stats/index.php:1) in /home/user/public_html/stats/index.php on line 60