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 | 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 | include_once __DIR__ . '/header.php'; |
||
24 | include_once XOOPS_ROOT_PATH."/class/module.errorhandler.php"; |
||
25 | $myts =& MyTextSanitizer::getInstance(); // MyTextSanitizer object |
||
26 | include_once XOOPS_ROOT_PATH."/modules/adslight/include/functions.php"; |
||
27 | if (!empty($HTTP_POST_VARS['submit'])) { |
||
28 | $eh = new ErrorHandler; //ErrorHandler object |
||
29 | if (empty($xoopsUser)) { |
||
30 | $ratinguser = 0; |
||
31 | } else { |
||
32 | $ratinguser = $xoopsUser->getVar('uid'); |
||
33 | } |
||
34 | |||
35 | //Make sure only 1 anonymous from an IP in a single day. |
||
36 | $anonwaitdays = 1; |
||
37 | $ip = getenv("REMOTE_ADDR"); |
||
38 | //$lid = intval($_POST['lid']); |
||
0 ignored issues
–
show
|
|||
39 | if (isset($_POST['lid']) ) { |
||
40 | $lid = intval($_POST['lid']); |
||
41 | } else { |
||
42 | $lid = 0; |
||
43 | } |
||
44 | $rating = intval($_POST['rating']); |
||
45 | |||
46 | // Check if Rating is Null |
||
47 | View Code Duplication | if ($rating=="--") { |
|
1 ignored issue
–
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. ![]() |
|||
48 | redirect_header("rate-item.php?lid=".$lid."",4,constant("_ADSLIGHT_NORATING")); |
||
49 | exit(); |
||
50 | } |
||
51 | |||
52 | // Check if Link POSTER is voting (UNLESS Anonymous users allowed to post) |
||
53 | if ($ratinguser != 0) { |
||
54 | $result=$xoopsDB->query("select submitter from ".$xoopsDB->prefix("adslight_listing")." where lid=".mysql_real_escape_string($lid).""); |
||
55 | while (list($ratinguserDB) = $xoopsDB->fetchRow($result)) { |
||
56 | if ($ratinguserDB == $ratinguser) { |
||
57 | redirect_header("viewads.php?lid=".$lid."",4,constant("_ADSLIGHT_CANTVOTEOWN")); |
||
58 | exit(); |
||
59 | } |
||
60 | } |
||
61 | |||
62 | // Check if REG user is trying to vote twice. |
||
63 | $result=$xoopsDB->query("select ratinguser from ".$xoopsDB->prefix("adslight_item_votedata")." where lid=".mysql_real_escape_string($lid).""); |
||
64 | View Code Duplication | while (list($ratinguserDB) = $xoopsDB->fetchRow($result)) { |
|
65 | if ($ratinguserDB == $ratinguser) { |
||
66 | redirect_header("viewads.php?lid=".$lid."",4,constant("_ADSLIGHT_VOTEONCE2")); |
||
67 | exit(); |
||
68 | } |
||
69 | } |
||
70 | |||
71 | View Code Duplication | } else { |
|
1 ignored issue
–
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. ![]() |
|||
72 | |||
73 | // Check if ANONYMOUS user is trying to vote more than once per day. |
||
74 | $yesterday = (time()-(86400 * $anonwaitdays)); |
||
75 | $result=$xoopsDB->query("select count(*) FROM ".$xoopsDB->prefix("adslight_item_votedata")." WHERE lid=".mysql_real_escape_string($lid)." AND ratinguser=0 AND ratinghostname = '$ip' AND ratingtimestamp > $yesterday"); |
||
76 | list($anonvotecount) = $xoopsDB->fetchRow($result); |
||
77 | if ($anonvotecount > 0) { |
||
78 | redirect_header("viewads.php?lid=".$lid."",4,constant("_ADSLIGHT_VOTEONCE2")); |
||
79 | exit(); |
||
80 | } |
||
81 | } |
||
82 | if ($rating > 10) { |
||
83 | $rating = 10; |
||
84 | } |
||
85 | |||
86 | //All is well. Add to Line Item Rate to DB. |
||
87 | $newid = $xoopsDB->genId($xoopsDB->prefix("adslight_item_votedata")."_ratingid_seq"); |
||
88 | $datetime = time(); |
||
89 | $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); |
||
90 | $xoopsDB->query($sql) || $eh->show("0013"); |
||
91 | |||
92 | //All is well. Calculate Score & Add to Summary (for quick retrieval & sorting) to DB. |
||
93 | updateIrating($lid); |
||
94 | $ratemessage = constant("_ADSLIGHT_VOTEAPPRE")."<br />".sprintf(constant("_ADSLIGHT_THANKURATEITEM"),$xoopsConfig['sitename']); |
||
95 | redirect_header("viewads.php?lid=".$lid."",3,$ratemessage); |
||
96 | exit(); |
||
97 | |||
98 | View Code Duplication | } else { |
|
1 ignored issue
–
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. ![]() |
|||
99 | |||
100 | $xoopsOption['template_main'] = "adslight_rate_item.tpl"; |
||
101 | include XOOPS_ROOT_PATH."/header.php"; |
||
102 | //$lid = intval($_GET['lid']); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
67% 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. ![]() |
|||
103 | if (isset($_GET['lid']) ) { |
||
104 | $lid = intval($_GET['lid']); |
||
105 | } else { |
||
106 | $lid = 0; |
||
107 | } |
||
108 | $result=$xoopsDB->query("select lid, title from ".$xoopsDB->prefix("adslight_listing")." where lid=".mysql_real_escape_string($lid).""); |
||
109 | list($lid, $title) = $xoopsDB->fetchRow($result); |
||
110 | $xoopsTpl->assign('link', array('lid' => $lid, 'title' => $myts->htmlSpecialChars($title))); |
||
111 | $xoopsTpl->assign('lang_voteonce', constant("_ADSLIGHT_VOTEONCE")); |
||
112 | $xoopsTpl->assign('lang_ratingscale', constant("_ADSLIGHT_RATINGSCALE")); |
||
113 | $xoopsTpl->assign('lang_beobjective', constant("_ADSLIGHT_BEOBJECTIVE")); |
||
114 | $xoopsTpl->assign('lang_donotvote', constant("_ADSLIGHT_DONOTVOTE")); |
||
115 | $xoopsTpl->assign('lang_rateit', constant("_ADSLIGHT_RATEIT")); |
||
116 | $xoopsTpl->assign('lang_cancel', _CANCEL); |
||
117 | $xoopsTpl->assign('mydirname', $moduleDirName); |
||
118 | include XOOPS_ROOT_PATH.'/footer.php'; |
||
119 | } |
||
120 |
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.