AWStats without cPanel

AWStats logoThe following script displays AWStats for a site, without the need to log in via cPanel, and without needing to know the cPanel username and password. There are many situations where this is useful. If you're a web developer with business clients, you'll know that most business people can be classified into one of three types:

  1. those who don't know much about computers, and are afraid of breaking them;
  2. those who know a bit about computers, and use some intelligence to try things out; and
  3. those who think they know more than they actually do, and barge in clicking everything until their site breaks

This script is great for people in category (a), who often get overwhelmed and confused by all the options in cPanel. People in category (b) might be ok with cPanel, but this script is handy if they just want to look at their web stats. People in category (c) should be kept away from cPanel at all costs!

Although the script can be used without any password, I'd still recommend putting it into a password-protected directory to stop every man and his dog from playing with your statistics.

// For this script to show the graphics correctly, they must be uploaded to your server.
// The graphics from AWStats v6.8 are available from this page, or you can
// download a copy of the AWStats package from
// Within the package is the directory wwwroot/icon/
// FTP all the folders in this directory to a folder on your server.
// To view the stats for an addon or subdomain, just append to the URL:
//  ?
// Required settings
$Domain ''// change this to your own domain
$UserId 'username';          // change this to your cpanel username
$Secret 'password';          // change this to your cpanel password
$ImageDir='awstats_images';    // location of the AWStats graphics
// Optional settings
$DefaultLanguage 'en';
$HideLanguages   false;
$HideAwstatsLogo false;
$CustomLogo      '';
$CustomAltTitle  '';
$CustomUrl       '';
// ------------------------------------------------------
$SayDomain=(isset($_GET['config'])) ?  $_GET['config'] : $Domain;
$qs="config=$Domain&lang=$DefaultLanguage&framename=mainright"; }
$qs ''
    foreach (
$_GET as $key=>$value
$value urlencode(stripslashes($value)); $qs.="$key=$value&"; }
$Stats file_get_contents("http://$UserId:$Secret@$Domain:2082/$qs");
$Stats=str_replace('<form name="FormDateFilter"'"<center><h2>Web statistics for $SayDomain</h2></center>\r\n<form name=\"FormDateFilter\""$Stats);
$Stats=str_replace(''$_SERVER['PHP_SELF'], $Stats);
$Stats=str_replace('name="framename" value="index"''name="framename" value="mainright"'$Stats);
$HideLanguages$Stats=preg_replace('/<td align="right" rowspan="2">(<a .*<\/a>).*<br \/><a .*<\/td>/Us''<td align="right" rowspan="2">$1</td>'$Stats1);
$HideAwstatsLogo or $CustomLogo<>'')
$Img="<img src=\"$CustomLogo\" border=\"0\" alt=\"$CustomAltTitle\" title=\"$CustomAltTitle\" />";
$Logo=(''==$CustomUrl) ? $Img "<a href=\"$CustomUrl\" target=\"_blank\">$Img</a>";
$Stats=preg_replace('/<td align="right" rowspan="2">(<a .*<\/a>)/Us''<td align="right" rowspan="2">'.$Logo$Stats1);

If you want to use this script, remember to also grab the images that go with it (link below) or get them from the AWStats package on Sourceforge.


File date: 


Write a comment

  • Required fields are marked with *.