$displaytitle" ."
' ."" ."" .""; } else { echo ""; } echo "
" ."" .""._RATETHISRECIPES." " ."" ."" ."

"; if (is_user()) { echo ""._RSCOMMENTS.":
" ."


" ."
"; echo "
"; /*********************** recipesfooterchild($lid); echo "
"; ************************/ CloseTable(); recipesshowfooter(); } function addrating() { global $module_name, $recipesprefix, $db, $userinfo, $anonymous, $recipesconfig; $ratinglid = intval($_POST['ratinglid']); $ratinguser = $_POST['ratinguser']; $rating = intval($_POST['rating']); $ratingcomments = $_POST['ratingcomments']; list($ttitle) = $db->sql_ufetchrow("SELECT title FROM ".$recipesprefix."_recipes WHERE lid=$ratinglid"); $passtest = "yes"; //include("modules/$module_name/r_config.php"); recipesshowheader(); 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 recipes POSTER is voting (UNLESS Anonymous users allowed to post) */ if ($ratinguser != $anonymous && $ratinguser != "outside") { $result = $db->sql_query("select submitter from ".$recipesprefix."_recipes 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 ".$recipesprefix."_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 * $recipesconfig['anonwaitdays'])); $ytsDB = Date("Y-m-d H:i:s", $yesterdaytimestamp); $result = $db->sql_query("select * FROM ".$recipesprefix."_votedata WHERE ratinglid=$ratinglid AND ratinguser='"._ANONYMOUS."' AND ratinghostname = '$ip' AND TO_DAYS(NOW()) - TO_DAYS(ratingtimestamp) < ".$recipesconfig['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 * $recipesconfig['outsidewaitdays'])); $ytsDB = Date("Y-m-d H:i:s", $yesterdaytimestamp); $result = $db->sql_query("select * FROM ".$recipesprefix."_votedata WHERE ratinglid=$ratinglid AND ratinguser='outside' AND ratinghostname = '$ip' AND TO_DAYS(NOW()) - TO_DAYS(ratingtimestamp) < ".$recipesconfig['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 ".$recipesprefix."_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 recipes need to be refreshed with new weight. */ /* Running a SQL statement with your modded calc for ALL recipes will accomplish this. */ $voteresult = $db->sql_query("select rating, ratinguser, ratingcomments FROM ".$recipesprefix."_votedata WHERE ratinglid = $ratinglid",false,__FILE__,__LINE__); $totalvotesDB = $db->sql_numrows($voteresult); $outsidevotes = 0; $anonvotes = 0; $outsidevoteval = 0; $anonvoteval = 0; $regvoteval = 0; $truecomments = $totalvotesDB; while(list($ratingDB, $ratinguserDB, $ratingcommentsDB)= $db->sql_fetchrow($voteresult)) { if ($ratingcommentsDB=="") $truecomments--; if ($ratinguserDB==$anonymous) { $anonvotes++; $anonvoteval += $ratingDB; } if ($recipesconfig['useoutsidevoting'] == 1) { if ($ratinguserDB=='outside') { $outsidevotes++; $outsidevoteval += $ratingDB; } } else { $outsidevotes = 0; } if ($ratinguserDB!=$anonymous && $ratinguserDB!="outside") { $regvoteval += $ratingDB; } } $regvotes = $totalvotesDB - $anonvotes - $outsidevotes; if ($totalvotesDB == 0) { $finalrating = 0; } else if ($anonvotes == 0 && $regvotes == 0) { /* Figure Outside Only Vote */ $finalrating = $outsidevoteval / $outsidevotes; $finalrating = number_format($finalrating, 4); } else if ($outsidevotes == 0 && $regvotes == 0) { /* Figure Anon Only Vote */ $finalrating = $anonvoteval / $anonvotes; $finalrating = number_format($finalrating, 4); } else if ($outsidevotes == 0 && $anonvotes == 0) { /* Figure Reg Only Vote */ $finalrating = $regvoteval / $regvotes; $finalrating = number_format($finalrating, 4); } else if ($regvotes == 0 && $recipesconfig['useoutsidevoting'] == 1 && $outsidevotes != 0 && $anonvotes != 0 ) { /* Figure Reg and Anon Mix */ $avgAU = $anonvoteval / $anonvotes; $avgOU = $outsidevoteval / $outsidevotes; if ($anonweight > $outsideweight ) { /* Anon is 'standard weight' */ $newimpact = $recipesconfig['anonweight'] / $recipesconfig['outsideweight']; $impactAU = $anonvotes; $impactOU = $outsidevotes / $newimpact; $finalrating = ((($avgOU * $impactOU) + ($avgAU * $impactAU)) / ($impactAU + $impactOU)); $finalrating = number_format($finalrating, 4); } else { /* Outside is 'standard weight' */ $newimpact = $recipesconfig['outsideweight'] / $recipesconfig['anonweight']; $impactOU = $outsidevotes; $impactAU = $anonvotes / $newimpact; $finalrating = ((($avgOU * $impactOU) + ($avgAU * $impactAU)) / ($impactAU + $impactOU)); $finalrating = number_format($finalrating, 4); } } else { /* Registered User vs. Anonymous vs. Outside User Weight Calutions */ $impact = $recipesconfig['anonweight']; $outsideimpact = $recipesconfig['outsideweight']; if ($regvotes == 0) { $regvotes = 0; } else { $avgRU = $regvoteval / $regvotes; } if ($anonvotes == 0) { $avgAU = 0; } else { $avgAU = $anonvoteval / $anonvotes; } if ($outsidevotes == 0 ) { $avgOU = 0; } else { $avgOU = $outsidevoteval / $outsidevotes; } $impactRU = $regvotes; $impactAU = $anonvotes / $impact; $impactOU = $outsidevotes / $outsideimpact; $finalrating = (($avgRU * $impactRU) + ($avgAU * $impactAU) + ($avgOU * $impactOU)) / ($impactRU + $impactAU + $impactOU); $finalrating = number_format($finalrating, 4); } $db->sql_query("UPDATE ".$recipesprefix."_recipes SET recipesratingsummary=$finalrating,totalvotes=$totalvotesDB,totalcomments=$truecomments WHERE lid = $ratinglid",false,__FILE__,__LINE__); $error = "none"; completevote($error); } completevotefooter($ratinglid, $ttitle, $ratinguser); recipesshowfooter(); } function outsiderecipesetup($lid) { global $recipesconfig, $module_name, $sitename, $nukeurl, $BASEHREF, $mainindex; require_once('header.php'); //include("modules/$module_name/r_config.php"); recipesshowheader(); $promo1 = ''._RRATETHISSITE.' @ '.$sitename.''; $promo2 = '
'; $promo3 = '
'._RVOTE4THISSITE.'
'; echo '
'._RPROMOTEYOURSITE.'


'._RPROMOTE01.'

1) '._RTEXTLINK.'

'._RPROMOTE02.'

'.$promo1.'

'._RHTMLCODE1.'


'._RTHENUMBER.' "'.$lid.'" '._RIDREFER.'

2) '._RBUTTONLINK.'

'._RPROMOTE03.'

'.$promo2.' '._RHTMLCODE2.'



'._RPROMOTE05.'

'.$sitename.' '._RSTAFF.'

'; CloseTable(); recipesshowfooter(); }