Merge pull request #786 from patschi/logformat-awstats

Allow configuring awstats LogFormat
This commit is contained in:
Michael Kaufmann
2020-01-10 16:32:33 +01:00
committed by GitHub
9 changed files with 42 additions and 7 deletions

View File

@@ -173,7 +173,8 @@ return array(
'websrv_avail' => array( 'websrv_avail' => array(
'apache2', 'apache2',
'nginx' 'nginx'
) ),
'visible' => \Froxlor\Settings::Get('system.awstats_enabled') == 1
), ),
'system_logfiles_type' => array( 'system_logfiles_type' => array(
'label' => $lng['serversettings']['logfiles_type'], 'label' => $lng['serversettings']['logfiles_type'],

View File

@@ -33,7 +33,8 @@ return array(
1 => $lng['admin']['webalizer']['quiet'], 1 => $lng['admin']['webalizer']['quiet'],
2 => $lng['admin']['webalizer']['veryquiet'] 2 => $lng['admin']['webalizer']['veryquiet']
), ),
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField',
'visible' => \Froxlor\Settings::Get('system.awstats_enabled') == 1
), ),
'system_awstats_enabled' => array( 'system_awstats_enabled' => array(
'label' => $lng['serversettings']['awstats_enabled'], 'label' => $lng['serversettings']['awstats_enabled'],
@@ -78,6 +79,14 @@ return array(
'string_type' => 'dir', 'string_type' => 'dir',
'default' => '/usr/share/awstats/icon/', 'default' => '/usr/share/awstats/icon/',
'save_method' => 'storeSettingField' 'save_method' => 'storeSettingField'
),
'system_awstats_logformat' => array(
'label' => $lng['serversettings']['awstats']['logformat'],
'settinggroup' => 'system',
'varname' => 'awstats_logformat',
'type' => 'string',
'default' => '1',
'save_method' => 'storeSettingField'
) )
) )
) )

View File

@@ -572,6 +572,7 @@ opcache.interned_strings_buffer'),
('system', 'stdsubdomain', ''), ('system', 'stdsubdomain', ''),
('system', 'awstats_path', '/usr/bin/'), ('system', 'awstats_path', '/usr/bin/'),
('system', 'awstats_conf', '/etc/awstats/'), ('system', 'awstats_conf', '/etc/awstats/'),
('system', 'awstats_logformat', '1'),
('system', 'defaultttl', '604800'), ('system', 'defaultttl', '604800'),
('system', 'mod_fcgid_defaultini', '1'), ('system', 'mod_fcgid_defaultini', '1'),
('system', 'ftpserver', 'proftpd'), ('system', 'ftpserver', 'proftpd'),
@@ -703,7 +704,7 @@ opcache.interned_strings_buffer'),
('panel', 'customer_hide_options', ''), ('panel', 'customer_hide_options', ''),
('panel', 'is_configured', '0'), ('panel', 'is_configured', '0'),
('panel', 'version', '0.10.11'), ('panel', 'version', '0.10.11'),
('panel', 'db_version', '201912312'); ('panel', 'db_version', '201912313');
DROP TABLE IF EXISTS `panel_tasks`; DROP TABLE IF EXISTS `panel_tasks`;

View File

@@ -554,3 +554,10 @@ if (\Froxlor\Froxlor::isDatabaseVersion('201912311')) {
} }
\Froxlor\Froxlor::updateToDbVersion('201912312'); \Froxlor\Froxlor::updateToDbVersion('201912312');
} }
if (\Froxlor\Froxlor::isDatabaseVersion('201912312')) {
showUpdateStep("Adding option change awstats LogFormat");
Settings::AddNew("system.awstats_logformat", '1');
lastStepStatus(0);
\Froxlor\Froxlor::updateToDbVersion('201912313');
}

View File

@@ -10,7 +10,7 @@ final class Froxlor
const VERSION = '0.10.11'; const VERSION = '0.10.11';
// Database version (YYYYMMDDC where C is a daily counter) // Database version (YYYYMMDDC where C is a daily counter)
const DBVERSION = '201912312'; const DBVERSION = '201912313';
// Distribution branding-tag (used for Debian etc.) // Distribution branding-tag (used for Debian etc.)
const BRANDING = ''; const BRANDING = '';

View File

@@ -37,20 +37,31 @@ class Statistics
\Froxlor\FileDir::safe_exec('mkdir -p ' . escapeshellarg(Settings::Get('system.awstats_conf'))); \Froxlor\FileDir::safe_exec('mkdir -p ' . escapeshellarg(Settings::Get('system.awstats_conf')));
} }
$logformat = Settings::Get('system.awstats_logformat');
if (! is_numeric($logformat)) {
// if LogFormat is NOT numeric (e.g. 1,2,3,4), we quote it.
// 1-4 are pre-defined formats by awstats which must not be quoted to work properly. So if
// it is not a integer, it is something customized and we simply quote it.
// Only escaping double-quote should be fine, as we only put the whole string under double-quote.
$logformat = '"' . str_replace('"', '\"', Settings::Get('system.awstats_logformat')) . '"';
}
// These are the variables we will replace // These are the variables we will replace
$regex = array( $regex = array(
'/\{LOG_FILE\}/', '/\{LOG_FILE\}/',
'/\{SITE_DOMAIN\}/', '/\{SITE_DOMAIN\}/',
'/\{HOST_ALIASES\}/', '/\{HOST_ALIASES\}/',
'/\{CUSTOMER_DOCROOT\}/', '/\{CUSTOMER_DOCROOT\}/',
'/\{AWSTATS_CONF\}/' '/\{AWSTATS_CONF\}/',
'/\{AWSTATS_LOGFORMAT\}/'
); );
$replace = array( $replace = array(
\Froxlor\FileDir::makeCorrectFile($logFile), \Froxlor\FileDir::makeCorrectFile($logFile),
$siteDomain, $siteDomain,
$hostAliases, $hostAliases,
$awstats_dir, $awstats_dir,
\Froxlor\FileDir::makeCorrectDir(Settings::Get('system.awstats_conf')) \Froxlor\FileDir::makeCorrectDir(Settings::Get('system.awstats_conf')),
$logformat
); );
// File names // File names

View File

@@ -2092,3 +2092,6 @@ $lng['admin']['domain_sessionticketsenabled']['description'] = 'Default <strong>
$lng['serversettings']['phpfpm_settings']['restart_note'] = 'Attention: The config won\'t be checked for any errors. If it contains errors, PHP-FPM might not start again!'; $lng['serversettings']['phpfpm_settings']['restart_note'] = 'Attention: The config won\'t be checked for any errors. If it contains errors, PHP-FPM might not start again!';
$lng['serversettings']['phpfpm_settings']['custom_config']['title'] = 'Custom configuration'; $lng['serversettings']['phpfpm_settings']['custom_config']['title'] = 'Custom configuration';
$lng['serversettings']['phpfpm_settings']['custom_config']['description'] = 'Add custom configuration to each PHP-FPM version instance, for example <i>pm.status_path = /status</i> for monitoring. Variables below can be used here. ' . ' <strong>' . $lng['serversettings']['phpfpm_settings']['restart_note'] . '</strong>'; $lng['serversettings']['phpfpm_settings']['custom_config']['description'] = 'Add custom configuration to each PHP-FPM version instance, for example <i>pm.status_path = /status</i> for monitoring. Variables below can be used here. ' . ' <strong>' . $lng['serversettings']['phpfpm_settings']['restart_note'] . '</strong>';
$lng['serversettings']['awstats']['logformat']['title'] = 'LogFormat setting';
$lng['serversettings']['awstats']['logformat']['description'] = 'If you use customized logformat for your webserver, you need change the awstats LogFormat too.<br/>Default is 1. For more information check documentation <a target="_blank" href="https://awstats.sourceforge.io/docs/awstats_config.html#LogFormat">here</a>.';

View File

@@ -1739,3 +1739,6 @@ $lng['admin']['domain_sessionticketsenabled']['description'] = 'Standardwert <st
$lng['serversettings']['phpfpm_settings']['restart_note'] = 'Achtung: Der Code wird nicht auf Fehler geprüft. Bei etwaigen Fehlern könnte der PHP-FPM-Prozess nicht mehr starten!'; $lng['serversettings']['phpfpm_settings']['restart_note'] = 'Achtung: Der Code wird nicht auf Fehler geprüft. Bei etwaigen Fehlern könnte der PHP-FPM-Prozess nicht mehr starten!';
$lng['serversettings']['phpfpm_settings']['custom_config']['title'] = 'Benutzerdefinierte Konfiguration'; $lng['serversettings']['phpfpm_settings']['custom_config']['title'] = 'Benutzerdefinierte Konfiguration';
$lng['serversettings']['phpfpm_settings']['custom_config']['description'] = 'Füge eine benutzerdefinierte Einstellungen zur PHP-FPM Instanz hinzu, beispielsweise <i>pm.status_path = /status</i> für Monitoring. Unten ersichtliche Variablen können verwendet werden.' . ' <strong>' . $lng['serversettings']['phpfpm_settings']['restart_note'] . '</strong>'; $lng['serversettings']['phpfpm_settings']['custom_config']['description'] = 'Füge eine benutzerdefinierte Einstellungen zur PHP-FPM Instanz hinzu, beispielsweise <i>pm.status_path = /status</i> für Monitoring. Unten ersichtliche Variablen können verwendet werden.' . ' <strong>' . $lng['serversettings']['phpfpm_settings']['restart_note'] . '</strong>';
$lng['serversettings']['awstats']['logformat']['title'] = 'LogFormat Einstellung';
$lng['serversettings']['awstats']['logformat']['description'] = 'Wenn ein benutzerdefiniertes LogFormat beim Webserver verwendet wird, muss LogFormat von awstats ebenso angepasst werden.<br/>Standard ist 1. Für weitere Informationen siehe Dokumentation unter <a target="_blank" href="https://awstats.sourceforge.io/docs/awstats_config.html#LogFormat">hier</a>.';

View File

@@ -3,7 +3,7 @@ Include "{AWSTATS_CONF}awstats.model.conf"
LogFile="{LOG_FILE}" LogFile="{LOG_FILE}"
LogType=W LogType=W
LogFormat = 1 LogFormat = {AWSTATS_LOGFORMAT}
LogSeparator=" " LogSeparator=" "
SiteDomain="{SITE_DOMAIN}" SiteDomain="{SITE_DOMAIN}"
HostAliases="{HOST_ALIASES}" HostAliases="{HOST_ALIASES}"