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/videos/'; |
||||
31 | $uploadUrl = XOOPS_UPLOAD_URL . '/suico/videos/'; |
||||
32 | switch ($op) { |
||||
33 | case 'new': |
||||
34 | $adminObject->addItemButton(AM_SUICO_VIDEO_LIST, 'videos.php', 'list'); |
||||
35 | $adminObject->displayButton('left'); |
||||
36 | $videoObject = $videoHandler->create(); |
||||
37 | $form = $videoObject->getForm(); |
||||
38 | $form->display(); |
||||
39 | break; |
||||
40 | case 'save': |
||||
41 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||||
42 | redirect_header('videos.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
||||
43 | } |
||||
44 | if (0 !== Request::getInt('video_id', 0)) { |
||||
45 | $videoObject = $videoHandler->get(Request::getInt('video_id', 0)); |
||||
46 | } else { |
||||
47 | $videoObject = $videoHandler->create(); |
||||
48 | } |
||||
49 | // Form save fields |
||||
50 | $videoObject->setVar('uid_owner', Request::getVar('uid_owner', '')); |
||||
51 | $videoObject->setVar('video_title', Request::getVar('video_title', '')); |
||||
52 | $videoObject->setVar('video_desc', Request::getVar('video_desc', '')); |
||||
53 | |||||
54 | $videourl = Request::getVar('youtube_code', ''); |
||||
55 | //Get youtube video id |
||||
56 | if (11 === mb_strlen($videourl)) { |
||||
0 ignored issues
–
show
It seems like
$videourl can also be of type array ; however, parameter $string of mb_strlen() does only seem to accept string , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
57 | $videocode = $videourl; |
||||
58 | } else { |
||||
59 | //Get youtube video id |
||||
60 | preg_match('%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})%i', $videourl, $match); |
||||
0 ignored issues
–
show
It seems like
$videourl can also be of type array ; however, parameter $subject of preg_match() does only seem to accept string , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
61 | $videocode = $match[1]; |
||||
62 | } |
||||
63 | $videoObject->setVar('youtube_code', $videocode); |
||||
64 | $videoObject->setVar('featured_video', Request::getVar('featured_video', '')); |
||||
65 | $dateTimeObj = \DateTime::createFromFormat(_SHORTDATESTRING, Request::getString('date_created', '', 'POST')); |
||||
66 | $videoObject->setVar('date_created', $dateTimeObj->getTimestamp()); |
||||
67 | $dateTimeObj = \DateTime::createFromFormat(_SHORTDATESTRING, Request::getString('date_updated', '', 'POST')); |
||||
68 | $videoObject->setVar('date_updated', $dateTimeObj->getTimestamp()); |
||||
69 | if ($videoHandler->insert($videoObject)) { |
||||
70 | redirect_header('videos.php?op=list', 2, AM_SUICO_FORMOK); |
||||
71 | } |
||||
72 | echo $videoObject->getHtmlErrors(); |
||||
73 | $form = $videoObject->getForm(); |
||||
74 | $form->display(); |
||||
75 | break; |
||||
76 | case 'edit': |
||||
77 | $adminObject->addItemButton(AM_SUICO_ADD_VIDEO, 'videos.php?op=new', 'add'); |
||||
78 | $adminObject->addItemButton(AM_SUICO_VIDEO_LIST, 'videos.php', 'list'); |
||||
79 | $adminObject->displayButton('left'); |
||||
80 | $videoObject = $videoHandler->get(Request::getString('video_id', '')); |
||||
81 | $form = $videoObject->getForm(); |
||||
82 | $form->display(); |
||||
83 | break; |
||||
84 | case 'delete': |
||||
85 | $videoObject = $videoHandler->get(Request::getString('video_id', '')); |
||||
86 | if (1 === Request::getInt('ok', 0)) { |
||||
87 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||||
88 | redirect_header('videos.php', 3, implode(', ', $GLOBALS['xoopsSecurity']->getErrors())); |
||||
89 | } |
||||
90 | if ($videoHandler->delete($videoObject)) { |
||||
91 | redirect_header('videos.php', 3, AM_SUICO_FORMDELOK); |
||||
92 | } else { |
||||
93 | echo $videoObject->getHtmlErrors(); |
||||
94 | } |
||||
95 | } else { |
||||
96 | xoops_confirm( |
||||
97 | [ |
||||
98 | 'ok' => 1, |
||||
99 | 'video_id' => Request::getString('video_id', ''), |
||||
100 | 'op' => 'delete', |
||||
101 | ], |
||||
102 | Request::getUrl('REQUEST_URI', '', 'SERVER'), |
||||
103 | sprintf( |
||||
104 | AM_SUICO_FORMSUREDEL, |
||||
105 | $videoObject->getVar('video_desc') |
||||
106 | ) |
||||
107 | ); |
||||
108 | } |
||||
109 | break; |
||||
110 | case 'clone': |
||||
111 | $id_field = Request::getString('video_id', ''); |
||||
112 | if ($utility::cloneRecord('suico_videos', 'video_id', $id_field)) { |
||||
113 | redirect_header('videos.php', 3, AM_SUICO_CLONED_OK); |
||||
114 | } else { |
||||
115 | redirect_header('videos.php', 3, AM_SUICO_CLONED_FAILED); |
||||
116 | } |
||||
117 | break; |
||||
118 | case 'list': |
||||
119 | default: |
||||
120 | $adminObject->addItemButton(AM_SUICO_ADD_VIDEO, 'videos.php?op=new', 'add'); |
||||
121 | $adminObject->displayButton('left'); |
||||
122 | $start = Request::getInt('start', 0); |
||||
123 | $videoPaginationLimit = $helper->getConfig('userpager'); |
||||
124 | $criteria = new CriteriaCompo(); |
||||
125 | $criteria->setSort('video_id ASC, video_desc'); |
||||
126 | $criteria->setOrder('ASC'); |
||||
127 | $criteria->setLimit($videoPaginationLimit); |
||||
128 | $criteria->setStart($start); |
||||
129 | $videoTempRows = $videoHandler->getCount(); |
||||
130 | $videoTempArray = $videoHandler->getAll($criteria); |
||||
131 | /* |
||||
132 | // |
||||
133 | // |
||||
134 | <th class='center width5'>".AM_SUICO_FORM_ACTION."</th> |
||||
135 | // </tr>"; |
||||
136 | // $class = "odd"; |
||||
137 | */ |
||||
138 | // Display Page Navigation |
||||
139 | if ($videoTempRows > $videoPaginationLimit) { |
||||
140 | xoops_load('XoopsPageNav'); |
||||
141 | $pagenav = new \XoopsPageNav( |
||||
142 | $videoTempRows, |
||||
143 | $videoPaginationLimit, |
||||
144 | $start, |
||||
145 | 'start', |
||||
146 | 'op=list' . '&sort=' . $sort . '&order=' . $order . '' |
||||
147 | ); |
||||
148 | $GLOBALS['xoopsTpl']->assign('pagenav', null === $pagenav ? $pagenav->renderNav() : ''); |
||||
149 | } |
||||
150 | $GLOBALS['xoopsTpl']->assign('videoRows', $videoTempRows); |
||||
151 | $videoArray = []; |
||||
152 | // $fields = explode('|', video_id:int:11::NOT NULL::primary:video_id|uid_owner:int:11::NOT NULL:::uid_owner|video_desc:text:0::NOT NULL:::video_desc|youtube_code:varchar:11::NOT NULL:::youtube_code|featured_video:varchar:1::NOT NULL:::featured_video); |
||||
153 | // $fieldsCount = count($fields); |
||||
154 | $criteria = new CriteriaCompo(); |
||||
155 | //$criteria->setOrder('DESC'); |
||||
156 | $criteria->setSort($sort); |
||||
157 | $criteria->setOrder($order); |
||||
158 | $criteria->setLimit($videoPaginationLimit); |
||||
159 | $criteria->setStart($start); |
||||
160 | $videoCount = $videoHandler->getCount($criteria); |
||||
161 | $videoTempArray = $videoHandler->getAll($criteria); |
||||
162 | // for ($i = 0; $i < $fieldsCount; ++$i) { |
||||
163 | if ($videoCount > 0) { |
||||
164 | foreach (array_keys($videoTempArray) as $i) { |
||||
165 | // $field = explode(':', $fields[$i]); |
||||
166 | $GLOBALS['xoopsTpl']->assign('selectorvideo_id', AM_SUICO_VIDEO_VIDEO_ID); |
||||
167 | $videoArray['video_id'] = $videoTempArray[$i]->getVar('video_id'); |
||||
168 | $GLOBALS['xoopsTpl']->assign('selectoruid_owner', AM_SUICO_VIDEO_UID_OWNER); |
||||
169 | $videoArray['uid_owner'] = strip_tags( |
||||
170 | XoopsUser::getUnameFromId($videoTempArray[$i]->getVar('uid_owner')) |
||||
171 | ); |
||||
172 | $GLOBALS['xoopsTpl']->assign('selectorvideo_title', AM_SUICO_VIDEO_TITLE); |
||||
173 | $videoArray['video_title'] = strip_tags($videoTempArray[$i]->getVar('video_title')); |
||||
174 | $GLOBALS['xoopsTpl']->assign('selectorvideo_desc', AM_SUICO_VIDEO_VIDEO_DESC); |
||||
175 | $videoArray['video_desc'] = strip_tags($videoTempArray[$i]->getVar('video_desc')); |
||||
176 | $GLOBALS['xoopsTpl']->assign('selectoryoutube_code', AM_SUICO_VIDEO_YOUTUBE_CODE); |
||||
177 | $videoArray['youtube_code'] = $videoTempArray[$i]->getVar('youtube_code'); |
||||
178 | $GLOBALS['xoopsTpl']->assign('selectorfeatured_video', AM_SUICO_VIDEO_MAIN_VIDEO); |
||||
179 | $videoArray['featured_video'] = $videoTempArray[$i]->getVar('featured_video'); |
||||
180 | $GLOBALS['xoopsTpl']->assign('selectordate_created', AM_SUICO_VIDEO_DATE_CREATED); |
||||
181 | $videoArray['date_created'] = formatTimestamp($videoTempArray[$i]->getVar('date_created'), 's'); |
||||
182 | $GLOBALS['xoopsTpl']->assign('selectordate_updated', AM_SUICO_VIDEO_DATE_UPDATED); |
||||
183 | $videoArray['date_updated'] = formatTimestamp($videoTempArray[$i]->getVar('date_updated'), 's'); |
||||
184 | $videoArray['edit_delete'] = "<a href='videos.php?op=edit&video_id=" . $i . "'><img src=" . $pathIcon16 . "/edit.png alt='" . _EDIT . "' title='" . _EDIT . "'></a> |
||||
185 | <a href='videos.php?op=delete&video_id=" . $i . "'><img src=" . $pathIcon16 . "/delete.png alt='" . _DELETE . "' title='" . _DELETE . "'></a> |
||||
186 | <a href='videos.php?op=clone&video_id=" . $i . "'><img src=" . $pathIcon16 . "/editcopy.png alt='" . _CLONE . "' title='" . _CLONE . "'></a>"; |
||||
187 | $GLOBALS['xoopsTpl']->append_by_ref('videosArray', $videoArray); |
||||
188 | unset($videoArray); |
||||
189 | } |
||||
190 | unset($videoTempArray); |
||||
191 | // Display Navigation |
||||
192 | if ($videoCount > $videoPaginationLimit) { |
||||
193 | xoops_load('XoopsPageNav'); |
||||
194 | $pagenav = new \XoopsPageNav( |
||||
195 | $videoCount, |
||||
196 | $videoPaginationLimit, |
||||
197 | $start, |
||||
198 | 'start', |
||||
199 | 'op=list' . '&sort=' . $sort . '&order=' . $order . '' |
||||
200 | ); |
||||
201 | $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav(4)); |
||||
202 | } |
||||
203 | echo $GLOBALS['xoopsTpl']->fetch( |
||||
204 | XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['xoopsModule']->getVar('dirname') . '/templates/admin/suico_admin_videos.tpl' |
||||
205 | ); |
||||
206 | } |
||||
207 | break; |
||||
208 | } |
||||
209 | require_once __DIR__ . '/admin_footer.php'; |
||||
210 |
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: