Advertisement
rickyc81

Untitled

May 15th, 2017
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.38 KB | None | 0 0
  1. #!/usr/bin/php -q
  2. <?php
  3. //connessione al database
  4. $db = mysqli_connect('127.0.0.1', 'ricoh87', 'luc4v4cc4r0', 'casper');
  5. //Copio il file
  6. !copy("http://api.ivao.aero/getdata/whazzup/whazzup.txt", "/var/www/casper/whatsupp.txt");
  7. //apro il file
  8. $file_handle = fopen("/var/www/casper/whatsupp.txt", "r+");
  9. //leggo il file fin quando non finisce
  10. while (!feof($file_handle)) {
  11. //divido il file in righe ed esplodo la riga secondo il divisore ":"
  12. $line_of_text = fgets($file_handle);
  13. $parts = explode(':', $line_of_text);
  14. //controllo i primi 3 caratteri del primo campo dell'array
  15. $controllo = substr($parts[0], 0, 3);
  16. //se contiene "AFL"...
  17.   if($controllo == "AFL"){
  18.     //seleziono la tabella sul database e inserisco i dati in un array associativo
  19.     $query = 'SELECT * FROM ivao WHERE VID = ' . '"' . $parts[1] . '"';
  20.     $sth = mysqli_query($db, $query);
  21.     $check = mysqli_fetch_assoc($sth);
  22.       //se un nuovo utente si connette aggiorna il timestamp di connesione e lo status
  23.       if($check['VID']== $parts[1]){
  24.         $queryu = 'UPDATE `ivao` SET `timeTot` = `timeTot` + 5  WHERE `ivao`.`VID` =' . '"' . $parts[1] . '"';
  25.         $sth = mysqli_query($db, $queryu);
  26.         }
  27.  
  28.     //stampo i primi tre campi della riga
  29.     //print "Callsign: " . $parts[0] . " VID: " . $parts[1] . " Name: " . $parts[2] . " Time: " . $time . "<br>";
  30.   }
  31. }
  32.  
  33.  
  34.  
  35. fclose($file_handle);
  36.  
  37. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement