merging awstats branch to trunk, fixes #57, fixes #58

This commit is contained in:
Michael Kaufmann (d00p)
2010-03-22 12:36:59 +00:00
parent d4e310d150
commit 9b843a8ad5
54 changed files with 471 additions and 498 deletions

View File

@@ -51,11 +51,12 @@ function safe_exec($exec_string, &$return_value = false)
$settings['system']['apachereload_command'],
$settings['system']['bindreload_command'],
$settings['dkim']['dkimrestart_command'],
$settings['system']['awstats_updateall_command'],
'openssl',
'unzip',
'php',
'rm'
'rm',
'awstats_buildstaticpages.pl',
'ln'
);
//

View File

@@ -24,38 +24,54 @@
* @param logFile
* @param siteDomain
* @param hostAliases
* @return
* @author Michael Duergner
* @author Berend Dekens
* @return null
*/
function createAWStatsConf($logFile, $siteDomain, $hostAliases)
function createAWStatsConf($logFile, $siteDomain, $hostAliases, $customerDocroot)
{
global $pathtophpfiles;
global $pathtophpfiles, $settings;
// Generation header
$header = "## GENERATED BY SYSCP\n";
$header = "## GENERATED BY FROXLOR\n";
$header2 = "## Do not remove the line above! This tells Froxlor to update this configuration\n## If you wish to manually change this configuration file, remove the first line to make sure Froxlor won't rebuild this file\n## Generated for domain {SITE_DOMAIN} on " . date('l dS \of F Y h:i:s A') . "\n";
$awstats_dir = makeCorrectDir($customerDocroot.'/awstats/'.$siteDomain.'/');
if(!is_dir($awstats_dir))
{
safe_exec('mkdir -p '.escapeshellarg($awstats_dir));
}
// These are the variables we will replace
$regex = array(
'/\{LOG_FILE\}/',
'/\{SITE_DOMAIN\}/',
'/\{HOST_ALIASES\}/'
'/\{HOST_ALIASES\}/',
'/\{CUSTOMER_DOCROOT\}/'
);
$replace = array(
$logFile,
makeCorrectFile($logFile),
$siteDomain,
$hostAliases
$hostAliases,
$awstats_dir
);
// File names
$domain_file = '/etc/awstats/awstats.' . $siteDomain . '.conf';
$model_file = '/etc/awstats/awstats.model.conf.froxlor';
$model_file = dirname(dirname(dirname(dirname(__FILE__))));
$model_file.= '/templates/misc/awstatsmodel/';
if($settings['system']['mod_log_sql'] == '1')
{
$model_file.= 'awstats.froxlor.model_log_sql.conf';
} else {
$model_file.= 'awstats.froxlor.model.conf';
}
$model_file = makeCorrectFile($model_file);
// Test if the file exists
if(file_exists($domain_file))

View File

@@ -0,0 +1,21 @@
<?php
/**
* returns the customer-id of a customer by given domain
*
* @param string $domain users domain
*
* @return int customers id
*/
function getCustomerIdByDomain($domain = null)
{
global $db;
$result = $db->query_first("SELECT `customerid` FROM `" . TABLE_PANEL_DOMAINS . "` WHERE `domain` = '".$domain."'");
if(is_array($result)
&& isset($result['customerid'])
) {
return $result['customerid'];
}
return false;
}