CStar rating and IP restrict....---how to prevent repetitive reports from the same ip.

Dear all,

I am using CStarRating and it is pretty cool. However, I found that if you refresh the page, you can submit another rating…Any ideas about how to prevent that?

I want one people just submitting one rating…

Is there a way to do IP-restrict or something similar?(set readOnly=true if the same id…)


<div class="right last" id="rating_info_<?php echo $model->rating_id?>">

<?php  

        if ( $rating = Rating::model()->findByPk($model->rating_id) ) //if the record has an rating_id we echo it

                {       

                        //echo "Rating: <strong>" . $rating->vote_average ."</strong>";

                        //echo "  " . $rating->vote_count . " votes";

                }

?>


        </div>


<div class="right">

<?php 

if(Yii::app()->user->isGuest){

if ( isset($rating->vote_average) ){

         $value = round($rating->vote_average,0);

         }else{

         $value = 0;

         }

$this->widget('CStarRating',array(

         'name'=>'rating'.$model->rating_id, // an unique name

        'starCount'=>5,

        'readOnly'=>true,

        'resetText'=>'reset',

        'maxRating'=>10,

        'minRating'=>1, 

        'value'=>$value,

));


}




else{

if ( isset($rating->vote_average) ){

         $value = round($rating->vote_average,0);

         }else{

         $value = 0;

         }

        $this->widget('CStarRating',array(

         'name'=>'rating'.$model->rating_id, // an unique name

        'starCount'=>5,

        'readOnly'=>false,

        'resetText'=>'reset',

        'maxRating'=>10,

        'minRating'=>1, 

        'value'=>$value, 

    'callback'=>' 

        function(){

                url = "/notes/rating";

                jQuery.getJSON(url, {id: '.$model->rating_id.', val: $(this).val()}, function(model) {

                if (model.status == "success")

                {

                $("#rating_success_'.$model->rating_id.'").html(model.div);

                $("#rating_success_'.$model->rating_id.'").fadeIn("slow");               

                var pause = setTimeout("$(\"#rating_success_'.$model->rating_id.'\").fadeOut(\"slow\")",5000);

                $("#rating_info_'.$model->rating_id.'").html(model.info);

                $("input[id*='.$model->rating_id.'_]").rating("readOnly",true);

                }

                });

                }'  

                        ));


}


?>      

</div>

<div id="rating_success_<?=$model->id;?>" style="display:none"></div> 

</div>

I’m looking for exactly the same thing right now, but i think you (we) have to register an ip_address / user_id for every rating, in stead of directly combining the new rating with the existing ratings.

Do we really need to save user’s ip /user_id for each rating_id ? …

Then what?

…Is there a cleaner way to do so…?

:-d

Set a variable in a Session?