commit | author | age
|
0e11b4
|
1 |
<?php |
T |
2 |
|
b1a6a5
|
3 |
//###################################################################################################### |
0e11b4
|
4 |
// Re-Create webalizer statistics |
b1a6a5
|
5 |
//###################################################################################################### |
0e11b4
|
6 |
|
T |
7 |
|
cc7a82
|
8 |
$sql = "SELECT domain_id, domain, document_root FROM web_domain WHERE server_id = ?"; |
MC |
9 |
$records = $app->db->queryAllRecords($sql, $conf["server_id"]); |
0e11b4
|
10 |
foreach($records as $rec) { |
b1a6a5
|
11 |
$domain = escapeshellcmd($rec["domain"]); |
MC |
12 |
$logdir = escapeshellcmd($rec["document_root"].'/log'); |
|
13 |
$statsdir = escapeshellcmd($rec["document_root"].'/web/stats'); |
|
14 |
$webalizer = '/usr/bin/webalizer'; |
0e11b4
|
15 |
|
b1a6a5
|
16 |
$webalizer_conf_main = '/etc/webalizer/webalizer.conf'; |
MC |
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"); |
0e11b4
|
21 |
|
b1a6a5
|
22 |
setConfigVar($webalizer_conf, 'Incremental', 'yes'); |
MC |
23 |
setConfigVar($webalizer_conf, 'IncrementalName', $logdir.'/webalizer.current'); |
|
24 |
setConfigVar($webalizer_conf, 'HistoryName', $logdir.'/webalizer.hist'); |
|
25 |
} |
0e11b4
|
26 |
|
b1a6a5
|
27 |
if(!@is_dir($statsdir)) mkdir($statsdir); |
0e11b4
|
28 |
|
T |
29 |
|
b1a6a5
|
30 |
echo "Remove stats dir $statsdir ...\n"; |
MC |
31 |
exec("rm -rf $statsdir/*"); |
0e11b4
|
32 |
|
b1a6a5
|
33 |
echo "Re-Create stats for $domain...\n"; |
MC |
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"; |
0e11b4
|
36 |
} |
T |
37 |
|
|
38 |
die("finished.\n"); |
b1a6a5
|
39 |
?> |