123456789101112131415161718192021222324 |
- <?php
- function read_and_delete_first_line($filename)
- {
- $file = file($filename);
- array_shift($file);
- file_put_contents($filename, $file);
- }
- $decoded_location = json_decode(file_get_contents('php://input'));
- $inTime = gmdate('H:i:s',time());
- $file = 'db.txt';
- $totalLines = intval(exec("wc -l '$file'"));
- //echo $totalLines. "\n"; //For testing purposes
- if($totalLines > 15)
- {
- read_and_delete_first_line("db.txt");
- }
-
- $db = fopen("db.txt","a") or die("FAILED TO ACCESS DATABASE");
- fwrite($db,$decoded_location->latitude. "\t". $decoded_location->longitude. "\t". $inTime. "\n");
- fclose($db);
- //$totalLines = intval(exec("wc -l '$file'")); //For testing purposes
- //echo $totalLines; //For testing purposes
- ?>
|