XoopsModules25x /
wfdownloads
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 |
||||
| 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 | * Wfdownloads module |
||||
| 14 | * |
||||
| 15 | * @copyright XOOPS Project (https://xoops.org) |
||||
| 16 | * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
||||
| 17 | * @package wfdownload |
||||
| 18 | * @since 3.23 |
||||
| 19 | * @author Xoops Development Team |
||||
| 20 | */ |
||||
| 21 | |||||
| 22 | use Xmf\Module\Admin; |
||||
| 23 | use Xmf\Request; |
||||
| 24 | use XoopsModules\Wfdownloads\{ |
||||
| 25 | Helper, |
||||
| 26 | Mimetype, |
||||
| 27 | Utility |
||||
| 28 | }; |
||||
| 29 | /** @var Helper $helper */ |
||||
| 30 | /** @var Utility $utility */ |
||||
| 31 | /** @var Mimetype $mimetypeObj */ |
||||
| 32 | |||||
| 33 | $currentFile = basename(__FILE__); |
||||
| 34 | require_once __DIR__ . '/admin_header.php'; |
||||
| 35 | |||||
| 36 | $helper = Helper::getInstance(); |
||||
| 37 | |||||
| 38 | $op = Request::getString('op', 'mimetypes.list'); |
||||
| 39 | switch ($op) { |
||||
| 40 | /* |
||||
| 41 | case 'openurl': |
||||
| 42 | $fileext = trim($_POST['fileext']); |
||||
| 43 | $url = "http://filext.com/detaillist.php?extdetail={$fileext}"; |
||||
| 44 | if (!headers_sent()) { |
||||
| 45 | header("Location: $url"); |
||||
| 46 | } else { |
||||
| 47 | echo "<meta http-equiv='refresh' content='0;url={$url} target='_blank''>\r\n"; |
||||
| 48 | } |
||||
| 49 | break; |
||||
| 50 | */ |
||||
| 51 | case 'mimetype.edit': |
||||
| 52 | case 'mimetype.add': |
||||
| 53 | Utility::getCpHeader(); |
||||
| 54 | $adminObject = Admin::getInstance(); |
||||
| 55 | $adminObject->displayNavigation($currentFile); |
||||
| 56 | |||||
| 57 | //$adminObject = \Xmf\Module\Admin::getInstance(); |
||||
| 58 | $adminObject->addItemButton(_MI_WFDOWNLOADS_MENU_MIMETYPES, "{$currentFile}?op=mimetypes.list", 'list'); |
||||
| 59 | $adminObject->addItemButton(_AM_WFDOWNLOADS_MIME_CREATEF, "{$currentFile}?op=mimetype.add", 'add'); |
||||
| 60 | $adminObject->displayButton('left'); |
||||
| 61 | |||||
| 62 | echo "<fieldset>\n"; |
||||
| 63 | echo "<legend style='font-weight: bold; color: #900;'>" . _AM_WFDOWNLOADS_MIME_CREATEF . '/' . _AM_WFDOWNLOADS_MIME_MODIFYF . "</legend>\n"; |
||||
| 64 | echo '<div>' . _AM_WFDOWNLOADS_MIME_INFOTEXT . "</div>\n"; |
||||
| 65 | echo "</fieldset>\n"; |
||||
| 66 | |||||
| 67 | if (Request::hasVar('mime_id', 'REQUEST')) { |
||||
| 68 | $mimetypeObj = $helper->getHandler('Mimetype')->get($_REQUEST['mime_id']); |
||||
| 69 | } else { |
||||
| 70 | $mimetypeObj = $helper->getHandler('Mimetype')->create(); |
||||
| 71 | } |
||||
| 72 | /** @var XoopsThemeForm $form */ |
||||
| 73 | $form = $mimetypeObj->getForm(); |
||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 74 | $form->display(); |
||||
| 75 | |||||
| 76 | $extform = new XoopsThemeForm(_AM_WFDOWNLOADS_MIME_FINDMIMETYPE, 'op', $_SERVER['REQUEST_URI']); |
||||
| 77 | $buttonTray = new \XoopsFormElementTray('', ''); |
||||
| 78 | |||||
| 79 | $fileext_text = new XoopsFormText(_AM_WFDOWNLOADS_MIME_EXTFIND, 'fileext', 5, 60, $mimetypeObj->getVar('mime_ext')); |
||||
|
0 ignored issues
–
show
It seems like
$mimetypeObj->getVar('mime_ext') can also be of type array and array; however, parameter $value of XoopsFormText::__construct() 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
Loading history...
|
|||||
| 80 | $fileext_text->setDescription(_AM_WFDOWNLOADS_MIME_EXTFIND_DESC); |
||||
| 81 | $extform->addElement($fileext_text); |
||||
| 82 | $button_open = new XoopsFormButton('', '', _AM_WFDOWNLOADS_MIME_FINDIT, 'button'); |
||||
| 83 | $button_open->setExtra('onclick="document.getElementById(\'filext_iframe\').src = \'http://filext.com/detaillist.php?extdetail=\' + this.form.elements.fileext.value"'); |
||||
| 84 | $extform->addElement($button_open); |
||||
| 85 | $extform->addElement($buttonTray); |
||||
| 86 | $extform->display(); |
||||
| 87 | |||||
| 88 | echo "<iframe src='http://filext.com/detaillist.php?extdetail=" . $mimetypeObj->getVar('mime_ext') . "' id='filext_iframe' name='filext_iframe' class='outer' style='width:100%; height:400px;'></iframe>"; |
||||
| 89 | |||||
| 90 | xoops_cp_footer(); |
||||
| 91 | break; |
||||
| 92 | case 'mimetype.save': |
||||
| 93 | $mime_id = Request::getInt('mime_id', 0, 'POST'); |
||||
| 94 | if (!$mimetypeObj = $helper->getHandler('Mimetype')->get($mime_id)) { |
||||
| 95 | redirect_header($currentFile, 4, _AM_WFDOWNLOADS_ERROR_MIMETYPENOTFOUND); |
||||
| 96 | } |
||||
| 97 | |||||
| 98 | $mimetypeObj->setVar('mime_ext', $_POST['mime_ext']); |
||||
| 99 | $mimetypeObj->setVar('mime_name', $_POST['mime_name']); |
||||
| 100 | $mimetypeObj->setVar('mime_types', $_POST['mime_type']); |
||||
| 101 | $mimetypeObj->setVar('mime_admin', Request::getInt('mime_admin', 0, 'POST')); |
||||
| 102 | $mimetypeObj->setVar('mime_user', Request::getInt('mime_user', 0, 'POST')); |
||||
| 103 | if (!$helper->getHandler('Mimetype')->insert($mimetypeObj)) { |
||||
| 104 | $error = 'Could not update mimetype information'; |
||||
| 105 | trigger_error($error, E_USER_ERROR); |
||||
| 106 | } |
||||
| 107 | $dbupted = (0 == $mime_id) ? _AM_WFDOWNLOADS_MIME_CREATED : _AM_WFDOWNLOADS_MIME_MODIFIED; |
||||
| 108 | redirect_header($currentFile, 1, $dbupted); |
||||
| 109 | break; |
||||
| 110 | case 'mimetype.update': |
||||
| 111 | $mime_id = Request::getInt('mime_id', 0); |
||||
| 112 | if (!$mimetypeObj = $helper->getHandler('Mimetype')->get($mime_id)) { |
||||
| 113 | redirect_header($currentFile, 4, _AM_WFDOWNLOADS_ERROR_MIMETYPENOTFOUND); |
||||
| 114 | } |
||||
| 115 | |||||
| 116 | if (Request::hasVar('admin', 'REQUEST') && true === $_REQUEST['admin']) { |
||||
| 117 | if (true === $mimetypeObj->getVar('mime_admin')) { |
||||
| 118 | $mimetypeObj->setVar('mime_admin', false); |
||||
| 119 | } else { |
||||
| 120 | $mimetypeObj->setVar('mime_admin', true); |
||||
| 121 | } |
||||
| 122 | } |
||||
| 123 | if (Request::hasVar('user', 'REQUEST') && true === $_REQUEST['user']) { |
||||
| 124 | if (true === $mimetypeObj->getVar('mime_user')) { |
||||
| 125 | $mimetypeObj->setVar('mime_user', false); |
||||
| 126 | } else { |
||||
| 127 | $mimetypeObj->setVar('mime_user', true); |
||||
| 128 | } |
||||
| 129 | } |
||||
| 130 | if (!$helper->getHandler('Mimetype')->insert($mimetypeObj, true)) { |
||||
| 131 | trigger_error($error, E_USER_ERROR); |
||||
| 132 | } |
||||
| 133 | redirect_header("{$currentFile}?start=" . Request::getInt('start', 0, 'GET') . '', 0, _AM_WFDOWNLOADS_MIME_MODIFIED); |
||||
| 134 | break; |
||||
| 135 | case 'mimetypes.update': |
||||
| 136 | $mime_admin = Request::getBool('admin', false); |
||||
| 137 | $mime_user = Request::getBool('user', false); |
||||
| 138 | $type_all = Request::getInt('type_all', 0, 'GET'); |
||||
| 139 | |||||
| 140 | $field = 'mime_user'; |
||||
| 141 | if (true === $mime_admin) { |
||||
| 142 | $field = 'mime_admin'; |
||||
| 143 | } |
||||
| 144 | $criteria = new CriteriaCompo(); |
||||
| 145 | $criteria->setStart($start); |
||||
| 146 | $criteria->setLimit(20); |
||||
| 147 | if (!$helper->getHandler('Mimetype')->updateAll($field, $type_all, $criteria, true)) { |
||||
| 148 | $error = 'Could not update mimetype information'; |
||||
| 149 | trigger_error($error, E_USER_ERROR); |
||||
| 150 | } |
||||
| 151 | redirect_header("{$currentFile}?start=" . Request::getInt('start', 0, 'GET') . '', 1, _AM_WFDOWNLOADS_MIME_MODIFIED); |
||||
| 152 | break; |
||||
| 153 | case 'mimetype.delete': |
||||
| 154 | $mime_id = Request::getInt('mime_id', 0); |
||||
| 155 | $ok = Request::getBool('ok', false, 'POST'); |
||||
| 156 | if (!$mimetypeObj = $helper->getHandler('Mimetype')->get($mime_id)) { |
||||
| 157 | redirect_header($currentFile, 4, _AM_WFDOWNLOADS_ERROR_MIMETYPENOTFOUND); |
||||
| 158 | } |
||||
| 159 | if (true === $ok) { |
||||
| 160 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||||
| 161 | redirect_header($currentFile, 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
||||
| 162 | } |
||||
| 163 | if ($helper->getHandler('Mimetype')->delete($mimetypeObj)) { |
||||
| 164 | redirect_header($currentFile, 1, sprintf(_AM_WFDOWNLOADS_MIME_MIMEDELETED, $mimetypeObj->getVar('mime_name'))); |
||||
|
0 ignored issues
–
show
It seems like
$mimetypeObj->getVar('mime_name') can also be of type array and array; however, parameter $args of sprintf() 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
Loading history...
|
|||||
| 165 | } else { |
||||
| 166 | echo $mimetypeObj->getHtmlErrors(); |
||||
| 167 | exit(); |
||||
| 168 | } |
||||
| 169 | } else { |
||||
| 170 | Utility::getCpHeader(); |
||||
| 171 | xoops_confirm(['op' => 'mimetype.delete', 'mime_id' => $mime_id, 'ok' => true], $currentFile, _AM_WFDOWNLOADS_MIME_DELETETHIS . '<br><br>' . $mimetypeObj->getVar('mime_name'), _AM_WFDOWNLOADS_MIME_DELETE); |
||||
| 172 | xoops_cp_footer(); |
||||
| 173 | } |
||||
| 174 | break; |
||||
| 175 | case 'mimetypes.list': |
||||
| 176 | default: |
||||
| 177 | $start = Request::getInt('start', 0); |
||||
| 178 | |||||
| 179 | // Get mimetypes (20 per page) |
||||
| 180 | $criteria = new CriteriaCompo(); |
||||
| 181 | $criteria->setSort('mime_name'); |
||||
| 182 | $criteria->setStart($start); |
||||
| 183 | $criteria->setLimit(20); |
||||
| 184 | $mimetypeObjs = $helper->getHandler('Mimetype')->getObjects($criteria); |
||||
| 185 | $mimetypes_count = $helper->getHandler('Mimetype')->getCount(); |
||||
| 186 | |||||
| 187 | Utility::getCpHeader(); |
||||
| 188 | $adminObject = Admin::getInstance(); |
||||
| 189 | $adminObject->displayNavigation($currentFile); |
||||
| 190 | |||||
| 191 | //$adminObject = \Xmf\Module\Admin::getInstance(); |
||||
| 192 | $adminObject->addItemButton(_MI_WFDOWNLOADS_MENU_MIMETYPES, "{$currentFile}?op=mimetypes.list", 'list'); |
||||
| 193 | $adminObject->addItemButton(_AM_WFDOWNLOADS_MIME_CREATEF, "{$currentFile}?op=mimetype.add", 'add'); |
||||
| 194 | $adminObject->displayButton('left'); |
||||
| 195 | |||||
| 196 | $GLOBALS['xoopsTpl']->assign('mimetypes_count', $mimetypes_count); |
||||
| 197 | $GLOBALS['xoopsTpl']->assign('start', $start); |
||||
| 198 | |||||
| 199 | if ($mimetypes_count > 0) { |
||||
| 200 | $allowAdminMimetypes = []; |
||||
| 201 | $allowUserMimetypes = []; |
||||
| 202 | foreach ($mimetypeObjs as $mimetypeObj) { |
||||
| 203 | $mimetype_array = $mimetypeObj->toArray(); |
||||
| 204 | $GLOBALS['xoopsTpl']->append('mimetypes', $mimetype_array); |
||||
| 205 | } |
||||
| 206 | //Include page navigation |
||||
| 207 | require_once XOOPS_ROOT_PATH . '/class/pagenav.php'; |
||||
| 208 | $pagenav = new XoopsPageNav($mimetypes_count, 20, $start, 'start'); |
||||
| 209 | $GLOBALS['xoopsTpl']->assign('mimetypes_pagenav', $pagenav->renderNav()); |
||||
| 210 | } |
||||
| 211 | |||||
| 212 | // Get allowed mimetypes/estensione |
||||
| 213 | $allowAdminMimetypes = $helper->getHandler('Mimetype')->getList(new Criteria('mime_admin', 'true')); |
||||
| 214 | $allowUserMimetypes = $helper->getHandler('Mimetype')->getList(new Criteria('mime_user', 'true')); |
||||
| 215 | $GLOBALS['xoopsTpl']->assign('allowAdminMimetypes', $allowAdminMimetypes); |
||||
| 216 | $GLOBALS['xoopsTpl']->assign('allowUserMimetypes', $allowUserMimetypes); |
||||
| 217 | |||||
| 218 | $GLOBALS['xoopsTpl']->display("db:{$helper->getModule()->dirname()}_am_mimetypeslist.tpl"); |
||||
| 219 | |||||
| 220 | require_once __DIR__ . '/admin_footer.php'; |
||||
| 221 | break; |
||||
| 222 | } |
||||
| 223 |