mambax7 /
adslight
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 | use Xmf\Request; |
||
| 24 | |||
| 25 | include_once __DIR__ . '/header.php'; |
||
| 26 | //include_once XOOPS_ROOT_PATH . '/class/module.errorhandler.php'; |
||
| 27 | $myts = MyTextSanitizer::getInstance(); // MyTextSanitizer object |
||
| 28 | //include_once XOOPS_ROOT_PATH . '/modules/adslight/class/utilities.php'; |
||
| 29 | if (!empty($HTTP_POST_VARS['submit'])) { |
||
| 30 | // $erh = new ErrorHandler; //ErrorHandler object |
||
| 31 | $ratinguser = ($GLOBALS['xoopsUser'] instanceof XoopsUser) ? $GLOBALS['xoopsUser']->getVar('uid') : 0; |
||
| 32 | |||
| 33 | //Make sure only 1 anonymous from an IP in a single day. |
||
| 34 | $anonwaitdays = 1; |
||
| 35 | $ip = getenv('REMOTE_ADDR'); |
||
| 36 | $usid = Request::getInt('usid', 0, 'POST'); |
||
| 37 | $rating = Request::getInt('rating', 0, 'POST'); |
||
| 38 | |||
| 39 | // Check if Rating is Null |
||
| 40 | if ($rating == '--') { |
||
| 41 | redirect_header('rate-user.php?usid=' . addslashes($usid) . '', 4, constant('_ADSLIGHT_NORATING')); |
||
| 42 | } |
||
| 43 | |||
| 44 | // Check if Link POSTER is voting (UNLESS Anonymous users allowed to post) |
||
| 45 | if ($ratinguser != 0) { |
||
| 46 | $result = $xoopsDB->query('SELECT submitter FROM ' . $xoopsDB->prefix('adslight_listing') . ' WHERE usid=' . $xoopsDB->escape($usid)); |
||
| 47 | View Code Duplication | while (list($ratinguserDB) = $xoopsDB->fetchRow($result)) { |
|
|
1 ignored issue
–
show
|
|||
| 48 | if ($ratinguserDB == $ratinguser) { |
||
| 49 | redirect_header('members.php?usid=' . addslashes($usid) . '', 4, constant('_ADSLIGHT_CANTVOTEOWN')); |
||
| 50 | } |
||
| 51 | } |
||
| 52 | |||
| 53 | // Check if REG user is trying to vote twice. |
||
| 54 | $result = $xoopsDB->query('SELECT ratinguser FROM ' . $xoopsDB->prefix('adslight_user_votedata') . ' WHERE usid=' . $xoopsDB->escape($usid)); |
||
| 55 | View Code Duplication | while (list($ratinguserDB) = $xoopsDB->fetchRow($result)) { |
|
| 56 | if ($ratinguserDB == $ratinguser) { |
||
| 57 | redirect_header('members.php?usid=' . addslashes($usid) . '', 4, constant('_ADSLIGHT_VOTEONCE2')); |
||
| 58 | } |
||
| 59 | } |
||
| 60 | 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. Loading history...
|
|||
| 61 | |||
| 62 | // Check if ANONYMOUS user is trying to vote more than once per day. |
||
| 63 | $yesterday = (time() - (86400 * $anonwaitdays)); |
||
| 64 | $result = $xoopsDB->query('SELECT count(*) FROM ' |
||
| 65 | . $xoopsDB->prefix('adslight_user_votedata') |
||
| 66 | . ' WHERE usid=' |
||
| 67 | . $xoopsDB->escape($usid) |
||
| 68 | . " AND ratinguser=0 AND ratinghostname = '$ip' AND ratingtimestamp > $yesterday"); |
||
| 69 | list($anonvotecount) = $xoopsDB->fetchRow($result); |
||
| 70 | if ($anonvotecount > 0) { |
||
| 71 | redirect_header('members.php?usid=' . addslashes($usid) . '', 4, constant('_ADSLIGHT_VOTEONCE2')); |
||
| 72 | } |
||
| 73 | } |
||
| 74 | $rating = ($rating > 10) ? 10 : $rating; |
||
| 75 | |||
| 76 | //All is well. Add to Line Item Rate to DB. |
||
| 77 | $newid = $xoopsDB->genId($xoopsDB->prefix('adslight_user_votedata') . '_ratingid_seq'); |
||
| 78 | $datetime = time(); |
||
| 79 | $sql = sprintf("INSERT INTO %s (ratingid, usid, ratinguser, rating, ratinghostname, ratingtimestamp) VALUES (%u, %u, %u, %u, '%s', %u)", $xoopsDB->prefix('adslight_user_votedata'), $newid, |
||
| 80 | $usid, $ratinguser, $rating, $ip, $datetime); |
||
| 81 | // $xoopsDB->query($sql) || $erh->show('0013'); // '0013' => 'Could not query the database.', // <br>Error: ' . mysql_error() . '', |
||
| 82 | $success = $xoopsDB->query($sql); |
||
| 83 | View Code Duplication | if (!$success) { |
|
| 84 | $modHandler = xoops_getModuleHandler('module'); |
||
| 85 | $myModule = $modHandler->getByDirname('adslight'); |
||
| 86 | $myModule->setErrors('Could not query the database.'); |
||
| 87 | } |
||
| 88 | |||
| 89 | //All is well. Calculate Score & Add to Summary (for quick retrieval & sorting) to DB. |
||
| 90 | // updateUrating($usid); |
||
|
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. Loading history...
|
|||
| 91 | AdslightUtilities::updateUserRating($usid); |
||
| 92 | $ratemessage = constant('_ADSLIGHT_VOTEAPPRE') . '<br>' . sprintf(constant('_ADSLIGHT_THANKURATEUSER'), $xoopsConfig['sitename']); |
||
| 93 | redirect_header('members.php?usid=' . addslashes($usid) . '', 3, $ratemessage); |
||
| 94 | 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. Loading history...
|
|||
| 95 | $GLOBALS['xoopsOption']['template_main'] = 'adslight_rate_user.tpl'; |
||
| 96 | include XOOPS_ROOT_PATH . '/header.php'; |
||
| 97 | $usid = Request::getInt('usid', 0, 'GET'); |
||
| 98 | $result = $xoopsDB->query('SELECT title, usid, submitter FROM ' . $xoopsDB->prefix('adslight_listing') . ' WHERE usid=' . $xoopsDB->escape($usid)); |
||
| 99 | list($title, $usid, $submitter) = $xoopsDB->fetchRow($result); |
||
| 100 | $xoopsTpl->assign('link', array('usid' => $usid, 'title' => $myts->htmlSpecialChars($title), 'submitter' => $submitter)); |
||
| 101 | $xoopsTpl->assign('lang_voteonce', constant('_ADSLIGHT_VOTEONCE')); |
||
| 102 | $xoopsTpl->assign('lang_ratingscale', constant('_ADSLIGHT_RATINGSCALE')); |
||
| 103 | $xoopsTpl->assign('lang_beobjective', constant('_ADSLIGHT_BEOBJECTIVE')); |
||
| 104 | $xoopsTpl->assign('lang_donotvote', constant('_ADSLIGHT_DONOTVOTE')); |
||
| 105 | $xoopsTpl->assign('lang_rateit', constant('_ADSLIGHT_RATEIT')); |
||
| 106 | $xoopsTpl->assign('lang_cancel', _CANCEL); |
||
| 107 | $xoopsTpl->assign('mydirname', $moduleDirName); |
||
| 108 | include XOOPS_ROOT_PATH . '/footer.php'; |
||
| 109 | } |
||
| 110 |
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.