Issues (411)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  Header Injection
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

review.php (3 issues)

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');
0 ignored issues
show
$helper->getHandler('Category')->getObjects() cannot be passed to XoopsModules\Wfdownloads\ObjectTree::__construct() as the parameter $objectArr expects a reference. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

68
$categoryObjsTree = new ObjectTree(/** @scrutinizer ignore-type */ $helper->getHandler('Category')->getObjects(), 'cid', 'pid');
Loading history...
69
$breadcrumb       = new Common\Breadcrumb();
70
$breadcrumb->addLink($helper->getModule()->getVar('name'), WFDOWNLOADS_URL);
0 ignored issues
show
The constant WFDOWNLOADS_URL was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
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&amp;cid={$cid}&amp;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 ignore-call  annotation

130
        $pagenav          = /** @scrutinizer ignore-call */ new XoopsPageNav($reviewsCount, 5, $start, 'start', "op=reviews.list&amp;cid={$cid}&amp;lid={$lid}", 1);

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...
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