Skip to content

Commit cf2c95b

Browse files
committed
replaced some more functions by those of ISPConfig
1 parent 029e643 commit cf2c95b

File tree

3 files changed

+284
-9
lines changed

3 files changed

+284
-9
lines changed

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,8 @@ public function onRunJob() {
7777
}
7878

7979

80-
/* Check if goaccess binary is in path */
81-
system("type goaccess 2>&1>/dev/null", $retval);
82-
if ($retval === 0) {
80+
/* Check if goaccess binary is in path/installed */
81+
if($app->system->is_installed('goaccess')) {
8382

8483
foreach($records as $rec) {
8584
$yesterday = date('Ymd', strtotime("-1 day", time()));
@@ -118,7 +117,7 @@ public function onRunJob() {
118117
} elseif(!file_exists($goaccess_conf)) {
119118
/*
120119
By default the goaccess.conf should get copied by the webserver plugin but in case it wasn't, or it got deleted by accident we gonna copy it again to the destination dir.
121-
Also there was no /usr/local/ispconfig/server/conf-custom/goaccess.conf.master, so we gonna use /etc/goaccess.conf as the base conf.
120+
Also there was no /usr/local/ispconfig/server/conf-custom/goaccess.conf.master, so we gonna use /etc/goaccess.conf or /etc/goaccess/goaccess.conf as the base conf.
122121
*/
123122

124123
$app->system->copy($goaccess_conf_main, $goaccess_conf);
@@ -147,8 +146,7 @@ public function onRunJob() {
147146
if(!@is_dir($goa_db_dir)) $app->system->mkdirpath($goa_db_dir);
148147

149148
if(is_link('/var/log/ispconfig/httpd/'.$domain.'/yesterday-access.log')) $app->system->unlink('/var/log/ispconfig/httpd/'.$domain.'/yesterday-access.log');
150-
symlink($logfile, '/var/log/ispconfig/httpd/'.$domain.'/yesterday-access.log');
151-
149+
$app->system->create_relative_link($logfile, '/var/log/ispconfig/httpd/'.$domain.'/yesterday-access.log');
152150

153151
$app->system->exec_safe('chown -R ?:? ?', $username, $groupname, $statsdir);
154152

@@ -178,7 +176,11 @@ public function onRunJob() {
178176

179177
// don't rotate db files per month
180178
//rename($goa_db_dir, $statsdirold.'db');
181-
//mkdir($goa_db_dir);
179+
//mkdir($goa_db_dir);
180+
181+
$app->system->copy($output_html, $statsdirold);
182+
$app->system->unlink($output_html);
183+
182184

183185
$files = scandir($statsdir);
184186

@@ -228,8 +230,8 @@ public function onRunJob() {
228230

229231
$app->log('Created GoAccess statistics for ' . $domain, LOGLEVEL_DEBUG);
230232
if(is_file($rec['document_root']."/".$web_folder."/stats/index.php")) {
231-
chown($rec['document_root']."/".$web_folder."/stats/index.php", $rec['system_user']);
232-
chgrp($rec['document_root']."/".$web_folder."/stats/index.php", $rec['system_group']);
233+
$app->system->chown($rec['document_root']."/".$web_folder."/stats/index.php", $rec['system_user']);
234+
$app->system->chgrp($rec['document_root']."/".$web_folder."/stats/index.php", $rec['system_group']);
233235
}
234236

235237
$app->system->exec_safe('chown -R ?:? ?', $username, $groupname, $statsdir);

0 commit comments

Comments
 (0)