Simon: Rating

Hi,
ich hab nach längerer Suceh ein Bewertungsscript gefunden. Ich will auf meiner Homepage unter Jedem Foto so eine Bewertungsmöglichkeit. Das Problem ist nur dass man das Script nur einmal pro Seite anzeigen kann(wegen der Variabeln), dann hab ich mir gedacht ich ändere die Variabeln einfach in jedem Script. Das Problem ist nur das bei vielen Fotos das ändern viel zu lange dauert. Hat jemand vieleicht eine Idee das anders zu lösen?

Hier noch das Script:

<?
/********* PHP RATING SYSTEM v1.6 ************
Copyright 2002, Cgixp.netfirms.com
You have to leave the copyright.
If you have any problem just let us know.
E-mail: alipf@myecom.net
Website: http://www.cgixp.netfirms.com
Deutsche Übersetzung: Basti Baumann
Webseite: http://www.scriptworker.com

Last change: 09.09.2003
**********************************************/
$ficdest="rate.dat";

if(file_exists($ficdest)) {
     $compteur=fopen($ficdest, "r");
     $old_stats=file($ficdest);
     $stats=explode("|", $old_stats[0]);
     fclose($compteur);
     $new_count=$stats[0];
     if ($stats[3] != $REMOTE_ADDR) {
         $new_count +=1;
     }
     $ip_hit=$REMOTE_ADDR;
     $compteur=fopen($ficdest, "w");
     fputs($compteur, "$new_count|$stats[1]|$stats[2]|$ip_hit|$stats[4]");
     fclose($compteur);
}
else {
     $nouveau_compteur=fopen($ficdest, "w");
     fputs($nouveau_compteur, "1|||$REMOTE_ADDR|");
     fclose($nouveau_compteur);
}

if (!empty($envoi)) {
     $vote=fopen($ficdest, "r");
     $old_stats=file($ficdest);
     $stats=explode("|", $old_stats[0]);
     fclose($vote);
     $nbr_votes=$stats[1];
     $moy_votes=$stats[2];
     if ($stats[4] != $REMOTE_ADDR) {
         $nbr_votes +=1;
         $moy_votes=((($stats[1]*$stats[2])+$note)/$nbr_votes);
     }
else { echo "<font face=Verdana size=2 color=red>Sie haben schon abgestimmt</font>"; }
     $ip_vote=$REMOTE_ADDR;
     $vote=fopen($ficdest, "w");
     $new_stats=fputs($vote, "$new_count|$nbr_votes|$moy_votes|$stats[3]|$ip_vote");
     fclose($vote);
}

print ("<form method=post>");
$old_stats=file($ficdest);
$stats=explode("|", $old_stats[0]);
if ($stats[2]>=5)
{
 $star = "images/5star.gif" ;
}
if ($stats[2]<=4.5)
{
 $star = "images/45star.gif" ;
}
if ($stats[2]<=4)
{
 $star = "images/4star.gif" ;
}
if ($stats[2]<=3.5)
{
 $star = "images/35star.gif" ;
}
if ($stats[2]<=3)
{
 $star = "images/3star.gif" ;
}
if ($stats[2]<=2.5)
{
 $star = "images/25star.gif" ;
}
if ($stats[2]<=2)
{
 $star = "images/2star.gif" ;
}
if ($stats[2]<=1.5)
{
 $star = "images/15star.gif" ;
}
if ($stats[2]<=1)
{
 $star = "images/1star.gif" ;
}
if ($stats[2]<=0.5)
{
 $star = "images/05star.gif" ;
}
if ($stats[2]<=0)
{
 $star = "images/00star.gif" ;
}
print ("<font size=1 face=Verdana color=#999999>Bewertung: <img src="$star" alt="Durchschnittliche Bewertung: $stats[2]">&nbsp; $stats[1] Bewertung(en)</font>");
print ("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<select name=note>");
for ($i=1; $i<=5; $i++) {
print ("<option value=$i>$i");
}
print ("&nbsp;&nbsp;</select> <input type=hidden name=envoi value=1><input type=submit value=Rate>");
print ("</form></font>");

?>

MFG
Simon

  1. Hi,

    Hat jemand vieleicht eine Idee das anders zu lösen?

    arbeite objektorientiert ...

    Last change: 09.09.2003

    ... was u.a. eine etwas ausgeprägtere Aktualität impliziert. Vor einem halben Jahrzehnt war PHP 5 geringfügig weniger verbreitet, und der Vorgänger zeichnete sich durch einen erheblichen Mangel an OOP-Fähigkeiten aus.

    Cheatah

    --
    X-Self-Code: sh:( fo:} ch:~ rl:° br:> n4:& ie:% mo:) va:) de:] zu:) fl:{ ss:) ls:~ js:|
    X-Self-Code-Url: http://emmanuel.dammerer.at/selfcode.html
    X-Will-Answer-Email: No
    X-Please-Search-Archive-First: Absolutely Yes