sql_query('SELECT title FROM '.$linksprefix.'_links WHERE lid='.$lid); list($title) = $db->sql_fetchrow($result); $db->sql_freeresult($result); $options_out = "\n"; $options_out .= "\n"; $options_out .= "\n"; $options_out .= "\n"; $options_out .= "\n"; $options_out .= "\n"; $options_out .= "\n"; $options_out .= "\n"; $options_out .= "\n"; $options_out .= "\n"; $options_out .= "\n"; $cpgtpl->assign_vars(array( 'S_WLPMENU' => wlp_menu(1), 'S_HIDDENFIELDS' => '', 'S_OPTIONS' => $options_out, 'S_LINKFOOTER' => linkfooterchild($lid), 'S_TITLE' => $title, 'L_SCOMMENTS' => _WLP_SCOMMENTS, 'L_RATENOTE1' => _WLP_RATENOTE1, 'L_RATENOTE2' => _WLP_RATENOTE2, 'L_RATENOTE3' => _WLP_RATENOTE3, 'L_RATENOTE4' => _WLP_RATENOTE4, 'L_RATENOTE5' => _WLP_RATENOTE5, 'L_RATETHISSITE' => _WLP_RATETHISSITE, 'L_YOUAREREGGED' => _WLP_YOUAREREGGED, 'L_FEELFREE2ADD' => _WLP_FEELFREE2ADD, 'L_YOUARENOTREGGED' => _WLP_YOUARENOTREGGED, 'L_IFYOUWEREREG' => _WLP_IFYOUWEREREG, 'U_FORMACTION' => getlink('&l_op=addrating'), )); # Generate the page $cpgtpl->set_filenames(array('body' => 'wlpro/ratelink_body.html')); $cpgtpl->display('body'); } function addrating() { global $module_name, $linksprefix, $db, $userinfo, $sitename, $WLPRO_CFG; $ratinglid = isset($_POST['ratinglid']) ? intval($_POST['ratinglid']) : (isset($_GET['ratinglid']) ? intval($_GET['ratinglid']) : 0); $ratinguser = isset($_POST['ratinguser']) ? Fix_Quotes($_POST['ratinguser']) : (isset($_GET['ratinguser']) ? Fix_Quotes($_GET['ratinguser']) : ''); $rating = isset($_POST['rating']) ? intval($_POST['rating']) : (isset($_GET['rating']) ? intval($_GET['rating']) : ''); $ratingcomments = isset($_POST['ratingcomments']) ? Fix_Quotes($_POST['ratingcomments']) : (isset($_GET['ratingcomments']) ? Fix_Quotes($_GET['ratingcomments']) : ''); $anonwaitdays = $WLPRO_CFG['global']['anonwaitdays']; $outsidewaitdays = $WLPRO_CFG['global']['outsidewaitdays']; list($ttitle) = $db->sql_ufetchrow('SELECT title FROM '.$linksprefix.'_links WHERE lid='.$ratinglid); $ttitle = ereg_replace (" ", "_", $ttitle); if (empty($ratinguser)) { if (is_user()) { $ratinguser = $userinfo['username']; } 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=="--") { cpg_error(_WLP_COMPLETEVOTE5, _ERROR); } /* 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"); while(list($ratinguserDB) = $db->sql_fetchrow($result)) { if ($ratinguserDB == $ratinguser) { cpg_error(_WLP_COMPLETEVOTE4, _ERROR); } } } /* 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"); while(list($ratinguserDB)= $db->sql_fetchrow($result)) { if ($ratinguserDB==$ratinguser) { cpg_error(_WLP_COMPLETEVOTE3, _ERROR); } } } /* Check if ANONYMOUS user is trying to vote more than once per day. */ if ($ratinguser == _ANONYMOUS){ $yesterdaytimestamp = (gmtime()-(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 ratingtimestamp > $yesterdaytimestamp"); $anonvotecount = $db->sql_numrows($result); if ($anonvotecount >= 1) { cpg_error(sprintf(_WLP_COMPLETEVOTE2, $anonwaitdays), _ERROR); } } /* Check if OUTSIDE user is trying to vote more than once per day. */ if ($ratinguser=="outside"){ $yesterdaytimestamp = (gmtime()-(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 ratingtimestamp > $yesterdaytimestamp"); $outsidevotecount = $db->sql_numrows($result); if ($outsidevotecount >= 1) { cpg_error(sprintf(_WLP_COMPLETEVOTE6, $outsidewaitdays), _ERROR); } } /* Passed Tests */ /* All is well. Add to Line Item Rate to DB. */ $db->sql_query("INSERT into ".$linksprefix."_votedata (requestid, ratinglid, ratinguser, rating, ratinghostname, ratingcomments, ratingtimestamp) VALUES (DEFAULT,'$ratinglid', '$ratinguser', '$rating', '$ip', '$ratingcomments', '".gmtime()."')"); /* 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"); $totalvotesDB = $db->sql_numrows($voteresult); require('modules/'.$module_name.'/voteinclude.inc'); $db->sql_query("UPDATE ".$linksprefix."_links SET linkratingsummary='$finalrating', totalvotes='$totalvotesDB', totalcomments='$truecomments' WHERE lid=$ratinglid"); $message_tmp = _WLP_COMPLETEVOTE1; $result = $db->sql_query("SELECT url FROM ".$linksprefix."_links WHERE lid=$ratinglid"); list($url)= $db->sql_fetchrow($result); $message_tmp .= '
'._WLP_THANKSTOTAKETIME.' '.$sitename.'. '._WLP_LETSDECIDE.'



'; if ($ratinguser=="outside") { $message_tmp .= '
'._WLP_WEAPPREACIATE.' '.$sitename.'!
'._WLP_RETURNTO.' '.$ttitle.'


'; } cpg_error($message_tmp, _WLP_SUCCESS, getlink()); /* echo '
'; linkinfomenu($lid,$ttitle); echo '
'; */ } function outsidelinksetup($lid) { global $module_name, $sitename; require_once('header.php'); $cpgtpl->assign_vars(array( 'S_WLPMENU' => wlp_menu(1), 'S_LID' => $lid, 'S_SITENAME' => $sitename, 'L_RATETHISSITE' => _WLP_RATETHISSITE, 'L_PROMOTE01' => _WLP_PROMOTE01, 'L_PROMOTE02' => _WLP_PROMOTE02, 'L_PROMOTE03' => _WLP_PROMOTE03, 'L_PROMOTE04' => _WLP_PROMOTE04, 'L_PROMOTE05' => _WLP_PROMOTE05, 'L_RATEIT' => _WLP_RATEIT, 'L_VOTE4THISSITE' => _WLP_VOTE4THISSITE, 'L_LINKVOTE' => _WLP_LINKVOTE, 'L_PROMOTEYOURSITE' => _WLP_PROMOTEYOURSITE, 'L_TEXTLINK' => _WLP_TEXTLINK, 'L_BUTTONLINK' => _WLP_BUTTONLINK, 'L_HTMLCODE1' => _WLP_HTMLCODE1, 'L_HTMLCODE2' => _WLP_HTMLCODE2, 'L_HTMLCODE3' => _WLP_HTMLCODE3, 'L_THENUMBER' => _WLP_THENUMBER, 'L_IDREFER' => _WLP_IDREFER, 'L_REMOTEFORM' => _WLP_REMOTEFORM, 'L_STAFF' => _WLP_STAFF, 'U_FORMACTION' => getlink('&l_op=ratelink&lid='.$lid), 'U_FORMACTION_FULL' => getlink('&l_op=ratelink&lid='.$lid, true, true), )); # Generate the page $cpgtpl->set_filenames(array('body' => 'wlpro/rateoutside_body.html')); $cpgtpl->display('body'); }