home *** CD-ROM | disk | FTP | other *** search
/ H4CK3R 4 / hacker04 / 04_HACK04.ISO / src / PHP / phprate.php3.txt < prev    next >
Encoding:
Text File  |  2002-05-06  |  2.1 KB  |  69 lines

  1. PHP Rate 
  2.  
  3. PHP Rate is a simple counter and voting system, which requires no database 
  4.  
  5. <? 
  6. /********* PHP RATE v1.0 ************ 
  7. Copyright 2000, Mathias Daval 
  8. This script is a freeware. You can 
  9. use it and modify it freely but you 
  10. have to leave the copyright. 
  11. Please let me know if you use 
  12. this script (cyberlp@cybercable.fr) 
  13. *************************************/ 
  14.  
  15. $ficdest=explode(".",basename($PHP_SELF)); 
  16. $ficdest=$ficdest[0].".dat"; 
  17.  
  18. if(file_exists($ficdest)) { 
  19.      $compteur=fopen($ficdest, "r"); 
  20.      $old_stats=file($ficdest); 
  21.      $stats=explode("|", $old_stats[0]); 
  22.      fclose($compteur); 
  23.      $new_count=$stats[0]; 
  24.      if ($stats[3] != $REMOTE_ADDR) { 
  25.          $new_count +=1; 
  26.      } 
  27.      $ip_hit=$REMOTE_ADDR; 
  28.      $compteur=fopen($ficdest, "w"); 
  29.      fputs($compteur, "$new_count|$stats[1]|$stats[2]|$ip_hit|$stats[4]"); 
  30.      fclose($compteur); 
  31. else { 
  32.      $nouveau_compteur=fopen($ficdest, "w"); 
  33.      fputs($nouveau_compteur, "1|||$REMOTE_ADDR|"); 
  34.      fclose($nouveau_compteur); 
  35.  
  36. if (!empty($envoi)) { 
  37.      $vote=fopen($ficdest, "r"); 
  38.      $old_stats=file($ficdest); 
  39.      $stats=explode("|", $old_stats[0]); 
  40.      fclose($vote); 
  41.      $nbr_votes=$stats[1]; 
  42.      $moy_votes=$stats[2]; 
  43.      if ($stats[4] != $REMOTE_ADDR) { 
  44.          $nbr_votes +=1; 
  45.          $moy_votes=((($stats[1]*$stats[2])+$note)/$nbr_votes); 
  46.      } 
  47. else { echo "<font face=Verdana size=2 color=red>You have already voted</font>"; } 
  48.      $ip_vote=$REMOTE_ADDR; 
  49.      $vote=fopen($ficdest, "w"); 
  50.      $new_stats=fputs($vote, "$new_count|$nbr_votes|$moy_votes|$stats[3]|$ip_vote"); 
  51.      fclose($vote); 
  52.  
  53. print ("<form method=post>"); 
  54. $old_stats=file($ficdest); 
  55. $stats=explode("|", $old_stats[0]); 
  56. print ("<font size=1 face=Verdana color=#999999>Hits: $new_count | Votes: $stats[1] | Average vote: "); 
  57. if (!empty($stats[2])) { printf("%.1f", $stats[2]); } 
  58. print ("   <input type=hidden name=envoi value=1><input type=submit value=Vote>"); 
  59. print (" <select name=note>"); 
  60. for ($i=1; $i<=10; $i++) { 
  61.     print ("<option value=$i>$i"); 
  62. print ("</select></form></font>"); 
  63.  
  64. ?>
  65.