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_FRIENDSHIP_LIST, 'friendships.php', 'list'); |
||
35 | $adminObject->displayButton('left'); |
||
36 | $friendshipObject = $friendshipHandler->create(); |
||
37 | $form = $friendshipObject->getForm(); |
||
38 | $form->display(); |
||
39 | break; |
||
40 | case 'save': |
||
41 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||
42 | redirect_header('friendships.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
||
43 | } |
||
44 | if (0 !== Request::getInt('friendship_id', 0)) { |
||
45 | $friendshipObject = $friendshipHandler->get(Request::getInt('friendship_id', 0)); |
||
46 | } else { |
||
47 | $friendshipObject = $friendshipHandler->create(); |
||
48 | } |
||
49 | // Form save fields |
||
50 | $friendshipObject->setVar('friend1_uid', Request::getVar('friend1_uid', '')); |
||
51 | $friendshipObject->setVar('friend2_uid', Request::getVar('friend2_uid', '')); |
||
52 | $friendshipObject->setVar('level', Request::getVar('level', '')); |
||
53 | $friendshipObject->setVar('hot', Request::getVar('hot', '')); |
||
54 | $friendshipObject->setVar('trust', Request::getVar('trust', '')); |
||
55 | $friendshipObject->setVar('cool', Request::getVar('cool', '')); |
||
56 | $friendshipObject->setVar('fan', Request::getVar('fan', '')); |
||
57 | $dateTimeObj = \DateTime::createFromFormat(_SHORTDATESTRING, Request::getString('date_created', '', 'POST')); |
||
58 | $friendshipObject->setVar('date_created', $dateTimeObj->getTimestamp()); |
||
59 | $dateTimeObj = \DateTime::createFromFormat(_SHORTDATESTRING, Request::getString('date_updated', '', 'POST')); |
||
60 | $friendshipObject->setVar('date_updated', $dateTimeObj->getTimestamp()); |
||
61 | if ($friendshipHandler->insert($friendshipObject)) { |
||
62 | redirect_header('friendships.php?op=list', 2, AM_SUICO_FORMOK); |
||
63 | } |
||
64 | echo $friendshipObject->getHtmlErrors(); |
||
65 | $form = $friendshipObject->getForm(); |
||
66 | $form->display(); |
||
67 | break; |
||
68 | case 'edit': |
||
69 | $adminObject->addItemButton(AM_SUICO_ADD_FRIENDSHIP, 'friendships.php?op=new', 'add'); |
||
70 | $adminObject->addItemButton(AM_SUICO_FRIENDSHIP_LIST, 'friendships.php', 'list'); |
||
71 | $adminObject->displayButton('left'); |
||
72 | $friendshipObject = $friendshipHandler->get(Request::getString('friendship_id', '')); |
||
73 | $form = $friendshipObject->getForm(); |
||
74 | $form->display(); |
||
75 | break; |
||
76 | case 'delete': |
||
77 | $friendshipObject = $friendshipHandler->get(Request::getString('friendship_id', '')); |
||
78 | if (1 === Request::getInt('ok', 0)) { |
||
79 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||
80 | redirect_header('friendships.php', 3, implode(', ', $GLOBALS['xoopsSecurity']->getErrors())); |
||
81 | } |
||
82 | if ($friendshipHandler->delete($friendshipObject)) { |
||
83 | redirect_header('friendships.php', 3, AM_SUICO_FORMDELOK); |
||
84 | } else { |
||
85 | echo $friendshipObject->getHtmlErrors(); |
||
86 | } |
||
87 | } else { |
||
88 | xoops_confirm( |
||
89 | [ |
||
90 | 'ok' => 1, |
||
91 | 'friendship_id' => Request::getString('friendship_id', ''), |
||
92 | 'op' => 'delete', |
||
93 | ], |
||
94 | Request::getUrl('REQUEST_URI', '', 'SERVER'), |
||
95 | sprintf( |
||
96 | AM_SUICO_FORMSUREDEL, |
||
97 | $friendshipObject->getVar('friendship_id') |
||
98 | ) |
||
99 | ); |
||
100 | } |
||
101 | break; |
||
102 | case 'clone': |
||
103 | $id_field = Request::getString('friendship_id', ''); |
||
104 | if ($utility::cloneRecord('suico_friendships', 'friendship_id', $id_field)) { |
||
105 | redirect_header('friendships.php', 3, AM_SUICO_CLONED_OK); |
||
106 | } else { |
||
107 | redirect_header('friendships.php', 3, AM_SUICO_CLONED_FAILED); |
||
108 | } |
||
109 | break; |
||
110 | case 'list': |
||
111 | default: |
||
112 | $adminObject->addItemButton(AM_SUICO_ADD_FRIENDSHIP, 'friendships.php?op=new', 'add'); |
||
113 | $adminObject->displayButton('left'); |
||
114 | $start = Request::getInt('start', 0); |
||
115 | $friendshipPaginationLimit = $helper->getConfig('userpager'); |
||
116 | $criteria = new CriteriaCompo(); |
||
117 | $criteria->setSort('friendship_id ASC, friendship_id'); |
||
118 | $criteria->setOrder('ASC'); |
||
119 | $criteria->setLimit($friendshipPaginationLimit); |
||
120 | $criteria->setStart($start); |
||
121 | $friendshipTempRows = $friendshipHandler->getCount(); |
||
122 | $friendshipTempArray = $friendshipHandler->getAll($criteria); |
||
123 | /* |
||
124 | // |
||
125 | // |
||
126 | <th class='center width5'>".AM_SUICO_FORM_ACTION."</th> |
||
127 | // </tr>"; |
||
128 | // $class = "odd"; |
||
129 | */ |
||
130 | // Display Page Navigation |
||
131 | if ($friendshipTempRows > $friendshipPaginationLimit) { |
||
132 | xoops_load('XoopsPageNav'); |
||
133 | $pagenav = new \XoopsPageNav( |
||
134 | $friendshipTempRows, |
||
135 | $friendshipPaginationLimit, |
||
136 | $start, |
||
137 | 'start', |
||
138 | 'op=list' . '&sort=' . $sort . '&order=' . $order . '' |
||
139 | ); |
||
140 | $GLOBALS['xoopsTpl']->assign('pagenav', null === $pagenav ? $pagenav->renderNav() : ''); |
||
141 | } |
||
142 | $GLOBALS['xoopsTpl']->assign('friendshipRows', $friendshipTempRows); |
||
143 | $friendshipArray = []; |
||
144 | // $fields = explode('|', friendship_id:int:11::NOT NULL::primary:friendship_id|friend1_uid:int:11::NOT NULL:::friend1_uid|friend2_uid:int:11::NOT NULL:::friend2_uid|level:int:11::NOT NULL:::level|hot:tinyint:4::NOT NULL:::hot|trust:tinyint:4::NOT NULL:::trust|cool:tinyint:4::NOT NULL:::cool|fan:tinyint:4::NOT NULL:::fan); |
||
145 | // $fieldsCount = count($fields); |
||
146 | $criteria = new CriteriaCompo(); |
||
147 | //$criteria->setOrder('DESC'); |
||
148 | $criteria->setSort($sort); |
||
149 | $criteria->setOrder($order); |
||
150 | $criteria->setLimit($friendshipPaginationLimit); |
||
151 | $criteria->setStart($start); |
||
152 | $friendshipCount = $friendshipHandler->getCount($criteria); |
||
153 | $friendshipTempArray = $friendshipHandler->getAll($criteria); |
||
154 | // for ($i = 0; $i < $fieldsCount; ++$i) { |
||
155 | if ($friendshipCount > 0) { |
||
156 | foreach (array_keys($friendshipTempArray) as $i) { |
||
157 | // $field = explode(':', $fields[$i]); |
||
158 | $GLOBALS['xoopsTpl']->assign( |
||
159 | 'selectorfriendship_id', |
||
160 | AM_SUICO_FRIENDSHIP_FRIENDSHIP_ID |
||
161 | ); |
||
162 | $friendshipArray['friendship_id'] = $friendshipTempArray[$i]->getVar('friendship_id'); |
||
163 | $GLOBALS['xoopsTpl']->assign('selectorfriend1_uid', AM_SUICO_FRIENDSHIP_FRIEND1_UID); |
||
164 | $friendshipArray['friend1_uid'] = strip_tags( |
||
165 | XoopsUser::getUnameFromId($friendshipTempArray[$i]->getVar('friend1_uid')) |
||
166 | ); |
||
167 | $GLOBALS['xoopsTpl']->assign('selectorfriend2_uid', AM_SUICO_FRIENDSHIP_FRIEND2_UID); |
||
168 | $friendshipArray['friend2_uid'] = strip_tags( |
||
169 | XoopsUser::getUnameFromId($friendshipTempArray[$i]->getVar('friend2_uid')) |
||
170 | ); |
||
171 | $GLOBALS['xoopsTpl']->assign('selectorlevel', AM_SUICO_FRIENDSHIP_LEVEL); |
||
172 | $friendshipArray['level'] = $friendshipTempArray[$i]->getVar('level'); |
||
173 | $GLOBALS['xoopsTpl']->assign('selectorhot', AM_SUICO_FRIENDSHIP_HOT); |
||
174 | $friendshipArray['hot'] = $friendshipTempArray[$i]->getVar('hot'); |
||
175 | $GLOBALS['xoopsTpl']->assign('selectortrust', AM_SUICO_FRIENDSHIP_TRUST); |
||
176 | $friendshipArray['trust'] = $friendshipTempArray[$i]->getVar('trust'); |
||
177 | $GLOBALS['xoopsTpl']->assign('selectorcool', AM_SUICO_FRIENDSHIP_COOL); |
||
178 | $friendshipArray['cool'] = $friendshipTempArray[$i]->getVar('cool'); |
||
179 | $GLOBALS['xoopsTpl']->assign('selectorfan', AM_SUICO_FRIENDSHIP_FAN); |
||
180 | $friendshipArray['fan'] = $friendshipTempArray[$i]->getVar('fan'); |
||
181 | $GLOBALS['xoopsTpl']->assign('selectordate_created', AM_SUICO_FRIENDSHIP_DATE_CREATED); |
||
182 | $friendshipArray['date_created'] = formatTimestamp($friendshipTempArray[$i]->getVar('date_created'), 's'); |
||
183 | $GLOBALS['xoopsTpl']->assign('selectordate_updated', AM_SUICO_FRIENDSHIP_DATE_UPDATED); |
||
184 | $friendshipArray['date_updated'] = formatTimestamp($friendshipTempArray[$i]->getVar('date_updated'), 's'); |
||
185 | $friendshipArray['edit_delete'] = "<a href='friendships.php?op=edit&friendship_id=" . $i . "'><img src=" . $pathIcon16 . "/edit.png alt='" . _EDIT . "' title='" . _EDIT . "'></a> |
||
186 | <a href='friendships.php?op=delete&friendship_id=" . $i . "'><img src=" . $pathIcon16 . "/delete.png alt='" . _DELETE . "' title='" . _DELETE . "'></a> |
||
187 | <a href='friendships.php?op=clone&friendship_id=" . $i . "'><img src=" . $pathIcon16 . "/editcopy.png alt='" . _CLONE . "' title='" . _CLONE . "'></a>"; |
||
188 | $GLOBALS['xoopsTpl']->append_by_ref('friendshipsArray', $friendshipArray); |
||
189 | unset($friendshipArray); |
||
190 | } |
||
191 | unset($friendshipTempArray); |
||
192 | // Display Navigation |
||
193 | if ($friendshipCount > $friendshipPaginationLimit) { |
||
194 | xoops_load('XoopsPageNav'); |
||
195 | $pagenav = new \XoopsPageNav( |
||
196 | $friendshipCount, |
||
197 | $friendshipPaginationLimit, |
||
198 | $start, |
||
199 | 'start', |
||
200 | 'op=list' . '&sort=' . $sort . '&order=' . $order . '' |
||
201 | ); |
||
202 | $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav(4)); |
||
203 | } |
||
204 | echo $GLOBALS['xoopsTpl']->fetch( |
||
205 | XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['xoopsModule']->getVar( |
||
206 | 'dirname' |
||
207 | ) . '/templates/admin/suico_admin_friendships.tpl' |
||
208 | ); |
||
209 | } |
||
210 | break; |
||
211 | } |
||
212 | require_once __DIR__ . '/admin_footer.php'; |
||
213 |
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: