remove mod_log_sql as planned
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
@@ -537,45 +537,31 @@ class apache
|
||||
{
|
||||
$stats_text = '';
|
||||
|
||||
if($domain['speciallogfile'] == '1'
|
||||
&& $this->settings['system']['mod_log_sql'] != '1')
|
||||
{
|
||||
if($domain['parentdomainid'] == '0')
|
||||
{
|
||||
if($this->settings['system']['awstats_enabled'] == '1')
|
||||
{
|
||||
if($domain['speciallogfile'] == '1') {
|
||||
|
||||
if ($domain['parentdomainid'] == '0') {
|
||||
|
||||
if ($this->settings['system']['awstats_enabled'] == '1') {
|
||||
$stats_text.= ' Alias /awstats "' . makeCorrectFile($domain['customerroot'] . '/awstats/' . $domain['domain']) . '"' . "\n";
|
||||
$stats_text.= ' Alias /awstats-icon "' . makeCorrectDir($this->settings['system']['awstats_icons']) . '"' . "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$stats_text.= ' Alias /webalizer "' . makeCorrectFile($domain['customerroot'] . '/webalizer/' . $domain['domain']) . '"' . "\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if($this->settings['system']['awstats_enabled'] == '1')
|
||||
{
|
||||
} else {
|
||||
|
||||
if ($this->settings['system']['awstats_enabled'] == '1') {
|
||||
$stats_text.= ' Alias /awstats "' . makeCorrectFile($domain['customerroot'] . '/awstats/' . $domain['parentdomain']) . '"' . "\n";
|
||||
$stats_text.= ' Alias /awstats-icon "' . makeCorrectDir($this->settings['system']['awstats_icons']) . '"' . "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$stats_text.= ' Alias /webalizer "' . makeCorrectFile($domain['customerroot'] . '/webalizer/' . $domain['parentdomain']) . '"' . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if($domain['customerroot'] != $domain['documentroot'])
|
||||
{
|
||||
if($this->settings['system']['awstats_enabled'] == '1')
|
||||
{
|
||||
} else {
|
||||
if ($domain['customerroot'] != $domain['documentroot']) {
|
||||
if ($this->settings['system']['awstats_enabled'] == '1') {
|
||||
$stats_text.= ' Alias /awstats "' . makeCorrectFile($domain['customerroot'] . '/awstats/' . $domain['domain']) . '"' . "\n";
|
||||
$stats_text.= ' Alias /awstats-icon "' . makeCorrectDir($this->settings['system']['awstats_icons']) . '"' . "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$stats_text.= ' Alias /webalizer "' . makeCorrectFile($domain['customerroot'] . '/webalizer') . '"' . "\n";
|
||||
}
|
||||
}
|
||||
@@ -583,8 +569,7 @@ class apache
|
||||
// because the stats are in /awstats/[domain], not just /awstats/
|
||||
// also, the awstats-icons are someplace else too!
|
||||
// -> webalizer does not need this!
|
||||
elseif($this->settings['system']['awstats_enabled'] == '1')
|
||||
{
|
||||
elseif ($this->settings['system']['awstats_enabled'] == '1') {
|
||||
$stats_text.= ' Alias /awstats "' . makeCorrectFile($domain['documentroot'] . '/awstats/' . $domain['domain']) . '"' . "\n";
|
||||
$stats_text.= ' Alias /awstats-icon "' . makeCorrectDir($this->settings['system']['awstats_icons']) . '"' . "\n";
|
||||
}
|
||||
@@ -596,99 +581,65 @@ class apache
|
||||
/*
|
||||
* Lets set the logfiles
|
||||
*/
|
||||
protected function getLogfiles($domain) {
|
||||
|
||||
protected function getLogfiles($domain)
|
||||
{
|
||||
$logfiles_text = '';
|
||||
|
||||
if($domain['speciallogfile'] == '1'
|
||||
&& $this->settings['system']['mod_log_sql'] != '1')
|
||||
{
|
||||
if($domain['parentdomainid'] == '0')
|
||||
{
|
||||
if ($domain['speciallogfile'] == '1') {
|
||||
if ($domain['parentdomainid'] == '0') {
|
||||
$speciallogfile = '-' . $domain['domain'];
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$speciallogfile = '-' . $domain['parentdomain'];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$speciallogfile = '';
|
||||
}
|
||||
|
||||
if($this->settings['system']['mod_log_sql'] == '1')
|
||||
{
|
||||
// We are using mod_log_sql (http://www.outoforder.cc/projects/apache/mod_log_sql/)
|
||||
// TODO: See how we are able emulate the error_log
|
||||
// The normal access/error - logging is enabled
|
||||
$error_log = makeCorrectFile($this->settings['system']['logfiles_directory'] . $domain['loginname'] . $speciallogfile . '-error.log');
|
||||
// Create the logfile if it does not exist (fixes #46)
|
||||
touch($error_log);
|
||||
chown($error_log, $this->settings['system']['httpuser']);
|
||||
chgrp($error_log, $this->settings['system']['httpgroup']);
|
||||
|
||||
$logfiles_text.= ' LogSQLTransferLogTable access_log' . "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
// The normal access/error - logging is enabled
|
||||
$error_log = makeCorrectFile($this->settings['system']['logfiles_directory'] . $domain['loginname'] . $speciallogfile . '-error.log');
|
||||
// Create the logfile if it does not exist (fixes #46)
|
||||
touch($error_log);
|
||||
chown($error_log, $this->settings['system']['httpuser']);
|
||||
chgrp($error_log, $this->settings['system']['httpgroup']);
|
||||
$access_log = makeCorrectFile($this->settings['system']['logfiles_directory'] . $domain['loginname'] . $speciallogfile . '-access.log');
|
||||
// Create the logfile if it does not exist (fixes #46)
|
||||
touch($access_log);
|
||||
chown($access_log, $this->settings['system']['httpuser']);
|
||||
chgrp($access_log, $this->settings['system']['httpgroup']);
|
||||
|
||||
$access_log = makeCorrectFile($this->settings['system']['logfiles_directory'] . $domain['loginname'] . $speciallogfile . '-access.log');
|
||||
// Create the logfile if it does not exist (fixes #46)
|
||||
touch($access_log);
|
||||
chown($access_log, $this->settings['system']['httpuser']);
|
||||
chgrp($access_log, $this->settings['system']['httpgroup']);
|
||||
$logfiles_text.= ' ErrorLog "' . $error_log . "\"\n";
|
||||
$logfiles_text.= ' CustomLog "' . $access_log .'" combined' . "\n";
|
||||
|
||||
$logfiles_text.= ' ErrorLog "' . $error_log . "\"\n";
|
||||
$logfiles_text.= ' CustomLog "' . $access_log .'" combined' . "\n";
|
||||
|
||||
}
|
||||
|
||||
if($this->settings['system']['awstats_enabled'] == '1')
|
||||
{
|
||||
if((int)$domain['parentdomainid'] == 0)
|
||||
{
|
||||
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)
|
||||
{
|
||||
while (($alias_domain = $this->db->fetch_array($alias_domains)) !== false) {
|
||||
|
||||
$server_alias.= ' ' . $alias_domain['domain'] . ' ';
|
||||
|
||||
if($alias_domain['iswildcarddomain'] == '1')
|
||||
{
|
||||
if ($alias_domain['iswildcarddomain'] == '1') {
|
||||
$server_alias.= '*.' . $alias_domain['domain'];
|
||||
}
|
||||
else
|
||||
{
|
||||
if($alias_domain['wwwserveralias'] == '1')
|
||||
{
|
||||
} else {
|
||||
if ($alias_domain['wwwserveralias'] == '1') {
|
||||
$server_alias.= 'www.' . $alias_domain['domain'];
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$server_alias.= '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($domain['iswildcarddomain'] == '1')
|
||||
{
|
||||
if ($domain['iswildcarddomain'] == '1') {
|
||||
$alias = '*.' . $domain['domain'];
|
||||
}
|
||||
else
|
||||
{
|
||||
if($domain['wwwserveralias'] == '1')
|
||||
{
|
||||
} else {
|
||||
if ($domain['wwwserveralias'] == '1') {
|
||||
$alias = 'www.' . $domain['domain'];
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$alias = '';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -535,91 +535,63 @@ class lighttpd
|
||||
return $ssl_settings;
|
||||
}
|
||||
|
||||
protected function getLogFiles($domain)
|
||||
{
|
||||
protected function getLogFiles($domain) {
|
||||
|
||||
$logfiles_text = '';
|
||||
|
||||
if($domain['speciallogfile'] == '1'
|
||||
&& $this->settings['system']['mod_log_sql'] != '1')
|
||||
{
|
||||
if($domain['parentdomainid'] == '0')
|
||||
{
|
||||
if($domain['speciallogfile'] == '1') {
|
||||
|
||||
if ($domain['parentdomainid'] == '0') {
|
||||
$speciallogfile = '-' . $domain['domain'];
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$speciallogfile = '-' . $domain['parentdomain'];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$speciallogfile = '';
|
||||
}
|
||||
|
||||
if($this->settings['system']['mod_log_sql'] == 1)
|
||||
{
|
||||
// We are using mod_log_sql (http://www.outoforder.cc/projects/apache/mod_log_sql/)
|
||||
// TODO: See how we are able emulate the error_log
|
||||
}
|
||||
else
|
||||
{
|
||||
// The normal access/error - logging is enabled
|
||||
// error log cannot be set conditionally see
|
||||
// https://redmine.lighttpd.net/issues/665
|
||||
// The normal access/error - logging is enabled
|
||||
// error log cannot be set conditionally see
|
||||
// https://redmine.lighttpd.net/issues/665
|
||||
|
||||
$access_log = makeCorrectFile($this->settings['system']['logfiles_directory'] . $domain['loginname'] . $speciallogfile . '-access.log');
|
||||
// Create the logfile if it does not exist (fixes #46)
|
||||
touch($access_log);
|
||||
chown($access_log, $this->settings['system']['httpuser']);
|
||||
chgrp($access_log, $this->settings['system']['httpgroup']);
|
||||
$access_log = makeCorrectFile($this->settings['system']['logfiles_directory'] . $domain['loginname'] . $speciallogfile . '-access.log');
|
||||
// Create the logfile if it does not exist (fixes #46)
|
||||
touch($access_log);
|
||||
chown($access_log, $this->settings['system']['httpuser']);
|
||||
chgrp($access_log, $this->settings['system']['httpgroup']);
|
||||
|
||||
$logfiles_text.= ' accesslog.filename = "' . $access_log . '"' . "\n";
|
||||
}
|
||||
$logfiles_text.= ' accesslog.filename = "' . $access_log . '"' . "\n";
|
||||
|
||||
if($this->settings['system']['awstats_enabled'] == '1')
|
||||
{
|
||||
if((int)$domain['parentdomainid'] == 0)
|
||||
{
|
||||
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)
|
||||
{
|
||||
while (($alias_domain = $this->db->fetch_array($alias_domains)) !== false) {
|
||||
|
||||
$server_alias.= ' ' . $alias_domain['domain'] . ' ';
|
||||
|
||||
if($alias_domain['iswildcarddomain'] == '1')
|
||||
{
|
||||
if ($alias_domain['iswildcarddomain'] == '1') {
|
||||
$server_alias.= '*.' . $domain['domain'];
|
||||
}
|
||||
else
|
||||
{
|
||||
if($alias_domain['wwwserveralias'] == '1')
|
||||
{
|
||||
} else {
|
||||
if ($alias_domain['wwwserveralias'] == '1') {
|
||||
$server_alias.= 'www.' . $alias_domain['domain'];
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$server_alias.= '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($domain['iswildcarddomain'] == '1')
|
||||
{
|
||||
if ($domain['iswildcarddomain'] == '1') {
|
||||
$alias = '*.' . $domain['domain'];
|
||||
}
|
||||
else
|
||||
{
|
||||
if($domain['wwwserveralias'] == '1')
|
||||
{
|
||||
} else {
|
||||
if ($domain['wwwserveralias'] == '1') {
|
||||
$alias = 'www.' . $domain['domain'];
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$alias = '';
|
||||
}
|
||||
}
|
||||
@@ -876,49 +848,33 @@ class lighttpd
|
||||
* Lets set the text part for the stats software
|
||||
*/
|
||||
|
||||
protected function getStats($domain)
|
||||
{
|
||||
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')
|
||||
{
|
||||
if ($domain['speciallogfile'] == '1') {
|
||||
|
||||
if ($domain['parentdomainid'] == '0') {
|
||||
if ($this->settings['system']['awstats_enabled'] == '1') {
|
||||
$stats_text.= ' alias.url = ( "/awstats/" => "'.makeCorrectFile($domain['customerroot'] . '/awstats/' . $domain['domain']).'" )' . "\n";
|
||||
$stats_text.= ' alias.url += ( "/awstats-icon" => "' . makeCorrectDir($this->settings['system']['awstats_icons']) . '" )' . "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$stats_text.= ' alias.url = ( "/webalizer/" => "'.makeCorrectFile($domain['customerroot'] . '/webalizer/' . $domain['domain']).'/" )' . "\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if($this->settings['system']['awstats_enabled'] == '1')
|
||||
{
|
||||
} else {
|
||||
if ($this->settings['system']['awstats_enabled'] == '1') {
|
||||
$stats_text.= ' alias.url = ( "/awstats/" => "'.makeCorrectFile($domain['customerroot'] . '/awstats/' . $domain['parentdomain']).'" )' . "\n";
|
||||
$stats_text.= ' alias.url += ( "/awstats-icon" => "' . makeCorrectDir($this->settings['system']['awstats_icons']) . '" )' . "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
} 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')
|
||||
{
|
||||
} 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";
|
||||
$stats_text.= ' alias.url += ( "/awstats-icon" => "' . makeCorrectDir($this->settings['system']['awstats_icons']) . '" )' . "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$stats_text.= ' alias.url = ( "/webalizer/" => "'.makeCorrectFile($domain['customerroot'] . '/webalizer/').'" )' . "\n";
|
||||
}
|
||||
}
|
||||
@@ -926,8 +882,7 @@ class lighttpd
|
||||
// because the stats are in /awstats/[domain], not just /awstats/
|
||||
// also, the awstats-icons are someplace else too!
|
||||
// -> webalizer does not need this!
|
||||
elseif($this->settings['system']['awstats_enabled'] == '1')
|
||||
{
|
||||
elseif ($this->settings['system']['awstats_enabled'] == '1') {
|
||||
$stats_text.= ' alias.url = ( "/awstats/" => "'.makeCorrectFile($domain['documentroot'] . '/awstats/' . $domain['domain']).'" )' . "\n";
|
||||
$stats_text.= ' alias.url += ( "/awstats-icon" => "' . makeCorrectDir($this->settings['system']['awstats_icons']) . '" )' . "\n";
|
||||
}
|
||||
|
||||
@@ -735,27 +735,18 @@ class nginx
|
||||
return $stats_text;
|
||||
}
|
||||
|
||||
/**
|
||||
* @TODO mod_log_sql
|
||||
*/
|
||||
protected function getLogFiles($domain)
|
||||
{
|
||||
protected function getLogFiles($domain) {
|
||||
|
||||
$logfiles_text = '';
|
||||
|
||||
if($domain['speciallogfile'] == '1'
|
||||
&& $this->settings['system']['mod_log_sql'] != '1')
|
||||
{
|
||||
if($domain['parentdomainid'] == '0')
|
||||
{
|
||||
if ($domain['speciallogfile'] == '1') {
|
||||
|
||||
if ($domain['parentdomainid'] == '0') {
|
||||
$speciallogfile = '-' . $domain['domain'];
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$speciallogfile = '-' . $domain['parentdomain'];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$speciallogfile = '';
|
||||
}
|
||||
|
||||
@@ -775,50 +766,34 @@ class nginx
|
||||
$logfiles_text.= "\t".'access_log ' . $access_log . ' combined;' . "\n";
|
||||
$logfiles_text.= "\t".'error_log ' . $error_log . ' error;' . "\n";
|
||||
|
||||
if($this->settings['system']['awstats_enabled'] == '1')
|
||||
{
|
||||
if((int)$domain['parentdomainid'] == 0)
|
||||
{
|
||||
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)
|
||||
{
|
||||
while (($alias_domain = $this->db->fetch_array($alias_domains)) !== false) {
|
||||
$server_alias.= ' ' . $alias_domain['domain'] . ' ';
|
||||
|
||||
if($alias_domain['iswildcarddomain'] == '1')
|
||||
{
|
||||
if ($alias_domain['iswildcarddomain'] == '1') {
|
||||
$server_alias.= '*.' . $domain['domain'];
|
||||
}
|
||||
else
|
||||
{
|
||||
if($alias_domain['wwwserveralias'] == '1')
|
||||
{
|
||||
} else {
|
||||
if ($alias_domain['wwwserveralias'] == '1') {
|
||||
$server_alias.= 'www.' . $alias_domain['domain'];
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$server_alias.= '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($domain['iswildcarddomain'] == '1')
|
||||
{
|
||||
if ($domain['iswildcarddomain'] == '1') {
|
||||
$alias = '*.' . $domain['domain'];
|
||||
}
|
||||
else
|
||||
{
|
||||
if($domain['wwwserveralias'] == '1')
|
||||
{
|
||||
} else {
|
||||
if ($domain['wwwserveralias'] == '1') {
|
||||
$alias = 'www.' . $domain['domain'];
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$alias = '';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -291,80 +291,3 @@ function callWebalizerGetTraffic($logfile, $outputdir, $caption, $usersdomainlis
|
||||
|
||||
return floatval($returnval);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function saves the logfile written by mod_log_sql
|
||||
* into a logfile webalizer can parse
|
||||
*
|
||||
* @param string $domain The "speciallogfile" - domain(s)
|
||||
* @param string $loginname The loginname of the customer
|
||||
* @return bool
|
||||
*
|
||||
* @author Florian Aders <eleras@syscp.org>
|
||||
*/
|
||||
|
||||
function safeSQLLogfile($domains, $loginname)
|
||||
{
|
||||
global $db, $settings, $theme;
|
||||
$sql = "SELECT * FROM access_log ";
|
||||
$where = "WHERE virtual_host = ";
|
||||
|
||||
if(!is_array($domains))
|
||||
{
|
||||
// If it isn't an array, it's a speciallogfile-domain
|
||||
|
||||
$logname = $settings['system']['logfiles_directory'] . $loginname . '-' . $domains . '-access.log';
|
||||
$where.= "'$domains' OR virtual_host = 'www.$domains'";
|
||||
}
|
||||
else
|
||||
{
|
||||
// If we have an array, these are all domains aggregated into a single logfile
|
||||
|
||||
if(count($domains) == 0)
|
||||
{
|
||||
// If the $omains-array is empty, this customer has only speciallogfile-
|
||||
// domains, so just return, all logfiles are already written to disk
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
$logname = $settings['system']['logfiles_directory'] . $loginname . '-access.log';
|
||||
|
||||
// Build the "WHERE" - part of the sql-query
|
||||
|
||||
foreach($domains as $domain)
|
||||
{
|
||||
// A domain may be reached with or without the "www" in front.
|
||||
|
||||
$where.= "'$domain' OR virtual_host = 'www.$domain' OR virtual_host = ";
|
||||
}
|
||||
|
||||
$where = substr($where, 0, -19);
|
||||
}
|
||||
|
||||
// We want clean, ordered logfiles
|
||||
|
||||
$sql.= $where . " ORDER BY time_stamp;";
|
||||
$logs = $db->query($sql);
|
||||
|
||||
// Don't overwrite the logfile - append the new stuff
|
||||
|
||||
file_put_contents($logname, "", FILE_APPEND);
|
||||
|
||||
while($logline = $db->fetch_array($logs))
|
||||
{
|
||||
// Create a "CustomLog" - line
|
||||
|
||||
$writelog = $logline['remote_host'] . " " . $logline['virtual_host'] . " " . $logline['remote_user'] . " ";
|
||||
$writelog.= date("[d/M/Y:H:i:s O]", $logline['time_stamp']);
|
||||
$writelog.= " \"" . $logline['request_method'] . " " . $logline['request_uri'] . " " . $logline['request_protocol'] . "\" ";
|
||||
$writelog.= $logline['status'];
|
||||
$writelog.= " " . $logline['bytes_sent'] . " \"" . $logline['referer'] . "\" \"" . $logline['agent'] . "\"\n";
|
||||
file_put_contents($logname, $writelog, FILE_APPEND);
|
||||
}
|
||||
|
||||
// Remove the just written stuff
|
||||
|
||||
$db->query("DELETE FROM access_log " . $where);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -153,16 +153,14 @@ while($row_database = $db->fetch_array($databases))
|
||||
|
||||
$db_root->close();
|
||||
|
||||
# We are using the file-system quota, this will speed up the diskusage - collection
|
||||
if ($settings['system']['diskquota_enabled'])
|
||||
{
|
||||
// We are using the file-system quota, this will speed up the diskusage - collection
|
||||
if ($settings['system']['diskquota_enabled']) {
|
||||
$usedquota = getFilesystemQuota();
|
||||
}
|
||||
|
||||
$result = $db->query("SELECT * FROM `" . TABLE_PANEL_CUSTOMERS . "` ORDER BY `customerid` ASC");
|
||||
|
||||
while($row = $db->fetch_array($result))
|
||||
{
|
||||
while ($row = $db->fetch_array($result)) {
|
||||
/**
|
||||
* HTTP-Traffic
|
||||
*/
|
||||
@@ -170,31 +168,24 @@ while($row = $db->fetch_array($result))
|
||||
fwrite($debugHandler, 'http traffic for ' . $row['loginname'] . ' started...' . "\n");
|
||||
$httptraffic = 0;
|
||||
|
||||
if(isset($domainlist[$row['customerid']])
|
||||
if (isset($domainlist[$row['customerid']])
|
||||
&& is_array($domainlist[$row['customerid']])
|
||||
&& count($domainlist[$row['customerid']]) != 0)
|
||||
{
|
||||
&& count($domainlist[$row['customerid']]) != 0
|
||||
) {
|
||||
// Examining which caption to use for default webalizer stats...
|
||||
|
||||
if($row['standardsubdomain'] != '0')
|
||||
{
|
||||
if ($row['standardsubdomain'] != '0') {
|
||||
// ... of course we'd prefer to use the standardsubdomain ...
|
||||
|
||||
$caption = $domainlist[$row['customerid']][$row['standardsubdomain']];
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// ... but if there is no standardsubdomain, we have to use the loginname ...
|
||||
|
||||
$caption = $row['loginname'];
|
||||
|
||||
// ... which results in non-usable links to files in the stats, so lets have a look if we find a domain which is not speciallogfiledomain
|
||||
foreach ($domainlist[$row['customerid']] as $domainid => $domain) {
|
||||
|
||||
foreach($domainlist[$row['customerid']] as $domainid => $domain)
|
||||
{
|
||||
if(!isset($speciallogfile_domainlist[$row['customerid']])
|
||||
|| !isset($speciallogfile_domainlist[$row['customerid']][$domainid]))
|
||||
{
|
||||
if (!isset($speciallogfile_domainlist[$row['customerid']])
|
||||
|| !isset($speciallogfile_domainlist[$row['customerid']][$domainid])
|
||||
) {
|
||||
$caption = $domain;
|
||||
break;
|
||||
}
|
||||
@@ -204,38 +195,25 @@ while($row = $db->fetch_array($result))
|
||||
$httptraffic = 0;
|
||||
reset($domainlist[$row['customerid']]);
|
||||
|
||||
if(isset($speciallogfile_domainlist[$row['customerid']])
|
||||
if (isset($speciallogfile_domainlist[$row['customerid']])
|
||||
&& is_array($speciallogfile_domainlist[$row['customerid']])
|
||||
&& count($speciallogfile_domainlist[$row['customerid']]) != 0)
|
||||
{
|
||||
&& count($speciallogfile_domainlist[$row['customerid']]) != 0
|
||||
) {
|
||||
reset($speciallogfile_domainlist[$row['customerid']]);
|
||||
foreach($speciallogfile_domainlist[$row['customerid']] as $domainid => $domain)
|
||||
{
|
||||
if($settings['system']['mod_log_sql'] == 1)
|
||||
{
|
||||
safeSQLLogfile($domain, $row['loginname']);
|
||||
|
||||
// Remove this domain from the domainlist - it's already analysed
|
||||
// and doesn't need to be selected twice
|
||||
|
||||
unset($domainlist[$row['customerid']][$domainid]);
|
||||
}
|
||||
|
||||
if($settings['system']['awstats_enabled'] == '0')
|
||||
{
|
||||
if ($settings['system']['awstats_enabled'] == '0') {
|
||||
foreach ($speciallogfile_domainlist[$row['customerid']] as $domainid => $domain) {
|
||||
$httptraffic+= floatval(callWebalizerGetTraffic($row['loginname'] . '-' . $domain, $row['documentroot'] . '/webalizer/' . $domain . '/', $domain, $domainlist[$row['customerid']]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// logrotate speciallogfiles
|
||||
if(isset($speciallogfile_domainlist[$row['customerid']])
|
||||
&& is_array($speciallogfile_domainlist[$row['customerid']])
|
||||
&& count($speciallogfile_domainlist[$row['customerid']]) != 0)
|
||||
{
|
||||
if (isset($speciallogfile_domainlist[$row['customerid']])
|
||||
&& is_array($speciallogfile_domainlist[$row['customerid']])
|
||||
&& count($speciallogfile_domainlist[$row['customerid']]) != 0
|
||||
) {
|
||||
reset($speciallogfile_domainlist[$row['customerid']]);
|
||||
foreach($speciallogfile_domainlist[$row['customerid']] as $domainid => $domain)
|
||||
{
|
||||
foreach ($speciallogfile_domainlist[$row['customerid']] as $domainid => $domain) {
|
||||
|
||||
$logrotatefile = '/tmp/froxlor_logrotate_tmpfile.conf';
|
||||
$fh = fopen($logrotatefile, 'w');
|
||||
@@ -264,21 +242,13 @@ while($row = $db->fetch_array($result))
|
||||
|
||||
reset($domainlist[$row['customerid']]);
|
||||
|
||||
if($settings['system']['mod_log_sql'] == 1)
|
||||
{
|
||||
safeSQLLogfile($domainlist[$row['customerid']], $row['loginname']);
|
||||
}
|
||||
|
||||
// callAwstatsGetTraffic is called ONLY HERE and
|
||||
// *not* also in the special-logfiles-loop, because the function
|
||||
// will iterate through all customer-domains and the awstats-configs
|
||||
// know the logfile-name, #246
|
||||
if($settings['system']['awstats_enabled'] == '1')
|
||||
{
|
||||
if ($settings['system']['awstats_enabled'] == '1') {
|
||||
$httptraffic+= floatval(callAwstatsGetTraffic($row['customerid'], $row['documentroot'] . '/awstats/', $domainlist[$row['customerid']]));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$httptraffic+= floatval(callWebalizerGetTraffic($row['loginname'], $row['documentroot'] . '/webalizer/', $caption, $domainlist[$row['customerid']]));
|
||||
}
|
||||
|
||||
@@ -286,8 +256,7 @@ while($row = $db->fetch_array($result))
|
||||
makeChownWithNewStats($row);
|
||||
|
||||
// logrotate
|
||||
if($settings['system']['logrotate_enabled'] == '1')
|
||||
{
|
||||
if ($settings['system']['logrotate_enabled'] == '1') {
|
||||
fwrite($debugHandler, ' logrotate customers logs' . "\n");
|
||||
|
||||
$logrotatefile = '/tmp/froxlor_logrotate_tmpfile.conf';
|
||||
@@ -318,8 +287,8 @@ while($row = $db->fetch_array($result))
|
||||
* Webalizer/AWStats might run for some time, so we'd better check if our database is still present
|
||||
*/
|
||||
if (empty($db->link_id)
|
||||
|| $db->link_id === false)
|
||||
{
|
||||
|| $db->link_id === false
|
||||
) {
|
||||
fwrite($debugHandler, 'Database-connection seems to be down, trying to reconnect' . "\n");
|
||||
|
||||
// just in case
|
||||
@@ -348,8 +317,7 @@ while($row = $db->fetch_array($result))
|
||||
fwrite($debugHandler, 'ftp traffic for ' . $row['loginname'] . ' started...' . "\n");
|
||||
$ftptraffic = $db->query_first("SELECT SUM(`up_bytes`) AS `up_bytes_sum`, SUM(`down_bytes`) AS `down_bytes_sum` FROM `" . TABLE_FTP_USERS . "` WHERE `customerid`='" . (int)$row['customerid'] . "'");
|
||||
|
||||
if(!is_array($ftptraffic))
|
||||
{
|
||||
if (!is_array($ftptraffic)) {
|
||||
$ftptraffic = array(
|
||||
'up_bytes_sum' => 0,
|
||||
'down_bytes_sum' => 0
|
||||
|
||||
Reference in New Issue
Block a user