Posted on December 19th, 2006 at 12:57 am by Andrew
I got tired of having to log-in to cPanel and click a load of buttons to get my much needed site stats (do it several times daily) so I went in search of a short-cut. Haven't a clue how it works but here's what I found:
PHP:
<? $pass = 'CPANELPASSWORD'; //your cpanel password $domain = 'domain.com'; //do not include 'http://' or 'www.' or a trailing '/' /* NO NEED TO TOUCH ANYTHING BELOW HERE */ //retrieves the file, either .pl or .png function getFile($fileQuery){ } //it's a .png file... $fileQuery = $_SERVER['QUERY_STRING']; } //probably first time to access page... $fileQuery = "awstats.pl?config=$domain"; } //otherwise, all other accesses else { $fileQuery = 'awstats.pl?'.$_SERVER['QUERY_STRING']; } //now get the file $file = getFile($fileQuery); //check again to see if it was a .png file //if it's not, replace the links } //if it is a png, output appropriate header else { } //output the file
Good, no?
Just for my own satisfaction (having just googled some of the code above), I've found this script for webalizer without cPanel login:
PHP:
<? //dv at josheli.com $user = 'username'; $pass = 'password'; $url = 'www.mydomain.com';//do not include 'http://' //retrieves the webalizer file, either .html or .png function getFile($file){ } //alters links, either .html or .png function changeLinks($subject, $type) { } //get file (whether png or html) $page = getFile($_SERVER['QUERY_STRING']); //if png, output appropriate header } //change the .png src(s) else { $page = changeLinks($page, 'src'); } } else { //get index $page = getFile('index.html'); //change links $page = changeLinks($page, 'href'); //change the usage.png src $page = changeLinks($page, 'src'); } //output it echo $page;