1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
You may not change or alter any portion of this comment or credits |
4
|
|
|
of supporting developers from this source code or any supporting source code |
5
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
6
|
|
|
|
7
|
|
|
This program is distributed in the hope that it will be useful, |
8
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
9
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
10
|
|
|
*/ |
11
|
|
|
/** |
12
|
|
|
* userlog module |
13
|
|
|
* |
14
|
|
|
* @copyright XOOPS Project (https://xoops.org) |
15
|
|
|
* @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
16
|
|
|
* @package userlog admin |
17
|
|
|
* @since 1 |
18
|
|
|
* @author irmtfan ([email protected]) |
19
|
|
|
* @author XOOPS Project <www.xoops.org> <www.xoops.ir> |
20
|
|
|
*/ |
21
|
|
|
|
22
|
|
|
require_once __DIR__ . '/admin_header.php'; |
23
|
|
|
|
24
|
|
|
xoops_cp_header(); |
25
|
|
|
|
26
|
|
|
$adminObject = \Xmf\Module\Admin::getInstance(); |
27
|
|
|
$userlog = Userlog::getInstance(); |
28
|
|
|
|
29
|
|
|
// update all time stats |
30
|
|
|
$statsObj = UserlogStats::getInstance(); |
31
|
|
|
$statsObj->updateAll('log', 100); // prob = 100 |
32
|
|
|
$statsObj->updateAll('set', 100); // prob = 100 |
33
|
|
|
$statsObj->updateAll('file', 100); // prob = 100 |
34
|
|
|
|
35
|
|
|
$stats = $statsObj->getAll(['log', 'logdel', 'set', 'file']); |
36
|
|
|
// if no set in database - start with a setting! |
37
|
|
|
if (isset($stats['set'][0]) && 0 == $stats['set'][0]['value']) { |
38
|
|
|
$adminObject->addItemButton(_AM_USERLOG_SET_ADD, 'setting.php'); |
39
|
|
|
} else { |
40
|
|
|
$adminObject->addInfoBox(_AM_USERLOG_SUMMARY); |
41
|
|
|
$adminObject->addInfoBoxLine('<a href="logs.php?options[referer]=del&options[request_method]=POST">' . _AM_USERLOG_SUMMARY_DELETED . '</a>'); |
42
|
|
|
$adminObject->addInfoBoxLine('<a href="logs.php?options[admin]=1">' . _AM_USERLOG_SUMMARY_ADMIN . '</a>'); |
43
|
|
|
$adminObject->addInfoBoxLine('<a href="logs.php?options[referer]=google.com">' . _AM_USERLOG_SUMMARY_GOOGLE . '</a>'); |
44
|
|
|
} |
45
|
|
|
$adminObject->addInfoBox(_AM_USERLOG_STATS_ABSTRACT); |
46
|
|
|
$periods = array_flip($statsObj->period); |
47
|
|
|
$types = $statsObj->type; |
48
|
|
View Code Duplication |
foreach ($stats as $type => $arr) { |
|
|
|
|
49
|
|
|
if (strlen($type) > 10) { |
50
|
|
|
continue; |
51
|
|
|
} |
52
|
|
|
foreach ($arr as $period => $arr2) { |
53
|
|
|
// use sprintf in moduleadmin: sprintf($text, "<span style='color : " . $color . "; font-weight : bold;'>" . $value . "</span>") |
54
|
|
|
$adminObject->addInfoBoxLine( |
55
|
|
|
sprintf( |
56
|
|
|
sprintf(_AM_USERLOG_STATS_TYPE_PERIOD, '%1$s', $types[$type], constant('_AM_USERLOG_' . strtoupper($periods[$period]))) . ' ' . _AM_USERLOG_STATS_TIME_UPDATE . ' ' . $arr2['time_update'], |
57
|
|
|
$arr2['value'] |
58
|
|
|
), |
59
|
|
|
'', |
60
|
|
|
$arr2['value'] ? 'GREEN' : 'RED' |
61
|
|
|
); |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
// if there is no file in working check the parent folder chmod |
65
|
|
|
if ((isset($stats['fileall'][0]) && 0 == $stats['fileall'][0]['value']) || (0 == $stats['file' . $userlog->getWorkingFile()][0]['value'])) { |
66
|
|
|
$adminObject->addConfigBoxLine([$userlog->getConfig('logfilepath'), 755], 'chmod'); |
67
|
|
|
// core feature: if(!$adminObject->addConfigBoxLine()) |
68
|
|
|
if (substr(decoct(fileperms($userlog->getConfig('logfilepath'))), 2) < 755) { |
69
|
|
|
$adminObject->addConfigBoxLine("<span class='bold red'>" . sprintf(_AM_USERLOG_CONFIG_CHMOD_ERROR, $userlog->getConfig('logfilepath'), 755) . '</span>', 'default'); |
70
|
|
|
$adminObject->addConfigBoxLine("<span class='bold red'>" . sprintf(_AM_USERLOG_CONFIG_CREATE_FOLDER, $userlog->getConfig('logfilepath') . '/' . USERLOG_DIRNAME, 755) . '</span>', 'default'); |
71
|
|
|
} |
72
|
|
|
} else { |
73
|
|
|
// if there is file in working check the log folder chmod |
74
|
|
|
$adminObject->addConfigBoxLine([$userlog->getConfig('logfilepath') . '/' . USERLOG_DIRNAME, 755], 'chmod'); |
75
|
|
|
} |
76
|
|
|
$adminObject->addConfigBoxLine("<span class='bold " . ($userlog->getConfig('status') ? 'green' : 'red') . "'>" . _MI_USERLOG_STATUS . ' ' . ($userlog->getConfig('status') ? _MI_USERLOG_ACTIVE : _MI_USERLOG_IDLE) . '</span>', 'default'); |
77
|
|
|
|
78
|
|
|
$adminObject->displayNavigation(basename(__FILE__)); |
79
|
|
|
$adminObject->displayButton('left'); |
80
|
|
|
$adminObject->displayIndex(); |
81
|
|
|
|
82
|
|
|
xoops_cp_footer(); |
83
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.