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 | * 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 blocks |
||
17 | * @since 1 |
||
18 | * @author irmtfan ([email protected]) |
||
19 | * @author XOOPS Project <www.xoops.org> <www.xoops.ir> |
||
20 | */ |
||
21 | |||
22 | defined('XOOPS_ROOT_PATH') || exit('Restricted access.'); |
||
23 | require_once __DIR__ . '/../include/common.php'; |
||
24 | |||
25 | if (defined('USERLOG_BLOCK_VIEWS_DEFINED')) { |
||
26 | return; |
||
27 | } |
||
28 | define('USERLOG_BLOCK_VIEWS_DEFINED', true); |
||
29 | xoops_loadLanguage('admin', USERLOG_DIRNAME); |
||
30 | |||
31 | // options[0] - number of items to show in block. the default is 10 |
||
32 | // options[1] - items to select in Where claus |
||
33 | // options[2] - Time period - default: 1 day |
||
34 | // options[3] - Uid in WHERE claus: select some users to only count views by them -1 -> all (by default) |
||
35 | // options[4] - Gid in WHERE claus: select some groups to only count views by them 0 -> all (by default) |
||
36 | // options[5] - Sort - views, module dirname, module name, module views default: views |
||
37 | // options[6] - Order - DESC, ASC default: DESC |
||
38 | |||
39 | /** |
||
40 | * @param $options |
||
41 | * |
||
42 | * @return array |
||
43 | */ |
||
44 | function userlog_views_show($options) |
||
45 | { |
||
46 | $loglogObj = UserlogLog::getInstance(); |
||
47 | $module = []; |
||
48 | if (!empty($options[1])) { |
||
49 | $options_views = explode(',', $options[1]); // item views in where claus eg: news-storyid, newbb-topic_id, news-storytopic |
||
50 | View Code Duplication | foreach ($options_views as $key => $item) { |
|
0 ignored issues
–
show
|
|||
51 | $module_script_item = explode('-', $item); // news:article.php-storyid news:index.php-storytopic => $module["news"]=array("storyid","storytopic"); |
||
52 | $module_script = explode(':', $module_script_item[0]); // news:article.php => $module_script = array(news,article.php); |
||
53 | if (!isset($module[$module_script[0]])) { |
||
54 | $module[$module_script[0]]['item_name'] = []; |
||
55 | $module[$module_script[0]]['script'] = array_slice($module_script, 1); |
||
56 | } |
||
57 | $module[$module_script[0]]['script'] = array_unique(array_merge($module[$module_script[0]]['script'], array_slice($module_script, 1))); |
||
58 | $module[$module_script[0]]['item_name'][] = $module_script_item[1]; |
||
59 | } |
||
60 | } |
||
61 | $users = ($options[3] != -1) ? explode(',', $options[3]) : []; |
||
62 | $groups = !empty($options[4]) ? explode(',', $options[4]) : []; |
||
63 | |||
64 | $items = $loglogObj->getViews($options[0], 0, $options[5], $options[6], $module, $options[2], $users, $groups); |
||
65 | $block = []; |
||
66 | $block['items'] = $items; |
||
67 | $block['sort'] = $options[5]; |
||
68 | |||
69 | return $block; |
||
70 | } |
||
71 | |||
72 | /** |
||
73 | * @param $options |
||
74 | * |
||
75 | * @return string |
||
76 | */ |
||
77 | function userlog_views_edit($options) |
||
78 | { |
||
79 | // require_once XOOPS_ROOT_PATH . "/class/blockform.php"; //reserve for 2.6 |
||
80 | xoops_load('XoopsFormLoader'); |
||
81 | // $form = new XoopsBlockForm(); //reserve for 2.6 |
||
82 | $form = new XoopsThemeForm(_AM_USERLOG_VIEW, 'views', ''); |
||
83 | |||
84 | /** @var XoopsModuleHandler $moduleHandler */ |
||
85 | $moduleHandler = xoops_getHandler('module'); |
||
86 | $criteria = new CriteriaCompo(); |
||
87 | $criteria->add(new Criteria('hasnotification', 1)); |
||
88 | $criteria->add(new Criteria('isactive', 1)); |
||
89 | $modules = $moduleHandler->getObjects($criteria, true); |
||
90 | $hasviews = []; |
||
91 | foreach ($modules as $module) { |
||
92 | $not_config = $module->getInfo('notification'); |
||
93 | View Code Duplication | foreach ($not_config['category'] as $category) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
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. ![]() |
|||
94 | if (!empty($category['item_name'])) { |
||
95 | $script = is_array($category['subscribe_from']) ? implode(':', $category['subscribe_from']) : $category['subscribe_from']; |
||
96 | $hasviews[$module->dirname() . ':' . $script . '-' . $category['item_name']] = $module->dirname() . '/' . $script . '?' . $category['item_name'] . '=ITEM_ID'; |
||
97 | } |
||
98 | } |
||
99 | } |
||
100 | |||
101 | $i = 0; |
||
102 | // number of items to display element |
||
103 | $numitemsEle = new XoopsFormText(_AM_USERLOG_ITEMS_NUM, "options[{$i}]", 10, 255, (int)$options[$i]); |
||
104 | |||
105 | ++$i; |
||
106 | // views element |
||
107 | $options_views = explode(',', $options[$i]); |
||
108 | $viewsEle = new XoopsFormCheckBox(_AM_USERLOG_ITEMS, "options[{$i}][]", !empty($options_views) ? $options_views : 0); |
||
109 | $viewsEle->columns = 3; |
||
110 | if (!empty($hasviews)) { |
||
111 | $viewsEle->addOptionArray($hasviews); |
||
112 | $viewsEle->setExtra("onchange = \"validate('options[{$i}][]','checkbox', true)\""); // prevent user select no option |
||
113 | $check_all = _ALL . ": <input type=\"checkbox\" name=\"item_check\" id=\"item_check\" value=\"1\" onclick=\"xoopsCheckGroup('blockform', 'item_check','options[{$i}][]');\">"; // blockform is the main form |
||
114 | $viewsEle = new XoopsFormLabel(_AM_USERLOG_ITEMS, $check_all . "<br\>" . $viewsEle->render()); |
||
115 | } else { |
||
116 | // prevent to select |
||
117 | $viewsEle->addOption(0, _NONE); |
||
118 | $viewsEle->setExtra('class="hidden"'); |
||
119 | } |
||
120 | |||
121 | $viewsEle->setDescription(_AM_USERLOG_ITEMS_DSC); |
||
122 | |||
123 | ++$i; |
||
124 | $timeEle = new XoopsFormText(_AM_USERLOG_LOG_TIMEGT, "options[{$i}]", 10, 255, $options[$i]); |
||
125 | $timeEle->setDescription(_AM_USERLOG_LOG_TIMEGT_FORM); |
||
126 | |||
127 | ++$i; |
||
128 | $userRadioEle = new XoopsFormRadio(_AM_USERLOG_UID, "options[{$i}]", $options[$i]); |
||
129 | $userRadioEle->addOption(-1, _ALL); |
||
130 | $userRadioEle->addOption(($options[$i] != -1) ? $options[$i] : 0, _SELECT); // if no user in selection box it select uid=0 anon users |
||
131 | $userRadioEle->setExtra("onchange=\"var el=document.getElementById('options[{$i}]'); el.disabled=(this.id == 'options[{$i}]1'); if (!el.value) {el.value= this.value}\""); // if user dont select any option it select "all" |
||
132 | $userSelectEle = new XoopsFormSelectUser(_AM_USERLOG_UID, "options[{$i}]", true, explode(',', $options[$i]), 3, true); |
||
133 | $userEle = new XoopsFormLabel(_AM_USERLOG_UID, $userRadioEle->render() . $userSelectEle->render()); |
||
134 | |||
135 | ++$i; |
||
136 | $groupRadioEle = new XoopsFormRadio(_AM_USERLOG_GROUPS, "options[{$i}]", !empty($options[$i])); |
||
137 | $groupRadioEle->addOption(0, _ALL); |
||
138 | $groupRadioEle->addOption(!empty($options[$i]) ? $options[$i] : 2, _SELECT); // if no group in selection box it select gid=2 registered users |
||
139 | $groupRadioEle->setExtra("onchange=\"var el=document.getElementById('options[{$i}]'); el.disabled=(this.id == 'options[{$i}]1'); if (!el.value) {el.value= this.value}\""); // if group dont select any option it select "all" |
||
140 | $groupSelectEle = new XoopsFormSelectGroup(_AM_USERLOG_GROUPS, "options[{$i}]", true, explode(',', $options[$i]), 3, true); |
||
141 | $groupEle = new XoopsFormLabel(_AM_USERLOG_GROUPS, $groupRadioEle->render() . $groupSelectEle->render()); |
||
142 | |||
143 | ++$i; |
||
144 | $sortEle = new XoopsFormSelect(_AM_USERLOG_SORT, "options[{$i}]", $options[$i]); |
||
145 | $sortEle->addOptionArray([ |
||
146 | 'count' => _AM_USERLOG_VIEW, |
||
147 | 'module' => _AM_USERLOG_MODULE, |
||
148 | 'module_name' => _AM_USERLOG_MODULE_NAME, |
||
149 | 'module_count' => _AM_USERLOG_VIEW_MODULE |
||
150 | ]); |
||
151 | $sortEle->setDescription(_AM_USERLOG_SORT_DSC); |
||
152 | |||
153 | ++$i; |
||
154 | $orderEle = new XoopsFormSelect(_AM_USERLOG_ORDER, "options[{$i}]", $options[$i]); |
||
155 | $orderEle->addOption('DESC', _DESCENDING); |
||
156 | $orderEle->addOption('ASC', _ASCENDING); |
||
157 | $orderEle->setDescription(_AM_USERLOG_ORDER_DSC); |
||
158 | |||
159 | // add all elements to form |
||
160 | $form->addElement($numitemsEle); |
||
161 | $form->addElement($viewsEle); |
||
162 | $form->addElement($timeEle); |
||
163 | $form->addElement($userEle); |
||
164 | $form->addElement($groupEle); |
||
165 | $form->addElement($sortEle); |
||
166 | $form->addElement($orderEle); |
||
167 | |||
168 | return $form->render(); |
||
169 | } |
||
170 |
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.