Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2011
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.77 KB | None | 0 0
  1. <?php
  2.  
  3. mysql_connect('sql2.cluster1.easy-hebergement.net', 'blindtestmice2', '**********') or die(mysql_error());
  4. mysql_select_db('blindtestmice2');
  5.  
  6. $timestamp = time();
  7. $ip = $_SERVER["REMOTE_ADDR"];
  8.  
  9. $retour = mysql_query("SELECT COUNT(*) AS nbre_entrees FROM online WHERE ip='".$ip."' ");
  10. $donnees = mysql_fetch_array($retour);
  11.  
  12. if($donnees['nbre_entrees'] == 0) {
  13.     mysql_query("INSERT INTO online VALUES('', '".$ip."', '".$timestamp."') ");
  14. } else {
  15.     mysql_query("UPDATE online SET timestamp='".$timestamp."' WHERE ip='".$ip."' ");
  16. }
  17.  
  18. $timestamp_5min = $timestamp - (60 * 5);
  19. mysql_query("DELETE FROM online WHERE timestamp < ".$timestamp_5min);
  20.  
  21. mysql_close();
  22.  
  23. ?>
  24. <script>
  25. window.setInterval(function(){
  26.     document.location.reload();
  27. }, 20000);
  28. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement