From e756e7e8a99d604ef85a9630c856bc0ffae2a3f0 Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Tue, 10 Jan 2012 05:16:15 -0500
Subject: [PATCH] Fixed: FS#1967 - AWStats statistics not accessible when the website uses suphp.

---
 server/cron_daily.php |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/server/cron_daily.php b/server/cron_daily.php
index 9c52805..2ff012d 100644
--- a/server/cron_daily.php
+++ b/server/cron_daily.php
@@ -154,7 +154,7 @@
 // Create awstats statistics
 #######################################################################################################
 
-$sql = "SELECT domain_id, domain, document_root FROM web_domain WHERE stats_type = 'awstats' AND server_id = ".$conf['server_id'];
+$sql = "SELECT domain_id, domain, document_root, system_user, system_group FROM web_domain WHERE stats_type = 'awstats' AND server_id = ".$conf['server_id'];
 $records = $app->db->queryAllRecords($sql);
 
 $web_config = $app->getconf->get_server_config($conf['server_id'], 'web');
@@ -240,6 +240,11 @@
 		rename($rec['document_root'].'/web/stats/awstats.'.$domain.'.html',$rec['document_root'].'/web/stats/awsindex.html');
 		if(!is_file($rec['document_root']."/web/stats/index.php")) copy("/usr/local/ispconfig/server/conf/awstats_index.php.master",$rec['document_root']."/web/stats/index.php");
 		
+		if(is_file($rec['document_root']."/web/stats/index.php")) {
+			chown($rec['document_root']."/web/stats/index.php",$rec['system_user']);
+			chgrp($rec['document_root']."/web/stats/index.php",$rec['system_group']);
+		}
+		
 		$app->log('Created awstats statistics with command: '.$command,LOGLEVEL_DEBUG);
 	} else {
 		$app->log("No awstats statistics created. Either $awstats_pl or $awstats_buildstaticpages_pl is not owned by root user.",LOGLEVEL_WARN);

--
Gitblit v1.9.1