Jump to content

Robots vs. Rating System


jamiet757

Recommended Posts

I have a site that uses a rating system (simple 5 stars) It inserts the rating and IP into the database, so that if the same person tries to rate the same item, it doesn't change the rating. However I am having a big problem with robots.

 

The script is javascript, but it uses PHP to insert the rating into the database. When you hover over the stars and click, it sends the rating. For some reason it looks like the robots are rating every item 0. Since they have different IPs often, it keeps rating. How can I make it so the robots don't click on the rating?

 

Here is how the code is called:

 


function doVote(value) {
    var req = new JsHttpRequest();
    // Code automatically called on load finishing.
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
document.getElementById('votebox').innerHTML =req.responseText;
        }
    }
    req.open(null, '<?=site_root?>/members/vote_add.php?id_parent=<?=$id_parent?>', true);
    req.send( { vote: value } );
}

 

and here is the vote_add.php file:

 


<?
$JsHttpRequest =& new JsHttpRequest($mtg);
$sql="select ip,id from voteitems where ip='".result($_SERVER["REMOTE_ADDR"])."' and id=".(int)$_GET["id_parent"];
$ds->open($sql);
if($ds->eof)
{
$sql="insert into voteitems (id,ip,vote) values (".(int)$_GET["id_parent"].",'".result($_SERVER["REMOTE_ADDR"])."',".(int)$_REQUEST["vote"].")";
$ds->open($sql);
}
$item_rating=0.00;
$item_count=0;
$sql="select sum(vote) as sum_vote,count(ip) as count_user from voteitems where id=".(int)$_GET["id_parent"];
$dr->open($sql);
if(!$dr->eof)
{
if($dr->row["count_user"]!=0)
{
$item_rating=$dr->row["sum_vote"]/$dr->row["count_user"];
$item_count=$dr->row["count_user"];
$sql="update photos set rating=".$item_rating." where id_parent=".(int)$_GET["id_parent"];
$db->execute($sql);
}
}
$rating_text="<table border='0' cellpadding='1' cellspacing='0'><tr>";
for($j=1;$j<6;$j++)
{
$tt="2";
if($j<=$item_rating){$tt="1";}
if($j>$item_rating and $j-$item_rating>0.25 and $j-$item_rating<0.75){$tt="3";}
$rating_text.="<td><img src='".site_root."/".$site_template_url."images/rating".$tt.".gif' width='11px' height='11px' border='0'></td>";
}
$rating_text.="<td class='smalltext2'> ".float_opt($item_rating,2)."(".$item_count.")</td></tr></table>";
echo($rating_text);
?>

 

I can't figure out how to make the rating invisible to the robots, or how they are clicking on the vote.

Link to comment
https://forums.phpfreaks.com/topic/195437-robots-vs-rating-system/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.