";
fwrite($fp, $contents);
fclose($fp);
chmod ("ratings.php", 0666);
}
require("ratings.php");
if(isset($_POST['your_rating'])) {
$your_rating = $_POST['your_rating'];
}
if(isset($your_rating)) {
${$your_rating}++;
$fp = fopen("ratings.php","w");
if(!$fp) {
echo "error! the file could not be opened";
exit;
}
$contents = "<"."?php $"."one = "$one"; $"."two = "$two"; $"."three = "$three"; $"."four = "$four"; $"."five = "$five"; ?".">";
fwrite($fp, $contents);
fclose($fp);
}
$total = $one + $two + $three + $four + $five;
if($total != "0") {
$ones = $one / $total;
$ones = 1 * $ones;
$twos = $two / $total;
$twos = 2 * $twos;
$threes = $three / $total;
$threes = 3 * $threes;
$fours = $four / $total;
$fours = 4 * $fours;
$fives = $five / $total;
$fives = 5 * $fives;
$all = $ones + $twos + $threes + $fours + $fives;
$whole = substr($all, 0, 1);
$decimal = substr($all, 1, 4);
$decimal = $decimal * 10;
if($decimal >= 3.5 && $decimal <= 7.5) {
$half = "true";
} elseif($decimal > 7.5) {
$all++;
$half = "false";
} else {
$half = "false";
}
$decimal = $decimal / 10;
$all = floor($all);
$i = 0;
while($i < $all) {
echo "
";
$i++;
}
if($half == "true") {
echo "
";
}
} else {
echo "This has no votes yet.";
}
?>