Repositorio del curso CCOM4030 el semestre B91 del proyecto Trolley

123456789101112131415161718192021222324
  1. <?php
  2. function read_and_delete_first_line($filename)
  3. {
  4. $file = file($filename);
  5. array_shift($file);
  6. file_put_contents($filename, $file);
  7. }
  8. $decoded_location = json_decode(file_get_contents('php://input'));
  9. $inTime = gmdate('H:i:s',time());
  10. $file = 'db.txt';
  11. $totalLines = intval(exec("wc -l '$file'"));
  12. //echo $totalLines. "\n"; //For testing purposes
  13. if($totalLines > 15)
  14. {
  15. read_and_delete_first_line("db.txt");
  16. }
  17. $db = fopen("db.txt","a") or die("FAILED TO ACCESS DATABASE");
  18. fwrite($db,$decoded_location->latitude. "\t". $decoded_location->longitude. "\t". $inTime. "\n");
  19. fclose($db);
  20. //$totalLines = intval(exec("wc -l '$file'")); //For testing purposes
  21. //echo $totalLines; //For testing purposes
  22. ?>