diff --git a/server/conf/goaccess_index.php.master b/server/conf/goaccess_index.php.master index d0a8bf3c84a39a3e1cab901fef8f64f674a37315..ecb91c7a9cbaefeabd668a651f32cf1b24503f48 100644 --- a/server/conf/goaccess_index.php.master +++ b/server/conf/goaccess_index.php.master @@ -60,6 +60,7 @@ foreach ($goaprev as $key => $value) $goaccessindex = 'goaindex.html'; $html = "\n\n\nStats\n"; +$html .= "\n"; $html .= "\n\n\n"; diff --git a/server/lib/classes/cron.d/150-goaccess.inc.php b/server/lib/classes/cron.d/150-goaccess.inc.php index 8f397c819a2bde230d49314a8e861fd385749165..7bdbbeb03b28e2f02937e021a72020bc5f6ce5b3 100644 --- a/server/lib/classes/cron.d/150-goaccess.inc.php +++ b/server/lib/classes/cron.d/150-goaccess.inc.php @@ -56,7 +56,7 @@ class cronjob_goaccess extends cronjob { // Create goaccess 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' or type = 'vhostalias') and stats_type = 'goaccess' AND server_id = ?"; + $sql = "SELECT domain_id, sys_groupid, 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 = 'goaccess' AND server_id = ?"; $records = $app->db->queryAllRecords($sql, $conf['server_id']); $web_config = $app->getconf->get_server_config($conf['server_id'], 'web'); @@ -130,21 +130,13 @@ class cronjob_goaccess extends cronjob { unset($content); } - /* Update the primary domain name in the title, it could occasionally change */ - if(is_file($goaccess_conf) && (filesize($goaccess_conf) > 0)) { - $content = $app->system->file_get_contents($goaccess_conf, true); - $content = preg_replace('/^(#)?html-report-title(.*)/m', "html-report-title $domain", $content); - $app->system->file_put_contents($goaccess_conf, $content, true); - unset($content); - } - $username = $rec['system_user']; $groupname = $rec['system_group']; $docroot = $rec['document_root']; if(!@is_dir($statsdir)) $app->system->mkdirpath($statsdir, 0755, $username, $groupname); - $goa_db_dir = $docroot.'/'.$web_folder.'/stats/.db/'; + $goa_db_dir = $docroot.'/log/goaccess_db'; $output_html = $docroot.'/'.$web_folder.'/stats/goaindex.html'; if(!@is_dir($goa_db_dir)) $app->system->mkdirpath($goa_db_dir); @@ -177,11 +169,6 @@ class cronjob_goaccess extends cronjob { $app->system->mkdirpath($statsdirold, 0755, $username, $groupname); } - // don't rotate db files per month - //rename($goa_db_dir, $statsdirold.'db'); - //mkdir($goa_db_dir); - - $files = scandir($statsdir); foreach ($files as $file) { @@ -199,12 +186,48 @@ class cronjob_goaccess extends cronjob { } - /* - * GoAccess removed with 1.4 btree support and supports from this version on only "In-Memory with On-Disk Persitance Storage". - * For versions prior 1.4 you need GoAccess with btree support compiled! - */ - - $cust_lang = $conf['language']."_".strtoupper($conf['language']); + $sql_user = "SELECT client_id FROM sys_group WHERE groupid = ?"; + $rec_user = $app->db->queryOneRecord($sql_user, $rec['sys_groupid']); + $lang_query = "SELECT country,language FROM client WHERE client_id = ?"; + $lang_user = $app->db->queryOneRecord($lang_query, $rec_user['client_id']); + $cust_lang = $lang_user['language']."_".strtoupper($lang_user['language']).".UTF-8"; + + switch($lang_user['language']) + { + case 'en': + $cust_lang = 'en_UK.UTF-8'; + break; + case 'br': + $cust_lang = 'pt_PT.UTF-8'; + break; + case 'ca': + $cust_lang = 'en_US.UTF-8'; + break; + case 'ja': + $cust_lang = 'ja_JP.UTF-8'; + break; + case 'ar': + $cust_lang = 'es_ES.UTF-8'; + break; + case 'el': + $cust_lang = 'el_GR.UTF-8'; + break; + case 'se': + $cust_lang = 'sv_SE.UTF-8'; + break; + case 'dk': + $cust_lang = 'da_DK.UTF-8'; + break; + case 'cz': + $cust_lang = 'cs_CZ.UTF-8'; + break; + } + + + /* + * GoAccess removed with 1.4 B+Tree support and supports from this version on only "In-Memory with On-Disk Persistance Storage". + * For versions prior 1.4 you need GoAccess with B+Tree support compiled! + */ if(version_compare($goaccess_version,1.4) >= 0) { $app->system->exec_safe("LANG=? goaccess -f ? --config-file ? --restore --persist --db-path=? --output=?", $cust_lang, $logfile, $goaccess_conf, $goa_db_dir, $output_html); @@ -214,11 +237,16 @@ class cronjob_goaccess extends cronjob { if($match[0] == "keep-db-files") { $app->system->exec_safe("LANG=? goaccess -f ? --config-file ? --load-from-disk --keep-db-files --db-path=? --output=?", $cust_lang, $logfile, $goaccess_conf, $goa_db_dir, $output_html); } else { - $app->log("Stats not generated. The GoAccess binary was not compiled with btree support. Please recompile/reinstall GoAccess with btree support, or install GoAccess version >= 1.4!", LOGLEVEL_ERROR); + $app->log("Stats couldn't be generated. The GoAccess binary wasn't compiled with B+Tree support. Please recompile/reinstall GoAccess with B+Tree support, or install GoAccess version >= 1.4! (recommended)", LOGLEVEL_ERROR); } unset($output); } + unset($cust_lang); + unset($sql_user); + unset($rec_user); + unset($lang_query); + unset($lang_user); if(!is_file($rec['document_root']."/".$web_folder."/stats/index.php")) { if(file_exists("/usr/local/ispconfig/server/conf-custom/goaccess_index.php.master")) { @@ -237,7 +265,7 @@ class cronjob_goaccess extends cronjob { $app->system->exec_safe('chown -R ?:? ?', $username, $groupname, $statsdir); } } else { - $app->log("Stats not generated. The GoAccess binary couldn't be found. Make sure that GoAccess is installed and that it is in \$PATH", LOGLEVEL_ERROR); + $app->log("Stats couldn't be generated. The GoAccess binary couldn't be found. Make sure that GoAccess is installed and that it is in \$PATH", LOGLEVEL_ERROR); } } diff --git a/server/plugins-available/apache2_plugin.inc.php b/server/plugins-available/apache2_plugin.inc.php index f11476b4021f3a224d763b646433e66347b4066d..70976a65001fb56c28e493795a88da103000e21c 100644 --- a/server/plugins-available/apache2_plugin.inc.php +++ b/server/plugins-available/apache2_plugin.inc.php @@ -1893,7 +1893,7 @@ class apache2_plugin { if($data['new']['stats_type'] != '') { if(!is_dir($data['new']['document_root'].'/' . $web_folder . '/stats')) $app->system->mkdir($data['new']['document_root'].'/' . $web_folder . '/stats'); - $ht_file = "AuthType Basic\nAuthName \"Members Only\"\nAuthUserFile ".$data['new']['document_root']."/web/stats/.htpasswd_stats\nrequire valid-user\nDirectoryIndex index.html index.php\nHeader unset Content-Security-Policy"; + $ht_file = "AuthType Basic\nAuthName \"Members Only\"\nAuthUserFile ".$data['new']['document_root']."/web/stats/.htpasswd_stats\nrequire valid-user\nDirectoryIndex index.html index.php\nHeader unset Content-Security-Policy\n\nAddDefaultCharset UTF-8\n\n"; $app->system->file_put_contents($data['new']['document_root'].'/' . $web_folder . '/stats/.htaccess', $ht_file); $app->system->chmod($data['new']['document_root'].'/' . $web_folder . '/stats/.htaccess', 0755); unset($ht_file); @@ -3079,8 +3079,8 @@ class apache2_plugin { } } - if(!is_dir($data['new']['document_root']."/" . $web_folder . "/stats/.db")) $app->system->mkdirpath($data['new']['document_root'] . "/" . $web_folder . "/stats/.db"); - $goaccess_conf = $data['new']['document_root'].'/log/goaccess.conf'; + if(!is_dir($data['new']['document_root'] . "/log/goaccess_db")) $app->system->mkdirpath($data['new']['document_root'] . "/log/goaccess_db"); + $goaccess_conf = $data['new']['document_root'].'/log/goaccess.conf'; /* In case that you use a different log format, you should use a custom goaccess.conf which you'll have to put into /usr/local/ispconfig/server/conf-custom/. diff --git a/server/plugins-available/nginx_plugin.inc.php b/server/plugins-available/nginx_plugin.inc.php index 4b20a0339167f0ea41cf64c8bbc723ca0bba9be7..f2626b83ba0adcd14b95f4631e70093d01fd91cc 100644 --- a/server/plugins-available/nginx_plugin.inc.php +++ b/server/plugins-available/nginx_plugin.inc.php @@ -2604,7 +2604,7 @@ class nginx_plugin { } } - if(!is_dir($data['new']['document_root']."/" . $web_folder . "/stats/.db")) $app->system->mkdirpath($data['new']['document_root'] . "/" . $web_folder . "/stats/.db"); + if(!is_dir($data['new']['document_root'] . "/log/goaccess_db")) $app->system->mkdirpath($data['new']['document_root'] . "/log/goaccess_db"); $goaccess_conf = $data['new']['document_root'].'/log/goaccess.conf'; /*