12345678910111213141516171819202122232425262728293031323334353637383940 |
- <?php
-
-
-
- include 'dbcleaner.php';
-
- function read_and_delete_first_line($filename) //This function will delete the first line of db.txt.
- {
- $file = file($filename);
- array_shift($file);
- file_put_contents($filename, $file);
- }
- date_default_timezone_set('America/Puerto_Rico');
- $decoded_location = json_decode(file_get_contents('php://input'));
-
-
- if(isset($decoded_location->latitude) && isset($decoded_location->longitude))
- {
- if(is_float($decoded_location->latitude) && is_float($decoded_location->longitude))
- {
- if(($decoded_location->latitude >= -90 && $decoded_location->latitude <= 90) && ($decoded_location->longitude >= -180 && $decoded_location->longitude <= 180))
- {
- $decoded_location->inTime = date('h:i:s a',time());
- $encoded_location = json_encode($decoded_location);
- $file = 'db.txt';
- $totalLines = intval(exec("wc -l '$file'"));
-
- if($totalLines > 24)
- {
- read_and_delete_first_line($file);
- }
- $db = fopen("db.txt","a") or die("FAILED TO ACCESS DATABASE");
- fwrite($db,$encoded_location. "\n");
- fclose($db);
-
-
- }
- }
- }
- ?>
|