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.
1 | <?php declare(strict_types=1); |
||
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 | * @category Module |
||
14 | * @copyright {@link https://xoops.org/ XOOPS Project} |
||
15 | * @license GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
||
16 | * @author Marcello Brandão aka Suico, Mamba, LioMJ <https://xoops.org> |
||
17 | */ |
||
18 | |||
19 | use Xmf\Module\Helper\Permission; |
||
20 | use Xmf\Request; |
||
0 ignored issues
–
show
|
|||
21 | |||
22 | require_once __DIR__ . '/admin_header.php'; |
||
23 | xoops_cp_header(); |
||
24 | //It recovered the value of argument op in URL$ |
||
25 | $op = Request::getString('op', 'list'); |
||
26 | $order = Request::getString('order', 'desc'); |
||
27 | $sort = Request::getString('sort', ''); |
||
28 | $adminObject->displayNavigation(basename(__FILE__)); |
||
29 | $permHelper = new Permission(); |
||
30 | $uploadDir = XOOPS_UPLOAD_PATH . '/suico/images/'; |
||
31 | $uploadUrl = XOOPS_UPLOAD_URL . '/suico/images/'; |
||
32 | switch ($op) { |
||
33 | case 'new': |
||
34 | $adminObject->addItemButton(AM_SUICO_VISITORS_LIST, 'visitors.php', 'list'); |
||
35 | $adminObject->displayButton('left'); |
||
36 | $visitorsObject = $visitorsHandler->create(); |
||
37 | $form = $visitorsObject->getForm(); |
||
38 | $form->display(); |
||
39 | break; |
||
40 | case 'save': |
||
41 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||
42 | redirect_header('visitors.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
||
43 | } |
||
44 | if (0 !== Request::getInt('visit_id', 0)) { |
||
45 | $visitorsObject = $visitorsHandler->get(Request::getInt('visit_id', 0)); |
||
46 | } else { |
||
47 | $visitorsObject = $visitorsHandler->create(); |
||
48 | } |
||
49 | // Form save fields |
||
50 | $visitorsObject->setVar('uid_owner', Request::getVar('uid_owner', '')); |
||
51 | $visitorsObject->setVar('uid_visitor', Request::getVar('uid_visitor', '')); |
||
52 | $visitorsObject->setVar('uname_visitor', Request::getVar('uname_visitor', '')); |
||
53 | $dateTimeObj = \DateTime::createFromFormat(_SHORTDATESTRING, Request::getString('date_visited', '', 'POST')); |
||
54 | $visitorsObject->setVar('date_visited', $dateTimeObj->getTimestamp()); |
||
55 | if ($visitorsHandler->insert($visitorsObject)) { |
||
56 | redirect_header('visitors.php?op=list', 2, AM_SUICO_FORMOK); |
||
57 | } |
||
58 | echo $visitorsObject->getHtmlErrors(); |
||
59 | $form = $visitorsObject->getForm(); |
||
60 | $form->display(); |
||
61 | break; |
||
62 | case 'edit': |
||
63 | $adminObject->addItemButton(AM_SUICO_ADD_VISITORS, 'visitors.php?op=new', 'add'); |
||
64 | $adminObject->addItemButton(AM_SUICO_VISITORS_LIST, 'visitors.php', 'list'); |
||
65 | $adminObject->displayButton('left'); |
||
66 | $visitorsObject = $visitorsHandler->get(Request::getString('visit_id', '')); |
||
67 | $form = $visitorsObject->getForm(); |
||
68 | $form->display(); |
||
69 | break; |
||
70 | case 'delete': |
||
71 | $visitorsObject = $visitorsHandler->get(Request::getString('visit_id', '')); |
||
72 | if (1 === Request::getInt('ok', 0)) { |
||
73 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||
74 | redirect_header('visitors.php', 3, implode(', ', $GLOBALS['xoopsSecurity']->getErrors())); |
||
75 | } |
||
76 | if ($visitorsHandler->delete($visitorsObject)) { |
||
77 | redirect_header('visitors.php', 3, AM_SUICO_FORMDELOK); |
||
78 | } else { |
||
79 | echo $visitorsObject->getHtmlErrors(); |
||
80 | } |
||
81 | } else { |
||
82 | xoops_confirm( |
||
83 | [ |
||
84 | 'ok' => 1, |
||
85 | 'visit_id' => Request::getString('visit_id', ''), |
||
86 | 'op' => 'delete', |
||
87 | ], |
||
88 | Request::getUrl('REQUEST_URI', '', 'SERVER'), |
||
89 | sprintf( |
||
90 | AM_SUICO_FORMSUREDEL, |
||
91 | $visitorsObject->getVar('uname_visitor') |
||
92 | ) |
||
93 | ); |
||
94 | } |
||
95 | break; |
||
96 | case 'clone': |
||
97 | $id_field = Request::getString('visit_id', ''); |
||
98 | if ($utility::cloneRecord('suico_visitors', 'visit_id', $id_field)) { |
||
99 | redirect_header('visitors.php', 3, AM_SUICO_CLONED_OK); |
||
100 | } else { |
||
101 | redirect_header('visitors.php', 3, AM_SUICO_CLONED_FAILED); |
||
102 | } |
||
103 | break; |
||
104 | case 'list': |
||
105 | default: |
||
106 | $adminObject->addItemButton(AM_SUICO_ADD_VISITORS, 'visitors.php?op=new', 'add'); |
||
107 | $adminObject->displayButton('left'); |
||
108 | $start = Request::getInt('start', 0); |
||
109 | $visitorsPaginationLimit = $helper->getConfig('userpager'); |
||
110 | $criteria = new CriteriaCompo(); |
||
111 | $criteria->setSort('visit_id ASC, uname_visitor'); |
||
112 | $criteria->setOrder('ASC'); |
||
113 | $criteria->setLimit($visitorsPaginationLimit); |
||
114 | $criteria->setStart($start); |
||
115 | $visitorsTempRows = $visitorsHandler->getCount(); |
||
116 | $visitorsTempArray = $visitorsHandler->getAll($criteria); |
||
117 | /* |
||
118 | // |
||
119 | // |
||
120 | <th class='center width5'>".AM_SUICO_FORM_ACTION."</th> |
||
121 | // </tr>"; |
||
122 | // $class = "odd"; |
||
123 | */ |
||
124 | // Display Page Navigation |
||
125 | if ($visitorsTempRows > $visitorsPaginationLimit) { |
||
126 | xoops_load('XoopsPageNav'); |
||
127 | $pagenav = new \XoopsPageNav( |
||
128 | $visitorsTempRows, |
||
129 | $visitorsPaginationLimit, |
||
130 | $start, |
||
131 | 'start', |
||
132 | 'op=list' . '&sort=' . $sort . '&order=' . $order . '' |
||
133 | ); |
||
134 | $GLOBALS['xoopsTpl']->assign('pagenav', null === $pagenav ? $pagenav->renderNav() : ''); |
||
135 | } |
||
136 | $GLOBALS['xoopsTpl']->assign('visitorsRows', $visitorsTempRows); |
||
137 | $visitorsArray = []; |
||
138 | // $fields = explode('|', visit_id:int:11::NOT NULL::primary:visit_id|uid_owner:int:11::NOT NULL:::uid_owner|uid_visitor:int:11::NOT NULL:::uid_visitor|uname_visitor:varchar:30::NOT NULL:::uname_visitor|date_visited:timestamp:0::NOT NULL:CURRENT_TIMESTAMP::date_visited); |
||
139 | // $fieldsCount = count($fields); |
||
140 | $criteria = new CriteriaCompo(); |
||
141 | //$criteria->setOrder('DESC'); |
||
142 | $criteria->setSort($sort); |
||
143 | $criteria->setOrder($order); |
||
144 | $criteria->setLimit($visitorsPaginationLimit); |
||
145 | $criteria->setStart($start); |
||
146 | $visitorsCount = $visitorsHandler->getCount($criteria); |
||
147 | $visitorsTempArray = $visitorsHandler->getAll($criteria); |
||
148 | // for ($i = 0; $i < $fieldsCount; ++$i) { |
||
149 | if ($visitorsCount > 0) { |
||
150 | foreach (array_keys($visitorsTempArray) as $i) { |
||
151 | // $field = explode(':', $fields[$i]); |
||
152 | $GLOBALS['xoopsTpl']->assign( |
||
153 | 'selectorvisit_id', |
||
154 | AM_SUICO_VISITORS_VISIT_ID |
||
155 | ); |
||
156 | $visitorsArray['visit_id'] = $visitorsTempArray[$i]->getVar('visit_id'); |
||
157 | $GLOBALS['xoopsTpl']->assign('selectoruid_owner', AM_SUICO_VISITORS_UID_OWNER); |
||
158 | $visitorsArray['uid_owner'] = strip_tags( |
||
159 | XoopsUser::getUnameFromId($visitorsTempArray[$i]->getVar('uid_owner')) |
||
160 | ); |
||
161 | $GLOBALS['xoopsTpl']->assign('selectoruid_visitor', AM_SUICO_VISITORS_UID_VISITOR); |
||
162 | $visitorsArray['uid_visitor'] = strip_tags( |
||
163 | XoopsUser::getUnameFromId($visitorsTempArray[$i]->getVar('uid_visitor')) |
||
164 | ); |
||
165 | $GLOBALS['xoopsTpl']->assign('selectoruname_visitor', AM_SUICO_VISITORS_UNAME_VISITOR); |
||
166 | $visitorsArray['uname_visitor'] = $visitorsTempArray[$i]->getVar('uname_visitor'); |
||
167 | $GLOBALS['xoopsTpl']->assign('selectordate_visited', AM_SUICO_VISITORS_DATETIME); |
||
168 | $visitorsArray['date_visited'] = formatTimestamp($visitorsTempArray[$i]->getVar('date_visited'), 's'); |
||
169 | $visitorsArray['edit_delete'] = "<a href='visitors.php?op=edit&visit_id=" . $i . "'><img src=" . $pathIcon16 . "/edit.png alt='" . _EDIT . "' title='" . _EDIT . "'></a> |
||
170 | <a href='visitors.php?op=delete&visit_id=" . $i . "'><img src=" . $pathIcon16 . "/delete.png alt='" . _DELETE . "' title='" . _DELETE . "'></a> |
||
171 | <a href='visitors.php?op=clone&visit_id=" . $i . "'><img src=" . $pathIcon16 . "/editcopy.png alt='" . _CLONE . "' title='" . _CLONE . "'></a>"; |
||
172 | $GLOBALS['xoopsTpl']->append_by_ref('visitorsArrays', $visitorsArray); |
||
173 | unset($visitorsArray); |
||
174 | } |
||
175 | unset($visitorsTempArray); |
||
176 | // Display Navigation |
||
177 | if ($visitorsCount > $visitorsPaginationLimit) { |
||
178 | xoops_load('XoopsPageNav'); |
||
179 | $pagenav = new \XoopsPageNav( |
||
180 | $visitorsCount, |
||
181 | $visitorsPaginationLimit, |
||
182 | $start, |
||
183 | 'start', |
||
184 | 'op=list' . '&sort=' . $sort . '&order=' . $order . '' |
||
185 | ); |
||
186 | $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav(4)); |
||
187 | } |
||
188 | echo $GLOBALS['xoopsTpl']->fetch( |
||
189 | XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['xoopsModule']->getVar( |
||
190 | 'dirname' |
||
191 | ) . '/templates/admin/suico_admin_visitors.tpl' |
||
192 | ); |
||
193 | } |
||
194 | break; |
||
195 | } |
||
196 | require_once __DIR__ . '/admin_footer.php'; |
||
197 |
Let?s assume that you have a directory layout like this:
and let?s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: