// // ------------------------------------------------------------------------- // // Original Author: James Knickelbein // Author Website : http://www.journeymilwaukee.com // License Type : GPL: See /manual/LICENSES/GPL.txt // ------------------------------------------------------------------------- // include_once("header.php"); include_once(XOOPS_ROOT_PATH."/class/module.errorhandler.php"); if ($_POST['submit']) { $eh = new ErrorHandler(); if (!$xoopsUser) { $ratinguser = 0; } else { $ratinguser = $xoopsUser->uid(); } //Make sure only 1 anonymous from an IP in a single day. $anonwaitdays = 1; $ip = _REMOTE_ADDR; $lid = intval($_POST['lid']); $rating = intval($_POST['rating']); // Check if Rating is Null if ($rating=="--") { redirect_header("ratelink.php?lid=".$lid."", 4, _NORATINGSELECTED); exit(); } // Check if Link POSTER is voting (UNLESS Anonymous users allowed to post) if ($ratinguser != 0) { $result = $db->query("SELECT submitter FROM ".$db->prefix("mylinks_links")." WHERE lid=$lid"); while (list($ratinguserDB) = $db->fetchRow($result)) { if ($ratinguserDB == $ratinguser) { redirect_header("index.php", 4, _CANTVOTEYOURSELF); exit(); } } // Check if REG user is trying to vote twice. $result = $db->query("SELECT ratinguser FROM ".$db->prefix("mylinks_votedata")." WHERE lid=$lid"); while (list($ratinguserDB) = $db->fetchRow($result)) { if ($ratinguserDB == $ratinguser) { redirect_header("index.php", 4, _MD_VOTEONCE2); exit(); } } } // Check if ANONYMOUS user is trying to vote more than once per day. if ($ratinguser == 0) { $yesterday = (time()-(86400 * $anonwaitdays)); $result = $db->query("SELECT COUNT(*) FROM ".$db->prefix("mylinks_votedata")." WHERE lid=$lid AND ratinguser=0 AND ratinghostname='$ip' AND ratingtimestamp>$yesterday"); list($anonvotecount) = $db->fetchRow($result); if ($anonvotecount > 0) { redirect_header("index.php", 4, _MD_VOTEONCE2); exit(); } } if ($rating > 10) { $rating = 10; } //All is well. Add to Line Item Rate to DB. $newid = $db->genId($db->prefix("mylinks_votedata")."_ratingid_seq"); $datetime = time(); $db->query("INSERT INTO ".$db->prefix("mylinks_votedata")." SET ratingid=$newid, lid=$lid, ratinguser=$ratinguser, rating=$rating, ratinghostname='$ip', ratingtimestamp=$datetime") or $eh->show("0013"); //All is well. Calculate Score & Add to Summary (for quick retrieval & sorting) to DB. updaterating($lid); $ratemessage = _VOTEAPPRECTIATED."
".sprintf(_MD_THANKURATE, $bcoosConfig['title']); redirect_header("index.php", 2, $ratemessage); exit(); } else { include_once(XOOPS_ROOT_PATH."/header.php"); OpenTable(); mainheader(); $result = $db->query("SELECT title FROM ".$db->prefix("mylinks_links")." WHERE lid=$lid"); list($title) = $db->fetchRow($result); $title = $myts->makeTboxData4Show($title); ?>

"; CloseTable(); } include_once("footer.php"); ?>