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 | * @copyright {@link https://xoops.org/ XOOPS Project} |
||||
14 | * @license {@link http://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later} |
||||
15 | * @package efqdirectory |
||||
16 | * @since |
||||
17 | * @author Martijn Hertog (aka wtravel) |
||||
18 | * @author XOOPS Development Team, |
||||
19 | */ |
||||
20 | |||||
21 | include __DIR__ . '/header.php'; |
||||
22 | require_once XOOPS_ROOT_PATH . '/class/module.errorhandler.php'; |
||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||
23 | $myts = MyTextSanitizer::getInstance(); // MyTextSanitizer object |
||||
0 ignored issues
–
show
The type
MyTextSanitizer 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 ![]() |
|||||
24 | $moddir = $xoopsModule->getVar('dirname'); |
||||
25 | |||||
26 | if (!empty($_POST['submit'])) { |
||||
27 | $eh = new ErrorHandler; //ErrorHandler object |
||||
0 ignored issues
–
show
The type
ErrorHandler 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 ![]() |
|||||
28 | if (empty($xoopsUser)) { |
||||
29 | $ratinguser = 0; |
||||
30 | } else { |
||||
31 | $ratinguser = $xoopsUser->getVar('uid'); |
||||
32 | } |
||||
33 | |||||
34 | //Make sure only 1 anonymous from an IP in a single day. |
||||
35 | $anonwaitdays = $xoopsModuleConfig['anonvotes_waitdays']; |
||||
36 | $ip = getenv('REMOTE_ADDR'); |
||||
37 | $p_itemid = (int)$_POST['item']; |
||||
38 | $p_catid = (int)$_POST['catid']; |
||||
39 | $p_rating = (int)$_POST['rating']; |
||||
40 | |||||
41 | // Check if Rating is Null |
||||
42 | if ($p_rating == '--') { |
||||
43 | redirect_header('ratelisting.php?catid=' . $p_catid . '&item=' . $itemid . '', 2, _MD_NORATING); |
||||
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
![]() |
|||||
44 | exit(); |
||||
45 | } |
||||
46 | |||||
47 | // Check if Link POSTER is voting (UNLESS Anonymous users allowed to post) |
||||
48 | if ($ratinguser != 0) { |
||||
49 | $result = $xoopsDB->query('select submitter from ' . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_items') . " where itemid=$p_itemid"); |
||||
50 | View Code Duplication | while (list($ratinguserDB) = $xoopsDB->fetchRow($result)) { |
|||
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. ![]() |
|||||
51 | if ($ratinguserDB == $ratinguser) { |
||||
52 | redirect_header('index.php', 4, _MD_CANTVOTEOWN); |
||||
53 | exit(); |
||||
54 | } |
||||
55 | } |
||||
56 | |||||
57 | // Check if REG user is trying to vote twice. |
||||
58 | $result = $xoopsDB->query('select ratinguser from ' . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_votedata') . " where itemid=$p_itemid"); |
||||
59 | View Code Duplication | while (list($ratinguserDB) = $xoopsDB->fetchRow($result)) { |
|||
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. ![]() |
|||||
60 | if ($ratinguserDB == $ratinguser) { |
||||
61 | redirect_header('index.php', 4, _MD_VOTEONCE2); |
||||
62 | exit(); |
||||
63 | } |
||||
64 | } |
||||
65 | } else { |
||||
66 | |||||
67 | // Check if ANONYMOUS user is trying to vote more than once per day. |
||||
68 | $yesterday = (time() - (86400 * $anonwaitdays)); |
||||
69 | $result = $xoopsDB->query('select count(*) FROM ' . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_votedata') . " WHERE itemid=$p_itemid AND ratinguser=0 AND ratinghostname = '$ip' AND ratingtimestamp > $yesterday"); |
||||
70 | list($anonvotecount) = $xoopsDB->fetchRow($result); |
||||
71 | if ($anonvotecount > 0) { |
||||
72 | redirect_header('index.php', 4, _MD_VOTEONCE2); |
||||
73 | exit(); |
||||
74 | } |
||||
75 | } |
||||
76 | if ($rating > 10) { |
||||
77 | $rating = 10; |
||||
78 | } |
||||
79 | |||||
80 | //Add to Line Item Rate to DB. |
||||
81 | $newid = $xoopsDB->genId($xoopsDB->prefix($module->getVar('dirname', 'n') . '_votedata') . '_ratingid_seq'); |
||||
82 | $datetime = time(); |
||||
83 | $sql = sprintf("INSERT INTO %s (ratingid, itemid, ratinguser, rating, ratinghostname, ratingtimestamp) VALUES (%u, %u, %u, %u, '%s', %u)", $xoopsDB->prefix($module->getVar('dirname', 'n') . '_votedata'), $newid, $p_itemid, $ratinguser, $p_rating, $ip, $datetime); |
||||
84 | $xoopsDB->query($sql) or $eh->show('0013'); |
||||
85 | |||||
86 | //Calculate Score & Add to Summary (for quick retrieval & sorting) to DB. |
||||
87 | updaterating($p_itemid); |
||||
88 | if (!empty($_POST['catid'])) { |
||||
89 | $p_catid = (int)$_POST['catid']; |
||||
90 | } else { |
||||
91 | $p_catid = 0; |
||||
92 | } |
||||
93 | if (!empty($_POST['dirid'])) { |
||||
94 | $p_dirid = (int)$_POST['dirid']; |
||||
95 | } else { |
||||
96 | $p_dirid = 0; |
||||
97 | } |
||||
98 | if ($p_dirid == 0) { |
||||
99 | $dirid = getDirIdFromItem($p_itemid); |
||||
100 | } else { |
||||
101 | $dirid = $p_dirid; |
||||
102 | } |
||||
103 | $ratemessage = _MD_VOTEAPPRE . '<br>' . sprintf(_MD_THANKURATE, $xoopsConfig['sitename']); |
||||
104 | redirect_header('index.php?dirid=' . $dirid . '', 2, $ratemessage); |
||||
105 | exit(); |
||||
106 | } else { |
||||
107 | $GLOBALS['xoopsOption']['template_main'] = 'efqdiralpha1_ratelisting.tpl'; |
||||
108 | include XOOPS_ROOT_PATH . '/header.php'; |
||||
109 | if (isset($_GET['item'])) { |
||||
110 | $get_itemid = (int)$_GET['item']; |
||||
111 | } else { |
||||
112 | $get_itemid = '0'; |
||||
113 | } |
||||
114 | if (isset($_GET['catid'])) { |
||||
115 | $get_catid = (int)$_GET['catid']; |
||||
116 | } else { |
||||
117 | $get_catid = '0'; |
||||
118 | } |
||||
119 | |||||
120 | $result = $xoopsDB->query('select title from ' . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_listings') . " where itemid=$get_itemid"); |
||||
121 | list($title) = $xoopsDB->fetchRow($result); |
||||
122 | $xoopsTpl->assign('listing', array('itemid' => $get_itemid, 'catid' => $get_catid, 'title' => $myts->htmlSpecialChars($title))); |
||||
123 | $xoopsTpl->assign('moddir', $moddir); |
||||
124 | $xoopsTpl->assign('lang_voteonce', _MD_VOTEONCE); |
||||
125 | $xoopsTpl->assign('lang_ratingscale', _MD_RATINGSCALE); |
||||
126 | $xoopsTpl->assign('lang_beobjective', _MD_BEOBJECTIVE); |
||||
127 | $xoopsTpl->assign('lang_donotvote', _MD_DONOTVOTE); |
||||
128 | $xoopsTpl->assign('lang_rateit', _MD_RATEIT); |
||||
129 | $xoopsTpl->assign('lang_cancel', _CANCEL); |
||||
0 ignored issues
–
show
|
|||||
130 | include XOOPS_ROOT_PATH . '/footer.php'; |
||||
131 | } |
||||
132 |