Advertisement
totoyo

[PHP] Compteur de visites simple

Apr 15th, 2016
2,180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. <?php
  2.  
  3. $ip = fopen('last_ip.txt', 'c+');
  4. $check = fgets($ip);
  5.  
  6. $file = fopen('counter.txt', 'c+');
  7. $count = intval(fgets($file));
  8.  
  9. if($_SERVER['REMOTE_ADDR'] != $check)
  10. {
  11. fclose($ip);
  12.  
  13. $ip = fopen('last_ip.txt', 'w+');
  14.  
  15. fputs($ip, $_SERVER['REMOTE_ADDR']);
  16.  
  17. $count++;
  18. fseek($file, 0);
  19. fputs($file, $count);
  20. }
  21.  
  22. fclose($file);
  23. fclose($ip);
  24.  
  25. echo $count;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement