Webalizer on Cpanel without login

ENter username + password + url  > Save as whatever.php wherever on the site   ie: stat/stat.php

And it’s ready

<?php
$user = ‘username’; //cpanel username
$pass = ‘password’; //cpanel password
$url = ‘www.domain.net’; //do not include ‘http://’

//retrieves the webalizer file, either .html or .png
function getFile($file) {
global $user, $pass, $url;
return file_get_contents(“http://” . $user . “:” . $pass . “@” . $url . “:2082/tmp/” . $user . “/webalizer/” . $file);
}
//alters links, either .html or .png
function changeLinks($subject, $type) {
return preg_replace(“/($type=”)(?!http)(.*?)”/is”,”$1$PHP_SELF?$2″”,$subject);
}

if(!empty($_SERVER[‘QUERY_STRING’])) {

//get file (whether png or html)
$page = getFile($_SERVER[‘QUERY_STRING’]);

//if png, output appropriate header
if(strpos($_SERVER[‘QUERY_STRING’],’.png’) !== false) {
header(“Content-type: image/png”);
}
//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;
?>

0saves
If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

Leave a Reply

Your email address will not be published. Required fields are marked *