| | |
| | | } |
| | | |
| | | |
| | | $sql = "SELECT domain_id, domain, document_root, web_folder, type, parent_domain_id FROM web_domain WHERE (type = 'vhost' or type = 'vhostsubdomain') and stats_type = 'webalizer' AND server_id = ".$conf['server_id']; |
| | | $records = $app->db->queryAllRecords($sql); |
| | | $sql = "SELECT domain_id, domain, document_root, web_folder, type, parent_domain_id, system_user, system_group FROM web_domain WHERE (type = 'vhost' or type = 'vhostsubdomain' or type = 'vhostalias') and stats_type = 'webalizer' AND server_id = ?"; |
| | | $records = $app->db->queryAllRecords($sql, $conf['server_id']); |
| | | |
| | | foreach($records as $rec) { |
| | | //$yesterday = date('Ymd',time() - 86400); |
| | | $yesterday = date('Ymd', strtotime("-1 day", time())); |
| | | |
| | | $log_folder = 'log'; |
| | | if($rec['type'] == 'vhostsubdomain') { |
| | | $tmp = $app->db->queryOneRecord('SELECT `domain` FROM web_domain WHERE domain_id = '.intval($rec['parent_domain_id'])); |
| | | if($rec['type'] == 'vhostsubdomain' || $rec['type'] == 'vhostalias') { |
| | | $tmp = $app->db->queryOneRecord('SELECT `domain` FROM web_domain WHERE domain_id = ?', $rec['parent_domain_id']); |
| | | $subdomain_host = preg_replace('/^(.*)\.' . preg_quote($tmp['domain'], '/') . '$/', '$1', $rec['domain']); |
| | | if($subdomain_host == '') $subdomain_host = 'web'.$rec['domain_id']; |
| | | $log_folder .= '/' . $subdomain_host; |
| | |
| | | } |
| | | |
| | | $domain = escapeshellcmd($rec['domain']); |
| | | $statsdir = escapeshellcmd($rec['document_root'].'/'.($rec['type'] == 'vhostsubdomain' ? $rec['web_folder'] : 'web').'/stats'); |
| | | $statsdir = escapeshellcmd($rec['document_root'].'/'.(($rec['type'] == 'vhostsubdomain' || $rec['type'] == 'vhostalias') ? $rec['web_folder'] : 'web').'/stats'); |
| | | $webalizer = '/usr/bin/webalizer'; |
| | | $webalizer_conf_main = '/etc/webalizer/webalizer.conf'; |
| | | $webalizer_conf = escapeshellcmd($rec['document_root'].'/log/webalizer.conf'); |
| | |
| | | |
| | | |
| | | if(!@is_dir($statsdir)) mkdir($statsdir); |
| | | $username = escapeshellcmd($rec['system_user']); |
| | | $groupname = escapeshellcmd($rec['system_group']); |
| | | chown($statsdir, $username); |
| | | chgrp($statsdir, $groupname); |
| | | exec("$webalizer -c $webalizer_conf -n $domain -s $domain -r $domain -q -T -p -o $statsdir $logfile"); |
| | | |
| | | exec('chown -R '.$username.':'.$groupname.' '.$statsdir); |
| | | } |
| | | |
| | | |