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_reviews') && !Utility::userIsAdmin()) { |
||
| 57 | redirect_header('index.php', 3, _NOPERM); |
||
| 58 | } |
||
| 59 | $userGroups = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getGroups() : [0 => XOOPS_GROUP_ANONYMOUS]; |
||
| 60 | /** @var \XoopsGroupPermHandler $grouppermHandler */ |
||
| 61 | $grouppermHandler = xoops_getHandler('groupperm'); |
||
| 62 | if (!$grouppermHandler->checkRight('WFDownCatPerm', $cid, $userGroups, $helper->getModule()->mid())) { |
||
| 63 | redirect_header('index.php', 3, _NOPERM); |
||
| 64 | } |
||
| 65 | |||
| 66 | // Breadcrumb |
||
| 67 | require_once XOOPS_ROOT_PATH . '/class/tree.php'; |
||
| 68 | $categoryObjsTree = new ObjectTree($helper->getHandler('Category')->getObjects(), 'cid', 'pid'); |
||
| 69 | $breadcrumb = new Common\Breadcrumb(); |
||
| 70 | $breadcrumb->addLink($helper->getModule()->getVar('name'), WFDOWNLOADS_URL); |
||
| 71 | foreach (array_reverse($categoryObjsTree->getAllParent($cid)) as $parentCategory) { |
||
| 72 | $breadcrumb->addLink($parentCategory->getVar('title'), 'viewcat.php?cid=' . $parentCategory->getVar('cid')); |
||
| 73 | } |
||
| 74 | $breadcrumb->addLink($categoryObj->getVar('title'), "viewcat.php?cid={$cid}"); |
||
| 75 | $breadcrumb->addLink($downloadObj->getVar('title'), "singlefile.php?lid={$lid}"); |
||
| 76 | |||
| 77 | $op = Request::getString('op', 'review.add'); |
||
| 78 | switch ($op) { |
||
| 79 | case 'reviews.list': |
||
| 80 | case 'list': // this care is not removed for backward compatibility issues |
||
| 81 | $start = Request::getInt('start', 0); |
||
| 82 | |||
| 83 | $GLOBALS['xoopsOption']['template_main'] = "{$helper->getModule()->dirname()}_reviews.tpl"; |
||
| 84 | require_once XOOPS_ROOT_PATH . '/header.php'; |
||
| 85 | |||
| 86 | $xoTheme->addScript(XOOPS_URL . '/browse.php?Frameworks/jquery/jquery.js'); |
||
| 87 | $xoTheme->addScript(WFDOWNLOADS_URL . '/assets/js/magnific/jquery.magnific-popup.min.js'); |
||
| 88 | $xoTheme->addStylesheet(WFDOWNLOADS_URL . '/assets/js/magnific/magnific-popup.css'); |
||
| 89 | $xoTheme->addStylesheet(WFDOWNLOADS_URL . '/assets/css/module.css'); |
||
| 90 | |||
| 91 | $xoopsTpl->assign('wfdownloads_url', WFDOWNLOADS_URL . '/'); |
||
| 92 | |||
| 93 | // Generate content header |
||
| 94 | $sql = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('wfdownloads_indexpage') . ' '; |
||
| 95 | $head_arr = $GLOBALS['xoopsDB']->fetchArray($GLOBALS['xoopsDB']->query($sql)); |
||
| 96 | $catarray['imageheader'] = Utility::headerImage(); |
||
| 97 | $xoopsTpl->assign('catarray', $catarray); |
||
| 98 | $xoopsTpl->assign('category_path', $helper->getHandler('Category')->getNicePath($cid)); |
||
| 99 | $xoopsTpl->assign('category_id', $cid); |
||
| 100 | |||
| 101 | // Breadcrumb |
||
| 102 | $breadcrumb->addLink(_CO_WFDOWNLOADS_REVIEWS_LIST, ''); |
||
| 103 | $xoopsTpl->assign('wfdownloads_breadcrumb', $breadcrumb->render()); |
||
| 104 | |||
| 105 | // Count reviews |
||
| 106 | $criteria = new CriteriaCompo(new Criteria('lid', $lid)); |
||
| 107 | $criteria->add(new Criteria('submit', 1)); |
||
| 108 | $reviewsCount = $helper->getHandler('Review')->getCount($criteria); |
||
| 109 | |||
| 110 | // Get reviews |
||
| 111 | $criteria->setSort('date'); |
||
| 112 | $criteria->setLimit(5); |
||
| 113 | $criteria->setStart($start); |
||
| 114 | $reviewObjs = $helper->getHandler('Review')->getObjects($criteria); |
||
| 115 | |||
| 116 | $download_array = $downloadObj->toArray(); |
||
| 117 | $xoopsTpl->assign('down_arr', $download_array); |
||
| 118 | |||
| 119 | foreach ($reviewObjs as $reviewObj) { |
||
| 120 | $review_array = $reviewObj->toArray(); |
||
| 121 | $review_array['date'] = formatTimestamp($review_array['date'], $helper->getConfig('dateformat')); |
||
| 122 | $review_array['submitter'] = XoopsUserUtility::getUnameFromId($review_array['uid']); |
||
| 123 | $review_rating = round(number_format($review_array['rated'], 0) / 2); |
||
| 124 | $review_array['rated_img'] = "rate{$review_rating}.gif"; |
||
| 125 | $xoopsTpl->append('down_review', $review_array); |
||
| 126 | } |
||
| 127 | $xoopsTpl->assign('lang_review_found', sprintf(_MD_WFDOWNLOADS_REVIEWTOTAL, $reviewsCount)); |
||
| 128 | |||
| 129 | require_once XOOPS_ROOT_PATH . '/class/pagenav.php'; |
||
| 130 | $pagenav = new XoopsPageNav($reviewsCount, 5, $start, 'start', "op=reviews.list&cid={$cid}&lid={$lid}", 1); |
||
|
0 ignored issues
–
show
|
|||
| 131 | $navbar['navbar'] = $pagenav->renderNav(); |
||
| 132 | $xoopsTpl->assign('navbar', $navbar); |
||
| 133 | |||
| 134 | $xoopsTpl->assign('categoryPath', $pathstring . ' > ' . $download_array['title']); |
||
| 135 | $xoopsTpl->assign('module_home', Utility::moduleHome(true)); |
||
| 136 | |||
| 137 | require_once __DIR__ . '/footer.php'; |
||
| 138 | break; |
||
| 139 | case 'review.add': |
||
| 140 | default: |
||
| 141 | // Check if ANONYMOUS user can review |
||
| 142 | if (!is_object($GLOBALS['xoopsUser']) && !$helper->getConfig('rev_anonpost')) { |
||
| 143 | redirect_header(XOOPS_URL . '/user.php', 1, _MD_WFDOWNLOADS_MUSTREGFIRST); |
||
| 144 | } |
||
| 145 | |||
| 146 | // Get review poster 'uid' |
||
| 147 | $reviewerUid = is_object($GLOBALS['xoopsUser']) ? (int)$GLOBALS['xoopsUser']->getVar('uid') : 0; |
||
| 148 | |||
| 149 | if (Request::hasVar('submit', 'POST')) { |
||
| 150 | $reviewObj = $helper->getHandler('Review')->create(); |
||
| 151 | $reviewObj->setVar('title', trim($_POST['title'])); |
||
| 152 | $reviewObj->setVar('review', trim($_POST['review'])); |
||
| 153 | $reviewObj->setVar('lid', Request::getInt('lid', 0, 'POST')); |
||
| 154 | $reviewObj->setVar('rated', Request::getInt('rated', 0, 'POST')); |
||
| 155 | $reviewObj->setVar('date', time()); |
||
| 156 | $reviewObj->setVar('uid', $reviewerUid); |
||
| 157 | $submit = (Utility::userIsAdmin() ?: ($helper->getConfig('rev_approve') ? true : false)); |
||
| 158 | $reviewObj->setVar('submit', $submit); |
||
| 159 | |||
| 160 | if (!$helper->getHandler('Review')->insert($reviewObj)) { |
||
| 161 | redirect_header('index.php', 3, _MD_WFDOWNLOADS_ERROR_CREATEREVIEW); |
||
| 162 | } else { |
||
| 163 | $databaseMessage = $submit ? _MD_WFDOWNLOADS_ISAPPROVED : _MD_WFDOWNLOADS_ISNOTAPPROVED; |
||
| 164 | redirect_header('index.php', 2, $databaseMessage); |
||
| 165 | } |
||
| 166 | } else { |
||
| 167 | require_once XOOPS_ROOT_PATH . '/header.php'; |
||
| 168 | |||
| 169 | $xoTheme->addScript(XOOPS_URL . '/browse.php?Frameworks/jquery/jquery.js'); |
||
| 170 | $xoTheme->addScript(WFDOWNLOADS_URL . '/assets/js/magnific/jquery.magnific-popup.min.js'); |
||
| 171 | $xoTheme->addStylesheet(WFDOWNLOADS_URL . '/assets/js/magnific/magnific-popup.css'); |
||
| 172 | $xoTheme->addStylesheet(WFDOWNLOADS_URL . '/assets/css/module.css'); |
||
| 173 | |||
| 174 | $xoopsTpl->assign('wfdownloads_url', WFDOWNLOADS_URL . '/'); |
||
| 175 | |||
| 176 | // Breadcrumb |
||
| 177 | $breadcrumb->addLink(_MD_WFDOWNLOADS_REVIEWTHISFILE, ''); |
||
| 178 | echo $breadcrumb->render(); |
||
| 179 | |||
| 180 | echo "<div align='center'>" . Utility::headerImage() . "</div><br>\n"; |
||
| 181 | echo '<div>' . _MD_WFDOWNLOADS_REV_SNEWMNAMEDESC . "</div>\n"; |
||
| 182 | |||
| 183 | // Generate form |
||
| 184 | require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
||
| 185 | $sform = new XoopsThemeForm(_MD_WFDOWNLOADS_REV_SUBMITREV, 'reviewform', xoops_getenv('SCRIPT_NAME'), 'post', true); |
||
| 186 | $title_text = new XoopsFormText(_MD_WFDOWNLOADS_REV_TITLE, 'title', 50, 255); |
||
| 187 | //$title_text->setDescription(_MD_WFDOWNLOADS_REV_TITLE_DESC); |
||
| 188 | $sform->addElement($title_text, true); |
||
| 189 | $rating_select = new XoopsFormSelect(_MD_WFDOWNLOADS_REV_RATING, 'rated', '10'); |
||
| 190 | //$rating_select->setDescription(_MD_WFDOWNLOADS_REV_RATING_DESC); |
||
| 191 | $rating_select->addOptionArray( |
||
| 192 | [ |
||
| 193 | '1' => 1, |
||
| 194 | '2' => 2, |
||
| 195 | '3' => 3, |
||
| 196 | '4' => 4, |
||
| 197 | '5' => 5, |
||
| 198 | '6' => 6, |
||
| 199 | '7' => 7, |
||
| 200 | '8' => 8, |
||
| 201 | '9' => 9, |
||
| 202 | '10' => 10, |
||
| 203 | ] |
||
| 204 | ); |
||
| 205 | $sform->addElement($rating_select); |
||
| 206 | $review_textarea = new XoopsFormDhtmlTextArea(_MD_WFDOWNLOADS_REV_DESCRIPTION, 'review', '', 15, 60); |
||
| 207 | //$review_textarea->setDescription(_MD_WFDOWNLOADS_REV_DESCRIPTION_DESC); |
||
| 208 | $sform->addElement($review_textarea, true); |
||
| 209 | $sform->addElement(new XoopsFormHidden('lid', $lid)); |
||
| 210 | $sform->addElement(new XoopsFormHidden('cid', $cid)); |
||
| 211 | $sform->addElement(new XoopsFormHidden('uid', $reviewerUid)); |
||
| 212 | $buttonTray = new XoopsFormElementTray('', ''); |
||
| 213 | $submitButton = new XoopsFormButton('', 'submit', _SUBMIT, 'submit'); |
||
| 214 | $buttonTray->addElement($submitButton); |
||
| 215 | $cancelButton = new XoopsFormButton('', '', _CANCEL, 'button'); |
||
| 216 | $cancelButton->setExtra('onclick="history.go(-1)"'); |
||
| 217 | $buttonTray->addElement($cancelButton); |
||
| 218 | $sform->addElement($buttonTray); |
||
| 219 | $sform->display(); |
||
| 220 | require_once __DIR__ . '/footer.php'; |
||
| 221 | } |
||
| 222 | } |
||
| 223 |
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.