Questo script permette di accedere alla visualizzazione delle statistiche prodotte da webalizer senza accedere a cPanel dopo averlo adeguatamente configurato inserendo username, password e nome del dominio.
Codice:
<?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){
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;
?>
[/quote]