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 | use Xmf\Module\Admin; |
||||
4 | use Xmf\Request; |
||||
5 | use XoopsModules\Songlist\Helper; |
||||
6 | use XoopsModules\Songlist\Uploader; |
||||
7 | use XoopsModules\Songlist\AlbumsHandler; |
||||
8 | use XoopsModules\Songlist\Form\FormController; |
||||
9 | |||||
10 | require __DIR__ . '/header.php'; |
||||
11 | |||||
12 | xoops_loadLanguage('admin', 'songlist'); |
||||
13 | |||||
14 | xoops_cp_header(); |
||||
15 | |||||
16 | $op = $_REQUEST['op'] ?? 'albums'; |
||||
17 | $fct = $_REQUEST['fct'] ?? 'list'; |
||||
18 | $limit = Request::getInt('limit', 30, 'REQUEST'); |
||||
19 | $start = Request::getInt('start', 0, 'REQUEST'); |
||||
20 | $order = !empty($_REQUEST['order']) ? $_REQUEST['order'] : 'DESC'; |
||||
21 | $sort = !empty($_REQUEST['sort']) ? '' . $_REQUEST['sort'] . '' : 'created'; |
||||
22 | $filter = !empty($_REQUEST['filter']) ? '' . $_REQUEST['filter'] . '' : '1,1'; |
||||
23 | |||||
24 | switch ($op) { |
||||
25 | default: |
||||
26 | case 'albums': |
||||
27 | switch ($fct) { |
||||
28 | default: |
||||
29 | case 'list': |
||||
30 | $adminObject = Admin::getInstance(); |
||||
31 | $adminObject->displayNavigation(basename(__FILE__)); |
||||
32 | |||||
33 | /** @var AlbumsHandler $albumsHandler */ |
||||
34 | $albumsHandler = Helper::getInstance()->getHandler('Albums'); |
||||
35 | |||||
36 | $criteria = $albumsHandler->getFilterCriteria($GLOBALS['filter']); |
||||
37 | $ttl = $albumsHandler->getCount($criteria); |
||||
38 | $GLOBALS['sort'] = !empty($_REQUEST['sort']) ? '' . $_REQUEST['sort'] . '' : 'created'; |
||||
39 | |||||
40 | $pagenav = new \XoopsPageNav($ttl, $GLOBALS['limit'], $GLOBALS['start'], 'start', 'limit=' . $GLOBALS['limit'] . '&sort=' . $GLOBALS['sort'] . '&order=' . $GLOBALS['order'] . '&op=' . $GLOBALS['op'] . '&fct=' . $GLOBALS['fct'] . '&filter=' . $GLOBALS['filter']); |
||||
41 | $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
||||
42 | |||||
43 | foreach ($albumsHandler->filterFields() as $id => $key) { |
||||
44 | $GLOBALS['xoopsTpl']->assign( |
||||
45 | \mb_strtolower(str_replace('-', '_', $key) . '_th'), |
||||
46 | '<a href="' |
||||
47 | . $_SERVER['SCRIPT_NAME'] |
||||
48 | . '?start=' |
||||
49 | . $GLOBALS['start'] |
||||
50 | . '&limit=' |
||||
51 | . $GLOBALS['limit'] |
||||
52 | . '&sort=' |
||||
53 | . $key |
||||
54 | . '&order=' |
||||
55 | . (($key == $GLOBALS['sort']) ? ('DESC' == $GLOBALS['order'] ? 'ASC' : 'DESC') : $GLOBALS['order']) |
||||
56 | . '&op=' |
||||
57 | . $GLOBALS['op'] |
||||
58 | . '&filter=' |
||||
59 | . $GLOBALS['filter'] |
||||
60 | . '">' |
||||
61 | . (defined('_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) ? constant('_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) : '_AM_SONGLIST_TH_' . \mb_strtoupper(str_replace('-', '_', $key))) |
||||
62 | . '</a>' |
||||
63 | ); |
||||
64 | $GLOBALS['xoopsTpl']->assign('filter_' . \mb_strtolower(str_replace('-', '_', $key)) . '_th', $albumsHandler->getFilterForm($GLOBALS['filter'], $key, $GLOBALS['sort'], $GLOBALS['op'], $GLOBALS['fct'])); |
||||
65 | } |
||||
66 | |||||
67 | $GLOBALS['xoopsTpl']->assign('limit', $GLOBALS['limit']); |
||||
68 | $GLOBALS['xoopsTpl']->assign('start', $GLOBALS['start']); |
||||
69 | $GLOBALS['xoopsTpl']->assign('order', $GLOBALS['order']); |
||||
70 | $GLOBALS['xoopsTpl']->assign('sort', $GLOBALS['sort']); |
||||
71 | $GLOBALS['xoopsTpl']->assign('filter', $GLOBALS['filter']); |
||||
72 | $GLOBALS['xoopsTpl']->assign('xoConfig', $GLOBALS['songlistModuleConfig']); |
||||
73 | |||||
74 | $criteria->setStart($GLOBALS['start']); |
||||
75 | $criteria->setLimit($GLOBALS['limit']); |
||||
76 | $criteria->setSort('`' . $GLOBALS['sort'] . '`'); |
||||
77 | $criteria->setOrder($GLOBALS['order']); |
||||
78 | |||||
79 | $albumsArray = $albumsHandler->getObjects($criteria, true); |
||||
80 | foreach ($albumsArray as $cid => $album) { |
||||
81 | if (is_object($album)) { |
||||
82 | $GLOBALS['xoopsTpl']->append('albums', $album->toArray()); |
||||
83 | } |
||||
84 | } |
||||
85 | $GLOBALS['xoopsTpl']->assign('form', FormController::getFormAlbums(false)); |
||||
86 | $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
||||
87 | $GLOBALS['xoopsTpl']->display('db:songlist_cpanel_albums_list.tpl'); |
||||
88 | break; |
||||
89 | case 'new': |
||||
90 | case 'edit': |
||||
91 | $adminObject = Admin::getInstance(); |
||||
92 | $adminObject->displayNavigation(basename(__FILE__)); |
||||
93 | |||||
94 | $albumsHandler = Helper::getInstance()->getHandler('Albums'); |
||||
95 | if (Request::hasVar('id', 'REQUEST')) { |
||||
96 | $album = $albumsHandler->get(Request::getInt('id', 0, 'REQUEST')); |
||||
97 | } else { |
||||
98 | $album = $albumsHandler->create(); |
||||
99 | } |
||||
100 | |||||
101 | $GLOBALS['xoopsTpl']->assign('form', $album->getForm()); |
||||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
102 | $GLOBALS['xoopsTpl']->assign('php_self', $_SERVER['SCRIPT_NAME']); |
||||
103 | $GLOBALS['xoopsTpl']->display('db:songlist_cpanel_albums_edit.tpl'); |
||||
104 | break; |
||||
105 | case 'save': |
||||
106 | $albumsHandler = Helper::getInstance()->getHandler('Albums'); |
||||
107 | $id = 0; |
||||
108 | $id = Request::getInt('id', 0, 'REQUEST'); |
||||
109 | if ($id) { |
||||
110 | $album = $albumsHandler->get($id); |
||||
111 | } else { |
||||
112 | $album = $albumsHandler->create(); |
||||
113 | } |
||||
114 | $album->setVars($_POST[$id]); |
||||
115 | |||||
116 | if (!$id = $albumsHandler->insert($album)) { |
||||
117 | redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_ALBUMS_FAILEDTOSAVE); |
||||
118 | exit(0); |
||||
119 | } |
||||
120 | if (Request::hasVar('image', 'FILES') && !empty($_FILES['image']['name'])) { |
||||
121 | // if (!is_dir($GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas']))) { |
||||
122 | // foreach (explode('\\', $GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas'])) as $folders) { |
||||
123 | // foreach (explode('/', $folders) as $folder) { |
||||
124 | // $path .= DS . $folder; |
||||
125 | // if (!mkdir($path, 0777) && !is_dir($path)) { |
||||
126 | // throw new \RuntimeException(sprintf('Directory "%s" was not created', $path)); |
||||
127 | // } |
||||
128 | // } |
||||
129 | // } |
||||
130 | // } |
||||
131 | |||||
132 | // require_once $GLOBALS['xoops']->path('modules/songlist/include/uploader.php'); |
||||
133 | $album = $albumsHandler->get($id); |
||||
0 ignored issues
–
show
It seems like
$id can also be of type true ; however, parameter $id of XoopsModules\Songlist\AlbumsHandler::get() does only seem to accept null , 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
Loading history...
|
|||||
134 | $uploader = new Uploader( |
||||
135 | $GLOBALS['xoops']->path($GLOBALS['songlistModuleConfig']['upload_areas']. 'albums'), |
||||
136 | explode('|', $GLOBALS['songlistModuleConfig']['allowed_mimetype']), |
||||
137 | $GLOBALS['songlistModuleConfig']['filesize_upload'], |
||||
138 | 0, |
||||
139 | 0, |
||||
140 | explode('|', $GLOBALS['songlistModuleConfig']['allowed_extensions']) |
||||
141 | ); |
||||
142 | try { |
||||
143 | $uploader->setPrefix(mb_substr(md5((string)microtime(true)), random_int(0, 20), 13)); |
||||
144 | } catch (Exception $e) { |
||||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
|
|||||
145 | } |
||||
146 | |||||
147 | if ($uploader->fetchMedia('image')) { |
||||
148 | if (!$uploader->upload()) { |
||||
149 | $adminObject = Admin::getInstance(); |
||||
150 | $adminObject->displayNavigation(basename(__FILE__)); |
||||
151 | echo $uploader->getErrors(); |
||||
152 | require __DIR__ . '/admin_footer.php'; |
||||
153 | exit(0); |
||||
154 | } |
||||
155 | if (mb_strlen($album->getVar('image'))) { |
||||
156 | unlink($GLOBALS['xoops']->path($album->getVar('path')) . $album->getVar('image')); |
||||
157 | } |
||||
158 | |||||
159 | $album->setVar('path', $GLOBALS['songlistModuleConfig']['upload_areas']. 'albums/') ; |
||||
160 | $album->setVar('image', $uploader->getSavedFileName()); |
||||
161 | @$albumsHandler->insert($album); |
||||
0 ignored issues
–
show
It seems like you do not handle an error condition for
insert() . This can introduce security issues, and is generally not recommended.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
If you suppress an error, we recommend checking for the error condition explicitly: // For example instead of
@mkdir($dir);
// Better use
if (@mkdir($dir) === false) {
throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
|
|||||
162 | } else { |
||||
163 | $adminObject = Admin::getInstance(); |
||||
164 | $adminObject->displayNavigation(basename(__FILE__)); |
||||
165 | echo $uploader->getErrors(); |
||||
166 | require __DIR__ . '/admin_footer.php'; |
||||
167 | exit(0); |
||||
168 | } |
||||
169 | } |
||||
170 | |||||
171 | if ('new' == $_REQUEST['state'][$_REQUEST['id']]) { |
||||
172 | redirect_header( |
||||
173 | $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=edit&id=' . $_REQUEST['id'] . '&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
||||
174 | 10, |
||||
175 | _AM_SONGLIST_MSG_ALBUMS_SAVEDOKEY |
||||
176 | ); |
||||
177 | } else { |
||||
178 | redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_ALBUMS_SAVEDOKEY); |
||||
179 | } |
||||
180 | exit(0); |
||||
181 | |||||
182 | break; |
||||
183 | case 'savelist': |
||||
184 | $albumsHandler = Helper::getInstance()->getHandler('Albums'); |
||||
185 | foreach ($_REQUEST['id'] as $id) { |
||||
186 | $album = $albumsHandler->get($id); |
||||
187 | $album->setVars($_POST[$id]); |
||||
188 | if (!$albumsHandler->insert($album)) { |
||||
189 | redirect_header( |
||||
190 | $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
||||
191 | 10, |
||||
192 | _AM_SONGLIST_MSG_ALBUMS_FAILEDTOSAVE |
||||
193 | ); |
||||
194 | exit(0); |
||||
195 | } |
||||
196 | } |
||||
197 | redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_ALBUMS_SAVEDOKEY); |
||||
198 | exit(0); |
||||
199 | break; |
||||
200 | case 'delete': |
||||
201 | $albumsHandler = Helper::getInstance()->getHandler('Albums'); |
||||
202 | $id = 0; |
||||
203 | if (Request::hasVar('id', 'POST') && $id = Request::getInt('id', 0, 'POST')) { |
||||
204 | $album = $albumsHandler->get($id); |
||||
205 | if (!$albumsHandler->delete($album)) { |
||||
206 | redirect_header( |
||||
207 | $_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], |
||||
208 | 10, |
||||
209 | _AM_SONGLIST_MSG_ALBUMS_FAILEDTODELETE |
||||
210 | ); |
||||
211 | exit(0); |
||||
212 | } |
||||
213 | redirect_header($_SERVER['SCRIPT_NAME'] . '?op=' . $GLOBALS['op'] . '&fct=list&limit=' . $GLOBALS['limit'] . '&start=' . $GLOBALS['start'] . '&order=' . $GLOBALS['order'] . '&sort=' . $GLOBALS['sort'] . '&filter=' . $GLOBALS['filter'], 10, _AM_SONGLIST_MSG_ALBUMS_DELETED); |
||||
214 | exit(0); |
||||
215 | } |
||||
216 | $album = $albumsHandler->get(Request::getInt('id', 0, 'REQUEST')); |
||||
217 | xoops_confirm( |
||||
218 | ['id' => $_REQUEST['id'], 'op' => $_REQUEST['op'], 'fct' => $_REQUEST['fct'], 'limit' => $_REQUEST['limit'], 'start' => $_REQUEST['start'], 'order' => $_REQUEST['order'], 'sort' => $_REQUEST['sort'], 'filter' => $_REQUEST['filter']], |
||||
219 | $_SERVER['SCRIPT_NAME'], |
||||
220 | sprintf(_AM_SONGLIST_MSG_ALBUMS_DELETE, $album->getVar('title')) |
||||
0 ignored issues
–
show
It seems like
$album->getVar('title') can also be of type array and array ; however, parameter $values of sprintf() does only seem to accept double|integer|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
Loading history...
|
|||||
221 | ); |
||||
222 | |||||
223 | break; |
||||
224 | } |
||||
225 | break; |
||||
226 | } |
||||
227 | |||||
228 | xoops_cp_footer(); |
||||
229 |