1 | <?php |
||||||
2 | // |
||||||
3 | // ------------------------------------------------------------------------ // |
||||||
4 | // XOOPS - PHP Content Management System // |
||||||
5 | // Copyright (c) 2000-2016 XOOPS.org // |
||||||
6 | // <https://xoops.org/> // |
||||||
7 | // ------------------------------------------------------------------------ // |
||||||
8 | // This program is free software; you can redistribute it and/or modify // |
||||||
9 | // it under the terms of the GNU General Public License as published by // |
||||||
10 | // the Free Software Foundation; either version 2 of the License, or // |
||||||
11 | // (at your option) any later version. // |
||||||
12 | // // |
||||||
13 | // You may not change or alter any portion of this comment or credits // |
||||||
14 | // of supporting developers from this source code or any supporting // |
||||||
15 | // source code which is considered copyrighted (c) material of the // |
||||||
16 | // original comment or credit authors. // |
||||||
17 | // // |
||||||
18 | // This program is distributed in the hope that it will be useful, // |
||||||
19 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // |
||||||
20 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
||||||
21 | // GNU General Public License for more details. // |
||||||
22 | // // |
||||||
23 | // You should have received a copy of the GNU General Public License // |
||||||
24 | // along with this program; if not, write to the Free Software // |
||||||
25 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // |
||||||
26 | // ------------------------------------------------------------------------ // |
||||||
27 | // Author: phppp (D.J., [email protected]) // |
||||||
28 | // URL: https://xoops.org // |
||||||
29 | // Project: Article Project // |
||||||
30 | // ------------------------------------------------------------------------ // |
||||||
31 | |||||||
32 | use Xmf\Request; |
||||||
0 ignored issues
–
show
|
|||||||
33 | |||||||
34 | require_once __DIR__ . '/header.php'; |
||||||
35 | |||||||
36 | $ratinguser = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0; |
||||||
37 | $anonwaitdays = 1; |
||||||
38 | $ip = \Xmf\IPAddress::fromRequest()->asReadable(); |
||||||
0 ignored issues
–
show
The type
Xmf\IPAddress was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||||
39 | foreach (['topic_id', 'rate', 'forum'] as $var) { |
||||||
40 | // ${$var} = isset($_POST[$var]) ? (int)($_POST[$var]) : (isset($_GET[$var])?(int)($_GET[$var]):0); |
||||||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
84% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||||||
41 | ${$var} = Request::getInt($var, Request::getInt($var, 0, 'POST'), 'GET'); |
||||||
42 | } |
||||||
43 | |||||||
44 | ///** @var Newbb\TopicHandler $topicHandler */ |
||||||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
57% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||||||
45 | //$topicHandler = Newbb\Helper::getInstance()->getHandler('Topic'); |
||||||
46 | $topicObject = $topicHandler->get($topic_id); |
||||||
47 | if (!$topicHandler->getPermission($topicObject->getVar('forum_id'), $topicObject->getVar('topic_status'), 'post') |
||||||
48 | && !$topicHandler->getPermission($topicObject->getVar('forum_id'), $topicObject->getVar('topic_status'), 'reply')) { |
||||||
49 | // irmtfan - issue with javascript:history.go(-1) |
||||||
50 | redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _NOPERM); |
||||||
0 ignored issues
–
show
The function
redirect_header was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
51 | } |
||||||
52 | |||||||
53 | if (empty($rate)) { |
||||||
54 | redirect_header('viewtopic.php?topic_id=' . $topic_id . '&forum=' . $forum . '', 4, _MD_NEWBB_NOVOTERATE); |
||||||
55 | } |
||||||
56 | ///** @var Newbb\RateHandler $rateHandler */ |
||||||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
57% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||||||
57 | //$rateHandler = Newbb\Helper::getInstance()->getHandler('Rate'); |
||||||
58 | if (0 !== $ratinguser) { |
||||||
59 | // Check if Topic POSTER is voting (UNLESS Anonymous users allowed to post) |
||||||
60 | $crit_post = new \CriteriaCompo(new \Criteria('topic_id', $topic_id)); |
||||||
0 ignored issues
–
show
The type
CriteriaCompo was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() The type
Criteria was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||||
61 | $crit_post->add(new \Criteria('uid', $ratinguser)); |
||||||
62 | // /** @var Newbb\PostHandler $postHandler */ |
||||||
63 | // $postHandler = Newbb\Helper::getInstance()->getHandler('Post'); |
||||||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
57% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||||||
64 | if ($postHandler->getCount($crit_post)) { |
||||||
65 | redirect_header('viewtopic.php?topic_id=' . $topic_id . '&forum=' . $forum . '', 4, _MD_NEWBB_CANTVOTEOWN); |
||||||
66 | } |
||||||
67 | // Check if REG user is trying to vote twice. |
||||||
68 | $crit_rate = new \CriteriaCompo(new \Criteria('topic_id', $topic_id)); |
||||||
69 | $crit_rate->add(new \Criteria('ratinguser', $ratinguser)); |
||||||
70 | if ($rateHandler->getCount($crit_rate)) { |
||||||
71 | redirect_header('viewtopic.php?topic_id=' . $topic_id . '&forum=' . $forum . '', 4, _MD_NEWBB_VOTEONCE); |
||||||
72 | } |
||||||
73 | } else { |
||||||
74 | // Check if ANONYMOUS user is trying to vote more than once per day. |
||||||
75 | $crit_rate = new \CriteriaCompo(new \Criteria('topic_id', $topic_id)); |
||||||
76 | $crit_rate->add(new \Criteria('ratinguser', $ratinguser)); |
||||||
77 | $crit_rate->add(new \Criteria('ratinghostname', $ip)); |
||||||
78 | $crit_rate->add(new \Criteria('ratingtimestamp', time() - (86400 * $anonwaitdays), '>')); |
||||||
79 | if ($rateHandler->getCount($crit_rate)) { |
||||||
80 | redirect_header('viewtopic.php?topic_id=' . $topic_id . '&forum=' . $forum . '', 4, _MD_NEWBB_VOTEONCE); |
||||||
81 | } |
||||||
82 | } |
||||||
83 | $rateObject = $rateHandler->create(); |
||||||
84 | $rateObject->setVar('rating', $rate * 2); |
||||||
85 | $rateObject->setVar('topic_id', $topic_id); |
||||||
86 | $rateObject->setVar('ratinguser', $ratinguser); |
||||||
87 | $rateObject->setVar('ratinghostname', $ip); |
||||||
88 | $rateObject->setVar('ratingtimestamp', time()); |
||||||
89 | |||||||
90 | $ratingid = $rateHandler->insert($rateObject); |
||||||
91 | |||||||
92 | $query = 'SELECT rating FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_votedata') . ' WHERE topic_id = ' . $topic_id . ' '; |
||||||
93 | $voteresult = $GLOBALS['xoopsDB']->query($query); |
||||||
94 | $votesDB = $GLOBALS['xoopsDB']->getRowsNum($voteresult); |
||||||
95 | $totalrating = 0; |
||||||
96 | while (false !== (list($rating) = $GLOBALS['xoopsDB']->fetchRow($voteresult))) { |
||||||
97 | $totalrating += $rating; |
||||||
98 | } |
||||||
99 | $finalrating = $totalrating / $votesDB; |
||||||
100 | $finalrating = number_format($finalrating, 4); |
||||||
101 | $sql = sprintf('UPDATE "%s" SET rating = "%u", votes = "%u" WHERE topic_id = "%u"', $GLOBALS['xoopsDB']->prefix('newbb_topics'), $finalrating, $votesDB, $topic_id); |
||||||
102 | $GLOBALS['xoopsDB']->queryF($sql); |
||||||
103 | |||||||
104 | $ratemessage = _MD_NEWBB_VOTEAPPRE . '<br>' . sprintf(_MD_NEWBB_THANKYOU, $GLOBALS['xoopsConfig']['sitename']); |
||||||
105 | redirect_header('viewtopic.php?topic_id=' . $topic_id . '&forum=' . $forum . '', 2, $ratemessage); |
||||||
106 | // irmtfan enhance include footer.php |
||||||
107 | include $GLOBALS['xoops']->path('footer.php'); |
||||||
108 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths