mambax7 /
wflinks
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 | * Module: WF-Links |
||
| 5 | * Version: v1.0.3 |
||
| 6 | * Release Date: 21 June 2005 |
||
| 7 | * Developer: John N |
||
| 8 | * Team: WF-Projects |
||
| 9 | * Licence: GNU |
||
| 10 | */ |
||
| 11 | |||
| 12 | require_once __DIR__ . '/header.php'; |
||
| 13 | |||
| 14 | global $wfmyts, $xoTheme; |
||
|
0 ignored issues
–
show
|
|||
| 15 | |||
| 16 | // Check if linkload POSTER is voting (UNLESS Anonymous users allowed to post) |
||
| 17 | $lid = WfLinksUtility::cleanRequestVars($_REQUEST, 'lid', 0); |
||
| 18 | $lid = (int)$lid; |
||
| 19 | |||
| 20 | $ip = getenv('REMOTE_ADDR'); |
||
| 21 | $ratinguser = (!is_object($xoopsUser)) ? 0 : $xoopsUser->getVar('uid'); |
||
| 22 | |||
| 23 | if ($ratinguser != 0) { |
||
| 24 | $result = $xoopsDB->query('SELECT cid, submitter FROM ' . $xoopsDB->prefix('wflinks_links') . ' WHERE lid=' . $lid); |
||
| 25 | while (list($cid, $ratinguserDB) = $xoopsDB->fetchRow($result)) { |
||
| 26 | if ($ratinguserDB == $ratinguser) { |
||
| 27 | $ratemessage = _MD_WFL_CANTVOTEOWN; |
||
| 28 | redirect_header('singlelink.php?cid=' . (int)$cid . '&lid=' . $lid, 4, $ratemessage); |
||
| 29 | } |
||
| 30 | } |
||
| 31 | // Check if REG user is trying to vote twice. |
||
| 32 | $result = $xoopsDB->query('SELECT cid, ratinguser FROM ' . $xoopsDB->prefix('wflinks_votedata') . ' WHERE lid=' . $lid); |
||
| 33 | while (list($cid, $ratinguserDB) = $xoopsDB->fetchRow($result)) { |
||
| 34 | if ($ratinguserDB == $ratinguser) { |
||
| 35 | $ratemessage = _MD_WFL_VOTEONCE; |
||
| 36 | redirect_header('singlelink.php?cid=' . (int)$cid . '&lid=' . $lid, 4, $ratemessage); |
||
| 37 | } |
||
| 38 | } |
||
| 39 | } else { |
||
| 40 | // Check if ANONYMOUS user is trying to vote more than once per day. |
||
| 41 | $yesterday = (time() - (86400 * $anonwaitdays)); |
||
| 42 | $result = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('wflinks_votedata') . ' WHERE lid=' . $lid . ' AND ratinguser=0 AND ratinghostname=' . $ip . ' AND ratingtimestamp > ' . $yesterday); |
||
| 43 | list($anonvotecount) = $xoopsDB->fetchRow($result); |
||
| 44 | if ($anonvotecount >= 1) { |
||
| 45 | redirect_header('singlelink.php?cid=' . (int)$cid . '&lid=' . $lid, 4, _MD_WFL_VOTEONCE); |
||
| 46 | } |
||
| 47 | } |
||
| 48 | |||
| 49 | if (!empty($_POST['submit'])) { |
||
| 50 | $ratinguser = (!is_object($xoopsUser)) ? 0 : $xoopsUser->getVar('uid'); |
||
| 51 | // Make sure only 1 anonymous from an IP in a single day. |
||
| 52 | $anonwaitdays = 1; |
||
| 53 | $ip = getenv('REMOTE_ADDR'); |
||
| 54 | $lid = WfLinksUtility::cleanRequestVars($_REQUEST, 'lid', 0); |
||
| 55 | $cid = WfLinksUtility::cleanRequestVars($_REQUEST, 'cid', 0); |
||
| 56 | $rating = WfLinksUtility::cleanRequestVars($_REQUEST, 'rating', 0); |
||
| 57 | $title = $wfmyts->addSlashes(trim($_POST['title'])); |
||
| 58 | $lid = (int)$lid; |
||
| 59 | $cid = (int)$cid; |
||
| 60 | $rating = (int)$rating; |
||
| 61 | // Check if Rating is Null |
||
| 62 | if ($rating == '--') { |
||
| 63 | redirect_header('ratelink.php?cid=' . $cid . '&lid=' . $lid, 4, _MD_WFL_NORATING); |
||
| 64 | } |
||
| 65 | // All is well. Add to Line Item Rate to DB. |
||
| 66 | $newid = $xoopsDB->genId($xoopsDB->prefix('wflinks_votedata') . '_ratingid_seq'); |
||
| 67 | $datetime = time(); |
||
| 68 | $sql = sprintf('INSERT INTO %s (ratingid, lid, ratinguser, rating, ratinghostname, ratingtimestamp, title) VALUES (%u, %u, %u, %u, %s, %u, %s)', $xoopsDB->prefix('wflinks_votedata'), $newid, $lid, $ratinguser, $rating, $xoopsDB->quoteString($ip), $datetime, $xoopsDB->quoteString($title)); |
||
| 69 | if (!$result = $xoopsDB->query($sql)) { |
||
| 70 | $ratemessage = _MD_WFL_ERROR; |
||
| 71 | } else { |
||
| 72 | // All is well. Calculate Score & Add to Summary (for quick retrieval & sorting) to DB. |
||
| 73 | WfLinksUtility::updateRating($lid); |
||
| 74 | $ratemessage = _MD_WFL_VOTEAPPRE . '<br>' . sprintf(_MD_WFL_THANKYOU, $xoopsConfig['sitename']); |
||
| 75 | } |
||
| 76 | redirect_header('singlelink.php?cid=' . $cid . '&lid=' . $lid, 4, $ratemessage); |
||
| 77 | } else { |
||
| 78 | $GLOBALS['xoopsOption']['template_main'] = 'wflinks_ratelink.tpl'; |
||
| 79 | include XOOPS_ROOT_PATH . '/header.php'; |
||
| 80 | |||
| 81 | $catarray['imageheader'] = WfLinksUtility::getImageHeader(); |
||
| 82 | $cid = WfLinksUtility::cleanRequestVars($_REQUEST, 'cid', 0); |
||
| 83 | $cid = (int)$cid; |
||
| 84 | |||
| 85 | $catarray['imageheader'] = WfLinksUtility::getImageHeader(); |
||
| 86 | $catarray['letters'] = WfLinksUtility::getLetters(); |
||
| 87 | $catarray['toolbar'] = WfLinksUtility::getToolbar(); |
||
| 88 | $xoopsTpl->assign('catarray', $catarray); |
||
| 89 | |||
| 90 | $result = $xoopsDB->query('SELECT title FROM ' . $xoopsDB->prefix('wflinks_links') . ' WHERE lid=' . $lid); |
||
| 91 | list($title) = $xoopsDB->fetchRow($result); |
||
| 92 | $xoopsTpl->assign('link', array('id' => $lid, 'cid' => $cid, 'title' => $wfmyts->htmlSpecialCharsStrip($title))); |
||
| 93 | |||
| 94 | if (is_object($xoTheme)) { |
||
| 95 | $xoTheme->addMeta('meta', 'robots', 'noindex,nofollow'); |
||
| 96 | } else { |
||
| 97 | $xoopsTpl->assign('xoops_meta_robots', 'noindex,nofollow'); |
||
| 98 | } |
||
| 99 | |||
| 100 | $xoopsTpl->assign('module_dir', $xoopsModule->getVar('dirname')); |
||
| 101 | include XOOPS_ROOT_PATH . '/footer.php'; |
||
| 102 | } |
||
| 103 | |||
| 104 | if (is_object($xoTheme)) { |
||
| 105 | $xoTheme->addMeta('meta', 'robots', 'noindex,nofollow'); |
||
| 106 | } else { |
||
| 107 | $xoopsTpl->assign('xoops_meta_robots', 'noindex,nofollow'); |
||
| 108 | } |
||
| 109 | |||
| 110 | $xoopsTpl->assign('module_dir', $xoopsModule->getVar('dirname')); |
||
| 111 | include XOOPS_ROOT_PATH . '/footer.php'; |
||
| 112 |
Instead of relying on
globalstate, we recommend one of these alternatives:1. Pass all data via parameters
2. Create a class that maintains your state