mirror of
https://github.com/e107inc/e107.git
synced 2025-08-22 22:25:31 +02:00
Rating system re-work and cleanup.
This commit is contained in:
65
rate.php
65
rate.php
@@ -22,19 +22,40 @@
|
||||
require_once("class2.php");
|
||||
include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/lan_'.e_PAGE);
|
||||
|
||||
$qs = explode("^", e_QUERY);
|
||||
|
||||
if (!$qs[0] || USER == FALSE || $qs[3] > 10 || $qs[3] < 1 || strpos($qs[2], '://') !== false)
|
||||
{
|
||||
header("location:".e_BASE."index.php");
|
||||
if(!e_AJAX_REQUEST) // Legacy method.
|
||||
{
|
||||
$qs = explode("^", e_QUERY);
|
||||
|
||||
if (!$qs[0] || USER == FALSE || $qs[3] > 10 || $qs[3] < 1 || strpos($qs[2], '://') !== false)
|
||||
{
|
||||
header("location:".e_BASE."index.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
$table = $tp -> toDB($qs[0]);
|
||||
$itemid = intval($qs[1]);
|
||||
$returnurl = $tp -> toDB($qs[2]);
|
||||
$rate = intval($qs[3]);
|
||||
e107::getRate()->submitVote($table,$itemid,$rate);
|
||||
header("location:".$returnurl);
|
||||
exit;
|
||||
}
|
||||
else // Ajax Used.
|
||||
{
|
||||
$table = $tp->toDB($_POST['table']);
|
||||
$itemid = intval($_POST['id']);
|
||||
$rate = intval($_POST['score']) * 2;
|
||||
echo e107::getRate()->submitVote($table,$itemid,$rate);
|
||||
exit;
|
||||
}
|
||||
|
||||
$table = $tp -> toDB($qs[0]);
|
||||
$itemid = intval($qs[1]);
|
||||
$returnurl = $tp -> toDB($qs[2]);
|
||||
$rate = intval($qs[3]);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
if ($sql -> db_Select("rate", "*", "rate_table='{$table}' AND rate_itemid='{$itemid}'"))
|
||||
{
|
||||
$row = $sql -> db_Fetch();
|
||||
@@ -43,19 +64,41 @@ if ($sql -> db_Select("rate", "*", "rate_table='{$table}' AND rate_itemid='{$ite
|
||||
$rate_voters = $row['rate_voters'].".".USERID.".";
|
||||
$new_rating = $row['rate_rating']+$rate;
|
||||
$sql -> db_Update("rate", "rate_votes=rate_votes+1, rate_rating='{$new_rating}', rate_voters='{$rate_voters}' WHERE rate_id='{$row['rate_id']}' ");
|
||||
if(!$returnurl)
|
||||
{
|
||||
$voteStatus = e107::getRate()->renderVotes($rate_voters,($row['rate_votes'] +1));
|
||||
echo $voteStatus."|".RATELAN_3; // Thank you for your vote.
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
header("location:".e_BASE."index.php");
|
||||
if($returnurl)
|
||||
{
|
||||
header("location:".e_BASE."index.php");
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "You already voted!";
|
||||
}
|
||||
exit;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql->db_Insert("rate", " 0, '{$table}', '{$itemid}', '{$rate}', '1', '.".USERID.".' ");
|
||||
if($sql->db_Insert("rate", " 0, '{$table}', '{$itemid}', '{$rate}', '1', '.".USERID.".' "))
|
||||
{
|
||||
if(!$returnurl)
|
||||
{
|
||||
echo RATELAN_3; // Thank you for your vote.
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
header("location:".$returnurl);
|
||||
exit;
|
||||
|
||||
?>
|
Reference in New Issue
Block a user