View awstats outside of cPanel
From JumbaWiki
Sometimes you might not want to give a client/customer (or their client) the cPanel login details to access the site statistics. Here's a way of making a PHP page on your site that displays the awstats outside of cpanel.
Please note: you need to change the commented areas of the code for domain, username, and password.
<style type="text/css"> <!-- .aws_bodyl { } .aws_border { background-color: #CCCCDD; padding: 1px 1px 1px 1px; margin-top: 0; margin-bottom: 0; } .aws_title { font: 13px verdana, arial, helvetica, sans-serif; font-weight: bold; background-color: #CCCCDD; text-align: center; margin-top: 0; margin-bottom: 0; padding: 1px 1px 1px 1px; color: #000000; } .aws_blank { font: 13px verdana, arial, helvetica, sans-serif; background-color: #CCCCDD; text-align: center; margin-bottom: 0; padding: 1px 1px 1px 1px; } .aws_data { background-color: #FFFFFF; border-top-width: 1px; border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; } .aws_formfield { font: 13px verdana, arial, helvetica; } .aws_button { font-family: arial,verdana,helvetica, sans-serif; font-size: 12px; border: 1px solid #ccd7e0; background-image : url(/images/awstats/other/button.gif); } th { border-color: #ECECEC; border-left-width: 0px; border-right-width: 1px; border-top-width: 0px; border-bottom-width: 1px; padding: 1px 2px 1px 1px; font: 11px verdana, arial, helvetica, sans-serif; text-align:center; color: #000000; } th.aws { border-color: #ECECEC; border-left-width: 0px; border-right-width: 1px; border-top-width: 0px; border-bottom-width: 1px; padding: 1px 2px 1px 1px; font-size: 13px; font-weight: bold; } td { border-color: #ECECEC; border-left-width: 0px; border-right-width: 1px; border-top-width: 0px; border-bottom-width: 1px; padding: 0px; font: 10px arial, helvetica, sans-serif; text-align:left; color: #000000; } td.aws { border-color: #ECECEC; border-left-width: 0px; border-right-width: 1px; border-top-width: 0px; border-bottom-width: 1px; padding: 1px 1px 1px 1px; font: 11px verdana, arial, helvetica, sans-serif; text-align:left; color: #000000; } td.awsm { border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; padding: 0px 0px 0px 0px; font: 11px verdana, arial, helvetica, sans-serif; text-align:left; color: #000000; } //--> </style> <? $domain = "mydomain.com"; //edit this variable to include your domain $username = "username"; //edit this variable to include your cpanel username $password = "password"; //edit this variable to include your cpanel password echo "<div class=\"newsheader\">Site Statistics for ".$domain."</div><br> Please note that these statistics are indicatory only. They are taken from a server side, third party program, and are not guaranteed to be 100% accurate.<br><br>"; ?> <? file("http://".$username.":".$password."@".$domain.":2082/awstats.pl?config=".$domain."&lang=en&framename=mainright&update=1"); $t = file("http://".$username.":".$password."@".$domain.":2082/awstats.pl?config=".$domain."&lang=en&framename=mainright"); $r = implode("", $t); $qqq = explode("<a name=\"month\"> </a><br />", $r); //$top = explode("<a name=\"who\"> </a>", $qqq[1]); $top = explode("<a name=\"errors\"> </a><br />", $qqq[1]); if(!$top[0]) echo "Error Has Occured"; else { echo str_replace(array("Days of month ", "Days of week ", "Hours ", "/images/awstats", "a href"), array("Days of month (current month)", "Days of week (current month)", "Hours (current month)", "$domain/awstats","o "), $top[0]); $previsits = explode("<a name=\"sessions\"> </a><br />", $top[1]); $visits = explode("<a name=\"filetypes\"> </a><br />", $previsits[1]); echo str_replace("Visits Duration", "Visits Duration (current month)", $visits[0]); } //SOURCED FROM: http://www.totallyphp.co.uk ?>
Here is another PHP script that presents the awstats page, including graphics if you follow the instructions in the comments:
<? //For this script to show graphics correctly, there must be a folder in the www root //called "images/awstats" //Download a copy of the awstats package from http://awstats.sourceforge.net/ //Within the package (version 6.6 as of writing) is the directory \awstats-6.6\wwwroot\icon\ //ftp all the folders in this directory to the images/awstats directory in the root //of your website //graphics on the stats page should be displayed correctly now //Note: This will probably break when Jumba updates awstats to 6.6 //I'll fix it then :) $domain = "domain"; //edit this variable to include your domain $userid = "userid"; //edit this variable to include your cpanel userid $secret = "password"; //edit this variable to include your cpanel password $s = file("http://".$userid.":".$secret."@".$domain.":2082/awstats.pl?config=".$domain."&lang=en&framename=mainright"); //Remove update form at top of screen //A hideous hack! for ($key=49; $key<=89; $key++) { $s[$key] = ""; } //Turn array into a string $stats = implode("", $s); //Send to screen echo "<b><center>Current Month Stats for $domain</center></b><p>"; echo $stats; ?>

