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\Request; |
||||
| 23 | use XoopsModules\Wfdownloads\{ |
||||
| 24 | Common, |
||||
| 25 | Helper, |
||||
| 26 | Utility, |
||||
| 27 | ObjectTree |
||||
| 28 | }; |
||||
| 29 | /** @var Helper $helper */ |
||||
| 30 | /** @var Utility $utility */ |
||||
| 31 | |||||
| 32 | $currentFile = basename(__FILE__); |
||||
| 33 | require_once __DIR__ . '/header.php'; |
||||
| 34 | |||||
| 35 | $lid = Request::getInt('lid', 0); |
||||
| 36 | $downloadObj = $helper->getHandler('Download')->get($lid); |
||||
| 37 | if (null === $downloadObj) { |
||||
| 38 | redirect_header('index.php', 3, _CO_WFDOWNLOADS_ERROR_NODOWNLOAD); |
||||
| 39 | } |
||||
| 40 | $cid = Request::getInt('cid', $downloadObj->getVar('cid')); |
||||
| 41 | $categoryObj = $helper->getHandler('Category')->get($cid); |
||||
| 42 | if (null === $categoryObj) { |
||||
| 43 | redirect_header('index.php', 3, _CO_WFDOWNLOADS_ERROR_NOCATEGORY); |
||||
| 44 | } |
||||
| 45 | |||||
| 46 | // Download not published, expired or taken offline - redirect |
||||
| 47 | if (0 == $downloadObj->getVar('published') || $downloadObj->getVar('published') > time() |
||||
| 48 | || true === $downloadObj->getVar('offline') |
||||
| 49 | || (0 != $downloadObj->getVar('expired') |
||||
| 50 | && $downloadObj->getVar('expired') < time()) |
||||
| 51 | || _WFDOWNLOADS_STATUS_WAITING == $downloadObj->getVar('status')) { |
||||
| 52 | redirect_header('index.php', 3, _MD_WFDOWNLOADS_NODOWNLOAD); |
||||
| 53 | } |
||||
| 54 | |||||
| 55 | // Check permissions |
||||
| 56 | if (false === $helper->getConfig('enable_mirrors') && !Utility::userIsAdmin()) { |
||||
| 57 | redirect_header('index.php', 3, _NOPERM); |
||||
| 58 | } |
||||
| 59 | $userGroups = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getGroups() : [0 => XOOPS_GROUP_ANONYMOUS]; |
||||
| 60 | if (!$grouppermHandler->checkRight('WFDownCatPerm', $cid, $userGroups, $helper->getModule()->mid())) { |
||||
| 61 | redirect_header('index.php', 3, _NOPERM); |
||||
| 62 | } |
||||
| 63 | |||||
| 64 | // Breadcrumb |
||||
| 65 | require_once XOOPS_ROOT_PATH . '/class/tree.php'; |
||||
| 66 | $categoryObjsTree = new ObjectTree($helper->getHandler('Category')->getObjects(), 'cid', 'pid'); |
||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 67 | $breadcrumb = new Common\Breadcrumb(); |
||||
| 68 | $breadcrumb->addLink($helper->getModule()->getVar('name'), WFDOWNLOADS_URL); |
||||
|
0 ignored issues
–
show
|
|||||
| 69 | foreach (array_reverse($categoryObjsTree->getAllParent($cid)) as $parentCategory) { |
||||
| 70 | $breadcrumb->addLink($parentCategory->getVar('title'), 'viewcat.php?cid=' . $parentCategory->getVar('cid')); |
||||
| 71 | } |
||||
| 72 | $breadcrumb->addLink($categoryObj->getVar('title'), "viewcat.php?cid={$cid}"); |
||||
| 73 | $breadcrumb->addLink($downloadObj->getVar('title'), "singlefile.php?lid={$lid}"); |
||||
| 74 | |||||
| 75 | $op = Request::getString('op', 'mirror.add'); |
||||
| 76 | switch ($op) { |
||||
| 77 | case 'mirrors.list': |
||||
| 78 | case 'list': // this case is not removed for backward compatibility issues |
||||
| 79 | $start = Request::getInt('start', 0); |
||||
| 80 | |||||
| 81 | $GLOBALS['xoopsOption']['template_main'] = "{$helper->getModule()->dirname()}_mirrors.tpl"; |
||||
| 82 | require_once XOOPS_ROOT_PATH . '/header.php'; |
||||
| 83 | |||||
| 84 | $xoTheme->addScript(XOOPS_URL . '/browse.php?Frameworks/jquery/jquery.js'); |
||||
| 85 | $xoTheme->addScript(WFDOWNLOADS_URL . '/assets/js/magnific/jquery.magnific-popup.min.js'); |
||||
| 86 | $xoTheme->addStylesheet(WFDOWNLOADS_URL . '/assets/js/magnific/magnific-popup.css'); |
||||
| 87 | $xoTheme->addStylesheet(WFDOWNLOADS_URL . '/assets/css/module.css'); |
||||
| 88 | |||||
| 89 | $xoopsTpl->assign('wfdownloads_url', WFDOWNLOADS_URL . '/'); |
||||
| 90 | |||||
| 91 | // Generate content header |
||||
| 92 | $sql = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('wfdownloads_indexpage') . ' '; |
||||
| 93 | $head_arr = $GLOBALS['xoopsDB']->fetchArray($GLOBALS['xoopsDB']->query($sql)); |
||||
| 94 | $catarray['imageheader'] = Utility::headerImage(); |
||||
| 95 | $xoopsTpl->assign('catarray', $catarray); |
||||
| 96 | $xoopsTpl->assign('category_path', $helper->getHandler('Category')->getNicePath($cid)); |
||||
| 97 | $xoopsTpl->assign('category_id', $cid); |
||||
| 98 | |||||
| 99 | // Breadcrumb |
||||
| 100 | $breadcrumb->addLink(_CO_WFDOWNLOADS_MIRRORS_LIST, ''); |
||||
| 101 | $xoopsTpl->assign('wfdownloads_breadcrumb', $breadcrumb->render()); |
||||
| 102 | |||||
| 103 | // Count mirrors |
||||
| 104 | $criteria = new CriteriaCompo(new Criteria('lid', $lid)); |
||||
| 105 | $criteria->add(new Criteria('submit', 1)); // true |
||||
| 106 | $mirrorsCount = $helper->getHandler('Mirror')->getCount($criteria); |
||||
| 107 | |||||
| 108 | // Get mirrors |
||||
| 109 | $criteria->setSort('date'); |
||||
| 110 | $criteria->setLimit(5); |
||||
| 111 | $criteria->setStart($start); |
||||
| 112 | $mirrorObjs = $helper->getHandler('Mirror')->getObjects($criteria); |
||||
| 113 | |||||
| 114 | $download_array = $downloadObj->toArray(); |
||||
| 115 | $xoopsTpl->assign('down_arr', $download_array); |
||||
| 116 | |||||
| 117 | $add_mirror = false; |
||||
| 118 | if (!is_object($GLOBALS['xoopsUser']) |
||||
| 119 | && (_WFDOWNLOADS_ANONPOST_MIRROR == $helper->getConfig('anonpost') |
||||
| 120 | || _WFDOWNLOADS_ANONPOST_BOTH == $helper->getConfig('anonpost')) |
||||
| 121 | && (_WFDOWNLOADS_SUBMISSIONS_MIRROR == $helper->getConfig('submissions') |
||||
| 122 | || _WFDOWNLOADS_SUBMISSIONS_BOTH == $helper->getConfig('submissions'))) { |
||||
| 123 | $add_mirror = true; |
||||
| 124 | } elseif (is_object($GLOBALS['xoopsUser']) |
||||
| 125 | && (_WFDOWNLOADS_SUBMISSIONS_MIRROR == $helper->getConfig('submissions') |
||||
| 126 | || _WFDOWNLOADS_SUBMISSIONS_BOTH == $helper->getConfig('submissions') |
||||
| 127 | || $GLOBALS['xoopsUser']->isAdmin())) { |
||||
| 128 | $add_mirror = true; |
||||
| 129 | } |
||||
| 130 | |||||
| 131 | foreach ($mirrorObjs as $mirrorObj) { |
||||
| 132 | $mirror_array = $mirrorObj->toArray(); |
||||
| 133 | if (1 == $helper->getConfig('enable_onlinechk')) { |
||||
| 134 | $serverURL = str_replace('http://', '', trim($mirror_array['homeurl'])); |
||||
| 135 | $mirror_array['isonline'] = Utility::mirrorOnline($serverURL); |
||||
| 136 | } else { |
||||
| 137 | $mirror_array['isonline'] = 2; |
||||
| 138 | } |
||||
| 139 | $mirror_array['add_mirror'] = $add_mirror; |
||||
| 140 | $mirror_array['date'] = formatTimestamp($mirror_array['date'], $helper->getConfig('dateformat')); |
||||
| 141 | $mirror_array['submitter'] = XoopsUserUtility::getUnameFromId($mirror_array['uid']); |
||||
| 142 | $xoopsTpl->append('down_mirror', $mirror_array); |
||||
| 143 | } |
||||
| 144 | $xoopsTpl->assign('lang_mirror_found', sprintf(_MD_WFDOWNLOADS_MIRROR_TOTAL, $mirrorsCount)); |
||||
| 145 | |||||
| 146 | require_once XOOPS_ROOT_PATH . '/class/pagenav.php'; |
||||
| 147 | $pagenav = new XoopsPageNav($mirrorsCount, 5, $start, 'start', "op=mirrors.list&cid={$cid}&lid={$lid}", 1); |
||||
|
0 ignored issues
–
show
The call to
XoopsPageNav::__construct() has too many arguments starting with 1.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above. Loading history...
|
|||||
| 148 | $navbar['navbar'] = $pagenav->renderNav(); |
||||
| 149 | $xoopsTpl->assign('navbar', $navbar); |
||||
| 150 | |||||
| 151 | $xoopsTpl->assign('categoryPath', $pathstring . ' > ' . $download_array['title']); |
||||
| 152 | $xoopsTpl->assign('module_home', Utility::moduleHome(true)); |
||||
| 153 | |||||
| 154 | require_once __DIR__ . '/footer.php'; |
||||
| 155 | break; |
||||
| 156 | case 'mirror.add': |
||||
| 157 | default: |
||||
| 158 | // Check if ANONYMOUS user can post mirrors |
||||
| 159 | if (!is_object($GLOBALS['xoopsUser']) |
||||
| 160 | && (_WFDOWNLOADS_ANONPOST_NONE == $helper->getConfig('anonpost') |
||||
| 161 | || _WFDOWNLOADS_ANONPOST_DOWNLOAD == $helper->getConfig('anonpost'))) { |
||||
| 162 | redirect_header(XOOPS_URL . '/user.php', 1, _MD_WFDOWNLOADS_MUSTREGFIRST); |
||||
| 163 | } |
||||
| 164 | // Check if user can submit mirrors |
||||
| 165 | if (is_object($GLOBALS['xoopsUser']) |
||||
| 166 | && (_WFDOWNLOADS_SUBMISSIONS_NONE == $helper->getConfig('submissions') |
||||
| 167 | || _WFDOWNLOADS_SUBMISSIONS_DOWNLOAD == $helper->getConfig('submissions')) |
||||
| 168 | && !$GLOBALS['xoopsUser']->isAdmin()) { |
||||
| 169 | redirect_header('index.php', 1, _MD_WFDOWNLOADS_MIRROR_NOTALLOWESTOSUBMIT); |
||||
| 170 | } |
||||
| 171 | |||||
| 172 | // Get mirror poster 'uid' |
||||
| 173 | $mirroruserUid = is_object($GLOBALS['xoopsUser']) ? (int)$GLOBALS['xoopsUser']->getVar('uid') : 0; |
||||
| 174 | |||||
| 175 | if (Request::hasVar('submit', 'POST')) { |
||||
| 176 | $mirrorObj = $helper->getHandler('Mirror')->create(); |
||||
| 177 | $mirrorObj->setVar('title', trim($_POST['title'])); |
||||
| 178 | $mirrorObj->setVar('homeurl', formatURL(trim($_POST['homeurl']))); |
||||
| 179 | $mirrorObj->setVar('location', trim($_POST['location'])); |
||||
| 180 | $mirrorObj->setVar('continent', trim($_POST['continent'])); |
||||
| 181 | $mirrorObj->setVar('downurl', trim($_POST['downurl'])); |
||||
| 182 | $mirrorObj->setVar('lid', Request::getInt('lid', 0, 'POST')); |
||||
| 183 | $mirrorObj->setVar('uid', $mirroruserUid); |
||||
| 184 | $mirrorObj->setVar('date', time()); |
||||
| 185 | $approve = true; |
||||
| 186 | if ((_WFDOWNLOADS_AUTOAPPROVE_NONE == $helper->getConfig('autoapprove') || _WFDOWNLOADS_AUTOAPPROVE_DOWNLOAD == $helper->getConfig('autoapprove')) && !$wfdownloads_isAdmin) { |
||||
| 187 | $approve = false; |
||||
| 188 | } |
||||
| 189 | $submit = $approve ? true : false; |
||||
| 190 | $mirrorObj->setVar('submit', $submit); |
||||
| 191 | |||||
| 192 | if (!$helper->getHandler('Mirror')->insert($mirrorObj)) { |
||||
| 193 | redirect_header('index.php', 3, _MD_WFDOWNLOADS_ERROR_CREATEMIRROR); |
||||
| 194 | } else { |
||||
| 195 | $database_mess = $approve ? _MD_WFDOWNLOADS_ISAPPROVED : _MD_WFDOWNLOADS_ISNOTAPPROVED; |
||||
| 196 | redirect_header('index.php', 2, $database_mess); |
||||
| 197 | } |
||||
| 198 | } else { |
||||
| 199 | require_once XOOPS_ROOT_PATH . '/header.php'; |
||||
| 200 | |||||
| 201 | $xoTheme->addScript(XOOPS_URL . '/browse.php?Frameworks/jquery/jquery.js'); |
||||
| 202 | $xoTheme->addScript(WFDOWNLOADS_URL . '/assets/js/magnific/jquery.magnific-popup.min.js'); |
||||
| 203 | $xoTheme->addStylesheet(WFDOWNLOADS_URL . '/assets/js/magnific/magnific-popup.css'); |
||||
| 204 | $xoTheme->addStylesheet(WFDOWNLOADS_URL . '/assets/css/module.css'); |
||||
| 205 | |||||
| 206 | $xoopsTpl->assign('wfdownloads_url', WFDOWNLOADS_URL . '/'); |
||||
| 207 | |||||
| 208 | // Breadcrumb |
||||
| 209 | $breadcrumb->addLink(_MD_WFDOWNLOADS_ADDMIRROR, ''); |
||||
| 210 | echo $breadcrumb->render(); |
||||
| 211 | |||||
| 212 | echo "<div align='center'>" . Utility::headerImage() . "</div><br>\n"; |
||||
| 213 | echo '<div>' . _MD_WFDOWNLOADS_MIRROR_SNEWMNAMEDESC . "</div>\n"; |
||||
| 214 | |||||
| 215 | // Generate form |
||||
| 216 | require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
||||
| 217 | $sform = new XoopsThemeForm(_MD_WFDOWNLOADS_MIRROR_SUBMITMIRROR, 'mirrorform', xoops_getenv('SCRIPT_NAME'), 'post', true); |
||||
| 218 | $title_text = new XoopsFormText(_MD_WFDOWNLOADS_MIRROR_HOMEURLTITLE, 'title', 50, 255); |
||||
| 219 | $title_text->setDescription(_MD_WFDOWNLOADS_MIRROR_HOMEURLTITLE_DESC); |
||||
| 220 | $sform->addElement($title_text, true); |
||||
| 221 | $homeurl_text = new XoopsFormText(_MD_WFDOWNLOADS_MIRROR_HOMEURL, 'homeurl', 50, 255); |
||||
| 222 | $homeurl_text->setDescription(_MD_WFDOWNLOADS_MIRROR_HOMEURL_DESC); |
||||
| 223 | $sform->addElement($homeurl_text, true); |
||||
| 224 | $location_text = new XoopsFormText(_MD_WFDOWNLOADS_MIRROR_LOCATION, 'location', 50, 255); |
||||
| 225 | $location_text->setDescription(_MD_WFDOWNLOADS_MIRROR_LOCATION_DESC); |
||||
| 226 | $sform->addElement($location_text, true); |
||||
| 227 | $continent_select = new XoopsFormSelect(_MD_WFDOWNLOADS_MIRROR_CONTINENT, 'continent'); |
||||
| 228 | $continent_select->addOptionArray( |
||||
| 229 | [ |
||||
| 230 | _MD_WFDOWNLOADS_CONT1 => _MD_WFDOWNLOADS_CONT1, |
||||
| 231 | _MD_WFDOWNLOADS_CONT2 => _MD_WFDOWNLOADS_CONT2, |
||||
| 232 | _MD_WFDOWNLOADS_CONT3 => _MD_WFDOWNLOADS_CONT3, |
||||
| 233 | _MD_WFDOWNLOADS_CONT4 => _MD_WFDOWNLOADS_CONT4, |
||||
| 234 | _MD_WFDOWNLOADS_CONT5 => _MD_WFDOWNLOADS_CONT5, |
||||
| 235 | _MD_WFDOWNLOADS_CONT6 => _MD_WFDOWNLOADS_CONT6, |
||||
| 236 | _MD_WFDOWNLOADS_CONT7 => _MD_WFDOWNLOADS_CONT7, |
||||
| 237 | ] |
||||
| 238 | ); |
||||
| 239 | $sform->addElement($continent_select); |
||||
| 240 | $downurl_text = new XoopsFormText(_MD_WFDOWNLOADS_MIRROR_DOWNURL, 'downurl', 50, 255); |
||||
| 241 | $downurl_text->setDescription(_MD_WFDOWNLOADS_MIRROR_DOWNURL_DESC); |
||||
| 242 | $sform->addElement($downurl_text, true); |
||||
| 243 | $sform->addElement(new XoopsFormHidden('lid', $lid)); |
||||
| 244 | $sform->addElement(new XoopsFormHidden('cid', $cid)); |
||||
| 245 | $sform->addElement(new XoopsFormHidden('uid', $mirroruserUid)); |
||||
| 246 | $buttonTray = new XoopsFormElementTray('', ''); |
||||
| 247 | $submitButton = new XoopsFormButton('', 'submit', _SUBMIT, 'submit'); |
||||
| 248 | $buttonTray->addElement($submitButton); |
||||
| 249 | $cancelButton = new XoopsFormButton('', '', _CANCEL, 'button'); |
||||
| 250 | $cancelButton->setExtra('onclick="history.go(-1)"'); |
||||
| 251 | $buttonTray->addElement($cancelButton); |
||||
| 252 | $sform->addElement($buttonTray); |
||||
| 253 | $sform->display(); |
||||
| 254 | require_once __DIR__ . '/footer.php'; |
||||
| 255 | } |
||||
| 256 | break; |
||||
| 257 | } |
||||
| 258 |