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.

ratefile.php (2 issues)

Labels
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 (false === $downloadObj->getVar('published') || $downloadObj->getVar('published') > time()
48
    || true === $downloadObj->getVar('offline')
49
    || (0 != $downloadObj->getVar('expired')
50
        && $downloadObj->getVar('expired') < time())) {
51
    redirect_header('index.php', 3, _MD_WFDOWNLOADS_NODOWNLOAD);
52
}
53
54
// Check permissions
55
if (false === $helper->getConfig('enable_ratings') && !Utility::userIsAdmin()) {
56
    redirect_header('index.php', 3, _NOPERM);
57
}
58
// Breadcrumb
59
require_once XOOPS_ROOT_PATH . '/class/tree.php';
60
$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

60
$categoryObjsTree = new ObjectTree(/** @scrutinizer ignore-type */ $helper->getHandler('Category')->getObjects(), 'cid', 'pid');
Loading history...
61
$breadcrumb       = new Common\Breadcrumb();
62
$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...
63
foreach (array_reverse($categoryObjsTree->getAllParent($cid)) as $parentCategory) {
64
    $breadcrumb->addLink($parentCategory->getVar('title'), 'viewcat.php?cid=' . $parentCategory->getVar('cid'));
65
}
66
$breadcrumb->addLink($categoryObj->getVar('title'), "viewcat.php?cid={$cid}");
67
$breadcrumb->addLink($downloadObj->getVar('title'), "singlefile.php?lid={$lid}");
68
69
$op = Request::getString('op', 'vote.add');
70
switch ($op) {
71
    case 'vote.add':
72
    default:
73
        // Get vote poster 'uid'
74
        $ratinguserUid = is_object($GLOBALS['xoopsUser']) ? (int)$GLOBALS['xoopsUser']->getVar('uid') : 0;
75
        $ratinguserIp  = getenv('REMOTE_ADDR');
76
77
        if (Request::hasVar('submit', 'POST')) {
78
            $rating = Request::getString('rating', '--', 'POST');
79
80
            // Check if Rating is Null
81
            if ('--' === $rating) {
82
                redirect_header("?cid={$cid}&amp;lid={$lid}", 4, _MD_WFDOWNLOADS_NORATING);
83
            }
84
            if (0 != $ratinguserUid) {
85
                // Check if Download POSTER is voting (UNLESS Anonymous users allowed to post)
86
                if ($downloadObj->getVar('submitter') == $ratinguserUid) {
87
                    redirect_header(WFDOWNLOADS_URL . "/singlefile.php?cid={$cid}&amp;lid={$lid}", 4, _MD_WFDOWNLOADS_CANTVOTEOWN);
88
                }
89
                // Check if REG user is trying to vote twice.
90
                $criteria = new CriteriaCompo(new Criteria('lid', $lid));
91
                $criteria->add(new Criteria('ratinguser', $ratinguserUid));
92
                $ratingsCount = $helper->getHandler('Rating')->getCount($criteria);
93
                if ($ratingsCount > 0) {
94
                    redirect_header("singlefile.php?cid={$cid}&amp;lid={$lid}", 4, _MD_WFDOWNLOADS_VOTEONCE);
95
                }
96
            } else {
97
                // Check if ANONYMOUS user is trying to vote more than once per day (only 1 anonymous from an IP in a single day).
98
                $anonymousWaitDays = 1;
99
                $yesterday         = (time() - (86400 * $anonymousWaitDays));
100
                $criteria          = new CriteriaCompo(new Criteria('lid', $lid));
101
                $criteria->add(new Criteria('ratinguser', 0));
102
                $criteria->add(new Criteria('ratinghostname', $ratinguserIp));
103
                $criteria->add(new Criteria('ratingtimestamp', $yesterday, '>'));
104
                $anonymousVotesCount = $helper->getHandler('Rating')->getCount($criteria);
105
                if ($anonymousVotesCount > 0) {
106
                    redirect_header("singlefile.php?cid={$cid}&amp;lid={$lid}", 4, _MD_WFDOWNLOADS_VOTEONCE);
107
                }
108
            }
109
            // All is well. Add to Line Item Rate to DB.
110
            $ratingObj = $helper->getHandler('Rating')->create();
111
            $ratingObj->setVar('lid', $lid);
112
            $ratingObj->setVar('ratinguser', $ratinguserUid);
113
            $ratingObj->setVar('rating', (int)$rating);
114
            $ratingObj->setVar('ratinghostname', $ratinguserIp);
115
            $ratingObj->setVar('ratingtimestamp', time());
116
            if ($helper->getHandler('Rating')->insert($ratingObj)) {
117
                // All is well. Calculate Score & Add to Summary (for quick retrieval & sorting) to DB.
118
                Utility::updateRating($lid);
119
                $thankyouMessage = _MD_WFDOWNLOADS_VOTEAPPRE . '<br>' . sprintf(_MD_WFDOWNLOADS_THANKYOU, $GLOBALS['xoopsConfig']['sitename']);
120
                redirect_header("singlefile.php?cid={$cid}&amp;lid={$lid}", 4, $thankyouMessage);
121
            } else {
122
                echo $ratingObj->getHtmlErrors();
123
            }
124
        } else {
125
            $GLOBALS['xoopsOption']['template_main'] = "{$helper->getModule()->dirname()}_ratefile.tpl";
126
            require_once XOOPS_ROOT_PATH . '/header.php';
127
128
            $xoTheme->addScript(XOOPS_URL . '/browse.php?Frameworks/jquery/jquery.js');
129
            $xoTheme->addScript(WFDOWNLOADS_URL . '/assets/js/magnific/jquery.magnific-popup.min.js');
130
            $xoTheme->addStylesheet(WFDOWNLOADS_URL . '/assets/js/magnific/magnific-popup.css');
131
            $xoTheme->addStylesheet(WFDOWNLOADS_URL . '/assets/css/module.css');
132
133
            $xoopsTpl->assign('wfdownloads_url', WFDOWNLOADS_URL . '/');
134
135
            // Breadcrumb
136
            $breadcrumb->addLink(_MD_WFDOWNLOADS_RATETHISFILE, '');
137
            $xoopsTpl->assign('wfdownloads_breadcrumb', $breadcrumb->render());
138
139
            // Generate form
140
            require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
141
            $sform         = new XoopsThemeForm(_MD_WFDOWNLOADS_RATETHISFILE, 'voteform', xoops_getenv('SCRIPT_NAME'), 'post', true);
142
            $rating_select = new XoopsFormSelect(_MD_WFDOWNLOADS_REV_RATING, 'rating', '10');
143
            //$rating_select->setDescription(_MD_WFDOWNLOADS_REV_RATING_DESC);
144
            $rating_select->addOptionArray(
145
                [
146
                    '1'  => 1,
147
                    '2'  => 2,
148
                    '3'  => 3,
149
                    '4'  => 4,
150
                    '5'  => 5,
151
                    '6'  => 6,
152
                    '7'  => 7,
153
                    '8'  => 8,
154
                    '9'  => 9,
155
                    '10' => 10,
156
                ]
157
            );
158
            $sform->addElement($rating_select);
159
            $sform->addElement(new XoopsFormHidden('lid', $lid));
160
            $sform->addElement(new XoopsFormHidden('cid', $cid));
161
            $sform->addElement(new XoopsFormHidden('uid', $reviewerUid));
162
            $buttonTray   = new XoopsFormElementTray('', '');
163
            $submitButton = new XoopsFormButton('', 'submit', _MD_WFDOWNLOADS_RATEIT, 'submit');
164
            $buttonTray->addElement($submitButton);
165
            $cancelButton = new XoopsFormButton('', '', _CANCEL, 'button');
166
            $cancelButton->setExtra('onclick="history.go(-1)"');
167
            $buttonTray->addElement($cancelButton);
168
            $sform->addElement($buttonTray);
169
            $xoopsTpl->assign('voteform', $sform->render());
170
            $xoopsTpl->assign(
171
                'download',
172
                [
173
                    'lid'         => $lid,
174
                    'cid'         => $cid,
175
                    'title'       => $downloadObj->getVar('title'),
176
                    'description' => $downloadObj->getVar('description'),
177
                ]
178
            );
179
180
            $xoopsTpl->assign(
181
                'file',
182
                [
183
                    'id'          => $lid,
184
                    'lid'         => $lid,
185
                    'cid'         => $cid,
186
                    'title'       => $downloadObj->getVar('title'),
187
                    'imageheader' => Utility::headerImage(),
188
                ]
189
            ); // this definition is not removed for backward compatibility issues
190
            require_once __DIR__ . '/footer.php';
191
        }
192
        break;
193
}
194