Skip to content

Commit 0e11b4b

Browse files
committed
Added a script to recreate missing webalizer statistics.
1 parent 0358863 commit 0e11b4b

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
#######################################################################################################
4+
// Re-Create webalizer statistics
5+
#######################################################################################################
6+
7+
8+
$sql = "SELECT domain_id, domain, document_root FROM web_domain WHERE server_id = ".$conf["server_id"];
9+
$records = $app->db->queryAllRecords($sql);
10+
foreach($records as $rec) {
11+
$domain = escapeshellcmd($rec["domain"]);
12+
$logdir = escapeshellcmd($rec["document_root"].'/log');
13+
$statsdir = escapeshellcmd($rec["document_root"].'/web/stats');
14+
$webalizer = '/usr/bin/webalizer';
15+
16+
$webalizer_conf_main = '/etc/webalizer/webalizer.conf';
17+
$webalizer_conf = escapeshellcmd($rec["document_root"].'/log/webalizer.conf');
18+
exec("rm -rf $webalizer_conf");
19+
if(!@is_file($webalizer_conf)) {
20+
exec("cp $webalizer_conf_main $webalizer_conf");
21+
22+
setConfigVar($webalizer_conf, 'Incremental', 'yes');
23+
setConfigVar($webalizer_conf, 'IncrementalName', $logdir.'/webalizer.current');
24+
setConfigVar($webalizer_conf, 'HistoryName', $logdir.'/webalizer.hist');
25+
}
26+
27+
if(!@is_dir($statsdir)) mkdir($statsdir);
28+
29+
30+
echo "Remove stats dir $statsdir ...\n";
31+
exec("rm -rf $statsdir/*");
32+
33+
echo "Re-Create stats for $domain...\n";
34+
exec("for logfile in $logdir/*access*; do\n$webalizer -c $webalizer_conf -n $domain -s $domain -r $domain -q -T -p -o $statsdir ".'$logfile'."\ndone");
35+
echo "done.\n";
36+
}
37+
38+
die("finished.\n");
39+
?>

0 commit comments

Comments
 (0)