Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once 'meekrodb.2.3.class.php';
- if( $_GET["startDate"] || $_GET["endDate"] && $_GET['key']="AxYi951qSc" )
- {
- DB::$user = 'pol2ad_admin';
- DB::$password = ',2*Q9r$SeA?c';
- DB::$dbName = 'pol2ad_apptraxlogs';
- DB::$host = '104.243.43.2';
- $tables = DB::tableList();
- $startDate=$_GET["startDate"];
- $endDate=$_GET["endDate"];
- $sim_no="007044035179";
- $dates=returnBetweenDates( $startDate, $endDate );
- $positionarray=array();
- foreach($dates as $date){
- $tablename="log_$date";
- if(in_array(strtolower($tablename),$tables))
- {
- $result=DB::queryFirstRow("select * from $tablename where vehicle_sim=%s",$sim_no);
- if($result!=null){
- $pos=$result["pos"];
- $pos_json=json_decode($pos,true);
- foreach($pos_json as $pos_item){
- array_push($positionarray,$pos_item);
- }
- }else{
- }
- }else{
- //echo "Table $tablename does not exist <br/>";
- }
- }
- header('Content-Type: application/json');
- echo json_encode($positionarray);
- }
- exit();
- function returnBetweenDates( $startDate, $endDate ){
- $startDate = strtotime( $startDate );
- $endDate = strtotime( $endDate );
- if( $endDate > $startDate ){
- while( $endDate >= $startDate ){
- $dateArray[] = date( 'd_M_Y', $startDate );
- $startDate = strtotime( ' +1 day ', $startDate );
- }
- return $dateArray;
- }else{
- return $startDate;
- }
- }
- ?>
Add Comment
Please, Sign In to add comment