From f686264ad6d82cfaf4e401da2e259880f57bfade Mon Sep 17 00:00:00 2001
From: Marius Burkard <m.burkard@pixcept.de>
Date: Sat, 30 Jan 2016 07:44:29 -0500
Subject: [PATCH] Merge branch 'master' into 'stable-3.1'
---
server/lib/classes/cron.d/150-awstats.inc.php | 25 +++++++++++++++++--------
1 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/server/lib/classes/cron.d/150-awstats.inc.php b/server/lib/classes/cron.d/150-awstats.inc.php
index 1ef4ac4..2d281c7 100644
--- a/server/lib/classes/cron.d/150-awstats.inc.php
+++ b/server/lib/classes/cron.d/150-awstats.inc.php
@@ -54,8 +54,8 @@
// Create awstats statistics
//######################################################################################################
- $sql = "SELECT domain_id, domain, document_root, web_folder, type, system_user, system_group, parent_domain_id FROM web_domain WHERE (type = 'vhost' or type = 'vhostsubdomain') and stats_type = 'awstats' AND server_id = ".$conf['server_id'];
- $records = $app->db->queryAllRecords($sql);
+ $sql = "SELECT domain_id, domain, document_root, web_folder, type, system_user, system_group, parent_domain_id FROM web_domain WHERE (type = 'vhost' or type = 'vhostsubdomain' or type = 'vhostalias') and stats_type = 'awstats' AND server_id = ?";
+ $records = $app->db->queryAllRecords($sql, $conf['server_id']);
$web_config = $app->getconf->get_server_config($conf['server_id'], 'web');
@@ -64,8 +64,8 @@
$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;
@@ -78,7 +78,7 @@
continue;
}
}
- $web_folder = ($rec['type'] == 'vhostsubdomain' ? $rec['web_folder'] : 'web');
+ $web_folder = (($rec['type'] == 'vhostsubdomain' || $rec['type'] == 'vhostalias') ? $rec['web_folder'] : 'web');
$domain = escapeshellcmd($rec['domain']);
$statsdir = escapeshellcmd($rec['document_root'].'/'.$web_folder.'/stats');
$awstats_pl = $web_config['awstats_pl'];
@@ -89,8 +89,8 @@
if(is_file($awstats_website_conf_file)) unlink($awstats_website_conf_file);
- $sql = "SELECT domain FROM web_domain WHERE (type = 'alias' OR type = 'subdomain') AND parent_domain_id = ".$rec['domain_id'];
- $aliases = $app->db->queryAllRecords($sql);
+ $sql = "SELECT domain FROM web_domain WHERE (type = 'alias' OR type = 'subdomain') AND parent_domain_id = ?";
+ $aliases = $app->db->queryAllRecords($sql, $rec['domain_id']);
$aliasdomain = '';
if(is_array($aliases)) {
@@ -109,10 +109,18 @@
LogFile="/var/log/ispconfig/httpd/'.$domain.'/yesterday-access.log"
SiteDomain="'.$domain.'"
HostAliases="www.'.$domain.' localhost 127.0.0.1'.$aliasdomain.'"';
- file_put_contents($awstats_website_conf_file, $awstats_conf_file_content);
+ if (isset($include_file)) {
+ file_put_contents($awstats_website_conf_file, $awstats_conf_file_content);
+ } else {
+ $app->log("No awstats base config found. Either awstats.conf or awstats.model.conf must exist in ".$awstats_conf_dir.".", LOGLEVEL_WARN);
+ }
}
if(!@is_dir($statsdir)) mkdir($statsdir);
+ $username = escapeshellcmd($rec['system_user']);
+ $groupname = escapeshellcmd($rec['system_group']);
+ chown($statsdir, $username);
+ chgrp($statsdir, $groupname);
if(is_link('/var/log/ispconfig/httpd/'.$domain.'/yesterday-access.log')) unlink('/var/log/ispconfig/httpd/'.$domain.'/yesterday-access.log');
symlink($logfile, '/var/log/ispconfig/httpd/'.$domain.'/yesterday-access.log');
@@ -170,6 +178,7 @@
chgrp($rec['document_root']."/".$web_folder."/stats/index.php", $rec['system_group']);
}
+ exec('chown -R '.$username.':'.$groupname.' '.$statsdir);
}
--
Gitblit v1.9.1