<?PHP
require('/usr/local/ispconfig/server/lib/config.inc.php');
require('/usr/local/ispconfig/server/lib/app.inc.php');
set_time_limit(0);
// make sure server_id is always an int
$conf['server_id'] = intval($conf['server_id']);
// Load required base-classes
$app->uses('ini_parser,file,services,getconf');
function setConfigVar( $filename, $varName, $varValue ) {
if($lines = @file($filename)) {
$out = '';
$found = 0;
foreach($lines as $line) {
@list($key, $value) = preg_split('/[\t= ]+/', $line, 2);
if($key == $varName) {
$out .= $varName.' '.$varValue."\n";
$found = 1;
} else {
$out .= $line;
}
}
if($found == 0) {
//* add \n if the last line does not end with \n or \r
if(substr($out,-1) != "\n" && substr($out,-1) != "\r") $out .= "\n";
//* add the new line at the end of the file
if($append == 1) $out .= $varName.' '.$varValue."\n";
}
file_put_contents($filename,$out);
}
}
/*
$sql = "SELECT domain_id, domain, document_root FROM web_domain WHERE stats_type = 'webalizer' AND server_id = ".$conf['server_id'];
$records = $app->db->queryAllRecords($sql);
*/
//$yesterday = date('Ymd',time() - 86400);
$yesterday = '20111211';
$logfile = '/var/www/clients/client1/web44/log/'.$yesterday.'-access.log';
if(!@is_file($logfile)) {
$logfile = '/var/www/clients/client1/web44/log/'.$yesterday.'-access.log.gz';
if(!@is_file($logfile)) {
continue;
} }
$domain = 'domain.de';
$statsdir = '/var/www/clients/client1/web44/web/stats';
$webalizer = '/usr/bin/webalizer';
$webalizer_conf_main = '/etc/webalizer/webalizer.conf';
$webalizer_conf = '/var/www/clients/client1/web44/log/webalizer.conf';
if(!@is_file($webalizer_conf)) {
copy($webalizer_conf_main,$webalizer_conf);
}
if(@is_file($webalizer_conf)) {
setConfigVar($webalizer_conf, 'Incremental', 'yes');
setConfigVar($webalizer_conf, 'IncrementalName', $statsdir.'/webalizer.current');
setConfigVar($webalizer_conf, 'HistoryName', $statsdir.'/webalizer.hist');
}
if(!@is_dir($statsdir)) mkdir($statsdir);
exec("$webalizer -c $webalizer_conf -n $domain -s $domain -r $domain -q -T -p -o $statsdir $logfile");
?>