This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
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 | /** |
||
13 | * userlog module |
||
14 | * |
||
15 | * @copyright XOOPS Project (https://xoops.org) |
||
16 | * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
||
17 | * @package userlog admin |
||
18 | * @since 1 |
||
19 | * @author irmtfan ([email protected]) |
||
20 | * @author XOOPS Project <www.xoops.org> <www.xoops.ir> |
||
21 | */ |
||
22 | |||
23 | use Xmf\Request; |
||
24 | |||
25 | require_once __DIR__ . '/admin_header.php'; |
||
26 | require_once XOOPS_ROOT_PATH . '/class/pagenav.php'; |
||
27 | |||
28 | xoops_cp_header(); |
||
29 | $userlog = Userlog::getInstance(); |
||
30 | $op = Request::getString('op'); |
||
31 | // Where do we start ? |
||
32 | $set_id = Request::getInt('set_id', 0); |
||
33 | $logsetObj = $set_id ? $userlog->getHandler('setting')->get($set_id) : UserlogSetting::getInstance(); |
||
34 | if ($set_id && !is_object($logsetObj)) { |
||
35 | redirect_header('setting.php', 1, _AM_USERLOG_SET_ERROR); |
||
36 | } |
||
37 | $name = Request::getString('name', '', 'post'); |
||
38 | $logby = Request::getString('logby', '', 'post'); |
||
39 | if ('ip' === $logby) { |
||
40 | $unique_id = Request::getString('unique_id', -1, 'post'); |
||
41 | $unique_id = ip2long($unique_id); |
||
42 | } else { |
||
43 | $unique_id = Request::getInt('unique_id', -1, 'post'); |
||
44 | } |
||
45 | $option = Request::getArray('option', '', 'post'); |
||
46 | |||
47 | $scope = Request::getArray('scope', '', 'post'); |
||
48 | |||
49 | $startentry = Request::getInt('startentry', 0); |
||
50 | |||
51 | switch ($op) { |
||
52 | case 'del': |
||
53 | if (empty($set_id)) { |
||
54 | redirect_header('setting.php', 1, _AM_USERLOG_SET_ERROR); |
||
55 | } |
||
56 | $confirm = Request::getString('confirm', 0, 'post'); |
||
57 | if ($confirm) { |
||
58 | if ($logsetObj->deleteFile($logsetObj->logby(), $logsetObj->getVar('unique_id'))) { //use getVar to get IP long |
||
59 | $msgDel = _AM_USERLOG_SET_CLEANCACHE_SUCCESS; |
||
60 | } |
||
61 | if (!$userlog->getHandler('setting')->delete($logsetObj)) { |
||
62 | redirect_header('setting.php', 1, sprintf(_AM_USERLOG_SET_DELETE_ERROR, $logsetObj->name())); |
||
63 | } |
||
64 | $msgDel .= '<br>' . sprintf(_AM_USERLOG_SET_DELETE_SUCCESS, $logsetObj->name()); |
||
65 | redirect_header('setting.php', 1, sprintf($msgDel, 1)); // one cache file deleted |
||
66 | } else { |
||
67 | xoops_confirm(['op' => 'del', 'set_id' => $logsetObj->set_id(), 'confirm' => 1], 'setting.php', sprintf(_AM_USERLOG_SET_DELETE_CONFIRM, $logsetObj->name()), _DELETE); |
||
68 | xoops_cp_footer(); |
||
69 | } |
||
70 | break; |
||
71 | |||
72 | case 'addsetting': |
||
73 | $message = _AM_USERLOG_SET_EDIT; |
||
74 | // check to insure only one (logby and unique_id) added to database |
||
75 | if (!$set_id) { |
||
76 | $criteria = new CriteriaCompo(); |
||
77 | $criteria->add(new Criteria('logby', $logby)); |
||
78 | $criteria->add(new Criteria('unique_id', $unique_id)); |
||
79 | $logsetObj = $userlog->getHandler('setting')->getObjects($criteria); |
||
80 | if ($logsetObj) { |
||
81 | $logsetObj = $logsetObj[0]; |
||
82 | $message = _AM_USERLOG_SET_UPDATE; |
||
83 | } elseif ('' !== $logby) { |
||
84 | $logsetObj = $userlog->getHandler('setting')->create(); |
||
85 | $message = _AM_USERLOG_SET_CREATE; |
||
86 | } else { |
||
87 | redirect_header('setting.php', 1, _AM_USERLOG_SET_ERROR); |
||
88 | } |
||
89 | } |
||
90 | $logsetObj->setVar('name', $name); |
||
91 | $logsetObj->setVar('logby', $logby); |
||
92 | $logsetObj->setVar('unique_id', $unique_id); |
||
93 | // select views means store uid, groups, script name, pagetitle, pageadmin, module, module_name, item name, item id in Database |
||
94 | if (in_array('views', $option)) { |
||
95 | $option = array_merge([ |
||
96 | 'uid', |
||
97 | 'groups', |
||
98 | 'script', |
||
99 | 'pagetitle', |
||
100 | 'pageadmin', |
||
101 | 'module', |
||
102 | 'module_name', |
||
103 | 'item_name', |
||
104 | 'item_id' |
||
105 | ], $option); |
||
106 | } |
||
107 | // always log id and time |
||
108 | if (!empty($option[0])) { |
||
109 | $option = array_merge(['log_id', 'log_time'], $option); |
||
110 | } |
||
111 | $options_arr = $logsetObj->getOptions($option, 'key');// empty means all. sanitize options |
||
112 | $logsetObj->setVar('options', implode(',', $options_arr)); |
||
113 | $logsetObj->setVar('scope', implode(',', $scope)); |
||
114 | if ($logsetObj->storeSet(true)) { |
||
115 | $message .= '<br>' . _AM_USERLOG_SET_CACHE; |
||
116 | } else { |
||
117 | redirect_header('setting.php', 1, _AM_USERLOG_SET_ERROR); |
||
118 | } |
||
119 | redirect_header('setting.php', 1, sprintf($message, $logsetObj->name())); |
||
120 | break; |
||
121 | case 'cancel': |
||
122 | redirect_header('setting.php', 1, _AM_USERLOG_SET_CANCEL); |
||
123 | // no break |
||
124 | case 'cleanCash': |
||
125 | // delete all settings caches |
||
126 | if ($numfiles = $logsetObj->cleanCache()) { |
||
127 | redirect_header('setting.php', 1, sprintf(_AM_USERLOG_SET_CLEANCACHE_SUCCESS, $numfiles)); |
||
128 | } else { |
||
129 | redirect_header('setting.php', 1, _AM_USERLOG_SET_CLEANCACHE_NOFILE); |
||
130 | } |
||
131 | break; |
||
132 | case 'default': |
||
133 | default: |
||
134 | // get all dirnames for scope |
||
135 | $dirNames = $userlog->getModules(); |
||
136 | // unset userlog |
||
137 | //unset($dirNames[USERLOG_DIRNAME]); |
||
0 ignored issues
–
show
|
|||
138 | // get all settings as array |
||
139 | $sets = $userlog->getHandler('setting')->getSets($userlog->getConfig('sets_perpage'), $startentry, null, 'set_id', 'DESC', null, false); |
||
140 | $totalSets = $userlog->getHandler('setting')->getCount(); |
||
141 | $pagenav = new XoopsPageNav($totalSets, $userlog->getConfig('sets_perpage'), $startentry, 'startentry'); |
||
142 | // check set arrays |
||
143 | foreach ($sets as $id => $set) { |
||
144 | // ip to string |
||
145 | if ('ip' === $set['logby']) { |
||
146 | $sets[$id]['unique_id'] = long2ip($set['unique_id']); |
||
147 | } |
||
148 | // logby to title |
||
149 | $sets[$id]['logby'] = $logsetObj->all_logby[$set['logby']]; |
||
150 | |||
151 | // options to title |
||
152 | $options = $logsetObj->getOptions($set['options'], 'title'); |
||
153 | $sets[$id]['active'] = !empty($options['active']); // add active option to smarty var |
||
154 | $sets[$id]['options'] = implode(',', $options); |
||
155 | |||
156 | // modules to name |
||
157 | if (empty($set['scope'])) { |
||
158 | $sets[$id]['scope'] = _ALL; // no scope means all |
||
159 | continue; |
||
160 | } |
||
161 | $scope = explode(',', $set['scope']); |
||
162 | $dir_str = ''; |
||
163 | foreach ($scope as $sc) { |
||
164 | $dir_str .= ',' . $dirNames[$sc]; |
||
165 | } |
||
166 | $sets[$id]['scope'] = $dir_str; |
||
167 | } |
||
168 | // buttons |
||
169 | $adminObject = \Xmf\Module\Admin::getInstance(); |
||
170 | if ($totalSets > 0) { |
||
171 | $adminObject->addItemButton(_AM_USERLOG_SET_CLEANCACHE_ALL, 'setting.php?op=cleanCash', 'delete'); |
||
172 | } |
||
173 | if ($set_id) { // if in edit mode add a button |
||
174 | $adminObject->addItemButton(_AM_USERLOG_SET_ADD, 'setting.php'); |
||
175 | } |
||
176 | // template |
||
177 | $template_main = USERLOG_DIRNAME . '_admin_sets.tpl'; |
||
178 | // form |
||
179 | $form = new XoopsThemeForm($set_id ? _EDIT . ' ' . $logsetObj->name() : _AM_USERLOG_SET_ADD, 'setting', 'setting.php?op=addsetting', 'post', true); |
||
180 | $nameEle = new XoopsFormText(_AM_USERLOG_SET_NAME, 'name', 10, 20, $logsetObj->name()); |
||
181 | $nameEle->setDescription(_AM_USERLOG_SET_NAME_DSC); |
||
182 | |||
183 | $logbyEle = new XoopsFormSelect(_AM_USERLOG_SET_LOGBY, 'logby', $logsetObj->logby()); |
||
184 | $logbyEle->addOptionArray($logsetObj->all_logby); |
||
185 | $logbyEle->setDescription(_AM_USERLOG_SET_LOGBY_DSC); |
||
186 | |||
187 | $unique_idEle = new XoopsFormText(_AM_USERLOG_SET_UNIQUE_ID, 'unique_id', 10, 20, $logsetObj->unique_id()); |
||
188 | $unique_idEle->setDescription(_AM_USERLOG_SET_UNIQUE_ID_DSC); |
||
189 | |||
190 | $options_arr = explode(',', $logsetObj->options()); |
||
191 | $optionEle = new XoopsFormCheckBox(_AM_USERLOG_SET_OPTIONS, 'option[]', $options_arr); |
||
192 | $optionEle->columns = 4; |
||
193 | $headers = $logsetObj->getOptions('', 'title'); |
||
194 | // always log id and time |
||
195 | unset($headers['log_id'], $headers['log_time']); |
||
196 | $optionEle->addOptionArray($headers); |
||
197 | //$optionEle->isRequired(); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
84% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
198 | //$optionEle->renderValidationJS(); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
84% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
199 | $check_all = _ALL . ": <input type=\"checkbox\" name=\"option_check\" id=\"option_check\" value=\"0\" onclick=\"xoopsCheckGroup('setting', 'option_check','option[]');\">"; |
||
200 | //$optiontrayEle = new XoopsFormElementTray(_AM_USERLOG_SET_OPTIONS, "<br\>", 'tray'); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
53% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
201 | $optionEle = new XoopsFormLabel(_AM_USERLOG_SET_OPTIONS, $check_all . "<br\>" . $optionEle->render()); |
||
202 | $optionEle->setDescription(_AM_USERLOG_SET_OPTIONS_DSC); |
||
203 | |||
204 | $scope_arr = explode(',', $logsetObj->scope()); |
||
205 | $scopeEle = new XoopsFormCheckBox(_AM_USERLOG_SET_SCOPE, 'scope[]', $scope_arr); |
||
206 | $scopeEle->columns = 4; |
||
207 | $scopeEle->addOptionArray($dirNames); |
||
208 | $check_all = _ALL . ": <input type=\"checkbox\" name=\"scope_check\" id=\"scope_check\" value=\"1\" onclick=\"xoopsCheckGroup('setting', 'scope_check','scope[]');\">"; |
||
209 | $scopeEle = new XoopsFormLabel(_AM_USERLOG_SET_SCOPE, $check_all . "<br\>" . $scopeEle->render()); |
||
210 | $scopeEle->setDescription(_AM_USERLOG_SET_SCOPE_DSC); |
||
211 | |||
212 | $submitEle = new XoopsFormButton('', 'post', _SUBMIT, 'submit'); |
||
213 | $set_idEle = new XoopsFormHidden('set_id', $set_id); |
||
214 | |||
215 | $form->addElement($nameEle, true); |
||
216 | $form->addElement($logbyEle); |
||
217 | $form->addElement($unique_idEle, true); |
||
218 | $form->addElement($optionEle); |
||
219 | $form->addElement($scopeEle); |
||
220 | $form->addElement($set_idEle); |
||
221 | $form->addElement($submitEle); |
||
222 | |||
223 | break; |
||
224 | } |
||
225 | if (!empty($form)) { |
||
226 | $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
||
227 | } |
||
228 | if (!empty($sets)) { |
||
229 | //add set arrays to template |
||
230 | $GLOBALS['xoopsTpl']->assign('sets', $sets); |
||
231 | } |
||
232 | if (!empty($pagenav)) { |
||
233 | $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
||
234 | } |
||
235 | if (!empty($indexAdmin)) { |
||
236 | $GLOBALS['xoopsTpl']->assign('addset', $adminObject->displayButton('left')); |
||
237 | $GLOBALS['xoopsTpl']->assign('logo', $adminObject->displayNavigation(basename(__FILE__))); |
||
238 | } |
||
239 | if (!empty($template_main)) { |
||
240 | $GLOBALS['xoopsTpl']->display("db:{$template_main}"); |
||
241 | } |
||
242 | xoops_cp_footer(); |
||
243 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.