1 | <?php |
||
2 | /* |
||
3 | ------------------------------------------------------------------------- |
||
4 | ADSLIGHT 2 : Module for Xoops |
||
5 | |||
6 | Redesigned and ameliorate By Luc Bizet user at www.frxoops.org |
||
7 | Started with the Classifieds module and made MANY changes |
||
8 | Website : http://www.luc-bizet.fr |
||
9 | Contact : [email protected] |
||
10 | ------------------------------------------------------------------------- |
||
11 | Original credits below Version History |
||
12 | ########################################################################## |
||
13 | # Classified Module for Xoops # |
||
14 | # By John Mordo user jlm69 at www.xoops.org and www.jlmzone.com # |
||
15 | # Started with the MyAds module and made MANY changes # |
||
16 | ########################################################################## |
||
17 | Original Author: Pascal Le Boustouller |
||
18 | Author Website : [email protected] |
||
19 | Licence Type : GPL |
||
20 | ------------------------------------------------------------------------- |
||
21 | */ |
||
22 | |||
23 | use Xmf\Request; |
||
24 | |||
25 | require_once __DIR__ . '/header.php'; |
||
26 | //require_once XOOPS_ROOT_PATH . '/class/module.errorhandler.php'; |
||
27 | $myts = \MyTextSanitizer::getInstance(); // MyTextSanitizer object |
||
28 | if (!empty($_POST['submit'])) { |
||
29 | // $erh = new ErrorHandler; //ErrorHandler object |
||
30 | $ratinguser = ($GLOBALS['xoopsUser'] instanceof \XoopsUser) ? $GLOBALS['xoopsUser']->getVar('uid') : 0; |
||
31 | |||
32 | $anonwaitdays = 1; // Make sure only 1 anonymous rating from an IP in a single day. |
||
33 | $ip = getenv('REMOTE_ADDR'); |
||
34 | $lid = Request::getInt('lid', 0, 'POST'); |
||
35 | $rating = Request::getInt('rating', 0, 'POST'); |
||
36 | |||
37 | // Check if Rating is Null |
||
38 | if ('--' == $rating) { |
||
39 | redirect_header('rate-item.php?lid=' . $lid . '', 4, constant('_ADSLIGHT_NORATING')); |
||
40 | } |
||
41 | |||
42 | // Check if Link POSTER is voting (UNLESS Anonymous users allowed to post) |
||
43 | if (0 != $ratinguser) { |
||
44 | $result = $xoopsDB->query('SELECT submitter FROM ' . $xoopsDB->prefix('adslight_listing') . ' WHERE lid=' . $xoopsDB->escape($lid)); |
||
45 | while (false !== (list($ratinguserDB) = $xoopsDB->fetchRow($result))) { |
||
46 | if ($ratinguserDB == $ratinguser) { |
||
47 | redirect_header('viewads.php?lid=' . $lid . '', 4, constant('_ADSLIGHT_CANTVOTEOWN')); |
||
48 | } |
||
49 | } |
||
50 | |||
51 | // Check if REG user is trying to vote twice. |
||
52 | $result = $xoopsDB->query('SELECT ratinguser FROM ' . $xoopsDB->prefix('adslight_item_votedata') . ' WHERE lid=' . $xoopsDB->escape($lid)); |
||
53 | while (false !== (list($ratinguserDB) = $xoopsDB->fetchRow($result))) { |
||
54 | if ($ratinguserDB == $ratinguser) { |
||
55 | redirect_header('viewads.php?lid=' . $lid . '', 4, constant('_ADSLIGHT_VOTEONCE2')); |
||
56 | } |
||
57 | } |
||
58 | } else { |
||
59 | // Check if ANONYMOUS user is trying to vote more than once per day. |
||
60 | $yesterday = (time() - (86400 * $anonwaitdays)); |
||
61 | $result = $xoopsDB->query('SELECT count(*) FROM ' . $xoopsDB->prefix('adslight_item_votedata') . ' WHERE lid=' . $xoopsDB->escape($lid) . " AND ratinguser=0 AND ratinghostname = '$ip' AND ratingtimestamp > $yesterday"); |
||
62 | list($anonvotecount) = $xoopsDB->fetchRow($result); |
||
63 | if ($anonvotecount > 0) { |
||
64 | redirect_header('viewads.php?lid=' . $lid . '', 4, constant('_ADSLIGHT_VOTEONCE2')); |
||
65 | } |
||
66 | } |
||
67 | $rating = ($rating > 10) ? 10 : $rating; |
||
68 | |||
69 | //All is well. Add to Line Item Rate to DB. |
||
70 | $newid = $xoopsDB->genId($xoopsDB->prefix('adslight_item_votedata') . '_ratingid_seq'); |
||
71 | $datetime = time(); |
||
72 | $sql = sprintf("INSERT INTO `%s` (ratingid, lid, ratinguser, rating, ratinghostname, ratingtimestamp) VALUES (%u, %u, %u, %u, '%s', %u)", $xoopsDB->prefix('adslight_item_votedata'), $newid, $lid, $ratinguser, $rating, $ip, $datetime); |
||
73 | // $xoopsDB->query($sql) || $eh->show('0013'); // '0013' => 'Could not query the database.', // <br>Error: ' . $GLOBALS['xoopsDB']->error() . '', |
||
74 | $success = $xoopsDB->query($sql); |
||
75 | if (!$success) { |
||
76 | $moduleHandler = $helper->getHandler('Module'); |
||
77 | $myModule = $moduleHandler->getByDirname('adslight'); |
||
78 | $myModule->setErrors('Could not query the database.'); |
||
79 | } |
||
80 | |||
81 | //All is well. Calculate Score & Add to Summary (for quick retrieval & sorting) to DB. |
||
82 | // updateIrating($lid); |
||
83 | Adslight\Utility::updateItemRating($lid); |
||
0 ignored issues
–
show
|
|||
84 | $ratemessage = constant('_ADSLIGHT_VOTEAPPRE') . '<br>' . sprintf(constant('_ADSLIGHT_THANKURATEITEM'), $xoopsConfig['sitename']); |
||
85 | redirect_header('viewads.php?lid=' . $lid . '', 3, $ratemessage); |
||
86 | } else { |
||
87 | $GLOBALS['xoopsOption']['template_main'] = 'adslight_rate_item.tpl'; |
||
88 | require_once XOOPS_ROOT_PATH . '/header.php'; |
||
89 | $lid = Request::getInt('lid', 0, 'GET'); |
||
90 | $result = $xoopsDB->query('SELECT lid, title FROM ' . $xoopsDB->prefix('adslight_listing') . ' WHERE lid=' . $xoopsDB->escape($lid)); |
||
91 | list($lid, $title) = $xoopsDB->fetchRow($result); |
||
92 | $GLOBALS['xoopsTpl']->assign('link', [ |
||
93 | 'lid' => $lid, |
||
94 | 'title' => $myts->htmlSpecialChars($title), |
||
95 | ]); |
||
96 | $GLOBALS['xoopsTpl']->assign('lang_voteonce', constant('_ADSLIGHT_VOTEONCE')); |
||
97 | $GLOBALS['xoopsTpl']->assign('lang_ratingscale', constant('_ADSLIGHT_RATINGSCALE')); |
||
98 | $GLOBALS['xoopsTpl']->assign('lang_beobjective', constant('_ADSLIGHT_BEOBJECTIVE')); |
||
99 | $GLOBALS['xoopsTpl']->assign('lang_donotvote', constant('_ADSLIGHT_DONOTVOTE')); |
||
100 | $GLOBALS['xoopsTpl']->assign('lang_rateit', constant('_ADSLIGHT_RATEIT')); |
||
101 | $GLOBALS['xoopsTpl']->assign('lang_cancel', _CANCEL); |
||
102 | $GLOBALS['xoopsTpl']->assign('mydirname', $moduleDirName); |
||
103 | require_once XOOPS_ROOT_PATH . '/footer.php'; |
||
104 | } |
||
105 |
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