mambax7 /
newbb5
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 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 | |||
| 28 | use Xmf\Request; |
||
| 29 | |||
| 30 | include_once __DIR__ . '/header.php'; |
||
| 31 | $poll_id = Request::getInt('poll_id', Request::getInt('poll_id', 0, 'POST'), 'GET'); |
||
|
0 ignored issues
–
show
|
|||
| 32 | $topic_id = Request::getInt('topic_id', Request::getInt('topic_id', 0, 'POST'), 'GET'); |
||
|
0 ignored issues
–
show
$topic_id does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).
This check examines a number of code elements and verifies that they conform to the given naming conventions. You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods. Loading history...
|
|||
| 33 | $forum = Request::getInt('forum', Request::getInt('forum', 0, 'POST'), 'GET'); |
||
| 34 | |||
| 35 | ///** @var Newbb\TopicHandler $topicHandler */ |
||
| 36 | //$topicHandler = Newbb\Helper::getInstance()->getHandler('Topic'); |
||
| 37 | $topicObject = $topicHandler->get($topic_id); |
||
|
0 ignored issues
–
show
$topic_id does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).
This check examines a number of code elements and verifies that they conform to the given naming conventions. You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods. Loading history...
|
|||
| 38 | if (!$topicHandler->getPermission($topicObject->getVar('forum_id'), $topicObject->getVar('topic_status'), 'vote')) { |
||
| 39 | redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _NOPERM); |
||
| 40 | } |
||
| 41 | |||
| 42 | View Code Duplication | if (!Request::getInt('option_id', 0, 'POST')) { |
|
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 43 | // irmtfan - add error message - simple url |
||
| 44 | redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?topic_id={$topic_id}", 1, _MD_NEWBB_POLL_NOOPTION); |
||
|
0 ignored issues
–
show
$topic_id does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).
This check examines a number of code elements and verifies that they conform to the given naming conventions. You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods. Loading history...
|
|||
| 45 | } |
||
| 46 | // poll module |
||
| 47 | $pollModuleHandler = $moduleHandler->getByDirname($GLOBALS['xoopsModuleConfig']['poll_module']); |
||
| 48 | if (is_object($pollModuleHandler) && $pollModuleHandler->getVar('isactive')) { |
||
| 49 | // new xoopspoll module |
||
| 50 | if ($pollModuleHandler->getVar('version') >= 140) { |
||
| 51 | xoops_load('constants', $GLOBALS['xoopsModuleConfig']['poll_module']); |
||
| 52 | xoops_loadLanguage('main', $GLOBALS['xoopsModuleConfig']['poll_module']); |
||
| 53 | |||
| 54 | /** @var \XoopspollPollHandler $xpPollHandler */ |
||
| 55 | $xpPollHandler = xoops_getModuleHandler('poll', $GLOBALS['xoopsModuleConfig']['poll_module']); |
||
| 56 | /** @var \XoopspollLogHandler $xpLogHandler */ |
||
| 57 | $xpLogHandler = xoops_getModuleHandler('log', $GLOBALS['xoopsModuleConfig']['poll_module']); |
||
| 58 | /** @var \XoopsPoll $pollObject */ |
||
| 59 | $pollObject = $xpPollHandler->get($poll_id); // will create poll if poll_id = 0 exist |
||
|
0 ignored issues
–
show
$poll_id does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).
This check examines a number of code elements and verifies that they conform to the given naming conventions. You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods. Loading history...
|
|||
| 60 | // old xoopspoll or umfrage or any clone from them |
||
| 61 | View Code Duplication | } else { |
|
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 62 | include $GLOBALS['xoops']->path('modules/' . $GLOBALS['xoopsModuleConfig']['poll_module'] . '/include/constants.php'); |
||
| 63 | $classPoll = $topicObject->loadOldPoll(); |
||
| 64 | $pollObject = new $classPoll($poll_id); // will create poll if poll_id = 0 exist |
||
|
0 ignored issues
–
show
$poll_id does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).
This check examines a number of code elements and verifies that they conform to the given naming conventions. You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods. Loading history...
|
|||
| 65 | } |
||
| 66 | } else { |
||
| 67 | redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_POLLMODULE_ERROR); |
||
| 68 | } |
||
| 69 | |||
| 70 | $mail_author = false; |
||
|
0 ignored issues
–
show
$mail_author does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).
This check examines a number of code elements and verifies that they conform to the given naming conventions. You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods. Loading history...
|
|||
| 71 | // new xoopspoll module |
||
| 72 | if ($pollModuleHandler->getVar('version') >= 140) { |
||
| 73 | $classConstants = ucfirst($GLOBALS['xoopsModuleConfig']['poll_module']) . 'Constants'; |
||
| 74 | if (is_object($pollObject)) { |
||
| 75 | if ($pollObject->getVar('multiple')) { |
||
| 76 | $optionId = Request::getInt('option_id', 0, 'POST'); |
||
| 77 | $optionId = (array)$optionId; // type cast to make sure it's an array |
||
| 78 | $optionId = array_map('intval', $optionId); // make sure values are integers |
||
| 79 | } else { |
||
| 80 | $optionId = Request::getInt('option_id', 0, 'POST'); |
||
| 81 | } |
||
| 82 | if (!$pollObject->hasExpired()) { |
||
| 83 | $msg = constant('_MD_' . strtoupper($GLOBALS['xoopsModuleConfig']['poll_module']) . '_MUSTLOGIN'); |
||
| 84 | //@todo:: add $url to all redirects |
||
| 85 | // $url = $GLOBALS['xoops']->buildUrl("index.php", array('poll_id' => $poll_id)); |
||
| 86 | if ($pollObject->isAllowedToVote()) { |
||
| 87 | $thisVoter = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : null; |
||
| 88 | $votedThisPoll = $xpLogHandler->hasVoted($poll_id, xoops_getenv('REMOTE_ADDR'), $thisVoter); |
||
|
0 ignored issues
–
show
$poll_id does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).
This check examines a number of code elements and verifies that they conform to the given naming conventions. You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods. Loading history...
|
|||
| 89 | if (!$votedThisPoll) { |
||
| 90 | /* user that hasn't voted before in this poll or module preferences allow it */ |
||
| 91 | $voteTime = time(); |
||
| 92 | if ($pollObject->vote($optionId, xoops_getenv('REMOTE_ADDR'), $voteTime)) { |
||
| 93 | if (!$xpPollHandler->updateCount($pollObject)) { // update the count and save in db |
||
| 94 | echo $pollObject->getHtmlErrors(); |
||
| 95 | exit(); |
||
| 96 | } |
||
| 97 | $msg = constant('_MD_' . strtoupper($GLOBALS['xoopsModuleConfig']['poll_module']) . '_THANKSFORVOTE'); |
||
| 98 | } else { |
||
| 99 | /* there was a problem registering the vote */ |
||
| 100 | redirect_header($GLOBALS['xoops']->buildUrl('index.php', ['poll_id' => $poll_id]), $classConstants::REDIRECT_DELAY_MEDIUM, constant('_MD_' . strtoupper($GLOBALS['xoopsModuleConfig']['poll_module']) . '_VOTE_ERROR')); |
||
|
0 ignored issues
–
show
$poll_id does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).
This check examines a number of code elements and verifies that they conform to the given naming conventions. You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods. Loading history...
|
|||
| 101 | } |
||
| 102 | View Code Duplication | } else { |
|
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 103 | $msg = constant('_MD_' . strtoupper($GLOBALS['xoopsModuleConfig']['poll_module']) . '_ALREADYVOTED'); |
||
| 104 | } |
||
| 105 | /* set anon user vote (and the time they voted) */ |
||
| 106 | if (!is_object($GLOBALS['xoopsUser'])) { |
||
| 107 | xoops_load('pollUtility', $GLOBALS['xoopsModuleConfig']['poll_module']); |
||
| 108 | /** @var XoopspollPollUtility $classPollUtility */ |
||
| 109 | $classPollUtility = ucfirst($GLOBALS['xoopsModuleConfig']['poll_module']) . 'PollUtility'; |
||
| 110 | $classPollUtility::setVoteCookie($poll_id, $voteTime, 0); |
||
|
0 ignored issues
–
show
$poll_id does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).
This check examines a number of code elements and verifies that they conform to the given naming conventions. You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods. Loading history...
|
|||
| 111 | } |
||
| 112 | View Code Duplication | } else { |
|
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 113 | $msg = constant('_MD_' . strtoupper($GLOBALS['xoopsModuleConfig']['poll_module']) . '_CANNOTVOTE'); |
||
| 114 | } |
||
| 115 | View Code Duplication | } else { |
|
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 116 | /* poll has expired so just show the results */ |
||
| 117 | $msg = constant('_MD_' . strtoupper($GLOBALS['xoopsModuleConfig']['poll_module']) . 'SORRYEXPIRED'); |
||
| 118 | } |
||
| 119 | View Code Duplication | } else { |
|
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 120 | $msg = constant('_MD_' . strtoupper($GLOBALS['xoopsModuleConfig']['poll_module']) . '_ERROR_INVALID_POLLID'); |
||
| 121 | } |
||
| 122 | if (null !== $url) { |
||
| 123 | redirect_header($url, $classConstants::REDIRECT_DELAY_MEDIUM, $msg); |
||
| 124 | } else { |
||
| 125 | redirect_header($GLOBALS['xoops']->buildUrl('viewtopic.php', ['topic_id' => $topic_id]), $classConstants::REDIRECT_DELAY_MEDIUM, $msg); |
||
|
0 ignored issues
–
show
$topic_id does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).
This check examines a number of code elements and verifies that they conform to the given naming conventions. You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods. Loading history...
|
|||
| 126 | } |
||
| 127 | // old xoopspoll or umfrage or any clone from them |
||
| 128 | } else { |
||
| 129 | $classLog = $classPoll . 'Log'; |
||
| 130 | if (is_object($GLOBALS['xoopsUser'])) { |
||
| 131 | if ($classLog::hasVoted($poll_id, Request::getString('REMOTE_ADDR', '', 'SERVER'), $GLOBALS['xoopsUser']->getVar('uid'))) { |
||
|
0 ignored issues
–
show
$poll_id does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).
This check examines a number of code elements and verifies that they conform to the given naming conventions. You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods. Loading history...
|
|||
| 132 | $msg = _PL_ALREADYVOTED; |
||
| 133 | setcookie("newbb_polls[{$poll_id}]", 1); |
||
|
0 ignored issues
–
show
$poll_id does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).
This check examines a number of code elements and verifies that they conform to the given naming conventions. You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods. Loading history...
|
|||
| 134 | View Code Duplication | } else { |
|
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 135 | // irmtfan save ip to db |
||
| 136 | $pollObject->vote(Request::getInt('option_id', 0, 'POST'), Request::getString('REMOTE_ADDR', '', 'SERVER'), $GLOBALS['xoopsUser']->getVar('uid')); |
||
| 137 | $pollObject->updateCount(); |
||
| 138 | $msg = _PL_THANKSFORVOTE; |
||
| 139 | setcookie("newbb_polls[{$poll_id}]", 1); |
||
|
0 ignored issues
–
show
$poll_id does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).
This check examines a number of code elements and verifies that they conform to the given naming conventions. You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods. Loading history...
|
|||
| 140 | } |
||
| 141 | } else { |
||
| 142 | if ($classLog::hasVoted($poll_id, Request::getString('REMOTE_ADDR', '', 'SERVER'))) { |
||
|
0 ignored issues
–
show
$poll_id does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).
This check examines a number of code elements and verifies that they conform to the given naming conventions. You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods. Loading history...
|
|||
| 143 | $msg = _PL_ALREADYVOTED; |
||
| 144 | setcookie("newbb_polls[{$poll_id}]", 1); |
||
|
0 ignored issues
–
show
$poll_id does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).
This check examines a number of code elements and verifies that they conform to the given naming conventions. You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods. Loading history...
|
|||
| 145 | View Code Duplication | } else { |
|
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 146 | $pollObject->vote(Request::getInt('option_id', 0, 'POST'), Request::getString('REMOTE_ADDR', '', 'SERVER')); |
||
| 147 | $pollObject->updateCount(); |
||
| 148 | $msg = _PL_THANKSFORVOTE; |
||
| 149 | setcookie("newbb_polls[{$poll_id}]", 1); |
||
|
0 ignored issues
–
show
$poll_id does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).
This check examines a number of code elements and verifies that they conform to the given naming conventions. You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods. Loading history...
|
|||
| 150 | } |
||
| 151 | } |
||
| 152 | } |
||
| 153 | // irmtfan - simple url |
||
| 154 | redirect_header("viewtopic.php?topic_id={$topic_id}", 1, $msg); |
||
|
0 ignored issues
–
show
$topic_id does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).
This check examines a number of code elements and verifies that they conform to the given naming conventions. You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods. Loading history...
|
|||
| 155 |
This check examines a number of code elements and verifies that they conform to the given naming conventions.
You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.