Jump to content

Hi all... Help greatly needed...


Recommended Posts

Okay so I am making a website and have run into a bit of a problem. I am trying to use the 5 star rating system http://2008.gr0w.com/articles/uploads/rater.zip But I dont want to rate people on an average basis but rather after 10 votes half a bar 20 full bar 30 1 1/2 bar ect, ect, ect. I also need to be the only person who can vote.

If someone can tell me how I would go about editing this script to be a reward system rather then a tally type system I will be very appreciative... Thank you for taking the time to read....

Link to comment
Share on other sites

I thought it might help if I posted the script so here it is....

 

The problem I am having is figuring out how to changing the system. I just want to be able to click a button to add a point and for every five votes they get half a bar.

 

I have to be able to post the result on a persons page without the vote button, In other words just the graphics.

 

In this script there seems to be only 10 image results. I need different images....

 

I also need to be the only one who can vote...

Pleas if you can help I would be very happy.

 

 

 

<?

 

// User settings

$rater_ip_voting_restriction = true; // restrict ip address voting (true or false)

$rater_ip_vote_qty=1; // how many times an ip address can vote

$rater_already_rated_msg="You have already rated this item. You were allowed ".$rater_ip_vote_qty." vote(s).";

$rater_not_selected_msg="You have not selected a rating value.";

$rater_thankyou_msg="Thankyou for voting.";

$rater_generic_text="this item"; // generic item text

$rater_end_of_line_char="\n"; // may want to change for different operating systems

 

 

 

if(!isset($rater_id)) $rater_id=1;

if(!isset($rater_item_name)) $rater_item_name=$rater_generic_text;

 

 

// DO NOT MODIFY BELOW THIS LINE

$rater_filename='item_'.$rater_id.".rating";

$rater_rating=0;

$rater_stars="";

$rater_stars_txt="";

$rater_rating=0;

$rater_votes=0;

$rater_msg="";

 

// Rating action

if(isset($_REQUEST["rate".$rater_id])){

if(isset($_REQUEST["rating_".$rater_id])){

  while(list($key,$val)=each($_REQUEST["rating_".$rater_id])){

  $rater_rating=$val;

  }

  $rater_ip = getenv("REMOTE_ADDR");

  $rater_file=fopen($rater_filename,"a+");

  $rater_str="";

  $rater_str = rtrim(fread($rater_file, 1024*8),$rater_end_of_line_char);

  if($rater_str!=""){

  if($rater_ip_voting_restriction){

    $rater_data=explode($rater_end_of_line_char,$rater_str);

$rater_ip_vote_count=0;

    foreach($rater_data as $d){

$rater_tmp=explode("|",$d);

$rater_oldip=str_replace($rater_end_of_line_char,"",$rater_tmp[1]);

if($rater_ip==$rater_oldip){

  $rater_ip_vote_count++;

}

    }

if($rater_ip_vote_count > ($rater_ip_vote_qty - 1)){

    $rater_msg=$rater_already_rated_msg;

}else{

    fwrite($rater_file,$rater_rating."|".$rater_ip.$rater_end_of_line_char);

    $rater_msg=$rater_thankyou_msg;

}

  }else{

    fwrite($rater_file,$rater_rating."|".$rater_ip.$rater_end_of_line_char);

    $rater_msg=$rater_thankyou_msg;

  }

  }else{

  fwrite($rater_file,$rater_rating."|".$rater_ip.$rater_end_of_line_char);

  $rater_msg=$rater_thankyou_msg;

  }

  fclose($rater_file);

}else{

  $rater_msg=$rater_not_selected_msg;

}

}

 

// Get current rating

if(is_file($rater_filename)){

$rater_file=fopen($rater_filename,"r");

$rater_str="";

$rater_str = fread($rater_file, 1024*8);

if($rater_str!=""){

  $rater_data=explode($rater_end_of_line_char,$rater_str);

  $rater_votes=count($rater_data)-1;

  $rater_sum=0;

  foreach($rater_data as $d){

  $d=explode("|",$d);

  $rater_sum+=$d[0];

  }

  $rater_rating=number_format(($rater_sum/$rater_votes), 2, '.', '');

}

fclose($rater_file);

}else{

$rater_file=fopen($rater_filename,"w");

fclose($rater_file);

}

 

// Assign star image

if ($rater_rating <= 0  ){$rater_stars = "./img/0.jpg";$rater_stars_txt="Not Rated";}

if ($rater_rating >= 0.5){$rater_stars = "./img/1.jpg";$rater_stars_txt="0.5";}

if ($rater_rating >= 1  ){$rater_stars = "./img/2.jpg";$rater_stars_txt="1";}

if ($rater_rating >= 1.5){$rater_stars = "./img/3.jpg";$rater_stars_txt="1.5";}

if ($rater_rating >= 2  ){$rater_stars = "./img/4.jpg";$rater_stars_txt="2";}

if ($rater_rating >= 2.5){$rater_stars = "./img/5.jpg";$rater_stars_txt="2.5";}

if ($rater_rating >= 3  ){$rater_stars = "./img/6.jpg";$rater_stars_txt="3";}

if ($rater_rating >= 3.5){$rater_stars = "./img/7.jpg";$rater_stars_txt="3.5";}

if ($rater_rating >= 4  ){$rater_stars = "./img/8.jpg";$rater_stars_txt="4";}

if ($rater_rating >= 4.5){$rater_stars = "./img/9.jpg";$rater_stars_txt="4.5";}

if ($rater_rating >= 5  ){$rater_stars = "./img/10.jpg";$rater_stars_txt="5";}

 

 

// Output

echo '<div class="hreview">';

echo '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';

echo '<h3 class="item">Rate <span class="fn">'.$rater_item_name.'</span></h3>';

echo '<div>';

echo '<span  class="rating"><img src="'.$rater_stars.'?x='.uniqid((double)microtime()*1000000,1).'" alt="'.$rater_stars_txt.' stars" /> Ave. rating: '.$rater_stars_txt.'</span> from <span class="reviewcount"> '.$rater_votes.' votes</span>.';

echo '</div>';

echo '<div>';

echo '<label for="rate5_'.$rater_id.'"><input type="radio" value="5" name="rating_'.$rater_id.'[]" id="rate5_'.$rater_id.'" />Excellent</label>';

echo '<label for="rate4_'.$rater_id.'"><input type="radio" value="4" name="rating_'.$rater_id.'[]" id="rate4_'.$rater_id.'" />Very Good</label>';

echo '<label for="rate3_'.$rater_id.'"><input type="radio" value="3" name="rating_'.$rater_id.'[]" id="rate3_'.$rater_id.'" />Good</label>';

echo '<label for="rate2_'.$rater_id.'"><input type="radio" value="2" name="rating_'.$rater_id.'[]" id="rate2_'.$rater_id.'" />Fair</label>';

echo '<label for="rate1_'.$rater_id.'"><input type="radio" value="1" name="rating_'.$rater_id.'[]" id="rate1_'.$rater_id.'" />Poor</label>';

echo '<input type="hidden" name="rs_id" value="'.$rater_id.'" />';

echo '<input type="submit" name="rate'.$rater_id.'" value="Rate" />';

echo '</div>';

if($rater_msg!="") echo "<div>".$rater_msg."</div>";

echo '</form>';

echo '</div>';

 

?>

 

 

Link to comment
Share on other sites

I am guessing this is the input forms... So I removed 4 of them and left the one valued at 1.

 

echo '<div>';
echo '<label for="rate1_'.$rater_id.'"><input type="radio" value="1" name="rating_'.$rater_id.'[]" id="rate1_'.$rater_id.'" />1 Point</label>';
echo '<input type="hidden" name="rs_id" value="'.$rater_id.'" />';
echo '<input type="submit" name="rate'.$rater_id.'" value="Rate" />';
echo '</div>';
if($rater_msg!="") echo "<div>".$rater_msg."</div>";
echo '</form>';
echo '</div>';

 

 

This is the value of the votes...

 

// Output
echo '<div class="hreview">';
echo '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
echo '<h3 class="item">Rate <span class="fn">'.$rater_item_name.'</span></h3>';
echo '<div>';
echo '<span  class="rating"><img src="'.$rater_stars.'?x='.uniqid((double)microtime()*1000000,1).'" alt="'.$rater_stars_txt.' stars" /> Ave. rating: '.$rater_stars_txt.'</span> from <span class="reviewcount"> '.$rater_votes.' votes</span>.';
echo '</div>';

?>

 

And that this is the value of the image...

 


if ($rater_rating <= 0  ){$rater_stars = "./img/0.jpg";$rater_stars_txt="Not Rated";}
if ($rater_rating >= 0.5){$rater_stars = "./img/1.jpg";$rater_stars_txt="0.5";}
if ($rater_rating >= 1  ){$rater_stars = "./img/2.jpg";$rater_stars_txt="1";}
if ($rater_rating >= 1.5){$rater_stars = "./img/3.jpg";$rater_stars_txt="1.5";}
if ($rater_rating >= 2  ){$rater_stars = "./img/4.jpg";$rater_stars_txt="2";}
if ($rater_rating >= 2.5){$rater_stars = "./img/5.jpg";$rater_stars_txt="2.5";}
if ($rater_rating >= 3  ){$rater_stars = "./img/6.jpg";$rater_stars_txt="3";}
if ($rater_rating >= 3.5){$rater_stars = "./img/7.jpg";$rater_stars_txt="3.5";}
if ($rater_rating >= 4  ){$rater_stars = "./img/8.jpg";$rater_stars_txt="4";}
if ($rater_rating >= 4.5){$rater_stars = "./img/9.jpg";$rater_stars_txt="4.5";}
if ($rater_rating >= 5  ){$rater_stars = "./img/10.jpg";$rater_stars_txt="5";}

 

So if I edit the value of the image to this.

 


if ($rater_rating <= 0  ){$rater_stars = "./img/0.jpg";$rater_stars_txt="Not Rated";}
if ($rater_rating >= 5){$rater_stars = "./img/1.jpg";$rater_stars_txt="5";}
if ($rater_rating >= 10  ){$rater_stars = "./img/2.jpg";$rater_stars_txt="10";}
if ($rater_rating >= 15){$rater_stars = "./img/3.jpg";$rater_stars_txt="15";}
if ($rater_rating >= 20  ){$rater_stars = "./img/4.jpg";$rater_stars_txt="20";}
if ($rater_rating >= 25){$rater_stars = "./img/5.jpg";$rater_stars_txt="25";}
if ($rater_rating >= 30  ){$rater_stars = "./img/6.jpg";$rater_stars_txt="30";}
if ($rater_rating >= 35){$rater_stars = "./img/7.jpg";$rater_stars_txt="35";}
if ($rater_rating >= 40  ){$rater_stars = "./img/8.jpg";$rater_stars_txt="40";}
if ($rater_rating >= 45){$rater_stars = "./img/9.jpg";$rater_stars_txt="45";}
if ($rater_rating >= 50  ){$rater_stars = "./img/10.jpg";$rater_stars_txt="50";}
if ($rater_rating >= 55){$rater_stars = "./img/11.jpg";$rater_stars_txt="55";}
if ($rater_rating >= 60  ){$rater_stars = "./img/12.jpg";$rater_stars_txt="60";}
if ($rater_rating >= 65){$rater_stars = "./img/13.jpg";$rater_stars_txt="65";}
if ($rater_rating >= 70  ){$rater_stars = "./img/14.jpg";$rater_stars_txt="70";}
if ($rater_rating >= 75){$rater_stars = "./img/15.jpg";$rater_stars_txt="75";}
if ($rater_rating >= 80  ){$rater_stars = "./img/16.jpg";$rater_stars_txt="80";}
if ($rater_rating >= 85){$rater_stars = "./img/17.jpg";$rater_stars_txt="85";}
if ($rater_rating >= 90  ){$rater_stars = "./img/18.jpg";$rater_stars_txt="90";}
if ($rater_rating >= 95){$rater_stars = "./img/19.jpg";$rater_stars_txt="95";}
if ($rater_rating >= 100  ){$rater_stars = "./img/20.jpg";$rater_stars_txt="100";}

 

Then how would I change the value of each vote?

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.