|
1
|
|
|
<?php declare(strict_types=1); |
|
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
|
|
|
* @copyright {@link https://xoops.org/ XOOPS Project} |
|
14
|
|
|
* @license {@link https://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later} |
|
15
|
|
|
* @author XOOPS Development Team |
|
16
|
|
|
*/ |
|
17
|
|
|
|
|
18
|
|
|
use Xmf\Request; |
|
19
|
|
|
use XoopsModules\Newbb; |
|
20
|
|
|
use XoopsModules\Xoopspoll; |
|
21
|
|
|
use XoopsModules\Xoopspoll\Constants; |
|
22
|
|
|
|
|
23
|
|
|
require_once __DIR__ . '/header.php'; |
|
24
|
|
|
|
|
25
|
|
|
$poll_id = Request::getInt('poll_id', 0, 'GET'); |
|
26
|
|
|
$poll_id = Request::getInt('poll_id', $poll_id, 'POST'); |
|
27
|
|
|
$topic_id = Request::getInt('topic_id', 0, 'GET'); |
|
28
|
|
|
$topic_id = Request::getInt('topic_id', $topic_id, 'POST'); |
|
29
|
|
|
$forum = Request::getInt('forum', 0, 'GET'); |
|
30
|
|
|
$forum = Request::getInt('forum', $forum, 'POST'); |
|
31
|
|
|
|
|
32
|
|
|
/** @var Newbb\TopicHandler $topicHandler */ |
|
33
|
|
|
$topicHandler = Newbb\Helper::getInstance()->getHandler('Topic'); |
|
34
|
|
|
$topic_obj = $topicHandler->get($topic_id); |
|
35
|
|
|
if (!$topicHandler->getPermission($topic_obj->getVar('forum_id'), $topic_obj->getVar('topic_status'), 'vote')) { |
|
36
|
|
|
// irmtfan - issue with javascript:history.go(-1) |
|
37
|
|
|
redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _NOPERM); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
if (empty($_POST['option_id'])) { |
|
41
|
|
|
// irmtfan - add error message - simple url |
|
42
|
|
|
redirect_header("viewtopic.php?topic_id={$topic_id}", 1, _MD_POLL_NOOPTION); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
if (($xoopspoll instanceof \XoopsModule) && $xoopspoll->isactive()) { |
|
46
|
|
|
if ('xoopspoll' === $pollmodules) { |
|
47
|
|
|
/* xoopspoll module installed & active */ |
|
48
|
|
|
$pollmodul = 'xoopspoll'; |
|
49
|
|
|
xoops_loadLanguage('main', 'xoopspoll'); |
|
50
|
|
|
$xpPollHandler = Xoopspoll\Helper::getInstance()->getHandler('Poll'); |
|
51
|
|
|
$xpLogHandler = Xoopspoll\Helper::getInstance()->getHandler('Log'); |
|
52
|
|
|
} else { // Umfrage |
|
53
|
|
|
$pollmodul = 'umfrage'; |
|
54
|
|
|
require_once XOOPS_ROOT_PATH . '/modules/umfrage/include/constants.php'; |
|
55
|
|
|
require_once XOOPS_ROOT_PATH . '/modules/umfrage/class/umfrage.php'; |
|
56
|
|
|
require_once XOOPS_ROOT_PATH . '/modules/umfrage/class/umfrageoption.php'; |
|
57
|
|
|
require_once XOOPS_ROOT_PATH . '/modules/umfrage/class/umfragelog.php'; |
|
58
|
|
|
require_once XOOPS_ROOT_PATH . '/modules/umfrage/class/umfragerenderer.php'; |
|
59
|
|
|
} |
|
60
|
|
|
} else { |
|
61
|
|
|
//no active poll module found |
|
62
|
|
|
redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_POLLMODULE_ERROR); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
$mail_author = false; |
|
66
|
|
|
if ('xoopspoll' === $pollmodules) { |
|
67
|
|
|
$pollObj = $xpPollHandler->get($poll_id); |
|
68
|
|
|
if ($pollObj instanceof Xoopspoll\Poll) { |
|
69
|
|
|
if ($pollObj->getVar('multiple')) { |
|
70
|
|
|
$optionId = Request::getInt('option_id', 0, 'POST'); |
|
71
|
|
|
$optionId = (array)$optionId; // type cast to make sure it's an array |
|
72
|
|
|
$optionId = array_map('\intval', $optionId); // make sure values are integers |
|
73
|
|
|
} else { |
|
74
|
|
|
$optionId = $_POST['option_id']; |
|
75
|
|
|
} |
|
76
|
|
|
if (!$pollObj->hasExpired()) { |
|
77
|
|
|
$msg = _MD_XOOPSPOLL_MUSTLOGIN; |
|
78
|
|
|
//@todo:: add $url to all redirects |
|
79
|
|
|
// $url = $GLOBALS['xoops']->buildUrl("index.php", array('poll_id' => $poll_id)); |
|
80
|
|
|
if ($pollObj->isAllowedToVote()) { |
|
81
|
|
|
$thisVoter = (!empty($GLOBALS['xoopsUser']) |
|
82
|
|
|
&& ($GLOBALS['xoopsUser'] instanceof \XoopsUser)) ? $GLOBALS['xoopsUser']->getVar('uid') : null; |
|
83
|
|
|
$votedThisPoll = $xpLogHandler->hasVoted($poll_id, xoops_getenv('REMOTE_ADDR'), $thisVoter); |
|
84
|
|
|
if (!$votedThisPoll) { |
|
85
|
|
|
/* user that hasn't voted before in this poll or module preferences allow it */ |
|
86
|
|
|
$voteTime = time(); |
|
87
|
|
|
if ($pollObj->vote($optionId, xoops_getenv('REMOTE_ADDR'), $voteTime)) { |
|
88
|
|
|
if (!$xpPollHandler->updateCount($pollObj)) { // update the count and save in db |
|
89
|
|
|
echo $pollObj->getHtmlErrors(); |
|
90
|
|
|
exit(); |
|
91
|
|
|
} |
|
92
|
|
|
$msg = _MD_XOOPSPOLL_THANKSFORVOTE; |
|
93
|
|
|
} else { |
|
94
|
|
|
/* there was a problem registering the vote */ |
|
95
|
|
|
redirect_header($GLOBALS['xoops']->buildUrl('index.php', ['poll_id' => $poll_id]), Constants::REDIRECT_DELAY_MEDIUM, _MD_XOOPSPOLL_VOTE_ERROR); |
|
96
|
|
|
} |
|
97
|
|
|
} else { |
|
98
|
|
|
$msg = _MD_XOOPSPOLL_ALREADYVOTED; |
|
99
|
|
|
} |
|
100
|
|
|
/* set anon user vote (and the time they voted) */ |
|
101
|
|
|
if (!$GLOBALS['xoopsUser'] instanceof \XoopsUser) { |
|
102
|
|
|
Xoopspoll\Utility::setVoteCookie($poll_id, $voteTime, 0); |
|
103
|
|
|
} |
|
104
|
|
|
} else { |
|
105
|
|
|
$msg = _MD_XOOPSPOLL_CANNOTVOTE; |
|
106
|
|
|
} |
|
107
|
|
|
} else { |
|
108
|
|
|
/* poll has expired so just show the results */ |
|
109
|
|
|
$msg = _MD_XOOPSPOLL_SORRYEXPIRED; |
|
110
|
|
|
} |
|
111
|
|
|
} else { |
|
112
|
|
|
$msg = _MD_XOOPSPOLL_ERROR_INVALID_POLLID; |
|
113
|
|
|
} |
|
114
|
|
|
if (null !== $url) { |
|
115
|
|
|
redirect_header($url, Constants::REDIRECT_DELAY_MEDIUM, $msg); |
|
116
|
|
|
} else { |
|
117
|
|
|
/* |
|
118
|
|
|
redirect_header($GLOBALS['xoops']->buildUrl("pollresults.php", array('poll_id' => $poll_id)), |
|
119
|
|
|
Constants::REDIRECT_DELAY_MEDIUM, |
|
120
|
|
|
$msg); |
|
121
|
|
|
*/ |
|
122
|
|
|
redirect_header($GLOBALS['xoops']->buildUrl('viewtopic.php', ['topic_id' => $topic_id]), Constants::REDIRECT_DELAY_MEDIUM, $msg); |
|
123
|
|
|
} |
|
124
|
|
|
} else { //Umfrage |
|
125
|
|
|
$poll = new \Umfrage($poll_id); |
|
|
|
|
|
|
126
|
|
|
if (is_object($xoopsUser)) { |
|
127
|
|
|
if ((new UmfrageLog())->hasVoted($poll_id, $_SERVER['REMOTE_ADDR'], $xoopsUser->getVar('uid'))) { |
|
|
|
|
|
|
128
|
|
|
$msg = _PL_ALREADYVOTED; |
|
129
|
|
|
setcookie("bb_polls[$poll_id]", 1); |
|
130
|
|
|
} else { |
|
131
|
|
|
// irmtfan save ip to db |
|
132
|
|
|
$poll->vote($_POST['option_id'], $_SERVER['REMOTE_ADDR'], $xoopsUser->getVar('uid')); |
|
133
|
|
|
$poll->updateCount(); |
|
134
|
|
|
$msg = _PL_THANKSFORVOTE; |
|
135
|
|
|
setcookie("bb_polls[$poll_id]", 1); |
|
136
|
|
|
} |
|
137
|
|
|
} else { |
|
138
|
|
|
if ((new UmfrageLog())->hasVoted($poll_id, $_SERVER['REMOTE_ADDR'])) { |
|
139
|
|
|
$msg = _PL_ALREADYVOTED; |
|
140
|
|
|
setcookie("bb_polls[$poll_id]", 1); |
|
141
|
|
|
} else { |
|
142
|
|
|
$poll->vote($_POST['option_id'], $_SERVER['REMOTE_ADDR']); |
|
143
|
|
|
$poll->updateCount(); |
|
144
|
|
|
$msg = _PL_THANKSFORVOTE; |
|
145
|
|
|
setcookie("bb_polls[$poll_id]", 1); |
|
146
|
|
|
} |
|
147
|
|
|
} |
|
148
|
|
|
} |
|
149
|
|
|
// irmtfan - simple url |
|
150
|
|
|
redirect_header("viewtopic.php?topic_id={$topic_id}", 1, $msg); |
|
151
|
|
|
|
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