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_FRIENDREQUEST_LIST, 'friendrequests.php', 'list'); |
||
35 | $adminObject->displayButton('left'); |
||
36 | $friendrequestObject = $friendrequestHandler->create(); |
||
37 | $form = $friendrequestObject->getForm(); |
||
38 | $form->display(); |
||
39 | break; |
||
40 | case 'save': |
||
41 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||
42 | redirect_header('friendrequests.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
||
43 | } |
||
44 | if (0 !== Request::getInt('friendreq_id', 0)) { |
||
45 | $friendrequestObject = $friendrequestHandler->get(Request::getInt('friendreq_id', 0)); |
||
46 | } else { |
||
47 | $friendrequestObject = $friendrequestHandler->create(); |
||
48 | } |
||
49 | // Form save fields |
||
50 | $friendrequestObject->setVar('friendrequester_uid', Request::getVar('friendrequester_uid', '')); |
||
51 | $friendrequestObject->setVar('friendrequestto_uid', Request::getVar('friendrequestto_uid', '')); |
||
52 | $dateTimeObj = \DateTime::createFromFormat(_SHORTDATESTRING, Request::getString('date_created', '', 'POST')); |
||
53 | $friendrequestObject->setVar('date_created', $dateTimeObj->getTimestamp()); |
||
54 | if ($friendrequestHandler->insert($friendrequestObject)) { |
||
55 | redirect_header('friendrequests.php?op=list', 2, AM_SUICO_FORMOK); |
||
56 | } |
||
57 | echo $friendrequestObject->getHtmlErrors(); |
||
58 | $form = $friendrequestObject->getForm(); |
||
59 | $form->display(); |
||
60 | break; |
||
61 | case 'edit': |
||
62 | $adminObject->addItemButton(AM_SUICO_ADD_FRIENDREQUEST, 'friendrequests.php?op=new', 'add'); |
||
63 | $adminObject->addItemButton(AM_SUICO_FRIENDREQUEST_LIST, 'friendrequests.php', 'list'); |
||
64 | $adminObject->displayButton('left'); |
||
65 | $friendrequestObject = $friendrequestHandler->get(Request::getString('friendreq_id', '')); |
||
66 | $form = $friendrequestObject->getForm(); |
||
67 | $form->display(); |
||
68 | break; |
||
69 | case 'delete': |
||
70 | $friendrequestObject = $friendrequestHandler->get(Request::getString('friendreq_id', '')); |
||
71 | if (1 === Request::getInt('ok', 0)) { |
||
72 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||
73 | redirect_header('friendrequests.php', 3, implode(', ', $GLOBALS['xoopsSecurity']->getErrors())); |
||
74 | } |
||
75 | if ($friendrequestHandler->delete($friendrequestObject)) { |
||
76 | redirect_header('friendrequests.php', 3, AM_SUICO_FORMDELOK); |
||
77 | } else { |
||
78 | echo $friendrequestObject->getHtmlErrors(); |
||
79 | } |
||
80 | } else { |
||
81 | xoops_confirm( |
||
82 | [ |
||
83 | 'ok' => 1, |
||
84 | 'friendreq_id' => Request::getString('friendreq_id', ''), |
||
85 | 'op' => 'delete', |
||
86 | ], |
||
87 | Request::getUrl('REQUEST_URI', '', 'SERVER'), |
||
88 | sprintf( |
||
89 | AM_SUICO_FORMSUREDEL, |
||
90 | $friendrequestObject->getVar('friendreq_id') |
||
91 | ) |
||
92 | ); |
||
93 | } |
||
94 | break; |
||
95 | case 'clone': |
||
96 | $id_field = Request::getString('friendreq_id', ''); |
||
97 | if ($utility::cloneRecord('suico_friendrequests', 'friendreq_id', $id_field)) { |
||
98 | redirect_header('friendrequests.php', 3, AM_SUICO_CLONED_OK); |
||
99 | } else { |
||
100 | redirect_header('friendrequests.php', 3, AM_SUICO_CLONED_FAILED); |
||
101 | } |
||
102 | break; |
||
103 | case 'list': |
||
104 | default: |
||
105 | $adminObject->addItemButton(AM_SUICO_ADD_FRIENDREQUEST, 'friendrequests.php?op=new', 'add'); |
||
106 | $adminObject->displayButton('left'); |
||
107 | $start = Request::getInt('start', 0); |
||
108 | $friendrequestPaginationLimit = $helper->getConfig('userpager'); |
||
109 | $criteria = new CriteriaCompo(); |
||
110 | $criteria->setSort('friendreq_id ASC, friendreq_id'); |
||
111 | $criteria->setOrder('ASC'); |
||
112 | $criteria->setLimit($friendrequestPaginationLimit); |
||
113 | $criteria->setStart($start); |
||
114 | $friendrequestTempRows = $friendrequestHandler->getCount(); |
||
115 | $friendrequestTempArray = $friendrequestHandler->getAll($criteria); |
||
116 | // Display Page Navigation |
||
117 | if ($friendrequestTempRows > $friendrequestPaginationLimit) { |
||
118 | xoops_load('XoopsPageNav'); |
||
119 | $pagenav = new \XoopsPageNav( |
||
120 | $friendrequestTempRows, |
||
121 | $friendrequestPaginationLimit, |
||
122 | $start, |
||
123 | 'start', |
||
124 | 'op=list' . '&sort=' . $sort . '&order=' . $order . '' |
||
125 | ); |
||
126 | $GLOBALS['xoopsTpl']->assign('pagenav', null === $pagenav ? $pagenav->renderNav() : ''); |
||
127 | } |
||
128 | $GLOBALS['xoopsTpl']->assign('friendrequestRows', $friendrequestTempRows); |
||
129 | $friendrequestArray = []; |
||
130 | // $fields = explode('|', friendreq_id:int:11::NOT NULL::primary:friendreq_id|friendrequester_uid:int:11::NOT NULL:::friendrequester_uid|friendrequestto_uid:int:11::NOT NULL:::friendrequestto_uid); |
||
131 | // $fieldsCount = count($fields); |
||
132 | $criteria = new CriteriaCompo(); |
||
133 | //$criteria->setOrder('DESC'); |
||
134 | $criteria->setSort($sort); |
||
135 | $criteria->setOrder($order); |
||
136 | $criteria->setLimit($friendrequestPaginationLimit); |
||
137 | $criteria->setStart($start); |
||
138 | $friendrequestCount = $friendrequestHandler->getCount($criteria); |
||
139 | $friendrequestTempArray = $friendrequestHandler->getAll($criteria); |
||
140 | // for ($i = 0; $i < $fieldsCount; ++$i) { |
||
141 | if ($friendrequestCount > 0) { |
||
142 | foreach (array_keys($friendrequestTempArray) as $i) { |
||
143 | // $field = explode(':', $fields[$i]); |
||
144 | $GLOBALS['xoopsTpl']->assign( |
||
145 | 'selectorfriendreq_id', |
||
146 | AM_SUICO_FRIENDREQUEST_FRIENDPET_ID |
||
147 | ); |
||
148 | $friendrequestArray['friendreq_id'] = $friendrequestTempArray[$i]->getVar('friendreq_id'); |
||
149 | $GLOBALS['xoopsTpl']->assign('selectorfriendrequester_uid', AM_SUICO_FRIENDREQUEST_FRIENDREQUESTER_UID); |
||
150 | $friendrequestArray['friendrequester_uid'] = strip_tags( |
||
151 | XoopsUser::getUnameFromId($friendrequestTempArray[$i]->getVar('friendrequester_uid')) |
||
152 | ); |
||
153 | $GLOBALS['xoopsTpl']->assign('selectorfriendrequestto_uid', AM_SUICO_FRIENDREQUEST_FRIENDREQUESTTO_UID); |
||
154 | $friendrequestArray['friendrequestto_uid'] = strip_tags( |
||
155 | XoopsUser::getUnameFromId($friendrequestTempArray[$i]->getVar('friendrequestto_uid')) |
||
156 | ); |
||
157 | $GLOBALS['xoopsTpl']->assign('selectordate_created', AM_SUICO_FRIENDREQUEST_DATE_CREATED); |
||
158 | $friendrequestArray['date_created'] = formatTimestamp($friendrequestTempArray[$i]->getVar('date_created'), 's'); |
||
159 | $friendrequestArray['edit_delete'] = "<a href='friendrequests.php?op=edit&friendreq_id=" . $i . "'><img src=" . $pathIcon16 . "/edit.png alt='" . _EDIT . "' title='" . _EDIT . "'></a> |
||
160 | <a href='friendrequests.php?op=delete&friendreq_id=" . $i . "'><img src=" . $pathIcon16 . "/delete.png alt='" . _DELETE . "' title='" . _DELETE . "'></a> |
||
161 | <a href='friendrequests.php?op=clone&friendreq_id=" . $i . "'><img src=" . $pathIcon16 . "/editcopy.png alt='" . _CLONE . "' title='" . _CLONE . "'></a>"; |
||
162 | $GLOBALS['xoopsTpl']->append_by_ref('friendrequestsArray', $friendrequestArray); |
||
163 | unset($friendrequestArray); |
||
164 | } |
||
165 | unset($friendrequestTempArray); |
||
166 | // Display Navigation |
||
167 | if ($friendrequestCount > $friendrequestPaginationLimit) { |
||
168 | xoops_load('XoopsPageNav'); |
||
169 | $pagenav = new \XoopsPageNav( |
||
170 | $friendrequestCount, |
||
171 | $friendrequestPaginationLimit, |
||
172 | $start, |
||
173 | 'start', |
||
174 | 'op=list' . '&sort=' . $sort . '&order=' . $order . '' |
||
175 | ); |
||
176 | $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav(4)); |
||
177 | } |
||
178 | echo $GLOBALS['xoopsTpl']->fetch( |
||
179 | XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['xoopsModule']->getVar( |
||
180 | 'dirname' |
||
181 | ) . '/templates/admin/suico_admin_friendrequests.tpl' |
||
182 | ); |
||
183 | } |
||
184 | break; |
||
185 | } |
||
186 | require_once __DIR__ . '/admin_footer.php'; |
||
187 |
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: