From f2a4c5211066aa8bcf96518a773d093d4e736a72 Mon Sep 17 00:00:00 2001 From: "Michael Kaufmann (d00p)" Date: Tue, 8 Jun 2010 05:51:23 +0000 Subject: [PATCH] - chown awstats/webalizer directory after traffic-cron, fixes #258 --- scripts/jobs/cron_traffic.inc.functions.php | 34 +++++++++++++++++++++ scripts/jobs/cron_traffic.php | 2 ++ 2 files changed, 36 insertions(+) diff --git a/scripts/jobs/cron_traffic.inc.functions.php b/scripts/jobs/cron_traffic.inc.functions.php index 5c68047e..97985608 100644 --- a/scripts/jobs/cron_traffic.inc.functions.php +++ b/scripts/jobs/cron_traffic.inc.functions.php @@ -17,6 +17,40 @@ * @version $Id$ */ +/** + * chowns either awstats or webalizer folder, + * either with webserver-user or - if fcgid + * is used - the customers name, #258 + * + * @param array $row array if panel_customers + * + * @return void + */ +function makeChownWithNewStats($row) +{ + global $settings; + + // get correct user + $user = $row['loginname']; + $group = $row['guid']; + + // get correct directory + $dir = $row['documentroot']; + if($settings['system']['awstats_enabled'] == '1') + { + $dir .= '/awstats/'; + } else { + $dir .= '/webalizer/'; + } + + // only run chown if directory exists + if (file_exists($dir)) + { + // run chown + safe_exec('chown -R '.escapeshellarg($user).':'.escapeshellarg($group).' '.escapeshellarg(makeCorrectDir($dir))); + } +} + function awstatsDoSingleDomain($domain, $outputdir) { global $cronlog, $settings; diff --git a/scripts/jobs/cron_traffic.php b/scripts/jobs/cron_traffic.php index 1f623e94..5872ccfb 100644 --- a/scripts/jobs/cron_traffic.php +++ b/scripts/jobs/cron_traffic.php @@ -174,6 +174,8 @@ while($row = $db->fetch_array($result)) $httptraffic+= floatval(callWebalizerGetTraffic($row['loginname'] . '-' . $domain, $row['documentroot'] . '/webalizer/' . $domain . '/', $domain, $domainlist[$row['customerid']])); } } + // make the stuff readable for the customer, #258 + makeChownWithNewStats($row); } reset($domainlist[$row['customerid']]);