Skip to content

Commit 64055d9

Browse files
committed
try to get utf-8 working
1 parent 81444a9 commit 64055d9

File tree

2 files changed

+51
-7
lines changed

2 files changed

+51
-7
lines changed

server/conf/goaccess_index.php.master

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
header('Content-type: text/html; charset=utf-8');
23
$yearmonth_text = "Jump to previous stats: ";
34
$script = "<script>function load_content(url){var iframe = document.getElementById(\"content\");iframe.src = url;}</script>\n";
45

@@ -60,6 +61,7 @@ foreach ($goaprev as $key => $value)
6061
$goaccessindex = 'goaindex.html';
6162

6263
$html = "<!DOCTYPE html>\n<html>\n<head>\n<title>Stats</title>\n";
64+
$html .= "<meta charset="UTF-8">\n";
6365
$html .= "<style>\nhtml,body {margin:0px;padding:0px;width:100%;height:100%;background-color: #ccc;}\n";
6466
$html .= "#header\n{\nwidth:100%;margin:0px auto;\nheight:20px;\nposition:fixed;\npadding:4px;\ntext-align:center;\n}\n";
6567
$html .= "iframe {width:100%;height:95%;margin:0px;margin-top:40px;border:0px;padding:0px;}\n</style>\n</head>\n<body>\n";

server/lib/classes/cron.d/150-goaccess.inc.php

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function onRunJob() {
5656
// Create goaccess statistics
5757
//######################################################################################################
5858

59-
$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 = ?";
59+
$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 = ?";
6060
$records = $app->db->queryAllRecords($sql, $conf['server_id']);
6161

6262
$web_config = $app->getconf->get_server_config($conf['server_id'], 'web');
@@ -187,12 +187,49 @@ public function onRunJob() {
187187

188188

189189
/*
190-
* GoAccess removed with 1.4 btree support and supports from this version on only "In-Memory with On-Disk Persitance Storage".
191-
* For versions prior 1.4 you need GoAccess with btree support compiled!
190+
* GoAccess removed with 1.4 B+Tree support and supports from this version on only "In-Memory with On-Disk Persistance Storage".
191+
* For versions prior 1.4 you need GoAccess with B+Tree support compiled!
192192
*/
193-
194-
$cust_lang = $conf['language']."_".strtoupper($conf['language'])."UTF-8";
195193

194+
195+
$sql_user = "SELECT client_id FROM sys_group WHERE groupid = ?";
196+
$rec_user = $app->db->queryOneRecord($sql_user, $rec['sys_groupid']);
197+
$lang_query = "SELECT country,language FROM client WHERE client_id = ?";
198+
$lang_user = $app->db->queryOneRecord($lang_query, $rec_user['client_id']);
199+
$cust_lang = $lang_user['language']."_".strtoupper($lang_user['language']).".UTF-8";
200+
201+
switch($lang_user['language'])
202+
{
203+
case 'en':
204+
$cust_lang = 'en_UK.UTF-8';
205+
break;
206+
case 'br':
207+
$cust_lang = 'pt_BR.UTF-8';
208+
break;
209+
case 'ca':
210+
$cust_lang = 'en_CA.UTF-8';
211+
break;
212+
case 'ja':
213+
$cust_lang = 'ja_JP.UTF-8';
214+
break;
215+
case 'ar':
216+
$cust_lang = 'es_AR.UTF-8';
217+
break;
218+
case 'el':
219+
$cust_lang = 'el_GR.UTF-8';
220+
break;
221+
case 'se':
222+
$cust_lang = 'sv_SE.UTF-8';
223+
break;
224+
case 'dk':
225+
$cust_lang = 'da_DK.UTF-8';
226+
break;
227+
case 'cz':
228+
$cust_lang = 'cs_CZ.UTF-8';
229+
break;
230+
}
231+
232+
echo $cust_lang ."\n\n";
196233
if(version_compare($goaccess_version,1.4) >= 0) {
197234
$app->system->exec_safe("LANG=? goaccess -f ? --config-file ? --restore --persist --db-path=? --output=?", $cust_lang, $logfile, $goaccess_conf, $goa_db_dir, $output_html);
198235
} else {
@@ -201,11 +238,16 @@ public function onRunJob() {
201238
if($match[0] == "keep-db-files") {
202239
$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);
203240
} else {
204-
$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);
241+
$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);
205242
}
206243
unset($output);
207244
}
245+
208246
unset($cust_lang);
247+
unset($sql_user);
248+
unset($rec_user);
249+
unset($lang_query);
250+
unset($lang_user);
209251

210252
if(!is_file($rec['document_root']."/".$web_folder."/stats/index.php")) {
211253
if(file_exists("/usr/local/ispconfig/server/conf-custom/goaccess_index.php.master")) {
@@ -224,7 +266,7 @@ public function onRunJob() {
224266
$app->system->exec_safe('chown -R ?:? ?', $username, $groupname, $statsdir);
225267
}
226268
} else {
227-
$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);
269+
$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);
228270
}
229271

230272
}

0 commit comments

Comments
 (0)