Webalizer: visualizzare le statistiche senza accedere a Cpanel

[ Pubblicato il 20 apr 2009 by Tommaso ]

webalizer_cpanel
Tramite questo codice PHP potrete accedere alle statistiche di Webalizer senza dover accedere a cPanel.
With this PHP code yo can give to your hosting clients the ability to check their webalizer statistics without having to log into cPanel.
flags_of_italy
I passi da seguire sono semplici:
1- Create all’interno dello spazio FTP una nuova cartella, ad esempio “webstat”.
2- Inserite all’interno della cartella i due files: “index.php” e “img.php”
3- Se volete, potete successivamente proteggere la cartella tramite utente & password grazie alla funzione “Password Protect Directories” presente all’interno del cPanel.

flags_of_united-kingdom
The steps are simple:
1 - Create into your FTP space a new folder, for example “webstat”.
2 - Upload in this folder the two files: “index.php” and “img.php”.
3 - After, if you like, you can protect the folder by user & password. Go to ”Password Protect Directories” inside of cPanel.

Per scaricare il codice sorgente, clicca qui
Download the PHP code, click here.

“index.php”:

/*
 * "View Webalizer Stats without login to cPanel"
 *
 * @Author: Tommaso Capretti
 * @Link: http://www.webnet-italia.it/
 * @Version: 1.01
 * @Date: 20 Aprile 2009
 *
 * DISCLAIMER: The content provided in this PHP code is not warranted or guaranteed, so use this script
 * at your own risk. Please post any questions/improvements in the comments of my blog, thank you.
 *
 */
$pagina = basename(strip_tags(trim($_GET['p'])));
if (empty($pagina)) {
	$pagina_index = file_get_contents('../../tmp/webalizer/index.html');
	$pagina_stat = str_ireplace('href="', 'href="index.php?p=', $pagina_index);
} elseif (ereg("^usage_", $pagina)) {
	$pagina_stat = file_get_contents('../../tmp/webalizer/'.$pagina);
} else {
	die('<strong>Errore! Impossibile visualizzare la pagina</strong>');
}
$page_with_images = str_ireplace('SRC="', 'SRC="img.php?img=', $pagina_stat);
echo $page_with_images;

“img.php”:

/*
 * "View Webalizer Stats without login to cPanel"
 *
 * @Author: Tommaso Capretti
 * @Link: http://www.webnet-italia.it/
 * @Version: 1.01
 * @Date: 20 Aprile 2009
 *
 * DISCLAIMER: The content provided in this PHP code is not warranted or guaranteed, so use this script
 * at your own risk. Please post any questions/improvements in the comments of my blog, thank you.
 *
 */
$nome_file = basename(strip_tags($_GET["img"]));
$percorso_assoluto = "../../tmp/webalizer/";
header('Content-Type: image/png');
header("Cache-Control: no-cache, must-revalidate");
header("Cache-Control: private");
header("Pragma: public");
readfile($percorso_assoluto.$nome_file);

DISCLAIMER: The content provided in this PHP code is not warranted or guaranteed, so use this script at your own risk. Please post any questions/improvements in the comments, thank you.


One Response to “Webalizer: visualizzare le statistiche senza accedere a Cpanel”

  1. Questo post è veramente utile per tutti i webmaster che devono far vedere sul sito le statistiche senza dover accedere al pannello,
    U S A T E L O!!!!

Lascia un commento: