@@ -340,20 +340,26 @@ class apache
|
||||
{
|
||||
if($domain['parentdomainid'] == '0')
|
||||
{
|
||||
$stats_text.= ' Alias /webalizer "' . makeCorrectFile($domain['customerroot'] . '/webalizer/' . $domain['domain']) . '"' . "\n";
|
||||
|
||||
if($this->settings['system']['awstats_enabled'] == '1')
|
||||
{
|
||||
$stats_text.= createAWStatsVhost($domain['domain'], $this->settings);
|
||||
// @TODO see if this is correct for awstats
|
||||
$stats_text.= ' Alias /awstats "' . makeCorrectFile($domain['customerroot'] . '/awstats/' . $domain['domain']) . '"' . "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$stats_text.= ' Alias /webalizer "' . makeCorrectFile($domain['customerroot'] . '/webalizer/' . $domain['domain']) . '"' . "\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$stats_text.= ' Alias /webalizer "' . makeCorrectFile($domain['customerroot'] . '/webalizer/' . $domain['parentdomain']) . '"' . "\n";
|
||||
|
||||
if($this->settings['system']['awstats_enabled'] == '1')
|
||||
{
|
||||
$stats_text.= createAWStatsVhost($domain['parentdomain'], $this->settings);
|
||||
// @TODO see if this is correct for awstats
|
||||
$stats_text.= ' Alias /awstats "' . makeCorrectFile($domain['customerroot'] . '/awstats/' . $domain['parentdomain']) . '"' . "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$stats_text.= ' Alias /webalizer "' . makeCorrectFile($domain['customerroot'] . '/webalizer/' . $domain['parentdomain']) . '"' . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -361,12 +367,14 @@ class apache
|
||||
{
|
||||
if($domain['customerroot'] != $domain['documentroot'])
|
||||
{
|
||||
$stats_text.= ' Alias /webalizer "' . makeCorrectFile($domain['customerroot'] . '/webalizer') . '"' . "\n";
|
||||
}
|
||||
|
||||
if($this->settings['system']['awstats_enabled'] == '1')
|
||||
{
|
||||
$stats_text.= createAWStatsVhost($domain['domain'], $this->settings);
|
||||
if($this->settings['system']['awstats_enabled'] == '1')
|
||||
{
|
||||
$stats_text.= ' Alias /awstats "' . makeCorrectFile($domain['customerroot'] . '/awstats/' . $domain['domain']) . '"' . "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$stats_text.= ' Alias /webalizer "' . makeCorrectFile($domain['customerroot'] . '/webalizer') . '"' . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -427,51 +435,56 @@ class apache
|
||||
|
||||
if($this->settings['system']['awstats_enabled'] == '1')
|
||||
{
|
||||
// prepare the aliases for stats config files
|
||||
|
||||
$server_alias = '';
|
||||
$alias_domains = $this->db->query('SELECT `domain`, `iswildcarddomain`, `wwwserveralias` FROM `' . TABLE_PANEL_DOMAINS . '` WHERE `aliasdomain`=\'' . $domain['id'] . '\'');
|
||||
|
||||
while(($alias_domain = $this->db->fetch_array($alias_domains)) !== false)
|
||||
if((int)$domain['parentdomainid'] == 0)
|
||||
{
|
||||
$server_alias.= ' ' . $alias_domain['domain'] . ' ';
|
||||
// prepare the aliases and subdomains for stats config files
|
||||
|
||||
if($alias_domain['iswildcarddomain'] == '1')
|
||||
$server_alias = '';
|
||||
$alias_domains = $this->db->query('SELECT `domain`, `iswildcarddomain`, `wwwserveralias` FROM `' . TABLE_PANEL_DOMAINS . '`
|
||||
WHERE `aliasdomain`=\'' . $domain['id'] . '\'
|
||||
OR `parentdomainid` =\''. $domain['id']. '\'');
|
||||
|
||||
while(($alias_domain = $this->db->fetch_array($alias_domains)) !== false)
|
||||
{
|
||||
$server_alias.= '*.' . $domain['domain'];
|
||||
}
|
||||
else
|
||||
{
|
||||
if($alias_domain['wwwserveralias'] == '1')
|
||||
$server_alias.= ' ' . $alias_domain['domain'] . ' ';
|
||||
|
||||
if($alias_domain['iswildcarddomain'] == '1')
|
||||
{
|
||||
$server_alias.= 'www.' . $alias_domain['domain'];
|
||||
$server_alias.= '*.' . $domain['domain'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$server_alias.= '';
|
||||
if($alias_domain['wwwserveralias'] == '1')
|
||||
{
|
||||
$server_alias.= 'www.' . $alias_domain['domain'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$server_alias.= '';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($domain['iswildcarddomain'] == '1')
|
||||
{
|
||||
$alias = '*.' . $domain['domain'];
|
||||
}
|
||||
else
|
||||
{
|
||||
if($domain['wwwserveralias'] == '1')
|
||||
|
||||
if($domain['iswildcarddomain'] == '1')
|
||||
{
|
||||
$alias = 'www.' . $domain['domain'];
|
||||
$alias = '*.' . $domain['domain'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$alias = '';
|
||||
if($domain['wwwserveralias'] == '1')
|
||||
{
|
||||
$alias = 'www.' . $domain['domain'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$alias = '';
|
||||
}
|
||||
}
|
||||
|
||||
// After inserting the AWStats information,
|
||||
// be sure to build the awstats conf file as well
|
||||
createAWStatsConf($this->settings['system']['logfiles_directory'] . $domain['loginname'] . $speciallogfile . '-access.log', $domain['domain'], $alias . $server_alias, $domain['customerroot']);
|
||||
}
|
||||
|
||||
// After inserting the AWStats information, be sure to build the awstats conf file as well
|
||||
|
||||
createAWStatsConf($this->settings['system']['logfiles_directory'] . $domain['loginname'] . $speciallogfile . '-access.log', $domain['domain'], $alias . $server_alias);
|
||||
}
|
||||
|
||||
return $logfiles_text;
|
||||
@@ -617,7 +630,7 @@ class apache
|
||||
|
||||
public function createVirtualHosts()
|
||||
{
|
||||
$result_domains = $this->db->query("SELECT `d`.`id`, `d`.`domain`, `d`.`customerid`, `d`.`documentroot`, `d`.`ssl`, `d`.`parentdomainid`, `d`.`ipandport`, `d`.`ssl_ipandport`, `d`.`ssl_redirect`, `d`.`isemaildomain`, `d`.`iswildcarddomain`, `d`.`wwwserveralias`, `d`.`openbasedir`, `d`.`openbasedir_path`, `d`.`safemode`, `d`.`speciallogfile`, `d`.`specialsettings`, `pd`.`domain` AS `parentdomain`, `c`.`loginname`, `d`.`phpsettingid`, `c`.`adminid`, `c`.`guid`, `c`.`email`, `c`.`documentroot` AS `customerroot`, `c`.`deactivated`, `c`.`phpenabled` AS `phpenabled`, `d`.`mod_fcgid_starter`, `d`.`mod_fcgid_maxrequests` FROM `" . TABLE_PANEL_DOMAINS . "` `d` LEFT JOIN `" . TABLE_PANEL_CUSTOMERS . "` `c` USING(`customerid`) " . "LEFT JOIN `" . TABLE_PANEL_DOMAINS . "` `pd` ON (`pd`.`id` = `d`.`parentdomainid`) " . "WHERE `d`.`aliasdomain` IS NULL ORDER BY `d`.`iswildcarddomain`, `d`.`domain` ASC");
|
||||
$result_domains = $this->db->query("SELECT `d`.*, `pd`.`domain` AS `parentdomain`, `c`.`loginname`, `d`.`phpsettingid`, `c`.`adminid`, `c`.`guid`, `c`.`email`, `c`.`documentroot` AS `customerroot`, `c`.`deactivated`, `c`.`phpenabled` AS `phpenabled`, `d`.`mod_fcgid_starter`, `d`.`mod_fcgid_maxrequests` FROM `" . TABLE_PANEL_DOMAINS . "` `d` LEFT JOIN `" . TABLE_PANEL_CUSTOMERS . "` `c` USING(`customerid`) " . "LEFT JOIN `" . TABLE_PANEL_DOMAINS . "` `pd` ON (`pd`.`id` = `d`.`parentdomainid`) " . "WHERE `d`.`aliasdomain` IS NULL ORDER BY `d`.`iswildcarddomain`, `d`.`domain` ASC");
|
||||
|
||||
while($domain = $this->db->fetch_array($result_domains))
|
||||
{
|
||||
|
||||
@@ -62,7 +62,7 @@ class lighttpd
|
||||
public function reload()
|
||||
{
|
||||
fwrite($this->debugHandler, ' lighttpd::reload: reloading lighttpd' . "\n");
|
||||
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'reloading apache');
|
||||
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'reloading lighttpd');
|
||||
safe_exec($this->settings['system']['apachereload_command']);
|
||||
}
|
||||
|
||||
@@ -225,11 +225,11 @@ class lighttpd
|
||||
|
||||
if($ssl == '0')
|
||||
{
|
||||
$query2 = "SELECT `d`.`id`, `d`.`domain`, `d`.`customerid`, `d`.`documentroot`, `d`.`ssl`, `d`.`parentdomainid`, `d`.`ipandport`, `d`.`ssl_ipandport`, `d`.`ssl_redirect`, `d`.`isemaildomain`, `d`.`iswildcarddomain`, `d`.`wwwserveralias`, `d`.`openbasedir`, `d`.`openbasedir_path`, `d`.`safemode`, `d`.`speciallogfile`, `d`.`specialsettings`, `pd`.`domain` AS `parentdomain`, `c`.`loginname`, `c`.`guid`, `c`.`email`, `c`.`documentroot` AS `customerroot`, `c`.`deactivated`, `c`.`phpenabled` AS `phpenabled` FROM `" . TABLE_PANEL_DOMAINS . "` `d` LEFT JOIN `" . TABLE_PANEL_CUSTOMERS . "` `c` USING(`customerid`) LEFT JOIN `" . TABLE_PANEL_DOMAINS . "` `pd` ON (`pd`.`id` = `d`.`parentdomainid`) WHERE `d`.`ipandport`='" . $ipandport['id'] . "' AND `d`.`aliasdomain` IS NULL ORDER BY `d`.`iswildcarddomain`, `d`.`domain` ASC";
|
||||
$query2 = "SELECT `d`.*, `pd`.`domain` AS `parentdomain`, `c`.`loginname`, `c`.`guid`, `c`.`email`, `c`.`documentroot` AS `customerroot`, `c`.`deactivated`, `c`.`phpenabled` AS `phpenabled` FROM `" . TABLE_PANEL_DOMAINS . "` `d` LEFT JOIN `" . TABLE_PANEL_CUSTOMERS . "` `c` USING(`customerid`) LEFT JOIN `" . TABLE_PANEL_DOMAINS . "` `pd` ON (`pd`.`id` = `d`.`parentdomainid`) WHERE `d`.`ipandport`='" . $ipandport['id'] . "' AND `d`.`aliasdomain` IS NULL ORDER BY `d`.`iswildcarddomain`, `d`.`domain` ASC";
|
||||
}
|
||||
else
|
||||
{
|
||||
$query2 = "SELECT `d`.`id`, `d`.`domain`, `d`.`customerid`, `d`.`documentroot`, `d`.`ssl`, `d`.`parentdomainid`, `d`.`ipandport`, `d`.`ssl_ipandport`, `d`.`ssl_redirect`, `d`.`isemaildomain`, `d`.`iswildcarddomain`, `d`.`wwwserveralias`, `d`.`openbasedir`, `d`.`openbasedir_path`, `d`.`safemode`, `d`.`speciallogfile`, `d`.`specialsettings`, `pd`.`domain` AS `parentdomain`, `c`.`loginname`, `c`.`guid`, `c`.`email`, `c`.`documentroot` AS `customerroot`, `c`.`deactivated`, `c`.`phpenabled` AS `phpenabled` FROM `" . TABLE_PANEL_DOMAINS . "` `d` LEFT JOIN `" . TABLE_PANEL_CUSTOMERS . "` `c` USING(`customerid`) LEFT JOIN `" . TABLE_PANEL_DOMAINS . "` `pd` ON (`pd`.`id` = `d`.`parentdomainid`) WHERE `d`.`ssl_ipandport`='" . $ipandport['id'] . "' AND `d`.`aliasdomain` IS NULL ORDER BY `d`.`iswildcarddomain`, `d`.`domain` ASC";
|
||||
$query2 = "SELECT `d`.*, `pd`.`domain` AS `parentdomain`, `c`.`loginname`, `c`.`guid`, `c`.`email`, `c`.`documentroot` AS `customerroot`, `c`.`deactivated`, `c`.`phpenabled` AS `phpenabled` FROM `" . TABLE_PANEL_DOMAINS . "` `d` LEFT JOIN `" . TABLE_PANEL_CUSTOMERS . "` `c` USING(`customerid`) LEFT JOIN `" . TABLE_PANEL_DOMAINS . "` `pd` ON (`pd`.`id` = `d`.`parentdomainid`) WHERE `d`.`ssl_ipandport`='" . $ipandport['id'] . "' AND `d`.`aliasdomain` IS NULL ORDER BY `d`.`iswildcarddomain`, `d`.`domain` ASC";
|
||||
}
|
||||
|
||||
$included_vhosts = array();
|
||||
@@ -323,6 +323,7 @@ class lighttpd
|
||||
$vhost_content.= $this->create_htaccess($domain);
|
||||
$vhost_content.= $this->create_pathOptions($domain);
|
||||
$vhost_content.= $this->composePhpOptions($domain);
|
||||
$vhost_content.= $this->getStats($domain);
|
||||
$vhost_content.= $this->getLogFiles($domain);
|
||||
$vhost_content.= '}' . "\n";
|
||||
return $vhost_content;
|
||||
@@ -351,6 +352,60 @@ class lighttpd
|
||||
|
||||
$logfiles_text.= ' accesslog.filename = "' . $access_log . '"' . "\n";
|
||||
}
|
||||
|
||||
if($this->settings['system']['awstats_enabled'] == '1')
|
||||
{
|
||||
if((int)$domain['parentdomainid'] == 0)
|
||||
{
|
||||
// prepare the aliases and subdomains for stats config files
|
||||
|
||||
$server_alias = '';
|
||||
$alias_domains = $this->db->query('SELECT `domain`, `iswildcarddomain`, `wwwserveralias` FROM `' . TABLE_PANEL_DOMAINS . '`
|
||||
WHERE `aliasdomain`=\'' . $domain['id'] . '\'
|
||||
OR `parentdomainid` =\''. $domain['id']. '\'');
|
||||
|
||||
while(($alias_domain = $this->db->fetch_array($alias_domains)) !== false)
|
||||
{
|
||||
$server_alias.= ' ' . $alias_domain['domain'] . ' ';
|
||||
|
||||
if($alias_domain['iswildcarddomain'] == '1')
|
||||
{
|
||||
$server_alias.= '*.' . $domain['domain'];
|
||||
}
|
||||
else
|
||||
{
|
||||
if($alias_domain['wwwserveralias'] == '1')
|
||||
{
|
||||
$server_alias.= 'www.' . $alias_domain['domain'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$server_alias.= '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($domain['iswildcarddomain'] == '1')
|
||||
{
|
||||
$alias = '*.' . $domain['domain'];
|
||||
}
|
||||
else
|
||||
{
|
||||
if($domain['wwwserveralias'] == '1')
|
||||
{
|
||||
$alias = 'www.' . $domain['domain'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$alias = '';
|
||||
}
|
||||
}
|
||||
|
||||
// After inserting the AWStats information,
|
||||
// be sure to build the awstats conf file as well
|
||||
createAWStatsConf($this->settings['system']['logfiles_directory'] . $domain['loginname'] . $speciallogfile . '-access.log', $domain['domain'], $alias . $server_alias, $domain['customerroot']);
|
||||
}
|
||||
}
|
||||
|
||||
return $logfiles_text;
|
||||
}
|
||||
@@ -570,6 +625,60 @@ class lighttpd
|
||||
|
||||
return $webroot_text;
|
||||
}
|
||||
|
||||
/*
|
||||
* Lets set the text part for the stats software
|
||||
*/
|
||||
|
||||
protected function getStats($domain)
|
||||
{
|
||||
$stats_text = '';
|
||||
|
||||
if($domain['speciallogfile'] == '1'
|
||||
&& $this->settings['system']['mod_log_sql'] != '1')
|
||||
{
|
||||
if($domain['parentdomainid'] == '0')
|
||||
{
|
||||
if($this->settings['system']['awstats_enabled'] == '1')
|
||||
{
|
||||
// @TODO see if this is correct for awstats
|
||||
$stats_text.= ' alias.url = ( "/awstats/" => "'.makeCorrectFile($domain['customerroot'] . '/awstats/' . $domain['domain']).'" )' . "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$stats_text.= ' alias.url = ( "/webalizer/" => "'.makeCorrectFile($domain['customerroot'] . '/webalizer/' . $domain['domain']).'" )' . "\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if($this->settings['system']['awstats_enabled'] == '1')
|
||||
{
|
||||
// @TODO see if this is correct for awstats
|
||||
$stats_text.= ' alias.url = ( "/awstats/" => "'.makeCorrectFile($domain['customerroot'] . '/awstats/' . $domain['parentdomain']).'" )' . "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$stats_text.= ' alias.url = ( "/webalizer/" => "'.makeCorrectFile($domain['customerroot'] . '/webalizer/' . $domain['parentdomain']).'" )' . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if($domain['customerroot'] != $domain['documentroot'])
|
||||
{
|
||||
if($this->settings['system']['awstats_enabled'] == '1')
|
||||
{
|
||||
$stats_text.= ' alias.url = ( "/awstats/" => "'.makeCorrectFile($domain['customerroot'] . '/awstats/' . $domain['domain']).'" )' . "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$stats_text.= ' alias.url = ( "/webalizer/" => "'.makeCorrectFile($domain['customerroot'] . '/webalizer').'" )' . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $stats_text;
|
||||
}
|
||||
|
||||
public function writeConfigs()
|
||||
{
|
||||
|
||||
@@ -61,7 +61,7 @@ while($row = $db->fetch_array($result_tasks))
|
||||
* (e.g. awstats not installed yet or whatever)
|
||||
* fixes #45
|
||||
*/
|
||||
if (is_dir($awstatsclean['dir']))
|
||||
if (is_dir($awstatsclean['path']))
|
||||
{
|
||||
$awstatsclean['dir'] = dir($awstatsclean['path']);
|
||||
while($awstatsclean['entry'] = $awstatsclean['dir']->read()) {
|
||||
@@ -75,6 +75,7 @@ while($row = $db->fetch_array($result_tasks))
|
||||
$awstatsclean['headerRead'] = fgets($awstatsclean['fh'], strlen($awstatsclean['header'])+1);
|
||||
fclose($awstatsclean['fh']);
|
||||
if($awstatsclean['headerRead'] == $awstatsclean['header']) {
|
||||
$cronlog->logAction(CRON_ACTION, LOG_INFO, "Removing awstats configuration ".$awstatsclean['fullentry']." for re-creation");
|
||||
@unlink($awstatsclean['fullentry']);
|
||||
}
|
||||
}
|
||||
@@ -140,6 +141,8 @@ while($row = $db->fetch_array($result_tasks))
|
||||
{
|
||||
$cronlog->logAction(CRON_ACTION, LOG_NOTICE, 'Running: mkdir -p ' . escapeshellarg($settings['system']['documentroot_prefix'] . $row['data']['loginname'] . '/webalizer'));
|
||||
safe_exec('mkdir -p ' . escapeshellarg($settings['system']['documentroot_prefix'] . $row['data']['loginname'] . '/webalizer'));
|
||||
$cronlog->logAction(CRON_ACTION, LOG_NOTICE, 'Running: mkdir -p ' . escapeshellarg($settings['system']['documentroot_prefix'] . $row['data']['loginname'] . '/awstats'));
|
||||
safe_exec('mkdir -p ' . escapeshellarg($settings['system']['documentroot_prefix'] . $row['data']['loginname'] . '/awstats'));
|
||||
$cronlog->logAction(CRON_ACTION, LOG_NOTICE, 'Running: mkdir -p ' . escapeshellarg($settings['system']['vmail_homedir'] . $row['data']['loginname']));
|
||||
safe_exec('mkdir -p ' . escapeshellarg($settings['system']['vmail_homedir'] . $row['data']['loginname']));
|
||||
|
||||
@@ -162,7 +165,7 @@ while($row = $db->fetch_array($result_tasks))
|
||||
}
|
||||
|
||||
/**
|
||||
* TYPE=4 MEANS THAT SOMETHING IN THE BIND CONFIG HAS CHANGED. REBUILD syscp_bind.conf
|
||||
* TYPE=4 MEANS THAT SOMETHING IN THE BIND CONFIG HAS CHANGED. REBUILD froxlor_bind.conf
|
||||
*/
|
||||
elseif ($row['type'] == '4')
|
||||
{
|
||||
|
||||
@@ -17,6 +17,114 @@
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
function awstatsDoSingleDomain($domain, $outputdir)
|
||||
{
|
||||
global $cronlog;
|
||||
$returnval = 0;
|
||||
|
||||
$domainconfig = '/etc/awstats/awstats.' . $domain . '.conf';
|
||||
if(file_exists($domainconfig))
|
||||
{
|
||||
$outputdir = makeCorrectDir($outputdir . '/' . $domain);
|
||||
|
||||
if(!is_dir($outputdir))
|
||||
{
|
||||
safe_exec('mkdir -p ' . escapeshellarg($outputdir));
|
||||
}
|
||||
|
||||
$cronlog->logAction(CRON_ACTION, LOG_INFO, "Running awstats_buildstaticpages.pl for domain '".$domain."' (Output: '".$outputdir."')");
|
||||
safe_exec('awstats_buildstaticpages.pl -update -config=' . $domain . ' -dir='.escapeshellarg($outputdir));
|
||||
|
||||
/**
|
||||
* index file is saved like 'awstats.[domain].html',
|
||||
* so link a index.html to it
|
||||
*/
|
||||
$original_index = makeCorrectFile($outputdir.'/awstats.'.$domain.'.html');
|
||||
$new_index = makeCorrectFile($outputdir.'/index.html');
|
||||
if(!file_exists($new_index)) {
|
||||
safe_exec('ln -s '.escapeshellarg($original_index).' '.escapeshellarg($new_index));
|
||||
}
|
||||
|
||||
/**
|
||||
* statistics file looks like: 'awstats[month][year].[domain].txt'
|
||||
*/
|
||||
$file = makeCorrectFile($outputdir.'/awstats'.date('mY', time()).'.'.$domain.'.txt');
|
||||
$cronlog->logAction(CRON_ACTION, LOG_INFO, "Gathering traffic information from '".$file."'");
|
||||
|
||||
if (file_exists($file)) {
|
||||
$content = @file_get_contents($file);
|
||||
if ($content !== false) {
|
||||
$content_array = explode("\n", $content);
|
||||
|
||||
$count_bdw = false;
|
||||
foreach($content_array as $line)
|
||||
{
|
||||
if(trim($line) == '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$parts = explode(' ', $line);
|
||||
|
||||
if(isset($line[0])
|
||||
&& strtoupper($line[0]) == 'BEGIN_DOMAIN'
|
||||
) {
|
||||
$count_bdw = true;
|
||||
}
|
||||
elseif(isset($line[0])
|
||||
&& strtoupper($line[0]) == 'END_DOMAIN'
|
||||
) {
|
||||
$count_bdw = false;
|
||||
}
|
||||
|
||||
if ($count_bdw) {
|
||||
if (isset($line[3])) {
|
||||
$returnval += floatval($line[3]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $returnval;
|
||||
}
|
||||
|
||||
function callAwstatsGetTraffic($domain, $outputdir, $caption, $usersdomainlist)
|
||||
{
|
||||
global $settings, $db, $cronlog;
|
||||
$returnval = 0;
|
||||
|
||||
foreach($usersdomainlist as $domainid => $singledomain)
|
||||
{
|
||||
// as we check for the config-model awstats will only parse
|
||||
// 'real' domains and no subdomains which are aliases in the
|
||||
// model-config-file.
|
||||
$returnval += awstatsDoSingleDomain($singledomain, $outputdir);
|
||||
}
|
||||
|
||||
/**
|
||||
* now, because this traffic is being saved daily, we have to
|
||||
* subtract the values from all the month's values to return
|
||||
* a sane value for our panel_traffic and to remain the whole stats
|
||||
* (awstats overwrites the customers .html stats-files)
|
||||
*/
|
||||
$customerid = getCustomerIdByDomain($domain);
|
||||
|
||||
if($customerid !== false)
|
||||
{
|
||||
$result = $db->query_first("SELECT SUM(`http`) as `trafficmonth` FROM `" . TABLE_PANEL_TRAFFIC . "`
|
||||
WHERE `customerid` = '".(int)$customerid."'
|
||||
AND `year`='".date('Y', time())."'
|
||||
AND `month`='".date('m', time())."'");
|
||||
if(is_array($result)
|
||||
&& isset($result['trafficmonth'])
|
||||
) {
|
||||
$returnval = ($returnval - floatval($result['trafficmonth']));
|
||||
}
|
||||
}
|
||||
|
||||
return floatval($returnval);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function which make webalizer statistics and returns used traffic since last run
|
||||
*
|
||||
@@ -29,7 +137,7 @@
|
||||
|
||||
function callWebalizerGetTraffic($logfile, $outputdir, $caption, $usersdomainlist)
|
||||
{
|
||||
global $settings;
|
||||
global $settings, $cronlog;
|
||||
$returnval = 0;
|
||||
|
||||
if(file_exists($settings['system']['logfiles_directory'] . $logfile . '-access.log'))
|
||||
@@ -37,6 +145,7 @@ function callWebalizerGetTraffic($logfile, $outputdir, $caption, $usersdomainlis
|
||||
$domainargs = '';
|
||||
foreach($usersdomainlist as $domainid => $domain)
|
||||
{
|
||||
// hide referer
|
||||
$domainargs.= ' -r ' . escapeshellarg($domain);
|
||||
}
|
||||
|
||||
@@ -69,6 +178,7 @@ function callWebalizerGetTraffic($logfile, $outputdir, $caption, $usersdomainlis
|
||||
$verbosity = '-Q';
|
||||
}
|
||||
|
||||
$cronlog->logAction(CRON_ACTION, LOG_INFO, "Running webalizer for domain '".$caption."'");
|
||||
safe_exec('webalizer ' . $verbosity . ' -p -o ' . escapeshellarg($outputdir) . ' -n ' . escapeshellarg($caption) . $domainargs . ' ' . escapeshellarg($settings['system']['logfiles_directory'] . $logfile . '-access.log'));
|
||||
|
||||
/**
|
||||
@@ -80,6 +190,7 @@ function callWebalizerGetTraffic($logfile, $outputdir, $caption, $usersdomainlis
|
||||
|
||||
$httptraffic = array();
|
||||
$webalizer_hist = @file_get_contents($outputdir . 'webalizer.hist');
|
||||
$cronlog->logAction(CRON_ACTION, LOG_INFO, "Gathering traffic information from '".$webalizer_hist."'");
|
||||
$webalizer_hist_rows = explode("\n", $webalizer_hist);
|
||||
foreach($webalizer_hist_rows as $webalizer_hist_row)
|
||||
{
|
||||
@@ -108,6 +219,7 @@ function callWebalizerGetTraffic($logfile, $outputdir, $caption, $usersdomainlis
|
||||
reset($httptraffic);
|
||||
$httptrafficlast = array();
|
||||
$webalizer_lasthist = @file_get_contents($outputdir . 'webalizer.hist.1');
|
||||
$cronlog->logAction(CRON_ACTION, LOG_INFO, "Gathering traffic information from '".$webalizer_lasthist."'");
|
||||
$webalizer_lasthist_rows = explode("\n", $webalizer_lasthist);
|
||||
foreach($webalizer_lasthist_rows as $webalizer_lasthist_row)
|
||||
{
|
||||
@@ -229,4 +341,3 @@ function safeSQLLogfile($domains, $loginname)
|
||||
$db->query("DELETE FROM access_log " . $where);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -165,7 +165,14 @@ while($row = $db->fetch_array($result))
|
||||
unset($domainlist[$row['customerid']][$domainid]);
|
||||
}
|
||||
|
||||
$httptraffic+= floatval(callWebalizerGetTraffic($row['loginname'] . '-' . $domain, $row['documentroot'] . '/webalizer/' . $domain . '/', $domain, $domainlist[$row['customerid']]));
|
||||
if($this->settings['system']['awstats_enabled'] == '1')
|
||||
{
|
||||
$httptraffic+= floatval(callAwstatsGetTraffic($domain, $row['documentroot'] . '/webalizer/' . $domain . '/', $domainlist[$row['customerid']]));
|
||||
}
|
||||
else
|
||||
{
|
||||
$httptraffic+= floatval(callWebalizerGetTraffic($row['loginname'] . '-' . $domain, $row['documentroot'] . '/webalizer/' . $domain . '/', $domain, $domainlist[$row['customerid']]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,7 +183,14 @@ while($row = $db->fetch_array($result))
|
||||
safeSQLLogfile($domainlist[$row['customerid']], $row['loginname']);
|
||||
}
|
||||
|
||||
$httptraffic+= floatval(callWebalizerGetTraffic($row['loginname'], $row['documentroot'] . '/webalizer/', $caption, $domainlist[$row['customerid']]));
|
||||
if($settings['system']['awstats_enabled'] == '1')
|
||||
{
|
||||
$httptraffic+= floatval(callAwstatsGetTraffic($caption, $row['documentroot'] . '/awstats/', $caption, $domainlist[$row['customerid']]));
|
||||
}
|
||||
else
|
||||
{
|
||||
$httptraffic+= floatval(callWebalizerGetTraffic($row['loginname'], $row['documentroot'] . '/webalizer/', $caption, $domainlist[$row['customerid']]));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user