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/audio/'; |
||
31 | $uploadUrl = XOOPS_UPLOAD_URL . '/suico/audio/'; |
||
32 | switch ($op) { |
||
33 | case 'new': |
||
34 | $adminObject->addItemButton(AM_SUICO_AUDIO_LIST, 'audios.php', 'list'); |
||
35 | $adminObject->displayButton('left'); |
||
36 | $audioObject = $audioHandler->create(); |
||
37 | $form = $audioObject->getForm(); |
||
38 | $form->display(); |
||
39 | break; |
||
40 | case 'save': |
||
41 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||
42 | redirect_header('audios.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
||
43 | } |
||
44 | if (0 !== Request::getInt('audio_id', 0)) { |
||
45 | $audioObject = $audioHandler->get(Request::getInt('audio_id', 0)); |
||
46 | } else { |
||
47 | $audioObject = $audioHandler->create(); |
||
48 | } |
||
49 | // Form save fields |
||
50 | $audioObject->setVar('uid_owner', Request::getVar('uid_owner', '')); |
||
51 | $audioObject->setVar('title', Request::getVar('title', '')); |
||
52 | $audioObject->setVar('author', Request::getVar('author', '')); |
||
53 | $audioObject->setVar('description', Request::getText('description', '')); |
||
54 | // $audioObject->setVar('filename', Request::getVar('filename', '')); |
||
55 | require_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
||
56 | $uploadDir = XOOPS_UPLOAD_PATH . '/suico/audio/'; |
||
57 | $uploader = new \XoopsMediaUploader( |
||
58 | $uploadDir, |
||
59 | $helper->getConfig('mimetypes'), |
||
60 | $helper->getConfig('maxsize'), |
||
61 | null, |
||
62 | null |
||
63 | ); |
||
64 | if ($uploader->fetchMedia(Request::getString('xoops_upload_file', '', 'POST')[0])) { |
||
65 | // $uploader->setPrefix('url_'); |
||
66 | $uploader->setPrefix('aud_' . $uid . '_'); |
||
67 | $uploader->fetchMedia(Request::getString('xoops_upload_file', '', 'POST')[0]); |
||
68 | if ($uploader->upload()) { |
||
69 | $audioObject->setVar('filename', $uploader->getSavedFileName()); |
||
70 | } else { |
||
71 | $errors = $uploader->getErrors(); |
||
72 | redirect_header('javascript:history.go(-1)', 3, $errors); |
||
73 | } |
||
74 | } |
||
75 | $dateTimeObj = \DateTime::createFromFormat(_SHORTDATESTRING, Request::getString('date_created', '', 'POST')); |
||
76 | $audioObject->setVar('date_created', $dateTimeObj->getTimestamp()); |
||
77 | $dateTimeObj = \DateTime::createFromFormat(_SHORTDATESTRING, Request::getString('date_updated', '', 'POST')); |
||
78 | $audioObject->setVar('date_updated', $dateTimeObj->getTimestamp()); |
||
79 | //insert object |
||
80 | if ($audioHandler->insert($audioObject)) { |
||
81 | redirect_header('audios.php?op=list', 2, AM_SUICO_FORMOK); |
||
82 | } |
||
83 | echo $audioObject->getHtmlErrors(); |
||
84 | $form = $audioObject->getForm(); |
||
85 | $form->display(); |
||
86 | break; |
||
87 | case 'edit': |
||
88 | $adminObject->addItemButton(AM_SUICO_ADD_AUDIO, 'audios.php?op=new', 'add'); |
||
89 | $adminObject->addItemButton(AM_SUICO_AUDIO_LIST, 'audios.php', 'list'); |
||
90 | $adminObject->displayButton('left'); |
||
91 | $audioObject = $audioHandler->get(Request::getString('audio_id', '')); |
||
92 | $form = $audioObject->getForm(); |
||
93 | $form->display(); |
||
94 | break; |
||
95 | case 'delete': |
||
96 | $audioObject = $audioHandler->get(Request::getString('audio_id', '')); |
||
97 | if (1 === Request::getInt('ok', 0)) { |
||
98 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||
99 | redirect_header('audios.php', 3, implode(', ', $GLOBALS['xoopsSecurity']->getErrors())); |
||
100 | } |
||
101 | if ($audioHandler->delete($audioObject)) { |
||
102 | redirect_header('audios.php', 3, AM_SUICO_FORMDELOK); |
||
103 | } else { |
||
104 | echo $audioObject->getHtmlErrors(); |
||
105 | } |
||
106 | } else { |
||
107 | xoops_confirm( |
||
108 | [ |
||
109 | 'ok' => 1, |
||
110 | 'audio_id' => Request::getString('audio_id', ''), |
||
111 | 'op' => 'delete', |
||
112 | ], |
||
113 | Request::getUrl('REQUEST_URI', '', 'SERVER'), |
||
114 | sprintf( |
||
115 | AM_SUICO_FORMSUREDEL, |
||
116 | $audioObject->getVar('title') |
||
117 | ) |
||
118 | ); |
||
119 | } |
||
120 | break; |
||
121 | case 'clone': |
||
122 | $id_field = Request::getString('audio_id', ''); |
||
123 | if ($utility::cloneRecord('suico_audios', 'audio_id', $id_field)) { |
||
124 | redirect_header('audios.php', 3, AM_SUICO_CLONED_OK); |
||
125 | } else { |
||
126 | redirect_header('audios.php', 3, AM_SUICO_CLONED_FAILED); |
||
127 | } |
||
128 | break; |
||
129 | case 'list': |
||
130 | default: |
||
131 | $adminObject->addItemButton(AM_SUICO_ADD_AUDIO, 'audios.php?op=new', 'add'); |
||
132 | $adminObject->displayButton('left'); |
||
133 | $start = Request::getInt('start', 0); |
||
134 | $audioPaginationLimit = $helper->getConfig('userpager'); |
||
135 | $criteria = new CriteriaCompo(); |
||
136 | $criteria->setSort('audio_id ASC, title'); |
||
137 | $criteria->setOrder('ASC'); |
||
138 | $criteria->setLimit($audioPaginationLimit); |
||
139 | $criteria->setStart($start); |
||
140 | $audioTempRows = $audioHandler->getCount(); |
||
141 | $audioTempArray = $audioHandler->getAll($criteria); |
||
142 | /* |
||
143 | // |
||
144 | // |
||
145 | <th class='center width5'>".AM_SUICO_FORM_ACTION."</th> |
||
146 | // </tr>"; |
||
147 | // $class = "odd"; |
||
148 | */ |
||
149 | // Display Page Navigation |
||
150 | if ($audioTempRows > $audioPaginationLimit) { |
||
151 | xoops_load('XoopsPageNav'); |
||
152 | $pagenav = new \XoopsPageNav( |
||
153 | $audioTempRows, |
||
154 | $audioPaginationLimit, |
||
155 | $start, |
||
156 | 'start', |
||
157 | 'op=list' . '&sort=' . $sort . '&order=' . $order . '' |
||
158 | ); |
||
159 | $GLOBALS['xoopsTpl']->assign('pagenav', null === $pagenav ? $pagenav->renderNav() : ''); |
||
160 | } |
||
161 | $GLOBALS['xoopsTpl']->assign('audioRows', $audioTempRows); |
||
162 | $audioArray = []; |
||
163 | // $fields = explode('|', audio_id:int:11::NOT NULL::primary:audio_id|title:varchar:256::NOT NULL:::title|author:varchar:256::NOT NULL:::author|filename:varchar:256::NOT NULL:::filename|uid_owner:int:11::NOT NULL:::uid_owner|date_created:date:0::NOT NULL:::date_created|date_updated:timestamp:CURRENT_TIMESTAMP::NOT NULL:::date_updated); |
||
164 | // $fieldsCount = count($fields); |
||
165 | $criteria = new CriteriaCompo(); |
||
166 | //$criteria->setOrder('DESC'); |
||
167 | $criteria->setSort($sort); |
||
168 | $criteria->setOrder($order); |
||
169 | $criteria->setLimit($audioPaginationLimit); |
||
170 | $criteria->setStart($start); |
||
171 | $audioCount = $audioHandler->getCount($criteria); |
||
172 | $audioTempArray = $audioHandler->getAll($criteria); |
||
173 | // for ($i = 0; $i < $fieldsCount; ++$i) { |
||
174 | if ($audioCount > 0) { |
||
175 | foreach (array_keys($audioTempArray) as $i) { |
||
176 | // $field = explode(':', $fields[$i]); |
||
177 | $GLOBALS['xoopsTpl']->assign( |
||
178 | 'selectoraudio_id', |
||
179 | AM_SUICO_AUDIO_AUDIO_ID |
||
180 | ); |
||
181 | $audioArray['audio_id'] = $audioTempArray[$i]->getVar('audio_id'); |
||
182 | $GLOBALS['xoopsTpl']->assign('selectoruid_owner', AM_SUICO_AUDIO_UID_OWNER); |
||
183 | $audioArray['uid_owner'] = strip_tags( |
||
184 | XoopsUser::getUnameFromId($audioTempArray[$i]->getVar('uid_owner')) |
||
185 | ); |
||
186 | $GLOBALS['xoopsTpl']->assign('selectorauthor', AM_SUICO_AUDIO_AUTHOR); |
||
187 | $audioArray['author'] = $audioTempArray[$i]->getVar('author'); |
||
188 | $GLOBALS['xoopsTpl']->assign('selectortitle', AM_SUICO_AUDIO_TITLE); |
||
189 | $audioArray['title'] = $audioTempArray[$i]->getVar('title'); |
||
190 | $GLOBALS['xoopsTpl']->assign('selectordescription', AM_SUICO_AUDIO_DESCRIPTION); |
||
191 | $audioArray['description'] = $audioTempArray[$i]->getVar('description'); |
||
192 | $GLOBALS['xoopsTpl']->assign('selectorfilename', AM_SUICO_AUDIO_URL); |
||
193 | $audioArray['filename'] = $audioTempArray[$i]->getVar('filename'); |
||
194 | $GLOBALS['xoopsTpl']->assign('selectordate_created', AM_SUICO_AUDIO_DATE_CREATED); |
||
195 | $audioArray['date_created'] = formatTimestamp($audioTempArray[$i]->getVar('date_created'), 's'); |
||
196 | $GLOBALS['xoopsTpl']->assign('selectordate_updated', AM_SUICO_AUDIO_DATE_UPDATED); |
||
197 | $audioArray['date_updated'] = formatTimestamp($audioTempArray[$i]->getVar('date_updated'), 's'); |
||
198 | $audioArray['edit_delete'] = "<a href='audios.php?op=edit&audio_id=" . $i . "'><img src=" . $pathIcon16 . "/edit.png alt='" . _EDIT . "' title='" . _EDIT . "'></a> |
||
199 | <a href='audios.php?op=delete&audio_id=" . $i . "'><img src=" . $pathIcon16 . "/delete.png alt='" . _DELETE . "' title='" . _DELETE . "'></a> |
||
200 | <a href='audios.php?op=clone&audio_id=" . $i . "'><img src=" . $pathIcon16 . "/editcopy.png alt='" . _CLONE . "' title='" . _CLONE . "'></a>"; |
||
201 | $GLOBALS['xoopsTpl']->append_by_ref('audiosArrays', $audioArray); |
||
202 | unset($audioArray); |
||
203 | } |
||
204 | unset($audioTempArray); |
||
205 | // Display Navigation |
||
206 | if ($audioCount > $audioPaginationLimit) { |
||
207 | xoops_load('XoopsPageNav'); |
||
208 | $pagenav = new \XoopsPageNav( |
||
209 | $audioCount, |
||
210 | $audioPaginationLimit, |
||
211 | $start, |
||
212 | 'start', |
||
213 | 'op=list' . '&sort=' . $sort . '&order=' . $order . '' |
||
214 | ); |
||
215 | $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav(4)); |
||
216 | } |
||
217 | echo $GLOBALS['xoopsTpl']->fetch( |
||
218 | XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['xoopsModule']->getVar( |
||
219 | 'dirname' |
||
220 | ) . '/templates/admin/suico_admin_audios.tpl' |
||
221 | ); |
||
222 | } |
||
223 | break; |
||
224 | } |
||
225 | require_once __DIR__ . '/admin_footer.php'; |
||
226 |
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: