Guest User

reports.php

a guest
Feb 14th, 2016
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. <?php
  2. require_once 'meekrodb.2.3.class.php';
  3. if( $_GET["startDate"] || $_GET["endDate"] && $_GET['key']="AxYi951qSc" )
  4. {
  5. DB::$user = 'pol2ad_admin';
  6. DB::$password = ',2*Q9r$SeA?c';
  7. DB::$dbName = 'pol2ad_apptraxlogs';
  8. DB::$host = '104.243.43.2';
  9. $tables = DB::tableList();
  10. $startDate=$_GET["startDate"];
  11. $endDate=$_GET["endDate"];
  12. $sim_no="007044035179";
  13. $dates=returnBetweenDates( $startDate, $endDate );
  14. $positionarray=array();
  15. foreach($dates as $date){
  16. $tablename="log_$date";
  17. if(in_array(strtolower($tablename),$tables))
  18. {
  19. $result=DB::queryFirstRow("select * from $tablename where vehicle_sim=%s",$sim_no);
  20. if($result!=null){
  21. $pos=$result["pos"];
  22. $pos_json=json_decode($pos,true);
  23. foreach($pos_json as $pos_item){
  24. array_push($positionarray,$pos_item);
  25. }
  26. }else{
  27.  
  28. }
  29. }else{
  30. //echo "Table $tablename does not exist <br/>";
  31. }
  32. }
  33. header('Content-Type: application/json');
  34. echo json_encode($positionarray);
  35. }
  36. exit();
  37. function returnBetweenDates( $startDate, $endDate ){
  38. $startDate = strtotime( $startDate );
  39. $endDate = strtotime( $endDate );
  40.  
  41. if( $endDate > $startDate ){
  42. while( $endDate >= $startDate ){
  43. $dateArray[] = date( 'd_M_Y', $startDate );
  44. $startDate = strtotime( ' +1 day ', $startDate );
  45. }
  46. return $dateArray;
  47. }else{
  48. return $startDate;
  49. }
  50. }
  51. ?>
Add Comment
Please, Sign In to add comment