";
CloseTable();
require('footer.php');
}
function addrating() {
global $module_name, $linksprefix, $db, $userinfo, $anonymous;
$ratinglid = intval($_POST['ratinglid']);
$ratinguser = $_POST['ratinguser'];
$rating = intval($_POST['rating']);
$ratingcomments = $_POST['ratingcomments'];
list($ttitle) = $db->sql_ufetchrow("SELECT title FROM ".$linksprefix."_links WHERE lid=$ratinglid");
$passtest = "yes";
require_once('header.php');
include("modules/$module_name/l_config.php"); completevoteheader();
if(is_user()) {
$ratinguser = $userinfo['username'];
} else if ($ratinguser=="outside") {
$ratinguser = "outside";
} else {
$ratinguser = $anonymous;
}
/* Make sure only 1 anonymous from an IP in a single day. */
$ip = $userinfo['user_ip'];
/* Check if Rating is Null */
if ($rating=="--") {
$error = "nullerror";
completevote($error);
$passtest = "no";
}
/* Check if Link POSTER is voting (UNLESS Anonymous users allowed to post) */
if ($ratinguser != $anonymous && $ratinguser != "outside") {
$result = $db->sql_query("select submitter from ".$linksprefix."_links where lid=$ratinglid",false,__FILE__,__LINE__);
while(list($ratinguserDB)= $db->sql_fetchrow($result)) {
if ($ratinguserDB==$ratinguser) {
$error = "postervote";
completevote($error);
$passtest = "no";
}
}
}
/* Check if REG user is trying to vote twice. */
if ($ratinguser!=$anonymous && $ratinguser != "outside") {
$result = $db->sql_query("select ratinguser from ".$linksprefix."_votedata where ratinglid=$ratinglid",false,__FILE__,__LINE__);
while(list($ratinguserDB)= $db->sql_fetchrow($result)) {
if ($ratinguserDB==$ratinguser) {
$error = "regflood";
completevote($error);
$passtest = "no";
}
}
}
/* Check if ANONYMOUS user is trying to vote more than once per day. */
if ($ratinguser==$anonymous){
$yesterdaytimestamp = (time()-(86400 * $anonwaitdays));
$ytsDB = Date("Y-m-d H:i:s", $yesterdaytimestamp);
$result = $db->sql_query("select * FROM ".$linksprefix."_votedata WHERE ratinglid=$ratinglid AND ratinguser='"._ANONYMOUS."' AND ratinghostname = '$ip' AND TO_DAYS(NOW()) - TO_DAYS(ratingtimestamp) < $anonwaitdays",false,__FILE__,__LINE__);
$anonvotecount = $db->sql_numrows($result);
if ($anonvotecount >= 1) {
$error = "anonflood";
completevote($error);
$passtest = "no";
}
}
/* Check if OUTSIDE user is trying to vote more than once per day. */
if ($ratinguser=="outside"){
$yesterdaytimestamp = (time()-(86400 * $outsidewaitdays));
$ytsDB = Date("Y-m-d H:i:s", $yesterdaytimestamp);
$result = $db->sql_query("select * FROM ".$linksprefix."_votedata WHERE ratinglid=$ratinglid AND ratinguser='outside' AND ratinghostname = '$ip' AND TO_DAYS(NOW()) - TO_DAYS(ratingtimestamp) < $outsidewaitdays",false,__FILE__,__LINE__);
$outsidevotecount = $db->sql_numrows($result);
if ($outsidevotecount >= 1) {
$error = "outsideflood";
completevote($error);
$passtest = "no";
}
}
/* Passed Tests */
if ($passtest == "yes") {
$ratingcomments = Fix_Quotes($ratingcomments);
$ratinguser = Fix_Quotes($ratinguser);
/* All is well. Add to Line Item Rate to DB. */
$db->sql_query("INSERT into ".$linksprefix."_votedata values (NULL,'$ratinglid', '$ratinguser', '$rating', '$ip', '$ratingcomments', now())",false,__FILE__,__LINE__);
/* All is well. Calculate Score & Add to Summary (for quick retrieval & sorting) to DB. */
/* NOTE: If weight is modified, ALL links need to be refreshed with new weight. */
/* Running a SQL statement with your modded calc for ALL links will accomplish this. */
$voteresult = $db->sql_query("select rating, ratinguser, ratingcomments FROM ".$linksprefix."_votedata WHERE ratinglid = $ratinglid",false,__FILE__,__LINE__);
$totalvotesDB = $db->sql_numrows($voteresult);
require("modules/$module_name/voteinclude.php");
$db->sql_query("UPDATE ".$linksprefix."_links SET linkratingsummary=$finalrating,totalvotes=$totalvotesDB,totalcomments=$truecomments WHERE lid = $ratinglid",false,__FILE__,__LINE__);
$error = "none";
completevote($error);
}
completevotefooter($ratinglid, $ttitle, $ratinguser);
require('footer.php');
}
function outsidelinksetup($lid) {
global $module_name, $sitename, $nukeurl, $BASEHREF, $mainindex;
require_once('header.php');
include("modules/$module_name/l_config.php");
menu(1);
echo ' ';
OpenTable();
$promo1 = ''._RATETHISSITE.' @ '.$sitename.'';
$promo2 = '';
$promo3 = '';
echo '