| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | require_once(dirname(__FILE__).'/class.Scheduler.php'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | require_once(dirname(__FILE__).'/class.ACARS.php'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  | require_once(dirname(__FILE__).'/class.Image.php'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | $global_query = "SELECT spotter_output.* FROM spotter_output"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | class Spotter{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | 	public $aircraft_correct_icaotype = array('CL64' => 'CL60', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | 					'F9LX' => 'F900', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | 					'K35T' => 'K35R', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | 					'F5EX' => 'FA50', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | 					'G102' => 'GLID', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | 					'LJ36' => 'LJ35', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | 					'G500' => 'EGRT', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | 					'A300' => 'A30B', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | 					'ROT' => 'B77W', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | 					'BPN' => 'B772', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | 					'0011' => 'B77W', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | 					'F9DX' => 'F900', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | 					'B757' => 'B752', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | 					'4/05' => 'A332', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | 					'F/A3' => 'A320', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | 					'F2EX' => 'F2TH', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | 					'EA55' => 'EA50', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | 					'B73B' => 'B737', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  | 					'G450' => 'GLF4', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | 					'H25X' => 'H25B', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | 					'E175' => 'E75S', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | 					'B777' => 'B77W', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | 					'F2LX' => 'F2TH', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  | 					'CL65' => 'CL60', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  | 					'A380' => 'A388', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  | 					'G550' => 'GLF5', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  | 					'F9EX' => 'F900', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  | 					'E195' => 'E190', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  | 					'H750' => 'H25B', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  | 					'B747' => 'B744', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  | 					'B767' => 'B763', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  | 					'PA39' => 'PA30', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  | 					'H900' => 'H25B', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  | 					'AN74' => 'AN72', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  | 					'CL85' => 'CRJ2', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  | 					'G400' => 'GLF4', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  | 					'CL61' => 'CL60', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  | 					'F2TS' => 'F2TH', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  | 					'Z602' => 'CH60', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  | 					'G100' => 'ASTR'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  | 	public $db; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  | 	public function __construct($dbc = null) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  | 		$Connection = new Connection($dbc); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  | 		$this->db = $Connection->db(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  | 	* Get SQL query part for filter used | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  | 	* @param Array $filter the filter | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  | 	* @return Array the SQL part | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  | 	public function getFilter($filter = array(),$where = false,$and = false) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  | 		global $globalFilter, $globalStatsFilters, $globalFilterName; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  | 		$filters = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  | 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  | 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  | 				$filters = $globalStatsFilters[$globalFilterName]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  | 				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  | 		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  | 		$filter_query_join = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  | 		$filter_query_where = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  | 		foreach($filters as $flt) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  | 			if (isset($flt['airlines']) && !empty($flt['airlines'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  | 				if ($flt['airlines'][0] != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  | 					if (isset($flt['source'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  | 						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) so ON so.flightaware_id = spotter_output.flightaware_id"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  | 					} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  | 						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) so ON so.flightaware_id = spotter_output.flightaware_id"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  | 			if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  | 				if (isset($flt['source'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  | 					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) so ON so.flightaware_id = spotter_output.flightaware_id"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  | 				} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  | 					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) so ON so.flightaware_id = spotter_output.flightaware_id"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  | 			if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']))) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  | 				if (isset($flt['source'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  | 					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) so ON so.flightaware_id = spotter_output.flightaware_id"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  | 		if (isset($filter['airlines']) && !empty($filter['airlines'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  | 			if ($filter['airlines'][0] != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  | 					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_output.flightaware_id"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  | 		if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  | 			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_output.flightaware_id "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  | 		if (isset($filter['alliance']) && !empty($filter['alliance'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  | 			$filter_query_join .= " INNER JOIN (SELECT icao FROM airlines WHERE alliance = '".$filter['alliance']."') sal ON sal.icao = spotter_output.airline_icao "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  | 		if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  | 				$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) so ON so.flightaware_id = spotter_output.flightaware_id"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  | 		if (isset($filter['source']) && !empty($filter['source'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  | 			$filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  | 		if (isset($filter['ident']) && !empty($filter['ident'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  | 			$filter_query_where = " WHERE ident = '".$filter['ident']."'"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  | 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  | 			if ($filter_query_where == '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  | 				$filter_query_where = " WHERE format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  | 				$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  | 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  | 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  | 		$filter_query = $filter_query_join.$filter_query_where; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  | 		return $filter_query; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  | 	* Executes the SQL statements to get the spotter information | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  | 	* @param String $query the SQL query | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  | 	* @param Array $params parameter of the query | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  | 	* @param String $limitQuery the limit query | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  | 	* @return Array the spotter information | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  | 	public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  | 		global $globalSquawkCountry, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalAirlinesSource, $globalVAM; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  | 		$Image = new Image($this->db); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  | 		$Schedule = new Schedule($this->db); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  | 		$ACARS = new ACARS($this->db); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  | 		if (!isset($globalIVAO)) $globalIVAO = FALSE; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  | 		if (!isset($globalVATSIM)) $globalVATSIM = FALSE; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  | 		if (!isset($globalphpVMS)) $globalphpVMS = FALSE; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  | 		if (!isset($globalVAM)) $globalVAM = FALSE; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  | 		date_default_timezone_set('UTC'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  | 		if (!is_string($query)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  | 			return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  | 		if ($limitQuery != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  | 			if (!is_string($limitQuery)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  | 				return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  | 		try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  | 			$sth = $this->db->prepare($query.$limitQuery); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  | 			$sth->execute($params); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  | 		} catch (PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  | 			printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  | 			exit(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  | 	//	$num_rows = count($sth->fetchAll()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  | 		$num_rows = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  | 		$spotter_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  | 			$num_rows++; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  | 			$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  | 			if (isset($row['spotter_live_id'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  | 				//$temp_array['spotter_id'] = $row['spotter_live_id']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  | 				$temp_array['spotter_id'] = $this->getSpotterIDBasedOnFlightAwareID($row['flightaware_id']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  | 			} elseif (isset($row['spotter_archive_id'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  | 				$temp_array['spotter_id'] = $row['spotter_archive_id']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  | 			} elseif (isset($row['spotter_archive_output_id'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  | 				$temp_array['spotter_id'] = $row['spotter_archive_output_id']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  | 			} elseif (isset($row['spotter_id'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  | 				$temp_array['spotter_id'] = $row['spotter_id']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  | 				$temp_array['spotter_id'] = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  | 			if (isset($row['flightaware_id'])) $temp_array['flightaware_id'] = $row['flightaware_id']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  | 			if (isset($row['modes'])) $temp_array['modes'] = $row['modes']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  | 			$temp_array['ident'] = $row['ident']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  | 			if (isset($row['registration']) && $row['registration'] != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  | 				$temp_array['registration'] = $row['registration']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  | 			} elseif (isset($temp_array['modes'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  | 				$temp_array['registration'] = $this->getAircraftRegistrationBymodeS($temp_array['modes']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  | 			} else $temp_array['registration'] = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  | 			if (isset($row['aircraft_icao'])) $temp_array['aircraft_type'] = $row['aircraft_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  | 			$temp_array['departure_airport'] = $row['departure_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  | 			$temp_array['arrival_airport'] = $row['arrival_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  | 			if (isset($row['real_arrival_airport_icao']) && $row['real_arrival_airport_icao'] != NULL) $temp_array['real_arrival_airport'] = $row['real_arrival_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  | 			if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  | 			if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  | 			/* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  | 			if (Connection->tableExists('countries')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  | 				$country_info = $this->getCountryFromLatitudeLongitude($temp_array['latitude'],$temp_array['longitude']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  | 				if (is_array($country_info) && isset($country_info['name']) && isset($country_info['iso2'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  | 				    $temp_array['country'] = $country_info['name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  | 				    $temp_array['country_iso2'] = $country_info['iso2']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  | 			*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  | 			if (isset($row['waypoints'])) $temp_array['waypoints'] = $row['waypoints']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  | 			if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  | 			if (isset($row['route_stop'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  | 				$temp_array['route_stop'] = $row['route_stop']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  | 				if ($row['route_stop'] != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  | 					$allroute = explode(' ',$row['route_stop']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  | 					foreach ($allroute as $route) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  | 						$route_airport_array = $this->getAllAirportInfo($route); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  | 						if (isset($route_airport_array[0]['name'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  | 							$route_stop_details = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  | 							$route_stop_details['airport_name'] = $route_airport_array[0]['name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  | 							$route_stop_details['airport_city'] = $route_airport_array[0]['city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  | 							$route_stop_details['airport_country'] = $route_airport_array[0]['country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  | 							$route_stop_details['airport_icao'] = $route_airport_array[0]['icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  | 							$temp_array['route_stop_details'][] = $route_stop_details; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  | 						} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  | 			if (isset($row['altitude'])) $temp_array['altitude'] = $row['altitude']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  | 			if (isset($row['heading'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  | 				$temp_array['heading'] = $row['heading']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  | 				$heading_direction = $this->parseDirection($row['heading']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  | 				if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  | 			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  | 			$temp_array['image'] = ""; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  | 			$temp_array['image_thumbnail'] = ""; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  | 			$temp_array['image_source'] = ""; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  | 			$temp_array['image_copyright'] = ""; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 |  |  |   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  | 			if (isset($row['highlight'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  | 				$temp_array['highlight'] = $row['highlight']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  | 			} else $temp_array['highlight'] = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  | 			if (isset($row['date'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 |  |  | 				$dateArray = $this->parseDateString($row['date']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 |  |  | 				if ($dateArray['seconds'] < 10) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 |  |  | 				{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  | 					$temp_array['date'] = "a few seconds ago"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  | 				} elseif ($dateArray['seconds'] >= 5 && $dateArray['seconds'] < 30) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  | 				{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 |  |  | 					$temp_array['date'] = "half a minute ago"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 |  |  | 				} elseif ($dateArray['seconds'] >= 30 && $dateArray['seconds'] < 60) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  | 				{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  | 					$temp_array['date'] = "about a minute ago"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 |  |  | 				} elseif ($dateArray['minutes'] < 5) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 |  |  | 				{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 |  |  | 					$temp_array['date'] = "a few minutes ago"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 |  |  | 				} elseif ($dateArray['minutes'] >= 5 && $dateArray['minutes'] < 60) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  | 				{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 |  |  | 					$temp_array['date'] = "about ".$dateArray['minutes']." minutes ago"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  | 				} elseif ($dateArray['hours'] < 2) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  | 				{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 |  |  | 					$temp_array['date'] = "about an hour ago"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  | 				} elseif ($dateArray['hours'] >= 2 && $dateArray['hours'] < 24) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  | 				{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  | 					$temp_array['date'] = "about ".$dateArray['hours']." hours ago"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  | 				} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  | 					$temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC")); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  | 				$temp_array['date_minutes_past'] = $dateArray['minutes']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  | 				$temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC")); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  | 				$temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC")); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  | 				$temp_array['date_unix'] = strtotime($row['date']." UTC"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  | 			if (isset($row['aircraft_name']) && $row['aircraft_name'] != '' && isset($row['aircraft_shadow']) && $row['aircraft_shadow'] != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  | 				$temp_array['aircraft_name'] = $row['aircraft_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 |  |  | 				$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  | 				if (isset($row['aircraft_shadow'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 |  |  | 					$temp_array['aircraft_shadow'] = $row['aircraft_shadow']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  | 			} elseif (isset($row['aircraft_icao'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 |  |  | 				$aircraft_array = $this->getAllAircraftInfo($row['aircraft_icao']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 |  |  | 				if (count($aircraft_array) > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 |  |  | 					$temp_array['aircraft_name'] = $aircraft_array[0]['type']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 |  |  | 					$temp_array['aircraft_manufacturer'] = $aircraft_array[0]['manufacturer']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 |  |  | 				 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 |  |  | 					if ($aircraft_array[0]['aircraft_shadow'] != NULL) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 |  |  | 						$temp_array['aircraft_shadow'] = $aircraft_array[0]['aircraft_shadow']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 302 |  |  | 					} else $temp_array['aircraft_shadow'] = 'default.png'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 303 |  |  |                                 } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 304 |  |  |                             		$temp_array['aircraft_shadow'] = 'default.png'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 305 |  |  | 					$temp_array['aircraft_name'] = 'N/A'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 306 |  |  | 					$temp_array['aircraft_manufacturer'] = 'N/A'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 307 |  |  |                             	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 308 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 309 |  |  | 			$fromsource = NULL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 310 |  |  | 			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 311 |  |  | 			elseif (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 312 |  |  | 			elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') $fromsource = 'ivao'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 313 |  |  | 			elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 314 |  |  | 			elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 315 |  |  | 			if (!isset($row['airline_name']) || $row['airline_name'] == '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 316 |  |  | 				if (!is_numeric(substr($row['ident'], 0, 3))) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 317 |  |  | 					if (is_numeric(substr($row['ident'], 2, 1))) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 318 |  |  | 						$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 2),$fromsource); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 319 |  |  | 					} elseif (is_numeric(substr($row['ident'], 3, 1))) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 320 |  |  | 						$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 3),$fromsource); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 321 |  |  | 					} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 322 |  |  | 						$airline_array = $this->getAllAirlineInfo('NA'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 323 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 324 |  |  | 				} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 325 |  |  | 					$airline_array = $this->getAllAirlineInfo('NA'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 326 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 327 |  |  | 				if (count($airline_array) > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 328 |  |  | 					$temp_array['airline_icao'] = $airline_array[0]['icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 329 |  |  | 					$temp_array['airline_iata'] = $airline_array[0]['iata']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 330 |  |  | 					$temp_array['airline_name'] = $airline_array[0]['name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 331 |  |  | 					$temp_array['airline_country'] = $airline_array[0]['country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 332 |  |  | 					$temp_array['airline_callsign'] = $airline_array[0]['callsign']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 333 |  |  | 					$temp_array['airline_type'] = $airline_array[0]['type']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 334 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 335 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 336 |  |  | 				$temp_array['airline_icao'] = $row['airline_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 337 |  |  | 				if (isset($row['airline_iata'])) $temp_array['airline_iata'] = $row['airline_iata']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 338 |  |  | 				else $temp_array['airline_iata'] = 'N/A'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 339 |  |  | 				$temp_array['airline_name'] = $row['airline_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 340 |  |  | 				$temp_array['airline_country'] = $row['airline_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 341 |  |  | 				if (isset($row['airline_callsign'])) $temp_array['airline_callsign'] = $row['airline_callsign']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 342 |  |  | 				else $temp_array['airline_callsign'] = 'N/A'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 343 |  |  | 				$temp_array['airline_type'] = $row['airline_type']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 344 |  |  | 				if ($temp_array['airline_icao'] != '' && $temp_array['airline_iata'] == 'N/A') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 345 |  |  | 					$airline_array = $this->getAllAirlineInfo($temp_array['airline_icao']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 346 |  |  | 					if (count($airline_array) > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 347 |  |  | 						$temp_array['airline_icao'] = $airline_array[0]['icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 348 |  |  | 						$temp_array['airline_iata'] = $airline_array[0]['iata']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 349 |  |  | 						$temp_array['airline_name'] = $airline_array[0]['name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 350 |  |  | 						$temp_array['airline_country'] = $airline_array[0]['country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 351 |  |  | 						$temp_array['airline_callsign'] = $airline_array[0]['callsign']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 352 |  |  | 						$temp_array['airline_type'] = $airline_array[0]['type']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 353 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 354 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 355 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 356 |  |  | 			if (isset($temp_array['airline_iata']) && $temp_array['airline_iata'] != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 357 |  |  | 				$acars_array = $ACARS->getLiveAcarsData($temp_array['airline_iata'].substr($temp_array['ident'],3)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 358 |  |  | 				//$acars_array = ACARS->getLiveAcarsData('BA40YL'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 359 |  |  | 				if (count($acars_array) > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 360 |  |  | 					$temp_array['acars'] = $acars_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 361 |  |  | 					//print_r($acars_array); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 362 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 363 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 364 |  |  | 			if (isset($row['owner_name']) && $row['owner_name'] != '' && $row['owner_name'] != NULL) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 365 |  |  | 				$temp_array['aircraft_owner'] = $row['owner_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 366 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 367 |  |  | 			if ($temp_array['registration'] != "" && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && !isset($temp_array['aircraft_owner'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 368 |  |  | 				$owner_info = $this->getAircraftOwnerByRegistration($temp_array['registration']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 369 |  |  | 				if ($owner_info['owner'] != '') $temp_array['aircraft_owner'] = ucwords(strtolower($owner_info['owner'])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 370 |  |  | 				$temp_array['aircraft_base'] = $owner_info['base']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 371 |  |  | 				$temp_array['aircraft_date_first_reg'] = $owner_info['date_first_reg']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 372 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 373 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 374 |  |  | 			if($temp_array['registration'] != "" || ($globalIVAO && isset($temp_array['aircraft_type']) && $temp_array['aircraft_type'] != '')) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 375 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 376 |  |  | 				if ($globalIVAO) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 377 |  |  | 					if (isset($temp_array['airline_icao']))	$image_array = $Image->getSpotterImage('',$temp_array['aircraft_type'],$temp_array['airline_icao']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 378 |  |  | 					else $image_array = $Image->getSpotterImage('',$temp_array['aircraft_type']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 379 |  |  | 				} else $image_array = $Image->getSpotterImage($temp_array['registration']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 380 |  |  | 				if (count($image_array) > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 381 |  |  | 					$temp_array['image'] = $image_array[0]['image']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 382 |  |  | 					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 383 |  |  | 					$temp_array['image_source'] = $image_array[0]['image_source']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 384 |  |  | 					$temp_array['image_source_website'] = $image_array[0]['image_source_website']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 385 |  |  | 					if ($temp_array['image_source_website'] == '' && $temp_array['image_source'] == 'planespotters') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 386 |  |  | 						$planespotter_url_array = explode("_", $temp_array['image']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 387 |  |  | 						$planespotter_id = str_replace(".jpg", "", $planespotter_url_array[1]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 388 |  |  | 						$temp_array['image_source_website'] = 'http://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 389 |  |  | 					 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 390 |  |  | 					$temp_array['image_copyright'] = $image_array[0]['image_copyright']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 391 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 392 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 393 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 394 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 395 |  |  | 			if (isset($row['departure_airport_time']) && $row['departure_airport_time'] != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 396 |  |  | 				$temp_array['departure_airport_time'] = $row['departure_airport_time']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 397 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 398 |  |  | 			if (isset($row['arrival_airport_time']) && $row['arrival_airport_time'] != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 399 |  |  | 				$temp_array['arrival_airport_time'] = $row['arrival_airport_time']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 400 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 401 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 402 |  |  | 			if ((!isset($globalIVAO) || ! $globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 403 |  |  | 				if ($schedules === true) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 404 |  |  | 					$schedule_array = $Schedule->getSchedule($temp_array['ident']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 405 |  |  | 					//print_r($schedule_array); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 406 |  |  | 					if (count($schedule_array) > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 407 |  |  | 						if ($schedule_array['departure_airport_icao'] != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 408 |  |  | 							$row['departure_airport_icao'] = $schedule_array['departure_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 409 |  |  | 							$temp_array['departure_airport'] = $row['departure_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 410 |  |  | 						} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 411 |  |  | 						if ($schedule_array['arrival_airport_icao'] != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 412 |  |  | 							$row['arrival_airport_icao'] = $schedule_array['arrival_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 413 |  |  | 							$temp_array['arrival_airport'] = $row['arrival_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 414 |  |  | 						} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 415 |  |  | 						$temp_array['departure_airport_time'] = $schedule_array['departure_airport_time']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 416 |  |  | 						$temp_array['arrival_airport_time'] = $schedule_array['arrival_airport_time']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 417 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 418 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 419 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 420 |  |  | 				if (isset($row['real_departure_airport_time']) && $row['real_departure_airport_time'] != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 421 |  |  | 					$temp_array['departure_airport_time'] = $row['real_departure_airport_time']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 422 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 423 |  |  | 				if (isset($row['real_arrival_airport_time']) && $row['real_arrival_airport_time'] != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 424 |  |  | 					$temp_array['real_arrival_airport_time'] = $row['real_arrival_airport_time']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 425 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 426 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 427 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 428 |  |  | 			//if ($row['departure_airport_icao'] != '' && $row['departure_airport_name'] == '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 429 |  |  | 			if ($row['departure_airport_icao'] != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 430 |  |  | 				$departure_airport_array = $this->getAllAirportInfo($row['departure_airport_icao']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 431 |  |  | 				if (!isset($departure_airport_array[0]['name'])) $departure_airport_array = $this->getAllAirportInfo('NA'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 432 |  |  | 			/* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 433 |  |  | 			} elseif ($row['departure_airport_name'] != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 434 |  |  | 				$temp_array['departure_airport_name'] = $row['departure_airport_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 435 |  |  | 				$temp_array['departure_airport_city'] = $row['departure_airport_city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 436 |  |  | 				$temp_array['departure_airport_country'] = $row['departure_airport_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 437 |  |  | 				$temp_array['departure_airport_icao'] = $row['departure_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 438 |  |  | 			*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 439 |  |  | 			} else $departure_airport_array = $this->getAllAirportInfo('NA'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 440 |  |  | 			if (isset($departure_airport_array[0]['name'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 441 |  |  | 				$temp_array['departure_airport_name'] = $departure_airport_array[0]['name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 442 |  |  | 				$temp_array['departure_airport_city'] = $departure_airport_array[0]['city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 443 |  |  | 				$temp_array['departure_airport_country'] = $departure_airport_array[0]['country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 444 |  |  | 				$temp_array['departure_airport_iata'] = $departure_airport_array[0]['iata']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 445 |  |  | 				$temp_array['departure_airport_icao'] = $departure_airport_array[0]['icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 446 |  |  | 				$temp_array['departure_airport_latitude'] = $departure_airport_array[0]['latitude']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 447 |  |  | 				$temp_array['departure_airport_longitude'] = $departure_airport_array[0]['longitude']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 448 |  |  | 				$temp_array['departure_airport_altitude'] = $departure_airport_array[0]['altitude']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 449 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 450 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 451 |  |  | 			/* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 452 |  |  | 			if (isset($row['departure_airport_time'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 453 |  |  | 				$temp_array['departure_airport_time'] = $row['departure_airport_time']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 454 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 455 |  |  | 			*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 456 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 457 |  |  | 			if ($row['arrival_airport_icao'] != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 458 |  |  | 				$arrival_airport_array = $this->getAllAirportInfo($row['arrival_airport_icao']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 459 |  |  | 				if (count($arrival_airport_array) == 0) $arrival_airport_array = $this->getAllAirportInfo('NA'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 460 |  |  | 			} else $arrival_airport_array = $this->getAllAirportInfo('NA'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 461 |  |  | 			if (isset($arrival_airport_array[0]['name'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 462 |  |  | 				$temp_array['arrival_airport_name'] = $arrival_airport_array[0]['name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 463 |  |  | 				$temp_array['arrival_airport_city'] = $arrival_airport_array[0]['city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 464 |  |  | 				$temp_array['arrival_airport_country'] = $arrival_airport_array[0]['country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 465 |  |  | 				$temp_array['arrival_airport_iata'] = $arrival_airport_array[0]['iata']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 466 |  |  | 				$temp_array['arrival_airport_icao'] = $arrival_airport_array[0]['icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 467 |  |  | 				$temp_array['arrival_airport_latitude'] = $arrival_airport_array[0]['latitude']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 468 |  |  | 				$temp_array['arrival_airport_longitude'] = $arrival_airport_array[0]['longitude']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 469 |  |  | 				$temp_array['arrival_airport_altitude'] = $arrival_airport_array[0]['altitude']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 470 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 471 |  |  | 			/* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 472 |  |  | 			if (isset($row['arrival_airport_time'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 473 |  |  | 				$temp_array['arrival_airport_time'] = $row['arrival_airport_time']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 474 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 475 |  |  | 			*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 476 |  |  | 			if (isset($row['pilot_id']) && $row['pilot_id'] != '') $temp_array['pilot_id'] = $row['pilot_id']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 477 |  |  | 			if (isset($row['pilot_name']) && $row['pilot_name'] != '') $temp_array['pilot_name'] = $row['pilot_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 478 |  |  | 			if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 479 |  |  | 			if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 480 |  |  | 			if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 481 |  |  | 			if (isset($row['squawk'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 482 |  |  | 				$temp_array['squawk'] = $row['squawk']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 483 |  |  | 				if ($row['squawk'] != '' && isset($temp_array['country_iso2'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 484 |  |  | 					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['country_iso2']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 485 |  |  | 					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 486 |  |  | 				} elseif ($row['squawk'] != '' && isset($temp_array['over_country'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 487 |  |  | 					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['over_country']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 488 |  |  | 					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 489 |  |  | 				} elseif ($row['squawk'] != '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 490 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 491 |  |  |     			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 492 |  |  | 			$temp_array['query_number_rows'] = $num_rows; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 493 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 494 |  |  | 			$spotter_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 495 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 496 |  |  | 		if ($num_rows == 0) return array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 497 |  |  | 		$spotter_array[0]['query_number_rows'] = $num_rows; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 498 |  |  | 		return $spotter_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 499 |  |  | 	}	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 500 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 501 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 502 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 503 |  |  | 	* Gets all the spotter information | 
            
                                                                                                            
                            
            
                                    
            
            
                | 504 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 505 |  |  | 	* @return Array the spotter information | 
            
                                                                                                            
                            
            
                                    
            
            
                | 506 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 507 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 508 |  |  | 	public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 509 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 510 |  |  | 		global $globalTimezone, $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 511 |  |  | 		require_once(dirname(__FILE__).'/class.Translation.php'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 512 |  |  | 		$Translation = new Translation(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 513 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 514 |  |  | 		date_default_timezone_set('UTC'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 515 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 516 |  |  | 		$query_values = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 517 |  |  | 		$additional_query = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 518 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 519 |  |  | 		if ($q != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 520 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 521 |  |  | 			if (!is_string($q)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 522 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 523 |  |  | 				return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 524 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 525 |  |  | 				$q_array = explode(" ", $q); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 526 |  |  | 				foreach ($q_array as $q_item){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 527 |  |  | 					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 528 |  |  | 					$additional_query .= " AND ("; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 529 |  |  | 					if (is_int($q_item)) $additional_query .= "(spotter_output.spotter_id like '%".$q_item."%') OR "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 530 |  |  | 					$additional_query .= "(spotter_output.aircraft_icao like '%".$q_item."%') OR "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 531 |  |  | 					$additional_query .= "(spotter_output.aircraft_name like '%".$q_item."%') OR "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 532 |  |  | 					$additional_query .= "(spotter_output.aircraft_manufacturer like '%".$q_item."%') OR "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 533 |  |  | 					$additional_query .= "(spotter_output.airline_icao like '%".$q_item."%') OR "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 534 |  |  | 					$additional_query .= "(spotter_output.airline_name like '%".$q_item."%') OR "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 535 |  |  | 					$additional_query .= "(spotter_output.airline_country like '%".$q_item."%') OR "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 536 |  |  | 					$additional_query .= "(spotter_output.departure_airport_icao like '%".$q_item."%') OR "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 537 |  |  | 					$additional_query .= "(spotter_output.departure_airport_name like '%".$q_item."%') OR "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 538 |  |  | 					$additional_query .= "(spotter_output.departure_airport_city like '%".$q_item."%') OR "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 539 |  |  | 					$additional_query .= "(spotter_output.departure_airport_country like '%".$q_item."%') OR "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 540 |  |  | 					$additional_query .= "(spotter_output.arrival_airport_icao like '%".$q_item."%') OR "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 541 |  |  | 					$additional_query .= "(spotter_output.arrival_airport_name like '%".$q_item."%') OR "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 542 |  |  | 					$additional_query .= "(spotter_output.arrival_airport_city like '%".$q_item."%') OR "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 543 |  |  | 					$additional_query .= "(spotter_output.arrival_airport_country like '%".$q_item."%') OR "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 544 |  |  | 					$additional_query .= "(spotter_output.registration like '%".$q_item."%') OR "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 545 |  |  | 					$additional_query .= "(spotter_output.owner_name like '%".$q_item."%') OR "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 546 |  |  | 					$additional_query .= "(spotter_output.pilot_id like '%".$q_item."%') OR "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 547 |  |  | 					$additional_query .= "(spotter_output.pilot_name like '%".$q_item."%') OR "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 548 |  |  | 					$additional_query .= "(spotter_output.ident like '%".$q_item."%') OR "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 549 |  |  | 					$translate = $Translation->ident2icao($q_item); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 550 |  |  | 					if ($translate != $q_item) $additional_query .= "(spotter_output.ident like '%".$translate."%') OR "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 551 |  |  | 					$additional_query .= "(spotter_output.highlight like '%".$q_item."%')"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 552 |  |  | 					$additional_query .= ")"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 553 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 554 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 555 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 556 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 557 |  |  | 		if ($registration != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 558 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 559 |  |  | 			$registration = filter_var($registration,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 560 |  |  | 			if (!is_string($registration)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 561 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 562 |  |  | 				return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 563 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 564 |  |  | 				$additional_query .= " AND spotter_output.registration = :registration"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 565 |  |  | 				$query_values = array_merge($query_values,array(':registration' => $registration)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 566 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 567 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 568 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 569 |  |  | 		if ($aircraft_icao != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 570 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 571 |  |  | 			$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 572 |  |  | 			if (!is_string($aircraft_icao)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 573 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 574 |  |  | 				return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 575 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 576 |  |  | 				$additional_query .= " AND spotter_output.aircraft_icao = :aircraft_icao"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 577 |  |  | 				$query_values = array_merge($query_values,array(':aircraft_icao' => $aircraft_icao)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 578 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 579 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 580 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 581 |  |  | 		if ($aircraft_manufacturer != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 582 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 583 |  |  | 			$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 584 |  |  | 			if (!is_string($aircraft_manufacturer)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 585 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 586 |  |  | 				return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 587 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 588 |  |  | 				$additional_query .= " AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 589 |  |  | 				$query_values = array_merge($query_values,array(':aircraft_manufacturer' => $aircraft_manufacturer)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 590 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 591 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 592 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 593 |  |  | 		if ($highlights == "true") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 594 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 595 |  |  | 			if (!is_string($highlights)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 596 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 597 |  |  | 				return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 598 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 599 |  |  | 				$additional_query .= " AND (spotter_output.highlight <> '')"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 600 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 601 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 602 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 603 |  |  | 		if ($airline_icao != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 604 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 605 |  |  | 			$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 606 |  |  | 			if (!is_string($airline_icao)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 607 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 608 |  |  | 				return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 609 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 610 |  |  | 				$additional_query .= " AND spotter_output.airline_icao = :airline_icao"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 611 |  |  | 				$query_values = array_merge($query_values,array(':airline_icao' => $airline_icao)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 612 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 613 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 614 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 615 |  |  | 		if ($airline_country != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 616 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 617 |  |  | 			$airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 618 |  |  | 			if (!is_string($airline_country)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 619 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 620 |  |  | 				return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 621 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 622 |  |  | 				$additional_query .= " AND spotter_output.airline_country = :airline_country"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 623 |  |  | 				$query_values = array_merge($query_values,array(':airline_country' => $airline_country)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 624 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 625 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 626 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 627 |  |  | 		if ($airline_type != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 628 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 629 |  |  | 			if (!is_string($airline_type)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 630 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 631 |  |  | 				return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 632 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 633 |  |  | 				if ($airline_type == "passenger") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 634 |  |  | 				{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 635 |  |  | 					$additional_query .= " AND (spotter_output.airline_type = 'passenger')"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 636 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 637 |  |  | 				if ($airline_type == "cargo") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 638 |  |  | 				{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 639 |  |  | 					$additional_query .= " AND (spotter_output.airline_type = 'cargo')"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 640 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 641 |  |  | 				if ($airline_type == "military") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 642 |  |  | 				{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 643 |  |  | 					$additional_query .= " AND (spotter_output.airline_type = 'military')"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 644 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 645 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 646 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 647 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 648 |  |  | 		if ($airport != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 649 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 650 |  |  | 			$airport = filter_var($airport,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 651 |  |  | 			if (!is_string($airport)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 652 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 653 |  |  | 				return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 654 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 655 |  |  | 				$additional_query .= " AND (spotter_output.departure_airport_icao = :airport OR spotter_output.arrival_airport_icao = :airport)"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 656 |  |  | 				$query_values = array_merge($query_values,array(':airport' => $airport)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 657 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 658 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 659 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 660 |  |  | 		if ($airport_country != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 661 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 662 |  |  | 			$airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 663 |  |  | 			if (!is_string($airport_country)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 664 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 665 |  |  | 				return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 666 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 667 |  |  | 				$additional_query .= " AND (spotter_output.departure_airport_country = :airport_country OR spotter_output.arrival_airport_country = :airport_country)"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 668 |  |  | 				$query_values = array_merge($query_values,array(':airport_country' => $airport_country)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 669 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 670 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 671 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 672 |  |  | 		if ($callsign != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 673 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 674 |  |  | 			$callsign = filter_var($callsign,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 675 |  |  | 			if (!is_string($callsign)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 676 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 677 |  |  | 				return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 678 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 679 |  |  | 				$translate = $Translation->ident2icao($callsign); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 680 |  |  | 				if ($translate != $callsign) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 681 |  |  | 					$additional_query .= " AND (spotter_output.ident = :callsign OR spotter_output.ident = :translate)"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 682 |  |  | 					$query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 683 |  |  | 				} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 684 |  |  | 					$additional_query .= " AND spotter_output.ident = :callsign"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 685 |  |  | 					$query_values = array_merge($query_values,array(':callsign' => $callsign)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 686 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 687 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 688 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 689 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 690 |  |  | 		if ($owner != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 691 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 692 |  |  | 			$owner = filter_var($owner,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 693 |  |  | 			if (!is_string($owner)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 694 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 695 |  |  | 				return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 696 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 697 |  |  | 				$additional_query .= " AND spotter_output.owner_name = :owner"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 698 |  |  | 				$query_values = array_merge($query_values,array(':owner' => $owner)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 699 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 700 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 701 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 702 |  |  | 		if ($pilot_name != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 703 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 704 |  |  | 			$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 705 |  |  | 			if (!is_string($pilot_name)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 706 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 707 |  |  | 				return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 708 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 709 |  |  | 				$additional_query .= " AND spotter_output.pilot_name = :pilot_name"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 710 |  |  | 				$query_values = array_merge($query_values,array(':pilot_name' => $pilot_name)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 711 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 712 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 713 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 714 |  |  | 		if ($pilot_id != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 715 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 716 |  |  | 			$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 717 |  |  | 			if (!is_string($pilot_id)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 718 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 719 |  |  | 				return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 720 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 721 |  |  | 				$additional_query .= " AND spotter_output.pilot_id = :pilot_id"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 722 |  |  | 				$query_values = array_merge($query_values,array(':pilot_id' => $pilot_id)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 723 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 724 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 725 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 726 |  |  | 		if ($departure_airport_route != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 727 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 728 |  |  | 			$departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 729 |  |  | 			if (!is_string($departure_airport_route)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 730 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 731 |  |  | 				return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 732 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 733 |  |  | 				$additional_query .= " AND spotter_output.departure_airport_icao = :departure_airport_route"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 734 |  |  | 				$query_values = array_merge($query_values,array(':departure_airport_route' => $departure_airport_route)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 735 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 736 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 737 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 738 |  |  | 		if ($arrival_airport_route != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 739 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 740 |  |  | 			$arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 741 |  |  | 			if (!is_string($arrival_airport_route)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 742 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 743 |  |  | 				return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 744 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 745 |  |  | 				$additional_query .= " AND spotter_output.arrival_airport_icao = :arrival_airport_route"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 746 |  |  | 				$query_values = array_merge($query_values,array(':arrival_airport_route' => $arrival_airport_route)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 747 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 748 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 749 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 750 |  |  | 		if ($altitude != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 751 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 752 |  |  | 			$altitude_array = explode(",", $altitude); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 753 |  |  | 			$altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 754 |  |  | 			$altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 755 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 756 |  |  | 			if ($altitude_array[1] != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 757 |  |  | 			{                 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 758 |  |  | 				$altitude_array[0] = substr($altitude_array[0], 0, -2); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 759 |  |  | 				$altitude_array[1] = substr($altitude_array[1], 0, -2); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 760 |  |  | 				$additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 761 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 762 |  |  | 				$altitude_array[0] = substr($altitude_array[0], 0, -2); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 763 |  |  | 				$additional_query .= " AND altitude <= '".$altitude_array[0]."' "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 764 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 765 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 766 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 767 |  |  | 		if ($date_posted != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 768 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 769 |  |  | 			$date_array = explode(",", $date_posted); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 770 |  |  | 			$date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 771 |  |  | 			$date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 772 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 773 |  |  | 			if ($globalTimezone != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 774 |  |  | 				date_default_timezone_set($globalTimezone); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 775 |  |  | 				$datetime = new DateTime(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 776 |  |  | 				$offset = $datetime->format('P'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 777 |  |  | 			} else $offset = '+00:00'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 778 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 779 |  |  | 			if ($date_array[1] != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 780 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 781 |  |  | 				$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 782 |  |  | 				$date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 783 |  |  | 				if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 784 |  |  | 					$additional_query .= " AND TIMESTAMP(CONVERT_TZ(spotter_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' AND TIMESTAMP(CONVERT_TZ(spotter_output.date,'+00:00', '".$offset."')) <= '".$date_array[1]."' "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 785 |  |  | 				} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 786 |  |  | 					$additional_query .= " AND CAST(spotter_output.date AT TIME ZONE INTERVAL ".$offset." AS TIMESTAMP) >= '".$date_array[0]."' AND CAST(spotter_output.date AT TIME ZONE INTERVAL ".$offset." AS TIMESTAMP) <= '".$date_array[1]."' "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 787 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 788 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 789 |  |  | 				$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 790 |  |  | 				if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 791 |  |  | 					$additional_query .= " AND TIMESTAMP(CONVERT_TZ(spotter_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 792 |  |  | 				} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 793 |  |  | 					$additional_query .= " AND CAST(spotter_output.date AT TIME ZONE INTERVAL ".$offset." AS TIMESTAMP) >= '".$date_array[0]."' "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 794 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 795 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 796 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 797 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 798 |  |  | 		if ($limit != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 799 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 800 |  |  | 			$limit_array = explode(",", $limit); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 801 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 802 |  |  | 			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 803 |  |  | 			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 804 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 805 |  |  | 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 806 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 807 |  |  | 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 808 |  |  | 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 809 |  |  | 			} else $limit_query = ""; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 810 |  |  | 		} else $limit_query = ""; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 811 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 812 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 813 |  |  | 		if ($sort != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 814 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 815 |  |  | 			$search_orderby_array = $this->getOrderBy(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 816 |  |  | 			$orderby_query = $search_orderby_array[$sort]['sql']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 817 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 818 |  |  | 			if ($origLat != "" && $origLon != "" && $dist != "") { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 819 |  |  | 				$orderby_query = " ORDER BY distance ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 820 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 821 |  |  | 				$orderby_query = " ORDER BY spotter_output.date DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 822 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 823 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 824 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 825 |  |  | 		if ($includegeodata == "true") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 826 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 827 |  |  | 			$additional_query .= " AND spotter_output.waypoints <> ''"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 828 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 829 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 830 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 831 |  |  | 		if ($origLat != "" && $origLon != "" && $dist != "") { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 832 |  |  | 			$dist = number_format($dist*0.621371,2,'.',''); // convert km to mile | 
            
                                                                                                            
                            
            
                                    
            
            
                | 833 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 834 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 835 |  |  | 				$query="SELECT spotter_output.*, 1.60935*3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - spotter_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(spotter_archive.latitude*pi()/180)*POWER(SIN(($origLon-spotter_archive.longitude)*pi()/180/2),2))) as distance  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 836 |  |  | 						FROM spotter_archive,spotter_output".$filter_query." spotter_output.flightaware_id = spotter_archive.flightaware_id AND spotter_output.ident <> '' ".$additional_query."AND spotter_archive.longitude between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat)*69)) and spotter_archive.latitude between ($origLat-($dist/69)) and ($origLat+($dist/69))  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 837 |  |  | 						AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - spotter_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(spotter_archive.latitude*pi()/180)*POWER(SIN(($origLon-spotter_archive.longitude)*pi()/180/2),2)))) < $dist".$orderby_query; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 838 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 839 |  |  | 				$query="SELECT spotter_output.*, 1.60935 * 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(spotter_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(spotter_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 840 |  |  | 						FROM spotter_archive,spotter_output".$filter_query." spotter_output.flightaware_id = spotter_archive.flightaware_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(spotter_archive.longitude as double precision) between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat))*69) and CAST(spotter_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69))  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 841 |  |  | 						AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(spotter_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(spotter_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query.$orderby_query; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 842 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 843 |  |  | 		} else {		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 844 |  |  | 			$query  = "SELECT spotter_output.* FROM spotter_output".$filter_query." spotter_output.ident <> ''  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 845 |  |  | 					".$additional_query." | 
            
                                                                                                            
                            
            
                                    
            
            
                | 846 |  |  | 					".$orderby_query; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 847 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 848 |  |  | 		$spotter_array = $this->getDataFromDB($query, $query_values,$limit_query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 849 |  |  | 		return $spotter_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 850 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 851 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 852 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 853 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 854 |  |  | 	* Gets all the spotter information based on the latest data entry | 
            
                                                                                                            
                            
            
                                    
            
            
                | 855 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 856 |  |  | 	* @return Array the spotter information | 
            
                                                                                                            
                            
            
                                    
            
            
                | 857 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 858 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 859 |  |  | 	public function getLatestSpotterData($limit = '', $sort = '', $filter = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 860 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 861 |  |  | 		global $global_query; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 862 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 863 |  |  | 		date_default_timezone_set('UTC'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 864 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 865 |  |  | 		$filter_query = $this->getFilter($filter); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 866 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 867 |  |  | 		if ($limit != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 868 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 869 |  |  | 			$limit_array = explode(",", $limit); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 870 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 871 |  |  | 			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 872 |  |  | 			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 873 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 874 |  |  | 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 875 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 876 |  |  | 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 877 |  |  | 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 878 |  |  | 			} else $limit_query = ""; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 879 |  |  | 		} else $limit_query = ""; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 880 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 881 |  |  | 		if ($sort != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 882 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 883 |  |  | 			$search_orderby_array = $this->getOrderBy(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 884 |  |  | 			$orderby_query = $search_orderby_array[$sort]['sql']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 885 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 886 |  |  | 			$orderby_query = " ORDER BY spotter_output.date DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 887 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 888 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 889 |  |  | 		$query  = $global_query.$filter_query." ".$orderby_query; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 890 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 891 |  |  | 		$spotter_array = $this->getDataFromDB($query, array(),$limit_query,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 892 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 893 |  |  | 		return $spotter_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 894 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 895 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 896 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 897 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 898 |  |  | 	* Gets all the spotter information based on a user's latitude and longitude | 
            
                                                                                                            
                            
            
                                    
            
            
                | 899 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 900 |  |  | 	* @return Array the spotter information | 
            
                                                                                                            
                            
            
                                    
            
            
                | 901 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 902 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 903 |  |  | 	public function getLatestSpotterForLayar($lat, $lng, $radius, $interval) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 904 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 905 |  |  | 		date_default_timezone_set('UTC'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 906 |  |  | 		$limit_query = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 907 |  |  | 		if ($lat != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 908 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 909 |  |  | 			if (!is_numeric($lat)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 910 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 911 |  |  | 				return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 912 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 913 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 914 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 915 |  |  | 		if ($lng != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 916 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 917 |  |  | 			if (!is_numeric($lng)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 918 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 919 |  |  | 				return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 920 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 921 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 922 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 923 |  |  | 		if ($radius != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 924 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 925 |  |  | 			if (!is_numeric($radius)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 926 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 927 |  |  | 				return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 928 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 929 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 930 |  |  |     		$additional_query = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 931 |  |  | 		if ($interval != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 932 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 933 |  |  | 			if (!is_string($interval)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 934 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 935 |  |  | 				return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 936 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 937 |  |  | 				if ($interval == "30m"){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 938 |  |  | 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) <= $this_output.date '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 939 |  |  | 				} else if ($interval == "1h"){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 940 |  |  | 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) <= $this_output.date '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 941 |  |  | 				} else if ($interval == "3h"){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 942 |  |  | 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 3 HOUR) <= $this_output.date '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 943 |  |  | 				} else if ($interval == "6h"){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 944 |  |  | 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 6 HOUR) <= $this_output.date '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 945 |  |  | 				} else if ($interval == "12h"){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 946 |  |  | 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 HOUR) <= $this_output.date '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 947 |  |  | 				} else if ($interval == "24h"){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 948 |  |  | 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 24 HOUR) <= $this_output.date '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 949 |  |  | 				} else if ($interval == "7d"){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 950 |  |  | 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) <= $this_output.date '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 951 |  |  | 				} else if ($interval == "30d"){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 952 |  |  | 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 DAY) <= $this_output.date '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 953 |  |  | 				}  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 954 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 955 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 956 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 957 |  |  | 		$query  = "SELECT spotter_output.*, ( 6371 * acos( cos( radians($lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians($lng) ) + sin( radians($lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_output  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 958 |  |  |                    WHERE spotter_output.latitude <> ''  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 959 |  |  | 				   AND spotter_output.longitude <> ''  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 960 |  |  |                    ".$additional_query." | 
            
                                                                                                            
                            
            
                                    
            
            
                | 961 |  |  |                    HAVING distance < :radius   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 962 |  |  | 				   ORDER BY distance"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 963 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 964 |  |  | 		$spotter_array = $this->getDataFromDB($query, array(':radius' => $radius),$limit_query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 965 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 966 |  |  | 		return $spotter_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 967 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 968 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 969 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 970 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 971 |  |  | 	* Gets all the spotter information sorted by the newest aircraft type | 
            
                                                                                                            
                            
            
                                    
            
            
                | 972 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 973 |  |  | 	* @return Array the spotter information | 
            
                                                                                                            
                            
            
                                    
            
            
                | 974 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 975 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 976 |  |  | 	public function getNewestSpotterDataSortedByAircraftType($limit = '', $sort = '',$filter = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 977 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 978 |  |  | 		global $global_query; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 979 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 980 |  |  | 		date_default_timezone_set('UTC'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 981 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 982 |  |  | 		$filter_query = $this->getFilter($filter,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 983 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 984 |  |  | 		$limit_query = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 985 |  |  | 		if ($limit != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 986 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 987 |  |  | 			$limit_array = explode(",", $limit); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 988 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 989 |  |  | 			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 990 |  |  | 			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 991 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 992 |  |  | 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 993 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 994 |  |  | 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 995 |  |  | 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 996 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 997 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 998 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 999 |  |  | 		if ($sort != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1000 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1001 |  |  | 			$search_orderby_array = $this->getOrderBy(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1002 |  |  | 			$orderby_query = $search_orderby_array[$sort]['sql']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1003 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1004 |  |  | 			$orderby_query = " ORDER BY spotter_output.date DESC "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1005 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1006 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1007 |  |  | 		$query  = $global_query." ".$filter_query." spotter_output.aircraft_name <> '' GROUP BY spotter_output.aircraft_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1008 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1009 |  |  | 		$spotter_array = $this->getDataFromDB($query, array(), $limit_query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1010 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1011 |  |  | 		return $spotter_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1012 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1013 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1014 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1015 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1016 |  |  | 	* Gets all the spotter information sorted by the newest aircraft registration | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1017 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1018 |  |  | 	* @return Array the spotter information | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1019 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1020 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1021 |  |  | 	public function getNewestSpotterDataSortedByAircraftRegistration($limit = '', $sort = '', $filter = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1022 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1023 |  |  | 		global $global_query; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1024 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1025 |  |  | 		date_default_timezone_set('UTC'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1026 |  |  | 		$filter_query = $this->getFilter($filter,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1027 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1028 |  |  | 		$limit_query = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1029 |  |  | 		if ($limit != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1030 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1031 |  |  | 			$limit_array = explode(",", $limit); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1032 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1033 |  |  | 			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1034 |  |  | 			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1035 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1036 |  |  | 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1037 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1038 |  |  | 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1039 |  |  | 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1040 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1041 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1042 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1043 |  |  | 		if ($sort != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1044 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1045 |  |  | 			$search_orderby_array = $this->getOrderBy(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1046 |  |  | 			$orderby_query = $search_orderby_array[$sort]['sql']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1047 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1048 |  |  | 			$orderby_query = " ORDER BY spotter_output.date DESC "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1049 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1050 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1051 |  |  | 		$query  = $global_query." ".$filter_query." spotter_output.registration <> '' GROUP BY spotter_output.registration,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1052 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1053 |  |  | 		$spotter_array = $this->getDataFromDB($query, array(), $limit_query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1054 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1055 |  |  | 		return $spotter_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1056 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1057 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1058 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1059 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1060 |  |  | 	* Gets all the spotter information sorted by the newest airline | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1061 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1062 |  |  | 	* @return Array the spotter information | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1063 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1064 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1065 |  |  | 	public function getNewestSpotterDataSortedByAirline($limit = '', $sort = '',$filter = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1066 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1067 |  |  | 		global $global_query; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1068 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1069 |  |  | 		date_default_timezone_set('UTC'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1070 |  |  | 		$filter_query = $this->getFilter($filter,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1071 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1072 |  |  | 		$limit_query = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1073 |  |  | 		if ($limit != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1074 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1075 |  |  | 			$limit_array = explode(",", $limit); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1076 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1077 |  |  | 			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1078 |  |  | 			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1079 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1080 |  |  | 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1081 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1082 |  |  | 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1083 |  |  | 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1084 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1085 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1086 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1087 |  |  | 		if ($sort != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1088 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1089 |  |  | 			$search_orderby_array = $this->getOrderBy(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1090 |  |  | 			$orderby_query = $search_orderby_array[$sort]['sql']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1091 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1092 |  |  | 			$orderby_query = " ORDER BY spotter_output.date DESC "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1093 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1094 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1095 |  |  | 		$query  = $global_query." ".$filter_query." spotter_output.airline_name <> '' GROUP BY spotter_output.airline_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1096 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1097 |  |  | 		$spotter_array = $this->getDataFromDB($query, array(), $limit_query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1098 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1099 |  |  | 		return $spotter_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1100 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1101 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1102 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1103 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1104 |  |  | 	* Gets all the spotter information sorted by the newest departure airport | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1105 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1106 |  |  | 	* @return Array the spotter information | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1107 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1108 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1109 |  |  | 	public function getNewestSpotterDataSortedByDepartureAirport($limit = '', $sort = '', $filter = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1110 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1111 |  |  | 		global $global_query; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1112 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1113 |  |  | 		date_default_timezone_set('UTC'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1114 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1115 |  |  | 		$filter_query = $this->getFilter($filter,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1116 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1117 |  |  | 		$limit_query = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1118 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1119 |  |  | 		if ($limit != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1120 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1121 |  |  | 			$limit_array = explode(",", $limit); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1122 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1123 |  |  | 			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1124 |  |  | 			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1125 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1126 |  |  | 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1127 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1128 |  |  | 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1129 |  |  | 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1130 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1131 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1132 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1133 |  |  | 		if ($sort != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1134 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1135 |  |  | 			$search_orderby_array = $this->getOrderBy(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1136 |  |  | 			$orderby_query = $search_orderby_array[$sort]['sql']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1137 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1138 |  |  | 			$orderby_query = " ORDER BY spotter_output.date DESC "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1139 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1140 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1141 |  |  | 		$query  = $global_query." ".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' GROUP BY spotter_output.departure_airport_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1142 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1143 |  |  | 		$spotter_array = $this->getDataFromDB($query, array(), $limit_query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1144 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1145 |  |  | 		return $spotter_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1146 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1147 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1148 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1149 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1150 |  |  | 	* Gets all the spotter information sorted by the newest arrival airport | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1151 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1152 |  |  | 	* @return Array the spotter information | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1153 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1154 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1155 |  |  | 	public function getNewestSpotterDataSortedByArrivalAirport($limit = '', $sort = '', $filter = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1156 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1157 |  |  | 		global $global_query; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1158 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1159 |  |  | 		date_default_timezone_set('UTC'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1160 |  |  | 		$filter_query = $this->getFilter($filter,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1161 |  |  | 		$limit_query = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1162 |  |  | 		if ($limit != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1163 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1164 |  |  | 			$limit_array = explode(",", $limit); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1165 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1166 |  |  | 			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1167 |  |  | 			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1168 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1169 |  |  | 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1170 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1171 |  |  | 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1172 |  |  | 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1173 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1174 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1175 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1176 |  |  | 		if ($sort != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1177 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1178 |  |  | 			$search_orderby_array = $this->getOrderBy(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1179 |  |  | 			$orderby_query = $search_orderby_array[$sort]['sql']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1180 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1181 |  |  | 			$orderby_query = " ORDER BY spotter_output.date DESC "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1182 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1183 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1184 |  |  | 		$query  = $global_query.$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' GROUP BY spotter_output.arrival_airport_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1185 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1186 |  |  | 		$spotter_array = $this->getDataFromDB($query, array(), $limit_query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1187 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1188 |  |  | 		return $spotter_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1189 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1190 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1191 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1192 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1193 |  |  | 	* Gets all the spotter information based on the spotter id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1194 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1195 |  |  | 	* @return Array the spotter information | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1196 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1197 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1198 |  |  | 	public function getSpotterDataByID($id = '') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1199 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1200 |  |  | 		global $global_query; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1201 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1202 |  |  | 		date_default_timezone_set('UTC'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1203 |  |  | 		if ($id == '') return array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1204 |  |  | 		$additional_query = "spotter_output.spotter_id = :id"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1205 |  |  | 		$query_values = array(':id' => $id); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1206 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1207 |  |  | 		//$query  = $global_query." WHERE spotter_output.ident <> '' ".$additional_query." "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1208 |  |  | 		$query  = $global_query." WHERE ".$additional_query." "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1209 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1210 |  |  | 		$spotter_array = $this->getDataFromDB($query,$query_values); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1211 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1212 |  |  | 		return $spotter_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1213 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1214 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1215 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1216 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1217 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1218 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1219 |  |  | 	* Gets all the spotter information based on the callsign | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1220 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1221 |  |  | 	* @return Array the spotter information | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1222 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1223 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1224 |  |  | 	public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1225 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1226 |  |  | 		global $global_query; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1227 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1228 |  |  | 		date_default_timezone_set('UTC'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1229 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1230 |  |  | 		$query_values = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1231 |  |  | 		$limit_query = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1232 |  |  | 		$additional_query = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1233 |  |  | 		if ($ident != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1234 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1235 |  |  | 			if (!is_string($ident)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1236 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1237 |  |  | 				return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1238 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1239 |  |  | 				$additional_query = " AND (spotter_output.ident = :ident)"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1240 |  |  | 				$query_values = array(':ident' => $ident); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1241 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1242 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1243 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1244 |  |  | 		if ($limit != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1245 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1246 |  |  | 			$limit_array = explode(",", $limit); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1247 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1248 |  |  | 			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1249 |  |  | 			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1250 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1251 |  |  | 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1252 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1253 |  |  | 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1254 |  |  | 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1255 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1256 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1257 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1258 |  |  | 		if ($sort != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1259 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1260 |  |  | 			$search_orderby_array = $this->getOrderBy(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1261 |  |  | 			$orderby_query = $search_orderby_array[$sort]['sql']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1262 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1263 |  |  | 			$orderby_query = " ORDER BY spotter_output.date DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1264 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1265 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1266 |  |  | 		$query = $global_query." WHERE spotter_output.ident <> '' ".$additional_query." ".$orderby_query; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1267 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1268 |  |  | 		$spotter_array = $this->getDataFromDB($query, $query_values, $limit_query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1269 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1270 |  |  | 		return $spotter_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1271 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1272 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1273 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1274 |  |  | 	* Gets all the spotter information based on the owner | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1275 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1276 |  |  | 	* @return Array the spotter information | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1277 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1278 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1279 |  |  | 	public function getSpotterDataByOwner($owner = '', $limit = '', $sort = '') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1280 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1281 |  |  | 		global $global_query; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1282 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1283 |  |  | 		date_default_timezone_set('UTC'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1284 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1285 |  |  | 		$query_values = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1286 |  |  | 		$limit_query = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1287 |  |  | 		$additional_query = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1288 |  |  | 		if ($owner != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1289 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1290 |  |  | 			if (!is_string($owner)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1291 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1292 |  |  | 				return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1293 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1294 |  |  | 				$additional_query = " AND (spotter_output.owner_name = :owner)"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1295 |  |  | 				$query_values = array(':owner' => $owner); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1296 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1297 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1298 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1299 |  |  | 		if ($limit != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1300 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1301 |  |  | 			$limit_array = explode(",", $limit); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1302 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1303 |  |  | 			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1304 |  |  | 			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1305 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1306 |  |  | 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1307 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1308 |  |  | 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1309 |  |  | 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1310 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1311 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1312 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1313 |  |  | 		if ($sort != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1314 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1315 |  |  | 			$search_orderby_array = $this->getOrderBy(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1316 |  |  | 			$orderby_query = $search_orderby_array[$sort]['sql']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1317 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1318 |  |  | 			$orderby_query = " ORDER BY spotter_output.date DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1319 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1320 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1321 |  |  | 		$query = $global_query." WHERE spotter_output.owner_name <> '' ".$additional_query." ".$orderby_query; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1322 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1323 |  |  | 		$spotter_array = $this->getDataFromDB($query, $query_values, $limit_query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1324 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1325 |  |  | 		return $spotter_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1326 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1327 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1328 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1329 |  |  | 	* Gets all the spotter information based on the pilot | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1330 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1331 |  |  | 	* @return Array the spotter information | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1332 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1333 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1334 |  |  | 	public function getSpotterDataByPilot($pilot = '', $limit = '', $sort = '') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1335 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1336 |  |  | 		global $global_query; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1337 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1338 |  |  | 		date_default_timezone_set('UTC'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1339 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1340 |  |  | 		$query_values = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1341 |  |  | 		$limit_query = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1342 |  |  | 		$additional_query = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1343 |  |  | 		if ($pilot != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1344 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1345 |  |  | 			$additional_query = " AND (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot)"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1346 |  |  | 			$query_values = array(':pilot' => $pilot); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1347 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1348 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1349 |  |  | 		if ($limit != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1350 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1351 |  |  | 			$limit_array = explode(",", $limit); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1352 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1353 |  |  | 			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1354 |  |  | 			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1355 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1356 |  |  | 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1357 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1358 |  |  | 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1359 |  |  | 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1360 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1361 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1362 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1363 |  |  | 		if ($sort != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1364 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1365 |  |  | 			$search_orderby_array = $this->getOrderBy(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1366 |  |  | 			$orderby_query = $search_orderby_array[$sort]['sql']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1367 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1368 |  |  | 			$orderby_query = " ORDER BY spotter_output.date DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1369 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1370 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1371 |  |  | 		$query = $global_query." WHERE spotter_output.pilot_name <> '' ".$additional_query." ".$orderby_query; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1372 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1373 |  |  | 		$spotter_array = $this->getDataFromDB($query, $query_values, $limit_query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1374 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1375 |  |  | 		return $spotter_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1376 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1377 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1378 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1379 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1380 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1381 |  |  | 	* Gets all the spotter information based on the aircraft type | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1382 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1383 |  |  | 	* @return Array the spotter information | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1384 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1385 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1386 |  |  | 	public function getSpotterDataByAircraft($aircraft_type = '', $limit = '', $sort = '', $filter = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1387 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1388 |  |  | 		global $global_query; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1389 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1390 |  |  | 		date_default_timezone_set('UTC'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1391 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1392 |  |  | 		$query_values = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1393 |  |  | 		$limit_query = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1394 |  |  | 		$additional_query = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1395 |  |  | 		$filter_query = $this->getFilter($filter,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1396 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1397 |  |  | 		if ($aircraft_type != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1398 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1399 |  |  | 			if (!is_string($aircraft_type)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1400 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1401 |  |  | 				return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1402 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1403 |  |  | 				$additional_query = " AND (spotter_output.aircraft_icao = :aircraft_type)"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1404 |  |  | 				$query_values = array(':aircraft_type' => $aircraft_type); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1405 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1406 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1407 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1408 |  |  | 		if ($limit != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1409 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1410 |  |  | 			$limit_array = explode(",", $limit); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1411 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1412 |  |  | 			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1413 |  |  | 			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1414 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1415 |  |  | 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1416 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1417 |  |  | 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1418 |  |  | 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1419 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1420 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1421 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1422 |  |  | 		if ($sort != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1423 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1424 |  |  | 			$search_orderby_array = $this->getOrderBy(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1425 |  |  | 			$orderby_query = $search_orderby_array[$sort]['sql']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1426 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1427 |  |  | 			$orderby_query = " ORDER BY spotter_output.date DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1428 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1429 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1430 |  |  | 		$query = $global_query.$filter_query." spotter_output.ident <> '' ".$additional_query." ".$orderby_query; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1431 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1432 |  |  | 		$spotter_array = $this->getDataFromDB($query, $query_values, $limit_query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1433 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1434 |  |  | 		return $spotter_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1435 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1436 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1437 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1438 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1439 |  |  | 	* Gets all the spotter information based on the aircraft registration | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1440 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1441 |  |  | 	* @return Array the spotter information | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1442 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1443 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1444 |  |  | 	public function getSpotterDataByRegistration($registration = '', $limit = '', $sort = '', $filter = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1445 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1446 |  |  | 		global $global_query; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1447 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1448 |  |  | 		date_default_timezone_set('UTC'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1449 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1450 |  |  | 		$query_values = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1451 |  |  | 		$limit_query = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1452 |  |  | 		$additional_query = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1453 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1454 |  |  | 		if ($registration != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1455 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1456 |  |  | 			if (!is_string($registration)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1457 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1458 |  |  | 				return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1459 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1460 |  |  | 				$additional_query = " (spotter_output.registration = :registration)"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1461 |  |  | 				$query_values = array(':registration' => $registration); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1462 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1463 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1464 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1465 |  |  | 		if ($limit != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1466 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1467 |  |  | 			$limit_array = explode(",", $limit); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1468 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1469 |  |  | 			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1470 |  |  | 			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1471 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1472 |  |  | 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1473 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1474 |  |  | 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1475 |  |  | 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1476 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1477 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1478 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1479 |  |  | 		if ($sort != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1480 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1481 |  |  | 			$search_orderby_array = $this->getOrderBy(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1482 |  |  | 			$orderby_query = $search_orderby_array[$sort]['sql']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1483 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1484 |  |  | 			$orderby_query = " ORDER BY spotter_output.date DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1485 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1486 |  |  | 		$filter_query = $this->getFilter($filter,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1487 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1488 |  |  | 		//$query = $global_query.$filter_query." spotter_output.ident <> '' ".$additional_query." ".$orderby_query; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1489 |  |  | 		$query = $global_query.$filter_query." ".$additional_query." ".$orderby_query; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1490 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1491 |  |  | 		$spotter_array = $this->getDataFromDB($query, $query_values, $limit_query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1492 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1493 |  |  | 		return $spotter_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1494 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1495 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1496 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1497 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1498 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1499 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1500 |  |  | 	* Gets all the spotter information based on the airline | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1501 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1502 |  |  | 	* @return Array the spotter information | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1503 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1504 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1505 |  |  | 	public function getSpotterDataByAirline($airline = '', $limit = '', $sort = '',$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1506 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1507 |  |  | 		global $global_query; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1508 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1509 |  |  | 		date_default_timezone_set('UTC'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1510 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1511 |  |  | 		$query_values = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1512 |  |  | 		$limit_query = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1513 |  |  | 		$additional_query = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1514 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1515 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1516 |  |  | 		if ($airline != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1517 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1518 |  |  | 			if (!is_string($airline)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1519 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1520 |  |  | 				return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1521 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1522 |  |  | 				$additional_query = " AND (spotter_output.airline_icao = :airline)"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1523 |  |  | 				$query_values = array(':airline' => $airline); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1524 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1525 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1526 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1527 |  |  | 		if ($limit != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1528 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1529 |  |  | 			$limit_array = explode(",", $limit); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1530 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1531 |  |  | 			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1532 |  |  | 			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1533 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1534 |  |  | 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1535 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1536 |  |  | 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1537 |  |  | 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1538 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1539 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1540 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1541 |  |  | 		if ($sort != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1542 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1543 |  |  | 			$search_orderby_array = $this->getOrderBy(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1544 |  |  | 			$orderby_query = $search_orderby_array[$sort]['sql']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1545 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1546 |  |  | 			$orderby_query = " ORDER BY spotter_output.date DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1547 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1548 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1549 |  |  | 		$query = $global_query.$filter_query." spotter_output.ident <> '' ".$additional_query." ".$orderby_query; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1550 |  |  | 		$spotter_array = $this->getDataFromDB($query, $query_values, $limit_query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1551 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1552 |  |  | 		return $spotter_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1553 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1554 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1555 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1556 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1557 |  |  | 	* Gets all the spotter information based on the airport | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1558 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1559 |  |  | 	* @return Array the spotter information | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1560 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1561 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1562 |  |  | 	public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1563 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1564 |  |  | 		global $global_query; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1565 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1566 |  |  | 		date_default_timezone_set('UTC'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1567 |  |  | 		$query_values = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1568 |  |  | 		$limit_query = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1569 |  |  | 		$additional_query = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1570 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1571 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1572 |  |  | 		if ($airport != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1573 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1574 |  |  | 			if (!is_string($airport)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1575 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1576 |  |  | 				return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1577 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1578 |  |  | 				$additional_query .= " AND ((spotter_output.departure_airport_icao = :airport) OR (spotter_output.arrival_airport_icao = :airport))"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1579 |  |  | 				$query_values = array(':airport' => $airport); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1580 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1581 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1582 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1583 |  |  | 		if ($limit != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1584 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1585 |  |  | 			$limit_array = explode(",", $limit); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1586 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1587 |  |  | 			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1588 |  |  | 			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1589 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1590 |  |  | 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1591 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1592 |  |  | 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1593 |  |  | 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1594 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1595 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1596 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1597 |  |  | 		if ($sort != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1598 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1599 |  |  | 			$search_orderby_array = $this->getOrderBy(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1600 |  |  | 			$orderby_query = $search_orderby_array[$sort]['sql']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1601 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1602 |  |  | 			$orderby_query = " ORDER BY spotter_output.date DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1603 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1604 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1605 |  |  | 		$query = $global_query.$filter_query." spotter_output.ident <> '' ".$additional_query." AND ((spotter_output.departure_airport_icao <> 'NA') AND (spotter_output.arrival_airport_icao <> 'NA')) ".$orderby_query; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1606 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1607 |  |  | 		$spotter_array = $this->getDataFromDB($query, $query_values, $limit_query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1608 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1609 |  |  | 		return $spotter_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1610 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1611 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1612 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1613 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1614 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1615 |  |  | 	* Gets all the spotter information based on the date | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1616 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1617 |  |  | 	* @return Array the spotter information | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1618 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1619 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1620 |  |  | 	public function getSpotterDataByDate($date = '', $limit = '', $sort = '',$filter = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1621 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1622 |  |  | 		global $global_query, $globalTimezone, $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1623 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1624 |  |  | 		$query_values = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1625 |  |  | 		$limit_query = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1626 |  |  | 		$additional_query = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1627 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1628 |  |  | 		$filter_query = $this->getFilter($filter,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1629 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1630 |  |  | 		if ($date != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1631 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1632 |  |  | 			if ($globalTimezone != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1633 |  |  | 				date_default_timezone_set($globalTimezone); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1634 |  |  | 				$datetime = new DateTime($date); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1635 |  |  | 				$offset = $datetime->format('P'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1636 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1637 |  |  | 				date_default_timezone_set('UTC'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1638 |  |  | 				$datetime = new DateTime($date); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1639 |  |  | 				$offset = '+00:00'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1640 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1641 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1642 |  |  | 				$additional_query = " AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1643 |  |  | 				$query_values = array(':date' => $datetime->format('Y-m-d'), ':offset' => $offset); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1644 |  |  | 			} elseif ($globalDBdriver == 'pgsql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1645 |  |  | 				//$globalTimezone = 'UTC'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1646 |  |  | 				$additional_query = " AND to_char(spotter_output.date AT TIME ZONE :timezone,'YYYY-mm-dd') = :date "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1647 |  |  | 				$query_values = array(':date' => $datetime->format('Y-m-d'), ':timezone' => $globalTimezone); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1648 |  |  | 				//$additional_query = " AND to_char(spotter_output.date,'YYYY-mm-dd') = :date "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1649 |  |  | 				//$query_values = array(':date' => $datetime->format('Y-m-d')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1650 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1651 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1652 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1653 |  |  | 		if ($limit != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1654 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1655 |  |  | 			$limit_array = explode(",", $limit); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1656 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1657 |  |  | 			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1658 |  |  | 			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1659 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1660 |  |  | 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1661 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1662 |  |  | 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1663 |  |  | 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1664 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1665 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1666 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1667 |  |  | 		if ($sort != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1668 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1669 |  |  | 			$search_orderby_array = $this->getOrderBy(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1670 |  |  | 			$orderby_query = $search_orderby_array[$sort]['sql']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1671 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1672 |  |  | 			$orderby_query = " ORDER BY spotter_output.date DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1673 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1674 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1675 |  |  | 		$query = $global_query.$filter_query." spotter_output.ident <> '' ".$additional_query.$orderby_query; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1676 |  |  | 		$spotter_array = $this->getDataFromDB($query, $query_values, $limit_query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1677 |  |  | 		return $spotter_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1678 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1679 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1680 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1681 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1682 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1683 |  |  | 	* Gets all the spotter information based on the country name | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1684 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1685 |  |  | 	* @return Array the spotter information | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1686 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1687 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1688 |  |  | 	public function getSpotterDataByCountry($country = '', $limit = '', $sort = '',$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1689 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1690 |  |  | 		global $global_query; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1691 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1692 |  |  | 		date_default_timezone_set('UTC'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1693 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1694 |  |  | 		$query_values = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1695 |  |  | 		$limit_query = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1696 |  |  | 		$additional_query = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1697 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1698 |  |  | 		if ($country != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1699 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1700 |  |  | 			if (!is_string($country)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1701 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1702 |  |  | 				return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1703 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1704 |  |  | 				$additional_query .= " AND ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country))"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1705 |  |  | 				$additional_query .= " OR spotter_output.airline_country = :country"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1706 |  |  | 				$query_values = array(':country' => $country); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1707 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1708 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1709 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1710 |  |  | 		if ($limit != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1711 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1712 |  |  | 			$limit_array = explode(",", $limit); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1713 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1714 |  |  | 			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1715 |  |  | 			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1716 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1717 |  |  | 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1718 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1719 |  |  | 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1720 |  |  | 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1721 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1722 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1723 |  |  | 					 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1724 |  |  | 		if ($sort != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1725 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1726 |  |  | 			$search_orderby_array = $this->getOrderBy(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1727 |  |  | 			$orderby_query = $search_orderby_array[$sort]['sql']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1728 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1729 |  |  | 			$orderby_query = " ORDER BY spotter_output.date DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1730 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1731 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1732 |  |  | 		$query = $global_query.$filter_query." spotter_output.ident <> '' ".$additional_query." ".$orderby_query; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1733 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1734 |  |  | 		$spotter_array = $this->getDataFromDB($query, $query_values, $limit_query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1735 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1736 |  |  | 		return $spotter_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1737 |  |  | 	}	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1738 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1739 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1740 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1741 |  |  | 	* Gets all the spotter information based on the manufacturer name | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1742 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1743 |  |  | 	* @return Array the spotter information | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1744 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1745 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1746 |  |  | 	public function getSpotterDataByManufacturer($aircraft_manufacturer = '', $limit = '', $sort = '', $filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1747 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1748 |  |  | 		global $global_query; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1749 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1750 |  |  | 		date_default_timezone_set('UTC'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1751 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1752 |  |  | 		$query_values = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1753 |  |  | 		$additional_query = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1754 |  |  | 		$limit_query = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1755 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1756 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1757 |  |  | 		if ($aircraft_manufacturer != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1758 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1759 |  |  | 			if (!is_string($aircraft_manufacturer)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1760 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1761 |  |  | 				return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1762 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1763 |  |  | 				$additional_query .= " AND (spotter_output.aircraft_manufacturer = :aircraft_manufacturer)"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1764 |  |  | 				$query_values = array(':aircraft_manufacturer' => $aircraft_manufacturer); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1765 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1766 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1767 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1768 |  |  | 		if ($limit != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1769 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1770 |  |  | 			$limit_array = explode(",", $limit); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1771 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1772 |  |  | 			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1773 |  |  | 			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1774 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1775 |  |  | 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1776 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1777 |  |  | 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1778 |  |  | 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1779 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1780 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1781 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1782 |  |  | 		if ($sort != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1783 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1784 |  |  | 			$search_orderby_array = $this->getOrderBy(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1785 |  |  | 			$orderby_query = $search_orderby_array[$sort]['sql']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1786 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1787 |  |  | 			$orderby_query = " ORDER BY spotter_output.date DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1788 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1789 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1790 |  |  | 		$query = $global_query.$filter_query." spotter_output.ident <> '' ".$additional_query." ".$orderby_query; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1791 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1792 |  |  | 		$spotter_array = $this->getDataFromDB($query, $query_values, $limit_query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1793 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1794 |  |  | 		return $spotter_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1795 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1796 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1797 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1798 |  |  |    | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1799 |  |  |    | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1800 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1801 |  |  | 	* Gets a list of all aircraft that take a route | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1802 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1803 |  |  | 	* @param String $departure_airport_icao ICAO code of departure airport | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1804 |  |  | 	* @param String $arrival_airport_icao ICAO code of arrival airport | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1805 |  |  | 	* @return Array the spotter information | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1806 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1807 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1808 |  |  | 	public function getSpotterDataByRoute($departure_airport_icao = '', $arrival_airport_icao = '', $limit = '', $sort = '', $filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1809 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1810 |  |  | 		global $global_query; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1811 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1812 |  |  | 		$query_values = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1813 |  |  | 		$additional_query = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1814 |  |  | 		$limit_query = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1815 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1816 |  |  | 		if ($departure_airport_icao != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1817 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1818 |  |  | 			if (!is_string($departure_airport_icao)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1819 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1820 |  |  | 				return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1821 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1822 |  |  | 				$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1823 |  |  | 				$additional_query .= " AND (spotter_output.departure_airport_icao = :departure_airport_icao)"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1824 |  |  | 				//$additional_query .= " AND (spotter_output.departure_airport_icao = :departure_airport_icao AND spotter_output.real_departure_airport_icao IS NULL) OR spotter_output.real_departure_airport_icao = :departure_airport_icao"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1825 |  |  | 				$query_values = array(':departure_airport_icao' => $departure_airport_icao); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1826 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1827 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1828 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1829 |  |  | 		if ($arrival_airport_icao != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1830 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1831 |  |  | 			if (!is_string($arrival_airport_icao)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1832 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1833 |  |  | 				return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1834 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1835 |  |  | 				$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1836 |  |  | 				$additional_query .= " AND (spotter_output.arrival_airport_icao = :arrival_airport_icao)"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1837 |  |  | 				//$additional_query .= " AND ((spotter_output.arrival_airport_icao = :arrival_airport_icao AND spotter_output.real_arrival_airport_icao IS NULL) OR spotter_output.real_arrival_airport_icao = :arrival_airport_icao)"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1838 |  |  | 				$query_values = array_merge($query_values,array(':arrival_airport_icao' => $arrival_airport_icao)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1839 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1840 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1841 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1842 |  |  | 		if ($limit != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1843 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1844 |  |  | 			$limit_array = explode(",", $limit); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1845 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1846 |  |  | 			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1847 |  |  | 			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1848 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1849 |  |  | 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1850 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1851 |  |  | 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1852 |  |  | 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1853 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1854 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1855 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1856 |  |  | 		if ($sort != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1857 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1858 |  |  | 			$search_orderby_array = $this->getOrderBy(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1859 |  |  | 			$orderby_query = $search_orderby_array[$sort]['sql']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1860 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1861 |  |  | 			$orderby_query = " ORDER BY spotter_output.date DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1862 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1863 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1864 |  |  | 		$query = $global_query.$filter_query." spotter_output.ident <> '' ".$additional_query." ".$orderby_query; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1865 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1866 |  |  | 		//$result = mysqli_query($GLOBALS["___mysqli_ston"], $query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1867 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1868 |  |  | 		$spotter_array = $this->getDataFromDB($query, $query_values, $limit_query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1869 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1870 |  |  | 		return $spotter_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1871 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1872 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1873 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1874 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1875 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1876 |  |  | 	* Gets all the spotter information based on the special column in the table | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1877 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1878 |  |  | 	* @return Array the spotter information | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1879 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1880 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1881 |  |  | 	public function getSpotterDataByHighlight($limit = '', $sort = '', $filter = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1882 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1883 |  |  | 		global $global_query; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1884 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1885 |  |  | 		date_default_timezone_set('UTC'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1886 |  |  | 		$filter_query = $this->getFilter($filter,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1887 |  |  | 		$limit_query = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1888 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1889 |  |  | 		if ($limit != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1890 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1891 |  |  | 			$limit_array = explode(",", $limit); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1892 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1893 |  |  | 			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1894 |  |  | 			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1895 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1896 |  |  | 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1897 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1898 |  |  | 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1899 |  |  | 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1900 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1901 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1902 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1903 |  |  | 		if ($sort != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1904 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1905 |  |  | 			$search_orderby_array = $this->getOrderBy(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1906 |  |  | 			$orderby_query = $search_orderby_array[$sort]['sql']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1907 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1908 |  |  | 			$orderby_query = " ORDER BY spotter_output.date DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1909 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1910 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1911 |  |  | 		$query  = $global_query.$filter_query." spotter_output.highlight <> '' ".$orderby_query; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1912 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1913 |  |  | 		$spotter_array = $this->getDataFromDB($query, array(), $limit_query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1914 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1915 |  |  | 		return $spotter_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1916 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1917 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1918 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1919 |  |  | 	* Gets all the highlight based on a aircraft registration | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1920 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1921 |  |  | 	* @return String the highlight text | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1922 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1923 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1924 |  |  | 	public function getHighlightByRegistration($registration,$filter = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1925 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1926 |  |  | 		global $global_query; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1927 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1928 |  |  | 		date_default_timezone_set('UTC'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1929 |  |  | 		$filter_query = $this->getFilter($filter,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1930 |  |  | 		$registration = filter_var($registration,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1931 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1932 |  |  | 		$query  = $global_query.$filter_query." spotter_output.highlight <> '' AND spotter_output.registration = :registration"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1933 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1934 |  |  | 		$sth->execute(array(':registration' => $registration)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1935 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1936 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1937 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1938 |  |  | 			$highlight = $row['highlight']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1939 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1940 |  |  | 		if (isset($highlight)) return $highlight; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1941 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1942 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1943 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1944 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1945 |  |  | 	* Gets the squawk usage from squawk code | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1946 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1947 |  |  | 	* @param String $squawk squawk code | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1948 |  |  | 	* @param String $country country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1949 |  |  | 	* @return String usage | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1950 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1951 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1952 |  |  | 	public function getSquawkUsage($squawk = '',$country = 'FR') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1953 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1954 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1955 |  |  | 		$squawk = filter_var($squawk,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1956 |  |  | 		$country = filter_var($country,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1957 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1958 |  |  | 		$query  = "SELECT squawk.* FROM squawk WHERE squawk.code = :squawk AND squawk.country = :country LIMIT 1"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1959 |  |  | 		$query_values = array(':squawk' => ltrim($squawk,'0'), ':country' => $country); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1960 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1961 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1962 |  |  | 		$sth->execute($query_values); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1963 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1964 |  |  | 		$row = $sth->fetch(PDO::FETCH_ASSOC); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1965 |  |  | 		$sth->closeCursor(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1966 |  |  | 		if (count($row) > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1967 |  |  | 			return $row['usage']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1968 |  |  | 		} else return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1969 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1970 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1971 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1972 |  |  | 	* Gets the airport icao from the iata | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1973 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1974 |  |  | 	* @param String $airport_iata the iata code of the airport | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1975 |  |  | 	* @return String airport iata | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1976 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1977 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1978 |  |  | 	public function getAirportIcao($airport_iata = '') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1979 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1980 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1981 |  |  | 		$airport_iata = filter_var($airport_iata,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1982 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1983 |  |  | 		$query  = "SELECT airport.* FROM airport WHERE airport.iata = :airport LIMIT 1"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1984 |  |  | 		$query_values = array(':airport' => $airport_iata); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1985 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1986 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1987 |  |  | 		$sth->execute($query_values); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1988 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1989 |  |  | 		$row = $sth->fetch(PDO::FETCH_ASSOC); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1990 |  |  | 		$sth->closeCursor(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1991 |  |  | 		if (count($row) > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1992 |  |  | 			return $row['icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1993 |  |  | 		} else return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1994 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1995 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1996 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1997 |  |  | 	* Gets the airport distance | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1998 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1999 |  |  | 	* @param String $airport_icao the icao code of the airport | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2000 |  |  | 	* @param Float $latitude the latitude | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2001 |  |  | 	* @param Float $longitude the longitude | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2002 |  |  | 	* @return Float distance to the airport | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2003 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2004 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2005 |  |  | 	public function getAirportDistance($airport_icao,$latitude,$longitude) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2006 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2007 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2008 |  |  | 		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2009 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2010 |  |  | 		$query  = "SELECT airport.latitude, airport.longitude FROM airport WHERE airport.icao = :airport LIMIT 1"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2011 |  |  | 		$query_values = array(':airport' => $airport_icao); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2012 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2013 |  |  | 		$sth->execute($query_values); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2014 |  |  | 		$row = $sth->fetch(PDO::FETCH_ASSOC); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2015 |  |  | 		$sth->closeCursor(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2016 |  |  | 		if (count($row) > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2017 |  |  | 			$airport_latitude = $row['latitude']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2018 |  |  | 			$airport_longitude = $row['longitude']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2019 |  |  | 			$Common = new Common(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2020 |  |  | 			return $Common->distance($latitude,$longitude,$airport_latitude,$airport_longitude); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2021 |  |  | 		} else return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2022 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2023 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2024 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2025 |  |  | 	* Gets the airport info based on the icao | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2026 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2027 |  |  | 	* @param String $airport the icao code of the airport | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2028 |  |  | 	* @return Array airport information | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2029 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2030 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2031 |  |  | 	public function getAllAirportInfo($airport = '') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2032 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2033 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2034 |  |  | 		$airport = filter_var($airport,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2035 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2036 |  |  | 		$query_values = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2037 |  |  | 		if ($airport == 'NA') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2038 |  |  | 			return array(array('name' => 'Not available','city' => 'N/A', 'country' => 'N/A','iata' => 'NA','icao' => 'NA','altitude' => NULL,'latitude' => 0,'longitude' => 0,'type' => 'NA','home_link' => '','wikipedia_link' => '','image_thumb' => '', 'image' => '')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2039 |  |  | 		} elseif ($airport == '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2040 |  |  | 			$query  = "SELECT airport.name, airport.city, airport.country, airport.iata, airport.icao, airport.latitude, airport.longitude, airport.altitude, airport.type, airport.home_link, airport.wikipedia_link, airport.image_thumb, airport.image FROM airport"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2041 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2042 |  |  | 			$query  = "SELECT airport.name, airport.city, airport.country, airport.iata, airport.icao, airport.latitude, airport.longitude, airport.altitude, airport.type, airport.home_link, airport.wikipedia_link, airport.image_thumb, airport.image FROM airport WHERE airport.icao = :airport LIMIT 1"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2043 |  |  | 			$query_values = array(':airport' => $airport); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2044 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2045 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2046 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2047 |  |  | 		$sth->execute($query_values); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2048 |  |  | 		/* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2049 |  |  | 		$airport_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2050 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2051 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2052 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2053 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2054 |  |  | 			$temp_array['name'] = $row['name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2055 |  |  | 			$temp_array['city'] = $row['city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2056 |  |  | 			$temp_array['country'] = $row['country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2057 |  |  | 			$temp_array['iata'] = $row['iata']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2058 |  |  | 			$temp_array['icao'] = $row['icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2059 |  |  | 			$temp_array['latitude'] = $row['latitude']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2060 |  |  | 			$temp_array['longitude'] = $row['longitude']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2061 |  |  | 			$temp_array['altitude'] = $row['altitude']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2062 |  |  | 			$temp_array['home_link'] = $row['home_link']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2063 |  |  | 			$temp_array['wikipedia_link'] = $row['wikipedia_link']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2064 |  |  | 			$temp_array['image'] = $row['image']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2065 |  |  | 			$temp_array['image_thumb'] = $row['image_thumb']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2066 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2067 |  |  | 			$airport_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2068 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2069 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2070 |  |  | 		return $airport_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2071 |  |  | 		*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2072 |  |  | 		return $sth->fetchAll(PDO::FETCH_ASSOC); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2073 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2074 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2075 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2076 |  |  | 	* Gets the airport info based on the country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2077 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2078 |  |  | 	* @param Array $countries Airports countries | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2079 |  |  | 	* @return Array airport information | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2080 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2081 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2082 |  |  | 	public function getAllAirportInfobyCountry($countries) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2083 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2084 |  |  | 		$lst_countries = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2085 |  |  | 		foreach ($countries as $country) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2086 |  |  | 			$country = filter_var($country,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2087 |  |  | 			if ($lst_countries == '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2088 |  |  | 				$lst_countries = "'".$country."'"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2089 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2090 |  |  | 				$lst_countries .= ",'".$country."'"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2091 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2092 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2093 |  |  | 		$query  = "SELECT airport.* FROM airport WHERE airport.country IN (".$lst_countries.")"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2094 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2095 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2096 |  |  | 		$sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2097 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2098 |  |  | 		$airport_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2099 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2100 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2101 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2102 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2103 |  |  | 			$temp_array['name'] = $row['name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2104 |  |  | 			$temp_array['city'] = $row['city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2105 |  |  | 			$temp_array['country'] = $row['country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2106 |  |  | 			$temp_array['iata'] = $row['iata']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2107 |  |  | 			$temp_array['icao'] = $row['icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2108 |  |  | 			$temp_array['latitude'] = $row['latitude']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2109 |  |  | 			$temp_array['longitude'] = $row['longitude']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2110 |  |  | 			$temp_array['altitude'] = $row['altitude']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2111 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2112 |  |  | 			$airport_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2113 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2114 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2115 |  |  | 		return $airport_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2116 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2117 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2118 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2119 |  |  | 	* Gets airports info based on the coord | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2120 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2121 |  |  | 	* @param Array $coord Airports longitude min,latitude min, longitude max, latitude max | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2122 |  |  | 	* @return Array airport information | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2123 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2124 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2125 |  |  | 	public function getAllAirportInfobyCoord($coord) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2126 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2127 |  |  | 		global $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2128 |  |  | 		if (is_array($coord)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2129 |  |  | 			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2130 |  |  | 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2131 |  |  | 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2132 |  |  | 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2133 |  |  | 		} else return array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2134 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2135 |  |  | 			$query  = "SELECT airport.* FROM airport WHERE airport.latitude BETWEEN ".$minlat." AND ".$maxlat." AND airport.longitude BETWEEN ".$minlong." AND ".$maxlong." AND airport.type != 'closed'"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2136 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2137 |  |  | 			$query  = "SELECT airport.* FROM airport WHERE CAST(airport.latitude AS FLOAT) BETWEEN ".$minlat." AND ".$maxlat." AND CAST(airport.longitude AS FLOAT) BETWEEN ".$minlong." AND ".$maxlong." AND airport.type != 'closed'"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2138 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2139 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2140 |  |  | 		$sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2141 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2142 |  |  | 		$airport_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2143 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2144 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2145 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2146 |  |  | 			$temp_array = $row; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2147 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2148 |  |  | 			$airport_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2149 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2150 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2151 |  |  | 		return $airport_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2152 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2153 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2154 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2155 |  |  | 	* Gets waypoints info based on the coord | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2156 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2157 |  |  | 	* @param Array $coord waypoints coord | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2158 |  |  | 	* @return Array airport information | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2159 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2160 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2161 |  |  | 	public function getAllWaypointsInfobyCoord($coord) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2162 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2163 |  |  | 		if (is_array($coord)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2164 |  |  | 			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2165 |  |  | 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2166 |  |  | 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2167 |  |  | 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2168 |  |  | 		} else return array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2169 |  |  | 		//$query  = "SELECT waypoints.* FROM waypoints WHERE waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2170 |  |  | 		$query  = "SELECT waypoints.* FROM waypoints WHERE (waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong.") OR (waypoints.latitude_end BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_end BETWEEN ".$minlong." AND ".$maxlong.")"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2171 |  |  | 		//$query  = "SELECT waypoints.* FROM waypoints"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2172 |  |  | 		//$query  = "SELECT waypoints.* FROM waypoints INNER JOIN (SELECT waypoints.* FROM waypoints WHERE waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong.") w ON w.name_end = waypoints.name_begin OR w.name_begin = waypoints.name_begin OR w.name_begin = waypoints.name_end OR w.name_end = waypoints.name_end"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2173 |  |  | 		//$query = "SELECT * FROM waypoints LEFT JOIN waypoints w ON waypoints.name_end = w.name_begin WHERE waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2174 |  |  | 		//$query = "SELECT z.name_begin as name_begin, z.name_end as name_end, z.latitude_begin as latitude_begin, z.longitude_begin as longitude_begin, z.latitude_end as latitude_end, z.longitude_end as longitude_end, z.segment_name as segment_name, w.name_end as name_end_seg2, w.latitude_end as latitude_end_seg2, w.longitude_end as longitude_end_seg2, w.segment_name as segment_name_seg2 FROM waypoints z INNER JOIN waypoints w ON z.name_end = w.name_begin WHERE z.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND z.longitude_begin BETWEEN ".$minlong." AND ".$maxlong; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2175 |  |  | 		//echo $query; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2176 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2177 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2178 |  |  | 		$sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2179 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2180 |  |  | 		$waypoints_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2181 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2182 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2183 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2184 |  |  | 			$temp_array = $row; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2185 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2186 |  |  | 			$waypoints_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2187 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2188 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2189 |  |  | 		return $waypoints_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2190 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2191 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2192 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2193 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2194 |  |  | 	* Gets the airline info based on the icao code or iata code | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2195 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2196 |  |  | 	* @param String $airline_icao the iata code of the airport | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2197 |  |  | 	* @return Array airport information | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2198 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2199 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2200 |  |  | 	public function getAllAirlineInfo($airline_icao, $fromsource = NULL) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2201 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2202 |  |  | 		global $globalUseRealAirlines; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2203 |  |  | 		if (isset($globalUseRealAirlines) && $globalUseRealAirlines) $fromsource = NULL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2204 |  |  | 		$airline_icao = strtoupper(filter_var($airline_icao,FILTER_SANITIZE_STRING)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2205 |  |  | 		if ($airline_icao == 'NA') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2206 |  |  | 			$airline_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2207 |  |  | 			$airline_array[] = array('name' => 'Not Available','iata' => 'NA', 'icao' => 'NA', 'callsign' => '', 'country' => 'NA', 'type' =>''); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2208 |  |  | 			return $airline_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2209 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2210 |  |  | 			if (strlen($airline_icao) == 2) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2211 |  |  | 				if ($fromsource === NULL) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2212 |  |  | 					$query  = "SELECT airlines.name, airlines.iata, airlines.icao, airlines.callsign, airlines.country, airlines.type FROM airlines WHERE airlines.iata = :airline_icao AND airlines.active = 'Y' AND airlines.forsource IS NULL LIMIT 1"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2213 |  |  | 				} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2214 |  |  | 					$query  = "SELECT airlines.name, airlines.iata, airlines.icao, airlines.callsign, airlines.country, airlines.type FROM airlines WHERE airlines.iata = :airline_icao AND airlines.active = 'Y' AND airlines.forsource = :fromsource LIMIT 1"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2215 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2216 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2217 |  |  | 				if ($fromsource === NULL) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2218 |  |  | 					$query  = "SELECT airlines.name, airlines.iata, airlines.icao, airlines.callsign, airlines.country, airlines.type FROM airlines WHERE airlines.icao = :airline_icao AND airlines.active = 'Y' AND airlines.forsource IS NULL LIMIT 1"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2219 |  |  | 				} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2220 |  |  | 					$query  = "SELECT airlines.name, airlines.iata, airlines.icao, airlines.callsign, airlines.country, airlines.type FROM airlines WHERE airlines.icao = :airline_icao AND airlines.active = 'Y' AND airlines.forsource = :fromsource LIMIT 1"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2221 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2222 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2223 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2224 |  |  | 			$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2225 |  |  | 			if ($fromsource === NULL) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2226 |  |  | 				$sth->execute(array(':airline_icao' => $airline_icao)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2227 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2228 |  |  | 				$sth->execute(array(':airline_icao' => $airline_icao,':fromsource' => $fromsource)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2229 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2230 |  |  |                         /* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2231 |  |  | 			$airline_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2232 |  |  | 			$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2233 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2234 |  |  | 			while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2235 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2236 |  |  | 				$temp_array['name'] = $row['name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2237 |  |  | 				$temp_array['iata'] = $row['iata']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2238 |  |  | 				$temp_array['icao'] = $row['icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2239 |  |  | 				$temp_array['callsign'] = $row['callsign']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2240 |  |  | 				$temp_array['country'] = $row['country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2241 |  |  | 				$temp_array['type'] = $row['type']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2242 |  |  | 				$airline_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2243 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2244 |  |  | 			return $airline_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2245 |  |  | 			*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2246 |  |  | 			$result = $sth->fetchAll(PDO::FETCH_ASSOC); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2247 |  |  | 			if (empty($result) && $fromsource !== NULL) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2248 |  |  | 				/* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2249 |  |  | 				$query = 'SELECT COUNT(*) AS nb FROM airlines WHERE forsource = :fromsource'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2250 |  |  | 				$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2251 |  |  | 				$sth->execute(array(':fromsource' => $fromsource)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2252 |  |  | 				$row = $sth->fetch(PDO::FETCH_ASSOC); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2253 |  |  | 				$sth->closeCursor(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2254 |  |  | 				if ($row['nb'] == 0) $result = $this->getAllAirlineInfo($airline_icao); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2255 |  |  | 				*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2256 |  |  | 				$result = $this->getAllAirlineInfo($airline_icao); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2257 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2258 |  |  | 			return $result; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2259 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2260 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2261 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2262 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2263 |  |  | 	* Gets the airline info based on the airline name | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2264 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2265 |  |  | 	* @param String $airline_name the name of the airline | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2266 |  |  | 	* @return Array airline information | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2267 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2268 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2269 |  |  | 	public function getAllAirlineInfoByName($airline_name, $fromsource = NULL) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2270 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2271 |  |  | 		global $globalUseRealAirlines; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2272 |  |  | 		if (isset($globalUseRealAirlines) && $globalUseRealAirlines) $fromsource = NULL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2273 |  |  | 		$airline_name = strtolower(filter_var($airline_name,FILTER_SANITIZE_STRING)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2274 |  |  | 		$query  = "SELECT airlines.name, airlines.iata, airlines.icao, airlines.callsign, airlines.country, airlines.type FROM airlines WHERE lower(airlines.name) = :airline_name AND airlines.active = 'Y' AND airlines.forsource IS NULL LIMIT 1"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2275 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2276 |  |  | 		if ($fromsource === NULL) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2277 |  |  | 			$sth->execute(array(':airline_name' => $airline_name)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2278 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2279 |  |  | 			$sth->execute(array(':airline_name' => $airline_name,':fromsource' => $fromsource)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2280 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2281 |  |  | 		$result = $sth->fetchAll(PDO::FETCH_ASSOC); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2282 |  |  | 		if (empty($result) && $fromsource !== NULL) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2283 |  |  | 			$query = 'SELECT COUNT(*) AS nb FROM airlines WHERE forsource = :fromsource'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2284 |  |  | 			$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2285 |  |  | 			$sth->execute(array(':fromsource' => $fromsource)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2286 |  |  | 			$row = $sth->fetch(PDO::FETCH_ASSOC); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2287 |  |  | 			$sth->closeCursor(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2288 |  |  | 			if ($row['nb'] == 0) $result = $this->getAllAirlineInfoByName($airline_name); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2289 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2290 |  |  | 		return $result; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2291 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2292 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2293 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2294 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2295 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2296 |  |  | 	* Gets the aircraft info based on the aircraft type | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2297 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2298 |  |  | 	* @param String $aircraft_type the aircraft type | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2299 |  |  | 	* @return Array aircraft information | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2300 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2301 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2302 |  |  | 	public function getAllAircraftInfo($aircraft_type) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2303 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2304 |  |  | 		$aircraft_type = filter_var($aircraft_type,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2305 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2306 |  |  | 		if ($aircraft_type == 'NA') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2307 |  |  | 			return array(array('icao' => 'NA','type' => 'Not Available', 'manufacturer' => 'Not Available', 'aircraft_shadow' => NULL)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2308 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2309 |  |  | 		$query  = "SELECT aircraft.icao, aircraft.type,aircraft.manufacturer,aircraft.aircraft_shadow, aircraft.official_page, aircraft.aircraft_description, aircraft.engine_type, aircraft.engine_count, aircraft.wake_category FROM aircraft WHERE aircraft.icao = :aircraft_type"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2310 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2311 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2312 |  |  | 		$sth->execute(array(':aircraft_type' => $aircraft_type)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2313 |  |  | 		/* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2314 |  |  | 		$aircraft_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2315 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2316 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2317 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2318 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2319 |  |  | 			$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2320 |  |  | 			$temp_array['icao'] = $row['icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2321 |  |  | 			$temp_array['type'] = $row['type']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2322 |  |  | 			$temp_array['manufacturer'] = $row['manufacturer']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2323 |  |  | 			$temp_array['aircraft_shadow'] = $row['aircraft_shadow']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2324 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2325 |  |  | 			$aircraft_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2326 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2327 |  |  | 		return $aircraft_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2328 |  |  | 		*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2329 |  |  | 		return $sth->fetchAll(PDO::FETCH_ASSOC); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2330 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2331 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2332 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2333 |  |  | 	* Gets the aircraft icao based on the aircraft name/type | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2334 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2335 |  |  | 	* @param String $aircraft_type the aircraft type | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2336 |  |  | 	* @return String aircraft information | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2337 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2338 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2339 |  |  | 	public function getAircraftIcao($aircraft_type) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2340 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2341 |  |  | 		$aircraft_type = filter_var($aircraft_type,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2342 |  |  | 		$all_aircraft = array('737-300' => 'B733', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2343 |  |  | 				'777-200' => 'B772', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2344 |  |  | 				'777-200ER' => 'B772', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2345 |  |  | 				'777-300ER' => 'B77W', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2346 |  |  | 				'c172p' => 'C172', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2347 |  |  | 				'aerostar' => 'AEST', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2348 |  |  | 				'A320-211' => 'A320', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2349 |  |  | 				'747-8i' => 'B748', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2350 |  |  | 				'A380' => 'A388'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2351 |  |  | 		if (isset($all_aircraft[$aircraft_type])) return $all_aircraft[$aircraft_type]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2352 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2353 |  |  | 		$query  = "SELECT aircraft.icao FROM aircraft WHERE aircraft.type LIKE :saircraft_type OR aircraft.type = :aircraft_type OR aircraft.icao = :aircraft_type LIMIT 1"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2354 |  |  | 		$aircraft_type = strtoupper($aircraft_type); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2355 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2356 |  |  | 		$sth->execute(array(':saircraft_type' => '%'.$aircraft_type.'%',':aircraft_type' => $aircraft_type,)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2357 |  |  | 		$result = $sth->fetchAll(PDO::FETCH_ASSOC); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2358 |  |  | 		if (isset($result[0]['icao'])) return $result[0]['icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2359 |  |  | 		else return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2360 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2361 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2362 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2363 |  |  | 	* Gets the aircraft info based on the aircraft modes | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2364 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2365 |  |  | 	* @param String $aircraft_modes the aircraft ident (hex) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2366 |  |  | 	* @return String aircraft type | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2367 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2368 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2369 |  |  | 	public function getAllAircraftType($aircraft_modes) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2370 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2371 |  |  | 		$aircraft_modes = filter_var($aircraft_modes,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2372 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2373 |  |  | 		$query  = "SELECT aircraft_modes.ICAOTypeCode FROM aircraft_modes WHERE aircraft_modes.ModeS = :aircraft_modes ORDER BY FirstCreated DESC LIMIT 1"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2374 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2375 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2376 |  |  | 		$sth->execute(array(':aircraft_modes' => $aircraft_modes)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2377 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2378 |  |  | 		$row = $sth->fetch(PDO::FETCH_ASSOC); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2379 |  |  | 		$sth->closeCursor(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2380 |  |  | 		if (isset($row['icaotypecode'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2381 |  |  | 			$icao = $row['icaotypecode']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2382 |  |  | 			if (isset($this->aircraft_correct_icaotype[$icao])) $icao = $this->aircraft_correct_icaotype[$icao]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2383 |  |  | 			return $icao; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2384 |  |  | 		} else return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2385 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2386 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2387 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2388 |  |  | 	* Gets the aircraft info based on the aircraft registration | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2389 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2390 |  |  | 	* @param String $registration the aircraft registration | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2391 |  |  | 	* @return String aircraft type | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2392 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2393 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2394 |  |  | 	public function getAllAircraftTypeByRegistration($registration) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2395 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2396 |  |  | 		$registration = filter_var($registration,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2397 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2398 |  |  | 		$query  = "SELECT aircraft_modes.ICAOTypeCode FROM aircraft_modes WHERE aircraft_modes.registration = :registration ORDER BY FirstCreated DESC LIMIT 1"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2399 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2400 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2401 |  |  | 		$sth->execute(array(':registration' => $registration)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2402 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2403 |  |  | 		$row = $sth->fetch(PDO::FETCH_ASSOC); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2404 |  |  | 		$sth->closeCursor(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2405 |  |  | 		if (isset($row['icaotypecode'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2406 |  |  | 			return $row['icaotypecode']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2407 |  |  | 		} else return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2408 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2409 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2410 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2411 |  |  | 	* Gets the spotter_id and flightaware_id based on the aircraft registration | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2412 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2413 |  |  | 	* @param String $registration the aircraft registration | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2414 |  |  | 	* @return Array spotter_id and flightaware_id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2415 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2416 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2417 |  |  | 	public function getAllIDByRegistration($registration) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2418 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2419 |  |  | 		$registration = filter_var($registration,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2420 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2421 |  |  | 		$query  = "SELECT spotter_id,flightaware_id, date FROM spotter_output WHERE spotter_output.registration = :registration"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2422 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2423 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2424 |  |  | 		$sth->execute(array(':registration' => $registration)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2425 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2426 |  |  | 		$idarray = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2427 |  |  | 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2428 |  |  | 			$date = $row['date']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2429 |  |  | 			$idarray[$date] = array('flightaware_id' => $row['flightaware_id'],'spotter_id' => $row['spotter_id']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2430 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2431 |  |  | 		return $idarray; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2432 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2433 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2434 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2435 |  |  | 	* Gets correct aircraft operator code | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2436 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2437 |  |  | 	* @param String $operator the aircraft operator code (callsign) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2438 |  |  | 	* @return String aircraft operator code | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2439 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2440 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2441 |  |  | 	public function getOperator($operator) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2442 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2443 |  |  | 		$operator = filter_var($operator,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2444 |  |  | 		$query  = "SELECT translation.operator_correct FROM translation WHERE translation.operator = :operator LIMIT 1"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2445 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2446 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2447 |  |  | 		$sth->execute(array(':operator' => $operator)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2448 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2449 |  |  | 		$row = $sth->fetch(PDO::FETCH_ASSOC); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2450 |  |  | 		$sth->closeCursor(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2451 |  |  | 		if (isset($row['operator_correct'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2452 |  |  | 			return $row['operator_correct']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2453 |  |  | 		} else return $operator; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2454 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2455 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2456 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2457 |  |  | 	* Gets the aircraft route based on the aircraft callsign | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2458 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2459 |  |  | 	* @param String $callsign the aircraft callsign | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2460 |  |  | 	* @return Array aircraft type | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2461 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2462 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2463 |  |  | 	public function getRouteInfo($callsign) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2464 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2465 |  |  | 		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2466 |  |  |                 if ($callsign == '') return array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2467 |  |  | 		$query  = "SELECT routes.Operator_ICAO, routes.FromAirport_ICAO, routes.ToAirport_ICAO, routes.RouteStop, routes.FromAirport_Time, routes.ToAirport_Time FROM routes WHERE CallSign = :callsign LIMIT 1"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2468 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2469 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2470 |  |  | 		$sth->execute(array(':callsign' => $callsign)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2471 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2472 |  |  | 		$row = $sth->fetch(PDO::FETCH_ASSOC); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2473 |  |  | 		$sth->closeCursor(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2474 |  |  | 		if (count($row) > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2475 |  |  | 			return $row; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2476 |  |  | 		} else return array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2477 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2478 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2479 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2480 |  |  | 	* Gets the aircraft info based on the aircraft registration | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2481 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2482 |  |  | 	* @param String $registration the aircraft registration | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2483 |  |  | 	* @return Array aircraft information | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2484 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2485 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2486 |  |  | 	public function getAircraftInfoByRegistration($registration) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2487 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2488 |  |  | 		$registration = filter_var($registration,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2489 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2490 |  |  | 		$query  = "SELECT spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer, spotter_output.airline_icao FROM spotter_output WHERE spotter_output.registration = :registration"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2491 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2492 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2493 |  |  | 		$sth->execute(array(':registration' => $registration)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2494 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2495 |  |  | 		$aircraft_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2496 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2497 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2498 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2499 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2500 |  |  | 			$temp_array['airline_icao'] = $row['airline_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2501 |  |  | 			$temp_array['aircraft_icao'] = $row['aircraft_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2502 |  |  | 			$temp_array['aircraft_name'] = $row['aircraft_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2503 |  |  | 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2504 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2505 |  |  | 			$aircraft_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2506 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2507 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2508 |  |  | 		return $aircraft_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2509 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2510 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2511 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2512 |  |  | 	* Gets the aircraft owner & base based on the aircraft registration | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2513 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2514 |  |  | 	* @param String $registration the aircraft registration | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2515 |  |  | 	* @return Array aircraft information | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2516 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2517 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2518 |  |  | 	public function getAircraftOwnerByRegistration($registration) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2519 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2520 |  |  | 		$registration = filter_var($registration,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2521 |  |  | 		$Connection = new Connection($this->db); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2522 |  |  | 		if ($Connection->tableExists('aircraft_owner')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2523 |  |  | 			$query  = "SELECT aircraft_owner.base, aircraft_owner.owner, aircraft_owner.date_first_reg FROM aircraft_owner WHERE registration = :registration LIMIT 1"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2524 |  |  | 			$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2525 |  |  | 			$sth->execute(array(':registration' => $registration)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2526 |  |  | 			$result = $sth->fetch(PDO::FETCH_ASSOC); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2527 |  |  | 			$sth->closeCursor(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2528 |  |  | 			return $result; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2529 |  |  | 		} else return array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2530 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2531 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2532 |  |  |    | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2533 |  |  |   /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2534 |  |  | 	* Gets all flights (but with only little info) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2535 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2536 |  |  | 	* @return Array basic flight information | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2537 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2538 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2539 |  |  | 	public function getAllFlightsforSitemap() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2540 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2541 |  |  | 		//$query  = "SELECT spotter_output.spotter_id, spotter_output.ident, spotter_output.airline_name, spotter_output.aircraft_name, spotter_output.aircraft_icao FROM spotter_output ORDER BY LIMIT "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2542 |  |  | 		$query  = "SELECT spotter_output.spotter_id FROM spotter_output ORDER BY spotter_id DESC LIMIT 200 OFFSET 0"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2543 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2544 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2545 |  |  | 		$sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2546 |  |  |                   /* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2547 |  |  | 		$flight_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2548 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2549 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2550 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2551 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2552 |  |  | 			$temp_array['spotter_id'] = $row['spotter_id']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2553 |  |  | //			$temp_array['ident'] = $row['ident']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2554 |  |  | //			$temp_array['airline_name'] = $row['airline_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2555 |  |  | //			$temp_array['aircraft_type'] = $row['aircraft_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2556 |  |  | //			$temp_array['aircraft_name'] = $row['aircraft_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2557 |  |  | 			//$temp_array['image'] = $row['image']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2558 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2559 |  |  | 			$flight_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2560 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2561 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2562 |  |  | 		return $flight_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2563 |  |  | 		*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2564 |  |  | 		return $sth->fetchAll(PDO::FETCH_ASSOC); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2565 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2566 |  |  |    | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2567 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2568 |  |  | 	* Gets a list of all aircraft manufacturers | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2569 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2570 |  |  | 	* @return Array list of aircraft types | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2571 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2572 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2573 |  |  | 	public function getAllManufacturers() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2574 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2575 |  |  | 		/* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2576 |  |  | 		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer AS aircraft_manufacturer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2577 |  |  | 								FROM spotter_output | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2578 |  |  | 								WHERE spotter_output.aircraft_manufacturer <> ''  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2579 |  |  | 								ORDER BY spotter_output.aircraft_manufacturer ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2580 |  |  | 		  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2581 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2582 |  |  | 		$query = "SELECT DISTINCT manufacturer AS aircraft_manufacturer FROM aircraft WHERE manufacturer <> '' ORDER BY manufacturer ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2583 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2584 |  |  | 		$sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2585 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2586 |  |  | 		$manufacturer_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2587 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2588 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2589 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2590 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2591 |  |  | 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2592 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2593 |  |  | 			$manufacturer_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2594 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2595 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2596 |  |  | 		return $manufacturer_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2597 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2598 |  |  |    | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2599 |  |  |    | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2600 |  |  |   /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2601 |  |  | 	* Gets a list of all aircraft types | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2602 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2603 |  |  | 	* @return Array list of aircraft types | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2604 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2605 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2606 |  |  | 	public function getAllAircraftTypes($filters = array()) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2607 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2608 |  |  | 		/* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2609 |  |  | 		$query  = "SELECT DISTINCT spotter_output.aircraft_icao AS aircraft_icao, spotter_output.aircraft_name AS aircraft_name | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2610 |  |  | 								FROM spotter_output   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2611 |  |  | 								WHERE spotter_output.aircraft_icao <> ''  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2612 |  |  | 								ORDER BY spotter_output.aircraft_name ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2613 |  |  | 								 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2614 |  |  | 		*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2615 |  |  | 		//$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2616 |  |  | 		//$query = "SELECT DISTINCT icao AS aircraft_icao, type AS aircraft_name, manufacturer AS aircraft_manufacturer FROM aircraft".$filter_query." icao <> '' ORDER BY aircraft_manufacturer ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2617 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2618 |  |  | 		$query = "SELECT DISTINCT icao AS aircraft_icao, type AS aircraft_name, manufacturer AS aircraft_manufacturer FROM aircraft WHERE icao <> '' ORDER BY aircraft_manufacturer ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2619 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2620 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2621 |  |  | 		$sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2622 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2623 |  |  | 		$aircraft_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2624 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2625 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2626 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2627 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2628 |  |  | 			$temp_array['aircraft_icao'] = $row['aircraft_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2629 |  |  | 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2630 |  |  | 			$temp_array['aircraft_name'] = $row['aircraft_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2631 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2632 |  |  | 			$aircraft_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2633 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2634 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2635 |  |  | 		return $aircraft_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2636 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2637 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2638 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2639 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2640 |  |  | 	* Gets a list of all aircraft registrations | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2641 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2642 |  |  | 	* @return Array list of aircraft registrations | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2643 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2644 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2645 |  |  | 	public function getAllAircraftRegistrations($filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2646 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2647 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2648 |  |  | 		$query  = "SELECT DISTINCT spotter_output.registration  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2649 |  |  | 				FROM spotter_output".$filter_query." spotter_output.registration <> ''  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2650 |  |  | 				ORDER BY spotter_output.registration ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2651 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2652 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2653 |  |  | 		$sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2654 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2655 |  |  | 		$aircraft_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2656 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2657 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2658 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2659 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2660 |  |  | 			$temp_array['registration'] = $row['registration']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2661 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2662 |  |  | 			$aircraft_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2663 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2664 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2665 |  |  | 		return $aircraft_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2666 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2667 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2668 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2669 |  |  | 	* Gets all source name | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2670 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2671 |  |  | 	* @param String type format of source | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2672 |  |  | 	* @return Array list of source name | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2673 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2674 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2675 |  |  | 	public function getAllSourceName($type = '',$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2676 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2677 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2678 |  |  | 		$query_values = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2679 |  |  | 		$query  = "SELECT DISTINCT spotter_output.source_name  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2680 |  |  | 				FROM spotter_output".$filter_query." spotter_output.source_name <> ''"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2681 |  |  | 		if ($type != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2682 |  |  | 			$query_values = array(':type' => $type); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2683 |  |  | 			$query .= " AND format_source = :type"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2684 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2685 |  |  | 		$query .= " ORDER BY spotter_output.source_name ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2686 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2687 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2688 |  |  | 		if (!empty($query_values)) $sth->execute($query_values); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2689 |  |  | 		else $sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2690 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2691 |  |  | 		$source_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2692 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2693 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2694 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2695 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2696 |  |  | 			$temp_array['source_name'] = $row['source_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2697 |  |  | 			$source_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2698 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2699 |  |  | 		return $source_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2700 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2701 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2702 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2703 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2704 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2705 |  |  | 	* Gets a list of all airline names | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2706 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2707 |  |  | 	* @return Array list of airline names | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2708 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2709 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2710 |  |  | 	public function getAllAirlineNames($airline_type = '',$forsource = NULL,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2711 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2712 |  |  | 		global $globalAirlinesSource,$globalVATSIM, $globalIVAO; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2713 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2714 |  |  | 		$airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2715 |  |  | 		if ($airline_type == '' || $airline_type == 'all') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2716 |  |  | 			/* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2717 |  |  | 			$query  = "SELECT DISTINCT spotter_output.airline_icao AS airline_icao, spotter_output.airline_name AS airline_name, spotter_output.airline_type AS airline_type | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2718 |  |  | 								FROM spotter_output | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2719 |  |  | 								WHERE spotter_output.airline_icao <> ''  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2720 |  |  | 								ORDER BY spotter_output.airline_name ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2721 |  |  | 			*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2722 |  |  | 			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $forsource = $globalAirlinesSource; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2723 |  |  | 			elseif (isset($globalVATSIM) && $globalVATSIM) $forsource = 'vatsim'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2724 |  |  | 			elseif (isset($globalIVAO) && $globalIVAO) $forsource = 'ivao'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2725 |  |  | 			if ($forsource === NULL) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2726 |  |  | 				$query = "SELECT DISTINCT icao AS airline_icao, name AS airline_name, type AS airline_type FROM airlines WHERE forsource IS NULL ORDER BY name ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2727 |  |  | 				$query_data = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2728 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2729 |  |  | 				$query = "SELECT DISTINCT icao AS airline_icao, name AS airline_name, type AS airline_type FROM airlines WHERE forsource = :forsource ORDER BY name ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2730 |  |  | 				$query_data = array(':forsource' => $forsource); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2731 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2732 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2733 |  |  | 			$query  = "SELECT DISTINCT spotter_output.airline_icao AS airline_icao, spotter_output.airline_name AS airline_name, spotter_output.airline_type AS airline_type | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2734 |  |  | 					FROM spotter_output".$filter_query." spotter_output.airline_icao <> ''  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2735 |  |  | 					AND spotter_output.airline_type = :airline_type  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2736 |  |  | 					ORDER BY spotter_output.airline_icao ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2737 |  |  | 			$query_data = array(':airline_type' => $airline_type); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2738 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2739 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2740 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2741 |  |  | 		$sth->execute($query_data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2742 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2743 |  |  | 		$airline_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2744 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2745 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2746 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2747 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2748 |  |  | 			$temp_array['airline_icao'] = $row['airline_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2749 |  |  | 			$temp_array['airline_name'] = $row['airline_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2750 |  |  | 			$temp_array['airline_type'] = $row['airline_type']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2751 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2752 |  |  | 			$airline_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2753 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2754 |  |  | 		return $airline_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2755 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2756 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2757 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2758 |  |  | 	* Gets a list of all alliance names | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2759 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2760 |  |  | 	* @return Array list of alliance names | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2761 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2762 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2763 |  |  | 	public function getAllAllianceNames($forsource = NULL,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2764 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2765 |  |  | 		global $globalAirlinesSource,$globalVATSIM, $globalIVAO; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2766 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2767 |  |  | 		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $forsource = $globalAirlinesSource; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2768 |  |  | 		elseif (isset($globalVATSIM) && $globalVATSIM) $forsource = 'vatsim'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2769 |  |  | 		elseif (isset($globalIVAO) && $globalIVAO) $forsource = 'ivao'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2770 |  |  | 		if ($forsource === NULL) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2771 |  |  | 			$query = "SELECT DISTINCT alliance FROM airlines WHERE alliance IS NOT NULL AND forsource IS NULL ORDER BY alliance ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2772 |  |  | 			$query_data = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2773 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2774 |  |  | 			$query = "SELECT DISTINCT alliance FROM airlines WHERE alliance IS NOT NULL AND  forsource = :forsource ORDER BY alliance ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2775 |  |  | 			$query_data = array(':forsource' => $forsource); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2776 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2777 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2778 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2779 |  |  | 		$sth->execute($query_data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2780 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2781 |  |  | 		$alliance_array = array(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2782 |  |  | 		$alliance_array = $sth->fetchAll(PDO::FETCH_ASSOC); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2783 |  |  | 		return $alliance_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2784 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2785 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2786 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2787 |  |  | 	* Gets a list of all airline countries | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2788 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2789 |  |  | 	* @return Array list of airline countries | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2790 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2791 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2792 |  |  | 	public function getAllAirlineCountries($filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2793 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2794 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2795 |  |  | 		$query  = "SELECT DISTINCT spotter_output.airline_country AS airline_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2796 |  |  | 				FROM spotter_output".$filter_query." spotter_output.airline_country <> ''  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2797 |  |  | 				ORDER BY spotter_output.airline_country ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2798 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2799 |  |  | 		//$query = "SELECT DISTINCT country AS airline_country FROM airlines WHERE country <> '' AND active = 'Y' ORDER BY country ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2800 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2801 |  |  | 		$sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2802 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2803 |  |  | 		$airline_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2804 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2805 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2806 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2807 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2808 |  |  | 			$temp_array['airline_country'] = $row['airline_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2809 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2810 |  |  | 			$airline_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2811 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2812 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2813 |  |  | 		return $airline_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2814 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2815 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2816 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2817 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2818 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2819 |  |  | 	* Gets a list of all departure & arrival names | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2820 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2821 |  |  | 	* @return Array list of airport names | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2822 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2823 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2824 |  |  | 	public function getAllAirportNames($filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2825 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2826 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2827 |  |  | 		$airport_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2828 |  |  | 		$query  = "SELECT DISTINCT spotter_output.departure_airport_icao AS airport_icao, spotter_output.departure_airport_name AS airport_name, spotter_output.departure_airport_city AS airport_city, spotter_output.departure_airport_country AS airport_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2829 |  |  | 				FROM spotter_output".$filter_query." spotter_output.departure_airport_icao <> '' AND spotter_output.departure_airport_icao <> 'NA'  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2830 |  |  | 				ORDER BY spotter_output.departure_airport_city ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2831 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2832 |  |  | 		//$query = "SELECT DISTINCT icao AS airport_icao, name AS airport_name, city AS airport_city, country AS airport_country FROM airport ORDER BY city ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2833 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2834 |  |  | 		$sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2835 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2836 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2837 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2838 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2839 |  |  | 			$temp_array['airport_icao'] = $row['airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2840 |  |  | 			$temp_array['airport_name'] = $row['airport_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2841 |  |  | 			$temp_array['airport_city'] = $row['airport_city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2842 |  |  | 			$temp_array['airport_country'] = $row['airport_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2843 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2844 |  |  | 			$airport_array[$row['airport_city'].",".$row['airport_name']] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2845 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2846 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2847 |  |  | 		$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao AS airport_icao, spotter_output.arrival_airport_name AS airport_name, spotter_output.arrival_airport_city AS airport_city, spotter_output.arrival_airport_country AS airport_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2848 |  |  | 								FROM spotter_output".$filter_query." spotter_output.arrival_airport_icao <> '' AND spotter_output.arrival_airport_icao <> 'NA'  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2849 |  |  | 								ORDER BY spotter_output.arrival_airport_city ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2850 |  |  | 					 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2851 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2852 |  |  | 		$sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2853 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2854 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2855 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2856 |  |  | 		//	if ($airport_array[$row['airport_city'].",".$row['airport_name']]['airport_icao'] != $row['airport_icao']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2857 |  |  | 		//	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2858 |  |  | 				$temp_array['airport_icao'] = $row['airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2859 |  |  | 				$temp_array['airport_name'] = $row['airport_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2860 |  |  | 				$temp_array['airport_city'] = $row['airport_city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2861 |  |  | 				$temp_array['airport_country'] = $row['airport_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2862 |  |  | 				 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2863 |  |  | 				$airport_array[$row['airport_city'].",".$row['airport_name']] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2864 |  |  | 		//	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2865 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2866 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2867 |  |  | 		return $airport_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2868 |  |  | 	}  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2869 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2870 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2871 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2872 |  |  | 	* Gets a list of all departure & arrival airport countries | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2873 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2874 |  |  | 	* @return Array list of airport countries | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2875 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2876 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2877 |  |  | 	public function getAllAirportCountries($filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2878 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2879 |  |  | 		$airport_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2880 |  |  | 					 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2881 |  |  | 		  /* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2882 |  |  | 		$query  = "SELECT DISTINCT spotter_output.departure_airport_country AS airport_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2883 |  |  | 								FROM spotter_output | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2884 |  |  | 								WHERE spotter_output.departure_airport_country <> ''  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2885 |  |  | 								ORDER BY spotter_output.departure_airport_country ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2886 |  |  | 		*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2887 |  |  | 		$query = "SELECT DISTINCT country AS airport_country FROM airport ORDER BY country ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2888 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2889 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2890 |  |  | 		$sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2891 |  |  |     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2892 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2893 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2894 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2895 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2896 |  |  | 			$temp_array['airport_country'] = $row['airport_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2897 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2898 |  |  | 			$airport_array[$row['airport_country']] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2899 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2900 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2901 |  |  | 		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country AS airport_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2902 |  |  | 								FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> ''  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2903 |  |  | 								ORDER BY spotter_output.arrival_airport_country ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2904 |  |  | 					 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2905 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2906 |  |  | 		$sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2907 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2908 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2909 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2910 |  |  | 			if (isset($airport_array[$row['airport_country']]['airport_country']) && $airport_array[$row['airport_country']]['airport_country'] != $row['airport_country']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2911 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2912 |  |  | 				$temp_array['airport_country'] = $row['airport_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2913 |  |  | 				$airport_array[$row['airport_country']] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2914 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2915 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2916 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2917 |  |  | 		return $airport_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2918 |  |  | 	}  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2919 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2920 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2921 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2922 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2923 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2924 |  |  | 	* Gets a list of all countries (airline, departure airport & arrival airport) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2925 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2926 |  |  | 	* @return Array list of countries | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2927 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2928 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2929 |  |  | 	public function getAllCountries($filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2930 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2931 |  |  | 		$Connection= new Connection($this->db); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2932 |  |  | 		if ($Connection->tableExists('countries')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2933 |  |  | 			$query  = "SELECT countries.name AS airport_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2934 |  |  | 				FROM countries | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2935 |  |  | 				ORDER BY countries.name ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2936 |  |  | 			$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2937 |  |  | 			$sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2938 |  |  |     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2939 |  |  | 			$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2940 |  |  | 			$country_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2941 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2942 |  |  | 			while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2943 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2944 |  |  | 				$temp_array['country'] = $row['airport_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2945 |  |  | 				$country_array[$row['airport_country']] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2946 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2947 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2948 |  |  | 			$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2949 |  |  | 			$query  = "SELECT DISTINCT spotter_output.departure_airport_country AS airport_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2950 |  |  | 								FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> ''  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2951 |  |  | 								ORDER BY spotter_output.departure_airport_country ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2952 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2953 |  |  | 			$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2954 |  |  | 			$sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2955 |  |  |     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2956 |  |  | 			$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2957 |  |  | 			$country_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2958 |  |  | 			while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2959 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2960 |  |  | 				$temp_array['country'] = $row['airport_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2961 |  |  | 				$country_array[$row['airport_country']] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2962 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2963 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2964 |  |  | 		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country AS airport_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2965 |  |  | 								FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> ''  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2966 |  |  | 								ORDER BY spotter_output.arrival_airport_country ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2967 |  |  | 					 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2968 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2969 |  |  | 		$sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2970 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2971 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2972 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2973 |  |  | 			if ($country_array[$row['airport_country']]['country'] != $row['airport_country']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2974 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2975 |  |  | 				$temp_array['country'] = $row['airport_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2976 |  |  | 				 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2977 |  |  | 				$country_array[$row['country']] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2978 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2979 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2980 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2981 |  |  | 		$query  = "SELECT DISTINCT spotter_output.airline_country AS airline_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2982 |  |  | 								FROM spotter_output".$filter_query." spotter_output.airline_country <> ''  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2983 |  |  | 								ORDER BY spotter_output.airline_country ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2984 |  |  | 					 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2985 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2986 |  |  | 		$sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2987 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2988 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2989 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2990 |  |  | 			if (isset($country_array[$row['airline_country']]['country']) && $country_array[$row['airline_country']]['country'] != $row['airline_country']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2991 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2992 |  |  | 				$temp_array['country'] = $row['airline_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2993 |  |  | 				 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2994 |  |  | 				$country_array[$row['country']] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2995 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2996 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2997 |  |  | 		}   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2998 |  |  | 		return $country_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2999 |  |  | 	}  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3000 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3001 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3002 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3003 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3004 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3005 |  |  | 	* Gets a list of all idents/callsigns | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3006 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3007 |  |  | 	* @return Array list of ident/callsign names | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3008 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3009 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3010 |  |  | 	public function getAllIdents($filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3011 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3012 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3013 |  |  | 		$query  = "SELECT DISTINCT spotter_output.ident | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3014 |  |  | 								FROM spotter_output".$filter_query." spotter_output.ident <> ''  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3015 |  |  | 								ORDER BY spotter_output.date ASC LIMIT 700 OFFSET 0"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3016 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3017 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3018 |  |  | 		$sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3019 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3020 |  |  | 		$ident_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3021 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3022 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3023 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3024 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3025 |  |  | 			$temp_array['ident'] = $row['ident']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3026 |  |  | 			$ident_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3027 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3028 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3029 |  |  | 		return $ident_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3030 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3031 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3032 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3033 |  |  | 	* Get a list of flights from airport since 7 days | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3034 |  |  | 	* @return Array number, icao, name and city of airports | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3035 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3036 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3037 |  |  | 	public function getLast7DaysAirportsDeparture($airport_icao = '',$filters = array()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3038 |  |  | 		global $globalTimezone, $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3039 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3040 |  |  | 		if ($globalTimezone != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3041 |  |  | 			date_default_timezone_set($globalTimezone); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3042 |  |  | 			$datetime = new DateTime(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3043 |  |  | 			$offset = $datetime->format('P'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3044 |  |  | 		} else $offset = '+00:00'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3045 |  |  | 		if ($airport_icao == '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3046 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3047 |  |  | 				$query = "SELECT COUNT(departure_airport_icao) AS departure_airport_count, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output`".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND departure_airport_icao <> 'NA' AND departure_airport_icao <> '' GROUP BY departure_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), departure_airport_name, departure_airport_city, departure_airport_country ORDER BY departure_airport_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3048 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3049 |  |  | 				$query = "SELECT COUNT(departure_airport_icao) AS departure_airport_count, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date FROM spotter_output".$filter_query." spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND departure_airport_icao <> 'NA' AND departure_airport_icao <> '' GROUP BY departure_airport_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd'), departure_airport_name, departure_airport_city, departure_airport_country ORDER BY departure_airport_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3050 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3051 |  |  | 			$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3052 |  |  | 			$sth->execute(array(':offset' => $offset)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3053 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3054 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3055 |  |  | 				$query = "SELECT COUNT(departure_airport_icao) AS departure_airport_count, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output`".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND departure_airport_icao = :airport_icao GROUP BY departure_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), departure_airport_name, departure_airport_city, departure_airport_country ORDER BY departure_airport_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3056 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3057 |  |  | 				$query = "SELECT COUNT(departure_airport_icao) AS departure_airport_count, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date FROM spotter_output".$filter_query." spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND departure_airport_icao = :airport_icao GROUP BY departure_airport_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd'), departure_airport_name, departure_airport_city, departure_airport_country ORDER BY departure_airport_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3058 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3059 |  |  | 			$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3060 |  |  | 			$sth->execute(array(':offset' => $offset, ':airport_icao' => $airport_icao)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3061 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3062 |  |  | 		return $sth->fetchAll(PDO::FETCH_ASSOC); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3063 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3064 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3065 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3066 |  |  | 	* Get a list of flights from airport since 7 days | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3067 |  |  | 	* @return Array number, icao, name and city of airports | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3068 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3069 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3070 |  |  | 	public function getLast7DaysAirportsDepartureByAirlines($airport_icao = '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3071 |  |  | 		global $globalTimezone, $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3072 |  |  | 		if ($globalTimezone != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3073 |  |  | 			date_default_timezone_set($globalTimezone); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3074 |  |  | 			$datetime = new DateTime(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3075 |  |  | 			$offset = $datetime->format('P'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3076 |  |  | 		} else $offset = '+00:00'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3077 |  |  | 		if ($airport_icao == '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3078 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3079 |  |  | 				$query = "SELECT spotter_output.airline_icao, COUNT(departure_airport_icao) AS departure_airport_count, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output` WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND departure_airport_icao <> 'NA' AND departure_airport_icao <> '' AND spotter_output.airline_icao <> '' GROUP BY spotter_output.airline_icao, departure_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), departure_airport_name, departure_airport_city, departure_airport_country ORDER BY departure_airport_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3080 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3081 |  |  | 				$query = "SELECT spotter_output.airline_icao, COUNT(departure_airport_icao) AS departure_airport_count, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date FROM spotter_output WHERE spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND departure_airport_icao <> 'NA' AND departure_airport_icao <> '' AND spotter_output.airline_icao <> '' GROUP BY spotter_output.airline_icao, departure_airport_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd'), departure_airport_name, departure_airport_city, departure_airport_country ORDER BY departure_airport_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3082 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3083 |  |  | 			$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3084 |  |  | 			$sth->execute(array(':offset' => $offset)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3085 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3086 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3087 |  |  | 				$query = "SELECT spotter_output.airline_icao, COUNT(departure_airport_icao) AS departure_airport_count, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output` WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND departure_airport_icao = :airport_icao AND spotter_output.airline_icao <> '' GROUP BY spotter_output.airline_icao, departure_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), departure_airport_name, departure_airport_city, departure_airport_country ORDER BY departure_airport_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3088 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3089 |  |  | 				$query = "SELECT spotter_output.airline_icao, COUNT(departure_airport_icao) AS departure_airport_count, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date FROM spotter_output WHERE spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND departure_airport_icao = :airport_icao AND spotter_output.airline_icao <> '' GROUP BY spotter_output.airline_icao, departure_airport_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd'), departure_airport_name, departure_airport_city, departure_airport_country ORDER BY departure_airport_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3090 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3091 |  |  | 			$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3092 |  |  | 			$sth->execute(array(':offset' => $offset, ':airport_icao' => $airport_icao)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3093 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3094 |  |  | 		return $sth->fetchAll(PDO::FETCH_ASSOC); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3095 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3096 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3097 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3098 |  |  | 	* Get a list of flights from detected airport since 7 days | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3099 |  |  | 	* @return Array number, icao, name and city of airports | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3100 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3101 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3102 |  |  | 	public function getLast7DaysDetectedAirportsDeparture($airport_icao = '', $filters = array()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3103 |  |  | 		global $globalTimezone, $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3104 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3105 |  |  | 		if ($globalTimezone != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3106 |  |  | 			date_default_timezone_set($globalTimezone); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3107 |  |  | 			$datetime = new DateTime(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3108 |  |  | 			$offset = $datetime->format('P'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3109 |  |  | 		} else $offset = '+00:00'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3110 |  |  | 		if ($airport_icao == '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3111 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3112 |  |  | 				$query = "SELECT COUNT(real_departure_airport_icao) AS departure_airport_count, real_departure_airport_icao AS departure_airport_icao, airport.name AS departure_airport_name, airport.city AS departure_airport_city, airport.country AS departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3113 |  |  | 				FROM airport, spotter_output".$filter_query." airport.icao = spotter_output.real_departure_airport_icao AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND real_departure_airport_icao <> 'NA' AND real_departure_airport_icao <> ''  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3114 |  |  | 				GROUP BY real_departure_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), airport.name, airport.city, airport.country ORDER BY departure_airport_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3115 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3116 |  |  | 				$query = "SELECT COUNT(real_departure_airport_icao) AS departure_airport_count, real_departure_airport_icao AS departure_airport_icao, airport.name AS departure_airport_name, airport.city AS departure_airport_city, airport.country AS departure_airport_country, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3117 |  |  | 				FROM airport, spotter_output".$filter_query." airport.icao = spotter_output.real_departure_airport_icao AND spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND real_departure_airport_icao <> 'NA' AND real_departure_airport_icao <> ''  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3118 |  |  | 				GROUP BY real_departure_airport_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd'), airport.name, airport.city, airport.country ORDER BY departure_airport_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3119 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3120 |  |  | 			$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3121 |  |  | 			$sth->execute(array(':offset' => $offset)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3122 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3123 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3124 |  |  | 				$query = "SELECT COUNT(real_departure_airport_icao) AS departure_airport_count, real_departure_airport_icao AS departure_airport_icao, airport.name AS departure_airport_name, airport.city AS departure_airport_city, airport.country AS departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3125 |  |  | 				FROM airport,spotter_output".$filter_query." airport.icao = spotter_output.real_departure_airport_icao AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND real_departure_airport_icao = :airport_icao  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3126 |  |  | 				GROUP BY departure_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), airport.name, airport.city, airport.country ORDER BY departure_airport_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3127 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3128 |  |  | 				$query = "SELECT COUNT(real_departure_airport_icao) AS departure_airport_count, real_departure_airport_icao AS departure_airport_icao, airport.name AS departure_airport_name, airport.city AS departure_airport_city, airport.country AS departure_airport_country, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3129 |  |  | 				FROM airport,spotter_output".$filter_query." airport.icao = spotter_output.real_departure_airport_icao AND spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND real_departure_airport_icao = :airport_icao GROUP BY departure_airport_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd'), airport.name, airport.city, airport.country ORDER BY departure_airport_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3130 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3131 |  |  | 			$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3132 |  |  | 			$sth->execute(array(':offset' => $offset, ':airport_icao' => $airport_icao)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3133 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3134 |  |  | 		return $sth->fetchAll(PDO::FETCH_ASSOC); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3135 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3136 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3137 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3138 |  |  | 	* Get a list of flights from detected airport since 7 days | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3139 |  |  | 	* @return Array number, icao, name and city of airports | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3140 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3141 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3142 |  |  | 	public function getLast7DaysDetectedAirportsDepartureByAirlines($airport_icao = '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3143 |  |  | 		global $globalTimezone, $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3144 |  |  | 		if ($globalTimezone != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3145 |  |  | 			date_default_timezone_set($globalTimezone); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3146 |  |  | 			$datetime = new DateTime(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3147 |  |  | 			$offset = $datetime->format('P'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3148 |  |  | 		} else $offset = '+00:00'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3149 |  |  | 		if ($airport_icao == '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3150 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3151 |  |  | 				$query = "SELECT spotter_output.airline_icao, COUNT(real_departure_airport_icao) AS departure_airport_count, real_departure_airport_icao AS departure_airport_icao, airport.name AS departure_airport_name, airport.city AS departure_airport_city, airport.country AS departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3152 |  |  | 				FROM `spotter_output`, airport  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3153 |  |  | 				WHERE spotter_output.airline_icao <> '' AND airport.icao = spotter_output.real_departure_airport_icao AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND real_departure_airport_icao <> 'NA' AND real_departure_airport_icao <> ''  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3154 |  |  | 				GROUP BY spotter_output.airline_icao, real_departure_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), airport.name, airport.city, airport.country ORDER BY departure_airport_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3155 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3156 |  |  | 				$query = "SELECT spotter_output.airline_icao, COUNT(real_departure_airport_icao) AS departure_airport_count, real_departure_airport_icao AS departure_airport_icao, airport.name AS departure_airport_name, airport.city AS departure_airport_city, airport.country AS departure_airport_country, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3157 |  |  | 				FROM spotter_output, airport  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3158 |  |  | 				WHERE spotter_output.airline_icao <> '' AND airport.icao = spotter_output.real_departure_airport_icao AND spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND real_departure_airport_icao <> 'NA' AND real_departure_airport_icao <> ''  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3159 |  |  | 				GROUP BY spotter_output.airline_icao, real_departure_airport_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd'), airport.name, airport.city, airport.country ORDER BY departure_airport_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3160 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3161 |  |  | 			$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3162 |  |  | 			$sth->execute(array(':offset' => $offset)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3163 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3164 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3165 |  |  | 				$query = "SELECT spotter_output.airline_icao, COUNT(real_departure_airport_icao) AS departure_airport_count, real_departure_airport_icao AS departure_airport_icao, airport.name AS departure_airport_name, airport.city AS departure_airport_city, airport.country AS departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3166 |  |  | 				FROM `spotter_output`, airport  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3167 |  |  | 				WHERE spotter_output.airline_icao <> '' AND airport.icao = spotter_output.real_departure_airport_icao AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND real_departure_airport_icao = :airport_icao  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3168 |  |  | 				GROUP BY spotter_output.airline_icao, departure_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), airport.name, airport.city, airport.country ORDER BY departure_airport_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3169 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3170 |  |  | 				$query = "SELECT spotter_output.airline_icao, COUNT(real_departure_airport_icao) AS departure_airport_count, real_departure_airport_icao AS departure_airport_icao, airport.name AS departure_airport_name, airport.city AS departure_airport_city, airport.country AS departure_airport_country, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3171 |  |  | 				FROM spotter_output, airport  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3172 |  |  | 				WHERE spotter_output.airline_icao <> '' AND airport.icao = spotter_output.real_departure_airport_icao AND spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND real_departure_airport_icao = :airport_icao GROUP BY spotter_output.airline_icao, departure_airport_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd'), airport.name, airport.city, airport.country ORDER BY departure_airport_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3173 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3174 |  |  | 			$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3175 |  |  | 			$sth->execute(array(':offset' => $offset, ':airport_icao' => $airport_icao)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3176 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3177 |  |  | 		return $sth->fetchAll(PDO::FETCH_ASSOC); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3178 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3179 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3180 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3181 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3182 |  |  | 	* Get a list of flights to airport since 7 days | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3183 |  |  | 	* @return Array number, icao, name and city of airports | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3184 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3185 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3186 |  |  | 	public function getLast7DaysAirportsArrival($airport_icao = '', $filters = array()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3187 |  |  | 		global $globalTimezone, $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3188 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3189 |  |  | 		if ($globalTimezone != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3190 |  |  | 			date_default_timezone_set($globalTimezone); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3191 |  |  | 			$datetime = new DateTime(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3192 |  |  | 			$offset = $datetime->format('P'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3193 |  |  | 		} else $offset = '+00:00'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3194 |  |  | 		if ($airport_icao == '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3195 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3196 |  |  | 				$query = "SELECT COUNT(arrival_airport_icao) AS arrival_airport_count, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output`".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND arrival_airport_icao <> 'NA' AND arrival_airport_icao <> '' GROUP BY arrival_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), arrival_airport_name, arrival_airport_city, arrival_airport_country ORDER BY arrival_airport_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3197 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3198 |  |  | 				$query = "SELECT COUNT(arrival_airport_icao) AS arrival_airport_count, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date FROM spotter_output".$filter_query." spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND arrival_airport_icao <> 'NA' AND arrival_airport_icao <> '' GROUP BY arrival_airport_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd'), arrival_airport_name, arrival_airport_city, arrival_airport_country ORDER BY arrival_airport_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3199 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3200 |  |  | 			$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3201 |  |  | 			$sth->execute(array(':offset' => $offset)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3202 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3203 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3204 |  |  | 				$query = "SELECT COUNT(arrival_airport_icao) AS arrival_airport_count, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output`".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND arrival_airport_icao = :airport_icao GROUP BY arrival_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'),arrival_airport_name, arrival_airport_city, arrival_airport_country ORDER BY arrival_airport_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3205 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3206 |  |  | 				$query = "SELECT COUNT(arrival_airport_icao) AS arrival_airport_count, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date FROM spotter_output".$filter_query." spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND arrival_airport_icao = :airport_icao GROUP BY arrival_airport_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd'), arrival_airport_name, arrival_airport_city, arrival_airport_country ORDER BY arrival_airport_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3207 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3208 |  |  | 			$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3209 |  |  | 			$sth->execute(array(':offset' => $offset, ':airport_icao' => $airport_icao)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3210 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3211 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3212 |  |  | 		return $sth->fetchAll(PDO::FETCH_ASSOC); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3213 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3214 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3215 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3216 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3217 |  |  | 	* Get a list of flights detected to airport since 7 days | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3218 |  |  | 	* @return Array number, icao, name and city of airports | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3219 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3220 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3221 |  |  | 	public function getLast7DaysDetectedAirportsArrival($airport_icao = '',$filters = array()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3222 |  |  | 		global $globalTimezone, $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3223 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3224 |  |  | 		if ($globalTimezone != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3225 |  |  | 			date_default_timezone_set($globalTimezone); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3226 |  |  | 			$datetime = new DateTime(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3227 |  |  | 			$offset = $datetime->format('P'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3228 |  |  | 		} else $offset = '+00:00'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3229 |  |  | 		if ($airport_icao == '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3230 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3231 |  |  | 				$query = "SELECT COUNT(real_arrival_airport_icao) AS arrival_airport_count, real_arrival_airport_icao AS arrival_airport_icao, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3232 |  |  | 				FROM airport,spotter_output".$filter_query." airport.icao = spotter_output.real_arrival_airport_icao AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND arrival_airport_icao <> 'NA' AND arrival_airport_icao <> ''  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3233 |  |  | 				GROUP BY real_arrival_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), airport.name, airport.city, airport.country ORDER BY arrival_airport_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3234 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3235 |  |  | 				$query = "SELECT COUNT(real_arrival_airport_icao) AS arrival_airport_count, real_arrival_airport_icao AS arrival_airport_icao, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3236 |  |  | 				FROM airport,spotter_output".$filter_query." airport.icao = spotter_output.real_arrival_airport_icao AND spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND arrival_airport_icao <> 'NA' AND arrival_airport_icao <> ''  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3237 |  |  | 				GROUP BY real_arrival_airport_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd'), airport.name, airport.city, airport.country ORDER BY arrival_airport_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3238 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3239 |  |  | 			$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3240 |  |  | 			$sth->execute(array(':offset' => $offset)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3241 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3242 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3243 |  |  | 				$query = "SELECT COUNT(real_arrival_airport_icao) AS arrival_airport_count, real_arrival_airport_icao AS arrival_airport_icao, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3244 |  |  | 				FROM airport,spotter_output".$filter_query." airport.icao = spotter_output.real_arrival_airport_icao AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND arrival_airport_icao = :airport_icao  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3245 |  |  | 				GROUP BY real_arrival_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'),airport.name, airport.city, airport.country ORDER BY arrival_airport_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3246 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3247 |  |  | 				$query = "SELECT COUNT(real_arrival_airport_icao) AS arrival_airport_count, real_arrival_airport_icao AS arrival_airport_icao, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3248 |  |  | 				FROM airport, spotter_output".$filter_query." airport.icao = spotter_output.real_arrival_airport_icao AND spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND arrival_airport_icao = :airport_icao  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3249 |  |  | 				GROUP BY real_arrival_airport_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd'), airport.name, airport.city, airport.country ORDER BY arrival_airport_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3250 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3251 |  |  | 			$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3252 |  |  | 			$sth->execute(array(':offset' => $offset, ':airport_icao' => $airport_icao)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3253 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3254 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3255 |  |  | 		return $sth->fetchAll(PDO::FETCH_ASSOC); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3256 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3257 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3258 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3259 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3260 |  |  | 	* Get a list of flights to airport since 7 days | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3261 |  |  | 	* @return Array number, icao, name and city of airports | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3262 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3263 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3264 |  |  | 	public function getLast7DaysAirportsArrivalByAirlines($airport_icao = '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3265 |  |  | 		global $globalTimezone, $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3266 |  |  | 		if ($globalTimezone != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3267 |  |  | 			date_default_timezone_set($globalTimezone); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3268 |  |  | 			$datetime = new DateTime(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3269 |  |  | 			$offset = $datetime->format('P'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3270 |  |  | 		} else $offset = '+00:00'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3271 |  |  | 		if ($airport_icao == '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3272 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3273 |  |  | 				$query = "SELECT spotter_output.airline_icao, COUNT(arrival_airport_icao) AS arrival_airport_count, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output` WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND arrival_airport_icao <> 'NA' AND arrival_airport_icao <> '' AND spotter_output.airline_icao <> '' GROUP BY spotter_output.airline_icao, arrival_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), arrival_airport_name, arrival_airport_city, arrival_airport_country ORDER BY arrival_airport_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3274 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3275 |  |  | 				$query = "SELECT spotter_output.airline_icao, COUNT(arrival_airport_icao) AS arrival_airport_count, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date FROM spotter_output WHERE spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND arrival_airport_icao <> 'NA' AND arrival_airport_icao <> '' AND spotter_output.airline_icao <> '' GROUP BY spotter_output.airline_icao, arrival_airport_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd'), arrival_airport_name, arrival_airport_city, arrival_airport_country ORDER BY arrival_airport_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3276 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3277 |  |  | 			$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3278 |  |  | 			$sth->execute(array(':offset' => $offset)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3279 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3280 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3281 |  |  | 				$query = "SELECT spotter_output.airline_icao, COUNT(arrival_airport_icao) AS arrival_airport_count, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output` WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND arrival_airport_icao = :airport_icao AND spotter_output.airline_icao <> '' GROUP BY spotter_output.airline_icao, arrival_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'),arrival_airport_name, arrival_airport_city, arrival_airport_country ORDER BY arrival_airport_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3282 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3283 |  |  | 				$query = "SELECT spotter_output.airline_icao, COUNT(arrival_airport_icao) AS arrival_airport_count, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date FROM spotter_output WHERE spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND arrival_airport_icao = :airport_icao AND spotter_output.airline_icao <> '' GROUP BY spotter_output.airline_icao, arrival_airport_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd'), arrival_airport_name, arrival_airport_city, arrival_airport_country ORDER BY arrival_airport_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3284 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3285 |  |  | 			$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3286 |  |  | 			$sth->execute(array(':offset' => $offset, ':airport_icao' => $airport_icao)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3287 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3288 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3289 |  |  | 		return $sth->fetchAll(PDO::FETCH_ASSOC); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3290 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3291 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3292 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3293 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3294 |  |  | 	* Get a list of flights detected to airport since 7 days | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3295 |  |  | 	* @return Array number, icao, name and city of airports | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3296 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3297 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3298 |  |  | 	public function getLast7DaysDetectedAirportsArrivalByAirlines($airport_icao = '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3299 |  |  | 		global $globalTimezone, $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3300 |  |  | 		if ($globalTimezone != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3301 |  |  | 			date_default_timezone_set($globalTimezone); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3302 |  |  | 			$datetime = new DateTime(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3303 |  |  | 			$offset = $datetime->format('P'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3304 |  |  | 		} else $offset = '+00:00'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3305 |  |  | 		if ($airport_icao == '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3306 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3307 |  |  | 				$query = "SELECT spotter_output.airline_icao, COUNT(real_arrival_airport_icao) AS arrival_airport_count, real_arrival_airport_icao AS arrival_airport_icao, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3308 |  |  | 				FROM `spotter_output`, airport  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3309 |  |  | 				WHERE spotter_output.airline_icao <> '' AND airport.icao = spotter_output.real_arrival_airport_icao AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND arrival_airport_icao <> 'NA' AND arrival_airport_icao <> ''  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3310 |  |  | 				GROUP BY spotter_output.airline_icao, real_arrival_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), airport.name, airport.city, airport.country ORDER BY arrival_airport_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3311 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3312 |  |  | 				$query = "SELECT spotter_output.airline_icao, COUNT(real_arrival_airport_icao) AS arrival_airport_count, real_arrival_airport_icao AS arrival_airport_icao, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3313 |  |  | 				FROM spotter_output, airport  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3314 |  |  | 				WHERE spotter_output.airline_icao <> '' AND airport.icao = spotter_output.real_arrival_airport_icao AND spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND arrival_airport_icao <> 'NA' AND arrival_airport_icao <> ''  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3315 |  |  | 				GROUP BY spotter_output.airline_icao, real_arrival_airport_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd'), airport.name, airport.city, airport.country ORDER BY arrival_airport_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3316 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3317 |  |  | 			$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3318 |  |  | 			$sth->execute(array(':offset' => $offset)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3319 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3320 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3321 |  |  | 				$query = "SELECT spotter_output.airline_icao, COUNT(real_arrival_airport_icao) AS arrival_airport_count, real_arrival_airport_icao AS arrival_airport_icao, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3322 |  |  | 				FROM `spotter_output`, airport  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3323 |  |  | 				WHERE spotter_output.airline_icao <> '' AND airport.icao = spotter_output.real_arrival_airport_icao AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND arrival_airport_icao = :airport_icao  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3324 |  |  | 				GROUP BY spotter_output.airline_icao, real_arrival_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'),airport.name, airport.city, airport.country ORDER BY arrival_airport_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3325 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3326 |  |  | 				$query = "SELECT spotter_output.airline_icao, COUNT(real_arrival_airport_icao) AS arrival_airport_count, real_arrival_airport_icao AS arrival_airport_icao, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3327 |  |  | 				FROM spotter_output, airport  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3328 |  |  | 				WHERE spotter_output.airline_icao <> '' AND  airport.icao = spotter_output.real_arrival_airport_icao AND spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND arrival_airport_icao = :airport_icao  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3329 |  |  | 				GROUP BY spotter_output.airline_icao,real_arrival_airport_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd'), airport.name, airport.city, airport.country ORDER BY arrival_airport_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3330 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3331 |  |  | 			$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3332 |  |  | 			$sth->execute(array(':offset' => $offset, ':airport_icao' => $airport_icao)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3333 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3334 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3335 |  |  | 		return $sth->fetchAll(PDO::FETCH_ASSOC); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3336 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3337 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3338 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3339 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3340 |  |  | 	* Gets a list of all dates | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3341 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3342 |  |  | 	* @return Array list of date names | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3343 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3344 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3345 |  |  | 	public function getAllDates() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3346 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3347 |  |  | 		global $globalTimezone, $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3348 |  |  | 		if ($globalTimezone != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3349 |  |  | 			date_default_timezone_set($globalTimezone); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3350 |  |  | 			$datetime = new DateTime(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3351 |  |  | 			$offset = $datetime->format('P'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3352 |  |  | 		} else $offset = '+00:00'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3353 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3354 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3355 |  |  | 			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) as date | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3356 |  |  | 								FROM spotter_output | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3357 |  |  | 								WHERE spotter_output.date <> ''  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3358 |  |  | 								ORDER BY spotter_output.date ASC LIMIT 0,200"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3359 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3360 |  |  | 			$query  = "SELECT DISTINCT to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3361 |  |  | 								FROM spotter_output | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3362 |  |  | 								WHERE spotter_output.date <> ''  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3363 |  |  | 								ORDER BY spotter_output.date ASC LIMIT 0,200"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3364 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3365 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3366 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3367 |  |  | 		$sth->execute(array(':offset' => $offset)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3368 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3369 |  |  | 		$date_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3370 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3371 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3372 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3373 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3374 |  |  | 			$temp_array['date'] = $row['date']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3375 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3376 |  |  | 			$date_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3377 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3378 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3379 |  |  | 		return $date_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3380 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3381 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3382 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3383 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3384 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3385 |  |  | 	* Gets all route combinations | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3386 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3387 |  |  | 	* @return Array the route list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3388 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3389 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3390 |  |  | 	public function getAllRoutes() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3391 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3392 |  |  | 		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route,  spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3393 |  |  | 				FROM spotter_output | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3394 |  |  | 				WHERE spotter_output.ident <> ''  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3395 |  |  | 				GROUP BY route | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3396 |  |  | 				ORDER BY route ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3397 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3398 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3399 |  |  | 		$sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3400 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3401 |  |  | 		$routes_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3402 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3403 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3404 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3405 |  |  | 			$temp_array['route'] = $row['route']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3406 |  |  | 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3407 |  |  | 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3408 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3409 |  |  | 			$routes_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3410 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3411 |  |  | 		return $routes_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3412 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3413 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3414 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3415 |  |  | 	* Update ident spotter data | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3416 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3417 |  |  | 	* @param String $flightaware_id the ID from flightaware | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3418 |  |  | 	* @param String $ident the flight ident | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3419 |  |  | 	* @return String success or false | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3420 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3421 |  |  | 	*/	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3422 |  |  | 	public function updateIdentSpotterData($flightaware_id = '', $ident = '',$fromsource = NULL) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3423 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3424 |  |  | 		if (!is_numeric(substr($ident, 0, 3))) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3425 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3426 |  |  | 			if (is_numeric(substr(substr($ident, 0, 3), -1, 1))) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3427 |  |  | 				$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 2),$fromsource); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3428 |  |  | 			} elseif (is_numeric(substr(substr($ident, 0, 4), -1, 1))) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3429 |  |  | 				$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 3),$fromsource); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3430 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3431 |  |  | 				$airline_array = $this->getAllAirlineInfo("NA"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3432 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3433 |  |  | 			if (count($airline_array) == 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3434 |  |  | 				$airline_array = $this->getAllAirlineInfo("NA"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3435 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3436 |  |  | 			if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == ""){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3437 |  |  | 				$airline_array = $this->getAllAirlineInfo("NA"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3438 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3439 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3440 |  |  | 			$airline_array = $this->getAllAirlineInfo("NA"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3441 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3442 |  |  |                 $airline_name = $airline_array[0]['name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3443 |  |  |                 $airline_icao = $airline_array[0]['icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3444 |  |  |                 $airline_country = $airline_array[0]['country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3445 |  |  |                 $airline_type = $airline_array[0]['type']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3446 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3447 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3448 |  |  | 		$query = 'UPDATE spotter_output SET ident = :ident, airline_name = :airline_name, airline_icao = :airline_icao, airline_country = :airline_country, airline_type = :airline_type WHERE flightaware_id = :flightaware_id'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3449 |  |  |                 $query_values = array(':flightaware_id' => $flightaware_id,':ident' => $ident,':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3450 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3451 |  |  | 		try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3452 |  |  | 			$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3453 |  |  | 			$sth->execute($query_values); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3454 |  |  | 		} catch (PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3455 |  |  | 			return "error : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3456 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3457 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3458 |  |  | 		return "success"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3459 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3460 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3461 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3462 |  |  | 	* Update latest spotter data | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3463 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3464 |  |  | 	* @param String $flightaware_id the ID from flightaware | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3465 |  |  | 	* @param String $ident the flight ident | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3466 |  |  | 	* @param String $arrival_airport_icao the arrival airport | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3467 |  |  | 	* @return String success or false | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3468 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3469 |  |  | 	*/	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3470 |  |  | 	public function updateLatestSpotterData($flightaware_id = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $ground = false, $groundspeed = NULL, $date = '', $arrival_airport_icao = '',$arrival_airport_time = '') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3471 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3472 |  |  | 		if ($groundspeed == '') $groundspeed = NULL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3473 |  |  | 		$query = 'UPDATE spotter_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_altitude = :last_altitude, last_ground = :last_ground, last_seen = :last_seen, real_arrival_airport_icao = :real_arrival_airport_icao, real_arrival_airport_time = :real_arrival_airport_time, last_ground_speed = :last_ground_speed WHERE flightaware_id = :flightaware_id'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3474 |  |  |                 $query_values = array(':flightaware_id' => $flightaware_id,':real_arrival_airport_icao' => $arrival_airport_icao,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_altitude' => $altitude,':last_ground_speed' => $groundspeed,':last_seen' => $date,':real_arrival_airport_time' => $arrival_airport_time, ':last_ground' => $ground, ':ident' => $ident); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3475 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3476 |  |  | 		try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3477 |  |  | 			$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3478 |  |  | 			$sth->execute($query_values); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3479 |  |  | 		} catch (PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3480 |  |  | 			return "error : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3481 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3482 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3483 |  |  | 		return "success"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3484 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3485 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3486 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3487 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3488 |  |  | 	* Adds a new spotter data | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3489 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3490 |  |  | 	* @param String $flightaware_id the ID from flightaware | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3491 |  |  | 	* @param String $ident the flight ident | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3492 |  |  | 	* @param String $aircraft_icao the aircraft type | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3493 |  |  | 	* @param String $departure_airport_icao the departure airport | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3494 |  |  | 	* @param String $arrival_airport_icao the arrival airport | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3495 |  |  | 	* @param String $latitude latitude of flight | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3496 |  |  | 	* @param String $longitude latitude of flight | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3497 |  |  | 	* @param String $waypoints waypoints of flight | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3498 |  |  | 	* @param String $altitude altitude of flight | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3499 |  |  | 	* @param String $heading heading of flight | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3500 |  |  | 	* @param String $groundspeed speed of flight | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3501 |  |  | 	* @param String $date date of flight | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3502 |  |  | 	* @param String $departure_airport_time departure time of flight | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3503 |  |  | 	* @param String $arrival_airport_time arrival time of flight | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3504 |  |  | 	* @param String $squawk squawk code of flight | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3505 |  |  | 	* @param String $route_stop route stop of flight | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3506 |  |  | 	* @param String $highlight highlight or not | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3507 |  |  | 	* @param String $ModeS ModesS code of flight | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3508 |  |  | 	* @param String $registration registration code of flight | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3509 |  |  | 	* @param String $pilot_id pilot id of flight (for virtual airlines) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3510 |  |  | 	* @param String $pilot_name pilot name of flight (for virtual airlines) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3511 |  |  | 	* @param String $verticalrate vertival rate of flight | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3512 |  |  | 	* @return String success or false | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3513 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3514 |  |  | 	public function addSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $departure_airport_time = '', $arrival_airport_time = '',$squawk = '', $route_stop = '', $highlight = '', $ModeS = '', $registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $ground = false,$format_source = '', $source_name = '') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3515 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3516 |  |  | 		global $globalURL, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalDebugTimeElapsed, $globalAirlinesSource, $globalVAM; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3517 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3518 |  |  | 		//if (isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3519 |  |  | 		$Image = new Image($this->db); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3520 |  |  | 		$Common = new Common(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3521 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3522 |  |  | 		if (!isset($globalIVAO)) $globalIVAO = FALSE; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3523 |  |  | 		if (!isset($globalVATSIM)) $globalVATSIM = FALSE; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3524 |  |  | 		if (!isset($globalphpVMS)) $globalphpVMS = FALSE; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3525 |  |  | 		if (!isset($globalVAM)) $globalVAM = FALSE; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3526 |  |  | 		date_default_timezone_set('UTC'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3527 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3528 |  |  | 		//getting the registration | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3529 |  |  | 		if ($flightaware_id != "" && $registration == '') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3530 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3531 |  |  | 			if (!is_string($flightaware_id)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3532 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3533 |  |  | 				return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3534 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3535 |  |  | 				if ($ModeS != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3536 |  |  | 					$timeelapsed = microtime(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3537 |  |  | 					$registration = $this->getAircraftRegistrationBymodeS($ModeS); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3538 |  |  | 					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3539 |  |  | 				} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3540 |  |  | 					$myhex = explode('-',$flightaware_id); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3541 |  |  | 					if (count($myhex) > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3542 |  |  | 						$timeelapsed = microtime(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3543 |  |  | 						$registration = $this->getAircraftRegistrationBymodeS($myhex[0]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3544 |  |  | 						if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3545 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3546 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3547 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3548 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3549 |  |  | 		$fromsource = NULL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3550 |  |  | 		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3551 |  |  | 		elseif ($format_source == 'vatsimtxt') $fromsource = 'vatsim'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3552 |  |  | 		elseif ($format_source == 'whazzup') $fromsource = 'ivao'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3553 |  |  | 		elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3554 |  |  | 		elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3555 |  |  | 		//getting the airline information | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3556 |  |  | 		if ($ident != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3557 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3558 |  |  | 			if (!is_string($ident)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3559 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3560 |  |  | 				return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3561 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3562 |  |  | 				if (!is_numeric(substr($ident, 0, 3)) && !((substr($ident, 0, 3) == 'OGN' || substr($ident, 0, 3) == 'FLR' || substr($ident, 0, 3) == 'ICA') && $format_source == 'aprs')) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3563 |  |  | 				{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3564 |  |  | 					$timeelapsed = microtime(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3565 |  |  | 					if (is_numeric(substr(substr($ident, 0, 3), -1, 1))) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3566 |  |  | 						$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 2),$fromsource); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3567 |  |  | 					} elseif (is_numeric(substr(substr($ident, 0, 4), -1, 1))) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3568 |  |  | 						$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 3),$fromsource); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3569 |  |  | 					} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3570 |  |  | 						$airline_array = $this->getAllAirlineInfo("NA"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3571 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3572 |  |  | 					if (count($airline_array) == 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3573 |  |  | 						$airline_array = $this->getAllAirlineInfo("NA"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3574 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3575 |  |  | 					if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == ""){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3576 |  |  | 						$airline_array = $this->getAllAirlineInfo("NA"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3577 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3578 |  |  | 					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3579 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3580 |  |  | 				} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3581 |  |  | 					$timeelapsed = microtime(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3582 |  |  | 					$airline_array = $this->getAllAirlineInfo("NA"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3583 |  |  | 					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3584 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3585 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3586 |  |  | 		} else $airline_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3587 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3588 |  |  | 		//getting the aircraft information | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3589 |  |  | 		$aircraft_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3590 |  |  | 		if ($aircraft_icao != '') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3591 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3592 |  |  | 			if (!is_string($aircraft_icao)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3593 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3594 |  |  | 				return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3595 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3596 |  |  | 				if ($aircraft_icao == "" || $aircraft_icao == "XXXX") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3597 |  |  | 				{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3598 |  |  | 					$timeelapsed = microtime(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3599 |  |  | 					$aircraft_array = $this->getAllAircraftInfo("NA"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3600 |  |  | 					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3601 |  |  | 				} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3602 |  |  | 					$timeelapsed = microtime(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3603 |  |  | 					$aircraft_array = $this->getAllAircraftInfo($aircraft_icao); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3604 |  |  | 					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3605 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3606 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3607 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3608 |  |  | 			if ($ModeS != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3609 |  |  | 				$timeelapsed = microtime(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3610 |  |  | 				$aircraft_icao = $this->getAllAircraftType($ModeS); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3611 |  |  | 				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAircraftType : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3612 |  |  | 				if ($aircraft_icao == "" || $aircraft_icao == "XXXX") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3613 |  |  | 				{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3614 |  |  | 					$timeelapsed = microtime(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3615 |  |  | 					$aircraft_array = $this->getAllAircraftInfo("NA"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3616 |  |  | 					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3617 |  |  | 				} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3618 |  |  | 					$timeelapsed = microtime(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3619 |  |  | 					$aircraft_array = $this->getAllAircraftInfo($aircraft_icao); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3620 |  |  | 					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3621 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3622 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3623 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3624 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3625 |  |  | 		//getting the departure airport information | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3626 |  |  | 		$departure_airport_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3627 |  |  | 		$departure_airport_icao = trim($departure_airport_icao); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3628 |  |  | 		if ($departure_airport_icao != '') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3629 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3630 |  |  | 			if (!is_string($departure_airport_icao)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3631 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3632 |  |  | 				return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3633 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3634 |  |  | 				$timeelapsed = microtime(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3635 |  |  | 				$departure_airport_array = $this->getAllAirportInfo($departure_airport_icao); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3636 |  |  | 				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3637 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3638 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3639 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3640 |  |  | 		//getting the arrival airport information | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3641 |  |  | 		$arrival_airport_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3642 |  |  | 		$arrival_airport_icao = trim($arrival_airport_icao); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3643 |  |  | 		if ($arrival_airport_icao != '') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3644 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3645 |  |  | 			if (!is_string($arrival_airport_icao)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3646 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3647 |  |  | 				return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3648 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3649 |  |  | 				$timeelapsed = microtime(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3650 |  |  | 				$arrival_airport_array = $this->getAllAirportInfo($arrival_airport_icao); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3651 |  |  | 				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3652 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3653 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3654 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3655 |  |  | 		if ($latitude != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3656 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3657 |  |  | 			if (!is_numeric($latitude)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3658 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3659 |  |  | 				return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3660 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3661 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3662 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3663 |  |  | 		if ($longitude != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3664 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3665 |  |  | 			if (!is_numeric($longitude)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3666 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3667 |  |  | 				return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3668 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3669 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3670 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3671 |  |  | 		if ($waypoints != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3672 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3673 |  |  | 			if (!is_string($waypoints)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3674 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3675 |  |  | 				return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3676 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3677 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3678 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3679 |  |  | 		if ($altitude != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3680 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3681 |  |  | 			if (!is_numeric($altitude)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3682 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3683 |  |  | 				return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3684 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3685 |  |  | 		} else $altitude = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3686 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3687 |  |  | 		if ($heading != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3688 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3689 |  |  | 			if (!is_numeric($heading)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3690 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3691 |  |  | 				return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3692 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3693 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3694 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3695 |  |  | 		if ($groundspeed != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3696 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3697 |  |  | 			if (!is_numeric($groundspeed)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3698 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3699 |  |  | 				return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3700 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3701 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3702 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3703 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3704 |  |  | 		if ($date == "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3705 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3706 |  |  | 			$date = date("Y-m-d H:i:s", time()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3707 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3708 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3709 |  |  | 		//getting the aircraft image | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3710 |  |  | 		if (($registration != "" || $registration != 'NA') && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3711 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3712 |  |  | 			$timeelapsed = microtime(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3713 |  |  | 			$image_array = $Image->getSpotterImage($registration); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3714 |  |  | 			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getSpotterImage : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3715 |  |  | 			if (!isset($image_array[0]['registration'])) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3716 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3717 |  |  | 				//echo "Add image !!!! \n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3718 |  |  | 				$Image->addSpotterImage($registration); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3719 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3720 |  |  | 			$timeelapsed = microtime(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3721 |  |  | 			$owner_info = $this->getAircraftOwnerByRegistration($registration); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3722 |  |  | 			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftOwnerByRegistration : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3723 |  |  | 			if ($owner_info['owner'] != '') $aircraft_owner = ucwords(strtolower($owner_info['owner'])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3724 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3725 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3726 |  |  | 		if ($globalIVAO && $aircraft_icao != '') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3727 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3728 |  |  |             		if (isset($airline_array[0]['icao'])) $airline_icao = $airline_array[0]['icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3729 |  |  |             		else $airline_icao = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3730 |  |  | 			$image_array = $Image->getSpotterImage('',$aircraft_icao,$airline_icao); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3731 |  |  | 			if (!isset($image_array[0]['registration'])) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3732 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3733 |  |  | 				//echo "Add image !!!! \n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3734 |  |  | 				$Image->addSpotterImage('',$aircraft_icao,$airline_icao); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3735 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3736 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3737 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3738 |  |  | 		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3739 |  |  | 		$ident = filter_var($ident,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3740 |  |  | 		$registration = filter_var($registration,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3741 |  |  | 		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3742 |  |  | 		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3743 |  |  | 		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3744 |  |  | 		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3745 |  |  | 		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3746 |  |  | 		$waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3747 |  |  | 		$altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3748 |  |  | 		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3749 |  |  | 		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3750 |  |  | 		$squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3751 |  |  | 		$route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3752 |  |  | 		$ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3753 |  |  | 		$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3754 |  |  | 		$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3755 |  |  | 		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3756 |  |  | 		$verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3757 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3758 |  |  | 		if (count($airline_array) == 0)  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3759 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3760 |  |  |                         $airline_array = $this->getAllAirlineInfo('NA'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3761 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3762 |  |  |                 if (count($aircraft_array) == 0)  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3763 |  |  |                 { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3764 |  |  |                         $aircraft_array = $this->getAllAircraftInfo('NA'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3765 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3766 |  |  |                 if (count($departure_airport_array) == 0 || $departure_airport_array[0]['icao'] == '' || $departure_airport_icao == '')  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3767 |  |  |                 { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3768 |  |  |                         $departure_airport_array = $this->getAllAirportInfo('NA'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3769 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3770 |  |  |                 if (count($arrival_airport_array) == 0 || $arrival_airport_array[0]['icao'] == '' || $arrival_airport_icao == '')  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3771 |  |  |                 { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3772 |  |  |                         $arrival_airport_array = $this->getAllAirportInfo('NA'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3773 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3774 |  |  |                 if ($registration == '') $registration = 'NA'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3775 |  |  |                 if ($latitude == '' && $longitude == '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3776 |  |  |             		$latitude = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3777 |  |  |             		$longitude = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3778 |  |  |             	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3779 |  |  |                 if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3780 |  |  |                 if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3781 |  |  |                 if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3782 |  |  |                 if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3783 |  |  |                 if (!isset($aircraft_owner)) $aircraft_owner = NULL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3784 |  |  |                 $query  = "INSERT INTO spotter_output (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop,highlight,ModeS, pilot_id, pilot_name, verticalrate, owner_name, ground, format_source, source_name)  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3785 |  |  |                 VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name,:departure_airport_city,:departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date, :departure_airport_time, :arrival_airport_time, :squawk, :route_stop, :highlight, :ModeS, :pilot_id, :pilot_name, :verticalrate, :owner_name,:ground, :format_source, :source_name)"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3786 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3787 |  |  |                 $airline_name = $airline_array[0]['name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3788 |  |  |                 $airline_icao = $airline_array[0]['icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3789 |  |  |                 $airline_country = $airline_array[0]['country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3790 |  |  |                 $airline_type = $airline_array[0]['type']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3791 |  |  | 		if ($airline_type == '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3792 |  |  | 			$timeelapsed = microtime(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3793 |  |  | 			$airline_type = $this->getAircraftTypeBymodeS($ModeS); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3794 |  |  | 			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3795 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3796 |  |  | 		if ($airline_type == null) $airline_type = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3797 |  |  |                 $aircraft_type = $aircraft_array[0]['type']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3798 |  |  |                 $aircraft_manufacturer = $aircraft_array[0]['manufacturer']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3799 |  |  |                 $departure_airport_name = $departure_airport_array[0]['name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3800 |  |  | 	        $departure_airport_city = $departure_airport_array[0]['city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3801 |  |  |             	$departure_airport_country = $departure_airport_array[0]['country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3802 |  |  |                  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3803 |  |  |                 $arrival_airport_name = $arrival_airport_array[0]['name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3804 |  |  |                 $arrival_airport_city = $arrival_airport_array[0]['city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3805 |  |  |                 $arrival_airport_country = $arrival_airport_array[0]['country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3806 |  |  |                 $query_values = array(':flightaware_id' => $flightaware_id,':ident' => $ident, ':registration' => $registration,':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type,':aircraft_icao' => $aircraft_icao,':aircraft_type' => $aircraft_type,':aircraft_manufacturer' => $aircraft_manufacturer,':departure_airport_icao' => $departure_airport_icao,':departure_airport_name' => $departure_airport_name,':departure_airport_city' => $departure_airport_city,':departure_airport_country' => $departure_airport_country,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_name' => $arrival_airport_name,':arrival_airport_city' => $arrival_airport_city,':arrival_airport_country' => $arrival_airport_country,':latitude' => $latitude,':longitude' => $longitude, ':waypoints' => $waypoints,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date,':departure_airport_time' => $departure_airport_time,':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk, ':route_stop' => $route_stop, ':highlight' => $highlight, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':owner_name' => $aircraft_owner, ':format_source' => $format_source, ':ground' => $ground, ':source_name' => $source_name); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3807 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3808 |  |  | 		try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3809 |  |  | 		         | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3810 |  |  | 			$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3811 |  |  | 			$sth->execute($query_values); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3812 |  |  | 			$this->db = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3813 |  |  | 		} catch (PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3814 |  |  | 		    return "error : ".$e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3815 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3816 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3817 |  |  | 		return "success"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3818 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3819 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3820 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3821 |  |  |    | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3822 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3823 |  |  | 	* Gets the aircraft ident within the last hour | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3824 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3825 |  |  | 	* @return String the ident | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3826 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3827 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3828 |  |  | 	public function getIdentFromLastHour($ident) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3829 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3830 |  |  | 		global $globalDBdriver, $globalTimezone; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3831 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3832 |  |  | 			$query  = "SELECT spotter_output.ident FROM spotter_output  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3833 |  |  | 								WHERE spotter_output.ident = :ident  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3834 |  |  | 								AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR)  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3835 |  |  | 								AND spotter_output.date < UTC_TIMESTAMP()"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3836 |  |  | 			$query_data = array(':ident' => $ident); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3837 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3838 |  |  | 			$query  = "SELECT spotter_output.ident FROM spotter_output  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3839 |  |  | 								WHERE spotter_output.ident = :ident  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3840 |  |  | 								AND spotter_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3841 |  |  | 								AND spotter_output.date < now() AT TIME ZONE 'UTC'"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3842 |  |  | 			$query_data = array(':ident' => $ident); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3843 |  |  |     		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3844 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3845 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3846 |  |  | 		$sth->execute($query_data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3847 |  |  |     		$ident_result=''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3848 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3849 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3850 |  |  | 			$ident_result = $row['ident']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3851 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3852 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3853 |  |  | 		return $ident_result; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3854 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3855 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3856 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3857 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3858 |  |  | 	* Gets the aircraft data from the last 20 seconds | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3859 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3860 |  |  | 	* @return Array the spotter data | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3861 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3862 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3863 |  |  | 	public function getRealTimeData($q = '') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3864 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3865 |  |  | 		global $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3866 |  |  | 		$additional_query = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3867 |  |  | 		if ($q != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3868 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3869 |  |  | 			if (!is_string($q)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3870 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3871 |  |  | 				return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3872 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3873 |  |  | 				$q_array = explode(" ", $q); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3874 |  |  | 				foreach ($q_array as $q_item){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3875 |  |  | 					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3876 |  |  | 					$additional_query .= " AND ("; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3877 |  |  | 					$additional_query .= "(spotter_output.aircraft_icao like '%".$q_item."%') OR "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3878 |  |  | 					$additional_query .= "(spotter_output.aircraft_name like '%".$q_item."%') OR "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3879 |  |  | 					$additional_query .= "(spotter_output.aircraft_manufacturer like '%".$q_item."%') OR "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3880 |  |  | 					$additional_query .= "(spotter_output.airline_icao like '%".$q_item."%') OR "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3881 |  |  | 					$additional_query .= "(spotter_output.departure_airport_icao like '%".$q_item."%') OR "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3882 |  |  | 					$additional_query .= "(spotter_output.arrival_airport_icao like '%".$q_item."%') OR "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3883 |  |  | 					$additional_query .= "(spotter_output.registration like '%".$q_item."%') OR "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3884 |  |  | 					$additional_query .= "(spotter_output.ident like '%".$q_item."%')"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3885 |  |  | 					$additional_query .= ")"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3886 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3887 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3888 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3889 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3890 |  |  | 			$query  = "SELECT spotter_output.* FROM spotter_output  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3891 |  |  | 				WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query."  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3892 |  |  | 				AND spotter_output.date < UTC_TIMESTAMP()"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3893 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3894 |  |  | 			$query  = "SELECT spotter_output.* FROM spotter_output  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3895 |  |  | 				WHERE spotter_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query."  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3896 |  |  | 				AND spotter_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3897 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3898 |  |  | 		$spotter_array = $this->getDataFromDB($query, array()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3899 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3900 |  |  | 		return $spotter_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3901 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3902 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3903 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3904 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3905 |  |  | 	 /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3906 |  |  | 	* Gets all airlines that have flown over | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3907 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3908 |  |  | 	* @return Array the airline list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3909 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3910 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3911 |  |  | 	public function countAllAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(), $year = '', $month = '', $day = '') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3912 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3913 |  |  | 		global $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3914 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3915 |  |  | 		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3916 |  |  | 		 			FROM spotter_output".$filter_query." spotter_output.airline_name <> '' AND spotter_output.airline_icao <> 'NA'"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3917 |  |  | 		if ($olderthanmonths > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3918 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3919 |  |  | 				$query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3920 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3921 |  |  | 				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3922 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3923 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3924 |  |  |                 if ($sincedate != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3925 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3926 |  |  | 				$query .= " AND spotter_output.date > '".$sincedate."'"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3927 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3928 |  |  | 				$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3929 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3930 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3931 |  |  | 		$query_values = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3932 |  |  | 		if ($year != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3933 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3934 |  |  | 				$query .= " AND YEAR(spotter_output.date) = :year"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3935 |  |  | 				$query_values = array_merge($query_values,array(':year' => $year)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3936 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3937 |  |  | 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3938 |  |  | 				$query_values = array_merge($query_values,array(':year' => $year)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3939 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3940 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3941 |  |  | 		if ($month != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3942 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3943 |  |  | 				$query .= " AND MONTH(spotter_output.date) = :month"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3944 |  |  | 				$query_values = array_merge($query_values,array(':month' => $month)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3945 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3946 |  |  | 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3947 |  |  | 				$query_values = array_merge($query_values,array(':month' => $month)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3948 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3949 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3950 |  |  | 		if ($day != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3951 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3952 |  |  | 				$query .= " AND DAY(spotter_output.date) = :day"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3953 |  |  | 				$query_values = array_merge($query_values,array(':day' => $day)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3954 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3955 |  |  | 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3956 |  |  | 				$query_values = array_merge($query_values,array(':day' => $day)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3957 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3958 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3959 |  |  | 		$query .= " GROUP BY spotter_output.airline_name,spotter_output.airline_icao, spotter_output.airline_country ORDER BY airline_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3960 |  |  | 		if ($limit) $query .= " LIMIT 10 OFFSET 0"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3961 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3962 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3963 |  |  | 		$sth->execute($query_values); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3964 |  |  | 		$airline_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3965 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3966 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3967 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3968 |  |  | 			$temp_array['airline_name'] = $row['airline_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3969 |  |  | 			$temp_array['airline_icao'] = $row['airline_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3970 |  |  | 			$temp_array['airline_count'] = $row['airline_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3971 |  |  | 			$temp_array['airline_country'] = $row['airline_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3972 |  |  | 			$airline_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3973 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3974 |  |  | 		return $airline_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3975 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3976 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3977 |  |  | 	 /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3978 |  |  | 	* Gets all pilots that have flown over | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3979 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3980 |  |  | 	* @return Array the pilots list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3981 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3982 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3983 |  |  | 	public function countAllPilots($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '',$day = '') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3984 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3985 |  |  | 		global $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3986 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3987 |  |  | 		$query  = "SELECT DISTINCT spotter_output.pilot_id, spotter_output.pilot_name, COUNT(spotter_output.pilot_id) AS pilot_count, spotter_output.format_source | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3988 |  |  | 		 			FROM spotter_output".$filter_query." spotter_output.pilot_id <> '' "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3989 |  |  |                 if ($olderthanmonths > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3990 |  |  |             		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3991 |  |  | 				$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3992 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3993 |  |  | 				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3994 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3995 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3996 |  |  |                 if ($sincedate != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3997 |  |  |             		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3998 |  |  | 				$query .= "AND spotter_output.date > '".$sincedate."' "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3999 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4000 |  |  | 				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4001 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4002 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4003 |  |  | 		$query_values = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4004 |  |  | 		if ($year != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4005 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4006 |  |  | 				$query .= " AND YEAR(spotter_output.date) = :year"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4007 |  |  | 				$query_values = array_merge($query_values,array(':year' => $year)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4008 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4009 |  |  | 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4010 |  |  | 				$query_values = array_merge($query_values,array(':year' => $year)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4011 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4012 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4013 |  |  | 		if ($month != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4014 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4015 |  |  | 				$query .= " AND MONTH(spotter_output.date) = :month"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4016 |  |  | 				$query_values = array_merge($query_values,array(':month' => $month)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4017 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4018 |  |  | 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4019 |  |  | 				$query_values = array_merge($query_values,array(':month' => $month)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4020 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4021 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4022 |  |  | 		if ($day != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4023 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4024 |  |  | 				$query .= " AND DAY(spotter_output.date) = :day"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4025 |  |  | 				$query_values = array_merge($query_values,array(':day' => $day)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4026 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4027 |  |  | 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4028 |  |  | 				$query_values = array_merge($query_values,array(':day' => $day)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4029 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4030 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4031 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4032 |  |  | 		$query .= "GROUP BY spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.format_source ORDER BY pilot_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4033 |  |  | 		if ($limit) $query .= " LIMIT 10 OFFSET 0"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4034 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4035 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4036 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4037 |  |  | 		$sth->execute($query_values); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4038 |  |  | 		$airline_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4039 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4040 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4041 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4042 |  |  | 			$temp_array['pilot_name'] = $row['pilot_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4043 |  |  | 			$temp_array['pilot_id'] = $row['pilot_id']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4044 |  |  | 			$temp_array['pilot_count'] = $row['pilot_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4045 |  |  | 			$temp_array['format_source'] = $row['format_source']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4046 |  |  | 			$airline_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4047 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4048 |  |  | 		return $airline_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4049 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4050 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4051 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4052 |  |  | 	* Gets all pilots that have flown over | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4053 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4054 |  |  | 	* @return Array the pilots list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4055 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4056 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4057 |  |  | 	public function countAllPilotsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4058 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4059 |  |  | 		global $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4060 |  |  | 		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.pilot_id, spotter_output.pilot_name, COUNT(spotter_output.pilot_id) AS pilot_count, spotter_output.format_source | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4061 |  |  | 		 			FROM spotter_output WHERE spotter_output.pilot_id <> '' "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4062 |  |  |                 if ($olderthanmonths > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4063 |  |  |             		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4064 |  |  | 				$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4065 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4066 |  |  | 				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4067 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4068 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4069 |  |  |                 if ($sincedate != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4070 |  |  |             		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4071 |  |  | 				$query .= "AND spotter_output.date > '".$sincedate."' "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4072 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4073 |  |  | 				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4074 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4075 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4076 |  |  | 		$query .= "GROUP BY spotter_output.airline_icao, spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.format_source ORDER BY pilot_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4077 |  |  | 		if ($limit) $query .= " LIMIT 10 OFFSET 0"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4078 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4079 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4080 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4081 |  |  | 		$sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4082 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4083 |  |  | 		$airline_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4084 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4085 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4086 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4087 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4088 |  |  | 			$temp_array['pilot_name'] = $row['pilot_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4089 |  |  | 			$temp_array['pilot_id'] = $row['pilot_id']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4090 |  |  | 			$temp_array['pilot_count'] = $row['pilot_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4091 |  |  | 			$temp_array['airline_icao'] = $row['airline_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4092 |  |  | 			$temp_array['format_source'] = $row['format_source']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4093 |  |  | 			$airline_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4094 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4095 |  |  | 		return $airline_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4096 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4097 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4098 |  |  | 	 /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4099 |  |  | 	* Gets all owner that have flown over | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4100 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4101 |  |  | 	* @return Array the pilots list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4102 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4103 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4104 |  |  | 	public function countAllOwners($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '',$month = '',$day = '') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4105 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4106 |  |  | 		global $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4107 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4108 |  |  | 		$query  = "SELECT DISTINCT spotter_output.owner_name, COUNT(spotter_output.owner_name) AS owner_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4109 |  |  | 					FROM spotter_output".$filter_query." spotter_output.owner_name <> '' AND spotter_output.owner_name IS NOT NULL"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4110 |  |  |                 if ($olderthanmonths > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4111 |  |  |             		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4112 |  |  | 				$query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4113 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4114 |  |  | 				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4115 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4116 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4117 |  |  |                 if ($sincedate != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4118 |  |  |             		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4119 |  |  | 				$query .= "AND spotter_output.date > '".$sincedate."' "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4120 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4121 |  |  | 				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4122 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4123 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4124 |  |  | 		$query_values = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4125 |  |  | 		if ($year != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4126 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4127 |  |  | 				$query .= " AND YEAR(spotter_output.date) = :year"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4128 |  |  | 				$query_values = array_merge($query_values,array(':year' => $year)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4129 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4130 |  |  | 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4131 |  |  | 				$query_values = array_merge($query_values,array(':year' => $year)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4132 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4133 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4134 |  |  | 		if ($month != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4135 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4136 |  |  | 				$query .= " AND MONTH(spotter_output.date) = :month"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4137 |  |  | 				$query_values = array_merge($query_values,array(':month' => $month)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4138 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4139 |  |  | 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4140 |  |  | 				$query_values = array_merge($query_values,array(':month' => $month)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4141 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4142 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4143 |  |  | 		if ($day != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4144 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4145 |  |  | 				$query .= " AND DAY(spotter_output.date) = :day"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4146 |  |  | 				$query_values = array_merge($query_values,array(':day' => $day)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4147 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4148 |  |  | 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4149 |  |  | 				$query_values = array_merge($query_values,array(':day' => $day)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4150 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4151 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4152 |  |  | 		$query .= " GROUP BY spotter_output.owner_name ORDER BY owner_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4153 |  |  | 		if ($limit) $query .= " LIMIT 10 OFFSET 0"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4154 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4155 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4156 |  |  | 		$sth->execute($query_values); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4157 |  |  | 		$airline_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4158 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4159 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4160 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4161 |  |  | 			$temp_array['owner_name'] = $row['owner_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4162 |  |  | 			$temp_array['owner_count'] = $row['owner_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4163 |  |  | 			$airline_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4164 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4165 |  |  | 		return $airline_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4166 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4167 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4168 |  |  | 	 /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4169 |  |  | 	* Gets all owner that have flown over | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4170 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4171 |  |  | 	* @return Array the pilots list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4172 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4173 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4174 |  |  | 	public function countAllOwnersByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4175 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4176 |  |  | 		global $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4177 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4178 |  |  | 		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.owner_name, COUNT(spotter_output.owner_name) AS owner_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4179 |  |  | 		 			FROM spotter_output".$filter_query." spotter_output.owner_name <> '' AND spotter_output.owner_name IS NOT NULL "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4180 |  |  |                 if ($olderthanmonths > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4181 |  |  |             		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4182 |  |  | 				$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4183 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4184 |  |  | 				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4185 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4186 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4187 |  |  |                 if ($sincedate != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4188 |  |  |             		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4189 |  |  | 				$query .= "AND spotter_output.date > '".$sincedate."' "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4190 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4191 |  |  | 				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4192 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4193 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4194 |  |  | 		$query .= "GROUP BY spotter_output.airline_icao, spotter_output.owner_name ORDER BY owner_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4195 |  |  | 		if ($limit) $query .= " LIMIT 10 OFFSET 0"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4196 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4197 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4198 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4199 |  |  | 		$sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4200 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4201 |  |  | 		$airline_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4202 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4203 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4204 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4205 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4206 |  |  | 			$temp_array['owner_name'] = $row['owner_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4207 |  |  | 			$temp_array['owner_count'] = $row['owner_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4208 |  |  | 			$temp_array['airline_icao'] = $row['airline_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4209 |  |  | 			$airline_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4210 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4211 |  |  | 		return $airline_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4212 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4213 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4214 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4215 |  |  | 	* Gets all airlines that have flown over by aircraft | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4216 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4217 |  |  | 	* @return Array the airline list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4218 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4219 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4220 |  |  | 	public function countAllAirlinesByAircraft($aircraft_icao,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4221 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4222 |  |  | 		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4223 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4224 |  |  | 		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4225 |  |  | 		 	    FROM spotter_output".$filter_query." spotter_output.airline_name <> '' AND spotter_output.aircraft_icao = :aircraft_icao  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4226 |  |  | 			    GROUP BY spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4227 |  |  | 			    ORDER BY airline_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4228 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4229 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4230 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4231 |  |  | 		$sth->execute(array(':aircraft_icao' => $aircraft_icao)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4232 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4233 |  |  | 		$airline_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4234 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4235 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4236 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4237 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4238 |  |  | 			$temp_array['airline_name'] = $row['airline_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4239 |  |  | 			$temp_array['airline_icao'] = $row['airline_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4240 |  |  | 			$temp_array['airline_count'] = $row['airline_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4241 |  |  | 			$temp_array['airline_country'] = $row['airline_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4242 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4243 |  |  | 			$airline_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4244 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4245 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4246 |  |  | 		return $airline_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4247 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4248 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4249 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4250 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4251 |  |  | 	* Gets all airline countries that have flown over by aircraft | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4252 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4253 |  |  | 	* @return Array the airline country list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4254 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4255 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4256 |  |  | 	public function countAllAirlineCountriesByAircraft($aircraft_icao,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4257 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4258 |  |  | 		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4259 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4260 |  |  | 		$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4261 |  |  | 		 			FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND spotter_output.aircraft_icao = :aircraft_icao | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4262 |  |  |                     GROUP BY spotter_output.airline_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4263 |  |  | 					ORDER BY airline_country_count DESC | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4264 |  |  | 					LIMIT 10 OFFSET 0"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4265 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4266 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4267 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4268 |  |  | 		$sth->execute(array(':aircraft_icao' => $aircraft_icao)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4269 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4270 |  |  | 		$airline_country_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4271 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4272 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4273 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4274 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4275 |  |  | 			$temp_array['airline_country_count'] = $row['airline_country_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4276 |  |  | 			$temp_array['airline_country'] = $row['airline_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4277 |  |  |   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4278 |  |  | 			$airline_country_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4279 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4280 |  |  | 		return $airline_country_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4281 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4282 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4283 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4284 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4285 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4286 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4287 |  |  | 	* Gets all airlines that have flown over by airport | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4288 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4289 |  |  | 	* @return Array the airline list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4290 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4291 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4292 |  |  | 	public function countAllAirlinesByAirport($airport_icao,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4293 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4294 |  |  | 		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4295 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4296 |  |  | 		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4297 |  |  | 		    FROM spotter_output".$filter_query." spotter_output.airline_name <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao )  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4298 |  |  |                     GROUP BY spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4299 |  |  | 		    ORDER BY airline_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4300 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4301 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4302 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4303 |  |  | 		$sth->execute(array(':airport_icao' => $airport_icao)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4304 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4305 |  |  | 		$airline_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4306 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4307 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4308 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4309 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4310 |  |  | 			$temp_array['airline_name'] = $row['airline_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4311 |  |  | 			$temp_array['airline_icao'] = $row['airline_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4312 |  |  | 			$temp_array['airline_count'] = $row['airline_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4313 |  |  | 			$temp_array['airline_country'] = $row['airline_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4314 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4315 |  |  | 			$airline_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4316 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4317 |  |  | 		return $airline_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4318 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4319 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4320 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4321 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4322 |  |  | 	* Gets all airline countries that have flown over by airport icao | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4323 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4324 |  |  | 	* @return Array the airline country list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4325 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4326 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4327 |  |  | 	public function countAllAirlineCountriesByAirport($airport_icao,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4328 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4329 |  |  | 		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4330 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4331 |  |  | 		$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4332 |  |  | 		 			FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4333 |  |  | 					GROUP BY spotter_output.airline_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4334 |  |  | 					ORDER BY airline_country_count DESC | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4335 |  |  | 					LIMIT 10 OFFSET 0"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4336 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4337 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4338 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4339 |  |  | 		$sth->execute(array(':airport_icao' => $airport_icao)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4340 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4341 |  |  | 		$airline_country_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4342 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4343 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4344 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4345 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4346 |  |  | 			$temp_array['airline_country_count'] = $row['airline_country_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4347 |  |  | 			$temp_array['airline_country'] = $row['airline_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4348 |  |  |   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4349 |  |  | 			$airline_country_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4350 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4351 |  |  | 		return $airline_country_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4352 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4353 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4354 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4355 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4356 |  |  | 	* Gets all airlines that have flown over by aircraft manufacturer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4357 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4358 |  |  | 	* @return Array the airline list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4359 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4360 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4361 |  |  | 	public function countAllAirlinesByManufacturer($aircraft_manufacturer,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4362 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4363 |  |  | 		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4364 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4365 |  |  | 		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4366 |  |  | 		 			FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer = :aircraft_manufacturer  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4367 |  |  | 					GROUP BY spotter_output.airline_name | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4368 |  |  | 					ORDER BY airline_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4369 |  |  |   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4370 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4371 |  |  | 		$sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4372 |  |  |   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4373 |  |  | 		$airline_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4374 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4375 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4376 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4377 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4378 |  |  | 			$temp_array['airline_name'] = $row['airline_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4379 |  |  | 			$temp_array['airline_icao'] = $row['airline_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4380 |  |  | 			$temp_array['airline_count'] = $row['airline_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4381 |  |  | 			$temp_array['airline_country'] = $row['airline_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4382 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4383 |  |  | 			$airline_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4384 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4385 |  |  | 		return $airline_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4386 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4387 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4388 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4389 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4390 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4391 |  |  | 	* Gets all airline countries that have flown over by aircraft manufacturer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4392 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4393 |  |  | 	* @return Array the airline country list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4394 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4395 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4396 |  |  | 	public function countAllAirlineCountriesByManufacturer($aircraft_manufacturer,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4397 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4398 |  |  | 		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4399 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4400 |  |  | 		$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4401 |  |  | 		 			FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4402 |  |  | 					GROUP BY spotter_output.airline_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4403 |  |  | 					ORDER BY airline_country_count DESC | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4404 |  |  | 					LIMIT 10 OFFSET 0"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4405 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4406 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4407 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4408 |  |  | 		$sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4409 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4410 |  |  | 		$airline_country_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4411 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4412 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4413 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4414 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4415 |  |  | 			$temp_array['airline_country_count'] = $row['airline_country_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4416 |  |  | 			$temp_array['airline_country'] = $row['airline_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4417 |  |  | 			$airline_country_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4418 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4419 |  |  | 		return $airline_country_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4420 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4421 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4422 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4423 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4424 |  |  | 	* Gets all airlines that have flown over by date | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4425 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4426 |  |  | 	* @return Array the airline list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4427 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4428 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4429 |  |  | 	public function countAllAirlinesByDate($date,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4430 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4431 |  |  | 		global $globalTimezone, $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4432 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4433 |  |  | 		$date = filter_var($date,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4434 |  |  | 		if ($globalTimezone != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4435 |  |  | 			date_default_timezone_set($globalTimezone); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4436 |  |  | 			$datetime = new DateTime($date); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4437 |  |  | 			$offset = $datetime->format('P'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4438 |  |  | 		} else $offset = '+00:00'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4439 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4440 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4441 |  |  | 			$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4442 |  |  | 		 			FROM spotter_output".$filter_query." DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4443 |  |  | 					GROUP BY spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4444 |  |  | 					ORDER BY airline_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4445 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4446 |  |  | 			$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4447 |  |  | 		 			FROM spotter_output".$filter_query." to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4448 |  |  | 					GROUP BY spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4449 |  |  | 					ORDER BY airline_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4450 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4451 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4452 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4453 |  |  | 		$sth->execute(array(':date' => $date, ':offset' => $offset)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4454 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4455 |  |  | 		$airline_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4456 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4457 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4458 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4459 |  |  | 			$temp_array['airline_name'] = $row['airline_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4460 |  |  | 			$temp_array['airline_icao'] = $row['airline_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4461 |  |  | 			$temp_array['airline_count'] = $row['airline_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4462 |  |  | 			$temp_array['airline_country'] = $row['airline_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4463 |  |  |   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4464 |  |  | 			$airline_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4465 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4466 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4467 |  |  | 		return $airline_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4468 |  |  | 	}	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4469 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4470 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4471 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4472 |  |  | 	* Gets all airline countries that have flown over by date | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4473 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4474 |  |  | 	* @return Array the airline country list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4475 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4476 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4477 |  |  | 	public function countAllAirlineCountriesByDate($date,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4478 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4479 |  |  | 		global $globalTimezone, $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4480 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4481 |  |  | 		$date = filter_var($date,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4482 |  |  | 		if ($globalTimezone != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4483 |  |  | 			date_default_timezone_set($globalTimezone); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4484 |  |  | 			$datetime = new DateTime($date); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4485 |  |  | 			$offset = $datetime->format('P'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4486 |  |  | 		} else $offset = '+00:00'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4487 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4488 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4489 |  |  | 			$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4490 |  |  | 		 			FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4491 |  |  | 					GROUP BY spotter_output.airline_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4492 |  |  | 					ORDER BY airline_country_count DESC | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4493 |  |  | 					LIMIT 10 OFFSET 0"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4494 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4495 |  |  | 			$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4496 |  |  | 		 			FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4497 |  |  | 					GROUP BY spotter_output.airline_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4498 |  |  | 					ORDER BY airline_country_count DESC | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4499 |  |  | 					LIMIT 10 OFFSET 0"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4500 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4501 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4502 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4503 |  |  | 		$sth->execute(array(':date' => $date, ':offset' => $offset)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4504 |  |  |   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4505 |  |  | 		$airline_country_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4506 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4507 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4508 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4509 |  |  | 			$temp_array['airline_country_count'] = $row['airline_country_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4510 |  |  | 			$temp_array['airline_country'] = $row['airline_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4511 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4512 |  |  | 			$airline_country_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4513 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4514 |  |  | 		return $airline_country_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4515 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4516 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4517 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4518 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4519 |  |  | 	* Gets all airlines that have flown over by ident/callsign | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4520 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4521 |  |  | 	* @return Array the airline list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4522 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4523 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4524 |  |  | 	public function countAllAirlinesByIdent($ident,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4525 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4526 |  |  | 		$ident = filter_var($ident,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4527 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4528 |  |  | 		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4529 |  |  | 		 		FROM spotter_output".$filter_query." spotter_output.ident = :ident   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4530 |  |  | 				GROUP BY spotter_output.airline_icao, spotter_output.airline_name, spotter_output.airline_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4531 |  |  | 				ORDER BY airline_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4532 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4533 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4534 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4535 |  |  | 		$sth->execute(array(':ident' => $ident)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4536 |  |  | 		return $sth->fetchAll(PDO::FETCH_ASSOC); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4537 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4538 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4539 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4540 |  |  | 	* Gets all airlines by owner | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4541 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4542 |  |  | 	* @return Array the airline list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4543 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4544 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4545 |  |  | 	public function countAllAirlinesByOwner($owner,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4546 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4547 |  |  | 		$owner = filter_var($owner,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4548 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4549 |  |  | 		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4550 |  |  | 		 		FROM spotter_output".$filter_query." spotter_output.owner_name = :owner   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4551 |  |  | 				GROUP BY spotter_output.airline_icao, spotter_output.airline_name, spotter_output.airline_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4552 |  |  | 				ORDER BY airline_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4553 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4554 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4555 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4556 |  |  | 		$sth->execute(array(':owner' => $owner)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4557 |  |  | 		return $sth->fetchAll(PDO::FETCH_ASSOC); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4558 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4559 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4560 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4561 |  |  | 	* Gets all airlines used by pilot | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4562 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4563 |  |  | 	* @return Array the airline list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4564 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4565 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4566 |  |  | 	public function countAllAirlinesByPilot($pilot,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4567 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4568 |  |  | 		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4569 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4570 |  |  | 		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4571 |  |  | 		 		FROM spotter_output".$filter_query." (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot)  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4572 |  |  | 				GROUP BY spotter_output.airline_icao, spotter_output.airline_name, spotter_output.airline_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4573 |  |  | 				ORDER BY airline_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4574 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4575 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4576 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4577 |  |  | 		$sth->execute(array(':pilot' => $pilot)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4578 |  |  | 		return $sth->fetchAll(PDO::FETCH_ASSOC); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4579 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4580 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4581 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4582 |  |  | 	* Gets all airlines that have flown over by route | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4583 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4584 |  |  | 	* @return Array the airline list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4585 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4586 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4587 |  |  | 	public function countAllAirlinesByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4588 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4589 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4590 |  |  | 		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4591 |  |  | 		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4592 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4593 |  |  | 		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4594 |  |  | 		 			FROM spotter_output".$filter_query." (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao)  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4595 |  |  | 					GROUP BY spotter_output.airline_name | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4596 |  |  | 					ORDER BY airline_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4597 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4598 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4599 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4600 |  |  | 		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4601 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4602 |  |  | 		$airline_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4603 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4604 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4605 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4606 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4607 |  |  | 			$temp_array['airline_name'] = $row['airline_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4608 |  |  | 			$temp_array['airline_icao'] = $row['airline_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4609 |  |  | 			$temp_array['airline_count'] = $row['airline_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4610 |  |  | 			$temp_array['airline_country'] = $row['airline_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4611 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4612 |  |  | 			$airline_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4613 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4614 |  |  | 		return $airline_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4615 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4616 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4617 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4618 |  |  | 	* Gets all airline countries that have flown over by route | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4619 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4620 |  |  | 	* @return Array the airline country list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4621 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4622 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4623 |  |  | 	public function countAllAirlineCountriesByRoute($departure_airport_icao, $arrival_airport_icao,$filters= array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4624 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4625 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4626 |  |  | 		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4627 |  |  | 		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4628 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4629 |  |  | 		$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4630 |  |  | 		 		FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao)  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4631 |  |  | 				GROUP BY spotter_output.airline_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4632 |  |  | 				ORDER BY airline_country_count DESC | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4633 |  |  | 				LIMIT 10 OFFSET 0"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4634 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4635 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4636 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4637 |  |  | 		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4638 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4639 |  |  | 		$airline_country_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4640 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4641 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4642 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4643 |  |  | 			$temp_array['airline_country_count'] = $row['airline_country_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4644 |  |  | 			$temp_array['airline_country'] = $row['airline_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4645 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4646 |  |  | 			$airline_country_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4647 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4648 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4649 |  |  | 		return $airline_country_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4650 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4651 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4652 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4653 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4654 |  |  | 	* Gets all airlines that have flown over by country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4655 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4656 |  |  | 	* @return Array the airline list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4657 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4658 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4659 |  |  | 	public function countAllAirlinesByCountry($country,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4660 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4661 |  |  | 		$country = filter_var($country,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4662 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4663 |  |  | 		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4664 |  |  | 		 	    FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4665 |  |  | 			    GROUP BY spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4666 |  |  | 			    ORDER BY airline_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4667 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4668 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4669 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4670 |  |  | 		$sth->execute(array(':country' => $country)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4671 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4672 |  |  | 		$airline_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4673 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4674 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4675 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4676 |  |  | 			$temp_array['airline_name'] = $row['airline_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4677 |  |  | 			$temp_array['airline_icao'] = $row['airline_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4678 |  |  | 			$temp_array['airline_count'] = $row['airline_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4679 |  |  | 			$temp_array['airline_country'] = $row['airline_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4680 |  |  |   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4681 |  |  | 			$airline_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4682 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4683 |  |  | 		return $airline_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4684 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4685 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4686 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4687 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4688 |  |  | 	* Gets all airline countries that have flown over by country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4689 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4690 |  |  | 	* @return Array the airline country list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4691 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4692 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4693 |  |  | 	public function countAllAirlineCountriesByCountry($country,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4694 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4695 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4696 |  |  | 		$country = filter_var($country,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4697 |  |  | 		$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4698 |  |  | 		 		FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4699 |  |  | 				GROUP BY spotter_output.airline_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4700 |  |  | 				ORDER BY airline_country_count DESC | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4701 |  |  | 				LIMIT 10 OFFSET 0"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4702 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4703 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4704 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4705 |  |  | 		$sth->execute(array(':country' => $country)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4706 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4707 |  |  | 		$airline_country_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4708 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4709 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4710 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4711 |  |  | 			$temp_array['airline_country_count'] = $row['airline_country_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4712 |  |  | 			$temp_array['airline_country'] = $row['airline_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4713 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4714 |  |  | 			$airline_country_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4715 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4716 |  |  | 		return $airline_country_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4717 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4718 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4719 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4720 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4721 |  |  | 	* Gets all airlines countries | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4722 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4723 |  |  | 	* @return Array the airline country list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4724 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4725 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4726 |  |  | 	public function countAllAirlineCountries($limit = true, $filters = array(), $year = '', $month = '', $day = '') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4727 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4728 |  |  | 		global $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4729 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4730 |  |  | 		$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4731 |  |  | 		 			FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND spotter_output.airline_country <> 'NA'"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4732 |  |  | 		$query_values = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4733 |  |  | 		if ($year != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4734 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4735 |  |  | 				$query .= " AND YEAR(spotter_output.date) = :year"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4736 |  |  | 				$query_values = array_merge($query_values,array(':year' => $year)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4737 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4738 |  |  | 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4739 |  |  | 				$query_values = array_merge($query_values,array(':year' => $year)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4740 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4741 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4742 |  |  | 		if ($month != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4743 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4744 |  |  | 				$query .= " AND MONTH(spotter_output.date) = :month"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4745 |  |  | 				$query_values = array_merge($query_values,array(':month' => $month)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4746 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4747 |  |  | 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4748 |  |  | 				$query_values = array_merge($query_values,array(':month' => $month)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4749 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4750 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4751 |  |  | 		if ($day != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4752 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4753 |  |  | 				$query .= " AND DAY(spotter_output.date) = :day"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4754 |  |  | 				$query_values = array_merge($query_values,array(':day' => $day)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4755 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4756 |  |  | 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4757 |  |  | 				$query_values = array_merge($query_values,array(':day' => $day)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4758 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4759 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4760 |  |  | 		$query .= " GROUP BY spotter_output.airline_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4761 |  |  | 					ORDER BY airline_country_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4762 |  |  | 		if ($limit) $query .= " LIMIT 10 OFFSET 0"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4763 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4764 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4765 |  |  | 		$sth->execute($query_values); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4766 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4767 |  |  | 		$airline_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4768 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4769 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4770 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4771 |  |  | 			$temp_array['airline_country_count'] = $row['airline_country_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4772 |  |  | 			$temp_array['airline_country'] = $row['airline_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4773 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4774 |  |  | 			$airline_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4775 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4776 |  |  | 		return $airline_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4777 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4778 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4779 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4780 |  |  | 	* Gets all number of flight over countries | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4781 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4782 |  |  | 	* @return Array the airline country list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4783 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4784 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4785 |  |  | 	public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4786 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4787 |  |  | 		global $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4788 |  |  | 		//$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4789 |  |  | 		$Connection= new Connection($this->db); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4790 |  |  | 		if (!$Connection->tableExists('countries')) return array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4791 |  |  | 		/* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4792 |  |  | 		$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4793 |  |  | 					FROM countries c, spotter_output s | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4794 |  |  | 					WHERE Within(GeomFromText(CONCAT('POINT(',s.longitude,' ',s.latitude,')')), ogc_geom) "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4795 |  |  | 		*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4796 |  |  | /* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4797 |  |  | 		$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4798 |  |  | 					FROM countries c, spotter_live s | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4799 |  |  | 					WHERE c.iso2 = s.over_country "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4800 |  |  | 		$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT flightaware_id,over_country FROM spottrer_live) l ON c.iso2 = l.over_country "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4801 |  |  | */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4802 |  |  | 		require_once('class.SpotterLive.php'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4803 |  |  | 		$SpotterLive = new SpotterLive(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4804 |  |  | 		$filter_query = $SpotterLive->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4805 |  |  | 		$filter_query .= ' over_country IS NOT NULL'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4806 |  |  |                 if ($olderthanmonths > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4807 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4808 |  |  | 				$filter_query .= ' AND spotter_live.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4809 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4810 |  |  | 				$filter_query .= " AND spotter_live.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4811 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4812 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4813 |  |  |                 if ($sincedate != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4814 |  |  |             		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4815 |  |  | 				$filter_query .= " AND spotter_live.date > '".$sincedate."' "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4816 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4817 |  |  | 				$filter_query .= " AND spotter_live.date > CAST('".$sincedate."' AS TIMESTAMP)"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4818 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4819 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4820 |  |  | 		$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT flightaware_id,over_country FROM spotter_live".$filter_query.") l ON c.iso2 = l.over_country "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4821 |  |  | 		$query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4822 |  |  | 		if ($limit) $query .= " LIMIT 10 OFFSET 0"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4823 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4824 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4825 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4826 |  |  | 		$sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4827 |  |  |   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4828 |  |  | 		$flight_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4829 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4830 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4831 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4832 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4833 |  |  | 			$temp_array['flight_count'] = $row['nb']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4834 |  |  | 			$temp_array['flight_country'] = $row['name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4835 |  |  | 			$temp_array['flight_country_iso3'] = $row['iso3']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4836 |  |  | 			$temp_array['flight_country_iso2'] = $row['iso2']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4837 |  |  | 			$flight_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4838 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4839 |  |  | 		return $flight_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4840 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4841 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4842 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4843 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4844 |  |  | 	* Gets all aircraft types that have flown over | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4845 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4846 |  |  | 	* @return Array the aircraft list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4847 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4848 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4849 |  |  | 	public function countAllAircraftTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4850 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4851 |  |  | 		global $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4852 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4853 |  |  | 		$query  = "SELECT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4854 |  |  | 		    FROM spotter_output ".$filter_query." spotter_output.aircraft_name  <> '' AND spotter_output.aircraft_icao  <> ''"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4855 |  |  | 		if ($olderthanmonths > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4856 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4857 |  |  | 				$query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4858 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4859 |  |  | 				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4860 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4861 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4862 |  |  | 		if ($sincedate != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4863 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4864 |  |  | 				$query .= " AND spotter_output.date > '".$sincedate."'"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4865 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4866 |  |  | 				$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4867 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4868 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4869 |  |  | 		$query_values = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4870 |  |  | 		if ($year != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4871 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4872 |  |  | 				$query .= " AND YEAR(spotter_output.date) = :year"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4873 |  |  | 				$query_values = array_merge($query_values,array(':year' => $year)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4874 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4875 |  |  | 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4876 |  |  | 				$query_values = array_merge($query_values,array(':year' => $year)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4877 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4878 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4879 |  |  | 		if ($month != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4880 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4881 |  |  | 				$query .= " AND MONTH(spotter_output.date) = :month"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4882 |  |  | 				$query_values = array_merge($query_values,array(':month' => $month)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4883 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4884 |  |  | 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4885 |  |  | 				$query_values = array_merge($query_values,array(':month' => $month)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4886 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4887 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4888 |  |  | 		if ($day != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4889 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4890 |  |  | 				$query .= " AND DAY(spotter_output.date) = :day"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4891 |  |  | 				$query_values = array_merge($query_values,array(':day' => $day)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4892 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4893 |  |  | 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4894 |  |  | 				$query_values = array_merge($query_values,array(':day' => $day)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4895 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4896 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4897 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4898 |  |  | 		$query .= " GROUP BY spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer ORDER BY aircraft_icao_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4899 |  |  | 		if ($limit) $query .= " LIMIT 10 OFFSET 0"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4900 |  |  |   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4901 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4902 |  |  | 		$sth->execute($query_values); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4903 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4904 |  |  | 		$aircraft_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4905 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4906 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4907 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4908 |  |  | 			$temp_array['aircraft_icao'] = $row['aircraft_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4909 |  |  | 			$temp_array['aircraft_name'] = $row['aircraft_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4910 |  |  | 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4911 |  |  | 			$temp_array['aircraft_icao_count'] = $row['aircraft_icao_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4912 |  |  | 			$aircraft_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4913 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4914 |  |  | 		return $aircraft_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4915 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4916 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4917 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4918 |  |  | 	* Gets all aircraft types that have flown over by airline | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4919 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4920 |  |  | 	* @return Array the aircraft list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4921 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4922 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4923 |  |  | 	public function countAllAircraftTypesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '', $day = '') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4924 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4925 |  |  | 		global $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4926 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4927 |  |  | 		$query  = "SELECT spotter_output.airline_icao, spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4928 |  |  | 		    FROM spotter_output".$filter_query." spotter_output.aircraft_name  <> '' AND spotter_output.aircraft_icao  <> '' AND spotter_output.airline_icao <>'' AND spotter_output.airline_icao <> 'NA' "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4929 |  |  | 		if ($olderthanmonths > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4930 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4931 |  |  | 				$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4932 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4933 |  |  | 				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4934 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4935 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4936 |  |  | 		if ($sincedate != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4937 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4938 |  |  | 				$query .= "AND spotter_output.date > '".$sincedate."' "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4939 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4940 |  |  | 				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4941 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4942 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4943 |  |  | 		$query_values = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4944 |  |  | 		if ($year != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4945 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4946 |  |  | 				$query .= " AND YEAR(spotter_output.date) = :year"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4947 |  |  | 				$query_values = array_merge($query_values,array(':year' => $year)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4948 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4949 |  |  | 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4950 |  |  | 				$query_values = array_merge($query_values,array(':year' => $year)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4951 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4952 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4953 |  |  | 		if ($month != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4954 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4955 |  |  | 				$query .= " AND MONTH(spotter_output.date) = :month"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4956 |  |  | 				$query_values = array_merge($query_values,array(':month' => $month)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4957 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4958 |  |  | 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4959 |  |  | 				$query_values = array_merge($query_values,array(':month' => $month)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4960 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4961 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4962 |  |  | 		if ($day != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4963 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4964 |  |  | 				$query .= " AND DAY(spotter_output.date) = :day"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4965 |  |  | 				$query_values = array_merge($query_values,array(':day' => $day)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4966 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4967 |  |  | 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4968 |  |  | 				$query_values = array_merge($query_values,array(':day' => $day)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4969 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4970 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4971 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4972 |  |  | 		$query .= "GROUP BY spotter_output.airline_icao, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer ORDER BY aircraft_icao_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4973 |  |  | 		if ($limit) $query .= " LIMIT 10 OFFSET 0"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4974 |  |  |   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4975 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4976 |  |  | 		$sth->execute($query_values); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4977 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4978 |  |  | 		$aircraft_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4979 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4980 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4981 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4982 |  |  | 			$temp_array['airline_icao'] = $row['airline_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4983 |  |  | 			$temp_array['aircraft_icao'] = $row['aircraft_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4984 |  |  | 			$temp_array['aircraft_name'] = $row['aircraft_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4985 |  |  | 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4986 |  |  | 			$temp_array['aircraft_icao_count'] = $row['aircraft_icao_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4987 |  |  | 			$aircraft_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4988 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4989 |  |  | 		return $aircraft_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4990 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4991 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4992 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4993 |  |  | 	* Gets all aircraft types that have flown over by months | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4994 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4995 |  |  | 	* @return Array the aircraft list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4996 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4997 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4998 |  |  | 	public function countAllAircraftTypesByMonths($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4999 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5000 |  |  | 		global $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5001 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5002 |  |  | 		$query  = "SELECT EXTRACT(month from spotter_output.date) as month, EXTRACT(year from spotter_output.date) as year,spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5003 |  |  | 		    FROM spotter_output".$filter_query." spotter_output.aircraft_name  <> '' AND spotter_output.aircraft_icao  <> '' AND spotter_output.airline_icao <>'' AND spotter_output.airline_icao <> 'NA' "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5004 |  |  | 		if ($olderthanmonths > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5005 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5006 |  |  | 				$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5007 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5008 |  |  | 				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5009 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5010 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5011 |  |  | 		if ($sincedate != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5012 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5013 |  |  | 				$query .= "AND spotter_output.date > '".$sincedate."' "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5014 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5015 |  |  | 				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5016 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5017 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5018 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5019 |  |  | 		$query .= "GROUP BY EXTRACT(month from spotter_output.date), EXTRACT(year from spotter_output.date), spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer ORDER BY aircraft_icao_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5020 |  |  | 		if ($limit) $query .= " LIMIT 10 OFFSET 0"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5021 |  |  |   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5022 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5023 |  |  | 		$sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5024 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5025 |  |  | 		$aircraft_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5026 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5027 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5028 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5029 |  |  | 			//$temp_array['airline_icao'] = $row['airline_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5030 |  |  | 			$temp_array['aircraft_icao'] = $row['aircraft_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5031 |  |  | 			$temp_array['aircraft_name'] = $row['aircraft_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5032 |  |  | 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5033 |  |  | 			$temp_array['aircraft_icao_count'] = $row['aircraft_icao_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5034 |  |  | 			$aircraft_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5035 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5036 |  |  | 		return $aircraft_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5037 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5038 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5039 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5040 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5041 |  |  | 	* Gets all aircraft registration that have flown over by aircaft icao | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5042 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5043 |  |  | 	* @return Array the aircraft list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5044 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5045 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5046 |  |  | 	public function countAllAircraftRegistrationByAircraft($aircraft_icao,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5047 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5048 |  |  | 		$Image = new Image($this->db); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5049 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5050 |  |  | 		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5051 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5052 |  |  | 		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5053 |  |  | 				FROM spotter_output".$filter_query." spotter_output.registration <> '' AND spotter_output.aircraft_icao = :aircraft_icao   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5054 |  |  | 				GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5055 |  |  | 				ORDER BY registration_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5056 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5057 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5058 |  |  | 		$sth->execute(array(':aircraft_icao' => $aircraft_icao)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5059 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5060 |  |  | 		$aircraft_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5061 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5062 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5063 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5064 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5065 |  |  | 			$temp_array['aircraft_icao'] = $row['aircraft_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5066 |  |  | 			$temp_array['aircraft_name'] = $row['aircraft_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5067 |  |  | 			$temp_array['registration'] = $row['registration']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5068 |  |  | 			$temp_array['airline_name'] = $row['airline_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5069 |  |  | 			$temp_array['image_thumbnail'] = ""; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5070 |  |  | 			if($row['registration'] != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5071 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5072 |  |  | 				$image_array = $Image->getSpotterImage($row['registration']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5073 |  |  | 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5074 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5075 |  |  | 			$temp_array['registration_count'] = $row['registration_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5076 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5077 |  |  | 			$aircraft_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5078 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5079 |  |  | 		return $aircraft_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5080 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5081 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5082 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5083 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5084 |  |  | 	* Gets all aircraft types that have flown over by airline icao | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5085 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5086 |  |  | 	* @return Array the aircraft list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5087 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5088 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5089 |  |  | 	public function countAllAircraftTypesByAirline($airline_icao,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5090 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5091 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5092 |  |  | 		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5093 |  |  | 		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5094 |  |  | 			    FROM spotter_output".$filter_query." spotter_output.aircraft_icao <> '' AND spotter_output.airline_icao = :airline_icao  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5095 |  |  | 			    GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5096 |  |  | 			    ORDER BY aircraft_icao_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5097 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5098 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5099 |  |  | 		$sth->execute(array(':airline_icao' => $airline_icao)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5100 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5101 |  |  | 		$aircraft_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5102 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5103 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5104 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5105 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5106 |  |  | 			$temp_array['aircraft_icao'] = $row['aircraft_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5107 |  |  | 			$temp_array['aircraft_name'] = $row['aircraft_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5108 |  |  | 			$temp_array['aircraft_icao_count'] = $row['aircraft_icao_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5109 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5110 |  |  | 			$aircraft_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5111 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5112 |  |  | 		return $aircraft_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5113 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5114 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5115 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5116 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5117 |  |  | 	* Gets all aircraft registration that have flown over by airline icao | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5118 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5119 |  |  | 	* @return Array the aircraft list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5120 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5121 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5122 |  |  | 	public function countAllAircraftRegistrationByAirline($airline_icao,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5123 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5124 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5125 |  |  | 		$Image = new Image($this->db); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5126 |  |  | 		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5127 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5128 |  |  | 		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5129 |  |  | 			    FROM spotter_output".$filter_query." spotter_output.registration <> '' AND spotter_output.airline_icao = :airline_icao  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5130 |  |  | 			    GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5131 |  |  | 			    ORDER BY registration_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5132 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5133 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5134 |  |  | 		$sth->execute(array(':airline_icao' => $airline_icao)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5135 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5136 |  |  | 		$aircraft_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5137 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5138 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5139 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5140 |  |  | 			$temp_array['aircraft_icao'] = $row['aircraft_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5141 |  |  | 			$temp_array['aircraft_name'] = $row['aircraft_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5142 |  |  | 			$temp_array['registration'] = $row['registration']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5143 |  |  | 			$temp_array['airline_name'] = $row['airline_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5144 |  |  | 			$temp_array['image_thumbnail'] = ""; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5145 |  |  | 			if($row['registration'] != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5146 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5147 |  |  | 				$image_array = $Image->getSpotterImage($row['registration']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5148 |  |  | 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5149 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5150 |  |  | 			$temp_array['registration_count'] = $row['registration_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5151 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5152 |  |  | 			$aircraft_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5153 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5154 |  |  | 		return $aircraft_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5155 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5156 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5157 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5158 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5159 |  |  | 	* Gets all aircraft manufacturer that have flown over by airline icao | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5160 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5161 |  |  | 	* @return Array the aircraft list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5162 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5163 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5164 |  |  | 	public function countAllAircraftManufacturerByAirline($airline_icao,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5165 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5166 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5167 |  |  | 		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5168 |  |  | 		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5169 |  |  | 				FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND spotter_output.airline_icao = :airline_icao  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5170 |  |  | 				GROUP BY spotter_output.aircraft_manufacturer  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5171 |  |  | 				ORDER BY aircraft_manufacturer_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5172 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5173 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5174 |  |  | 		$sth->execute(array(':airline_icao' => $airline_icao)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5175 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5176 |  |  | 		$aircraft_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5177 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5178 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5179 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5180 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5181 |  |  | 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5182 |  |  | 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5183 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5184 |  |  | 			$aircraft_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5185 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5186 |  |  | 		return $aircraft_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5187 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5188 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5189 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5190 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5191 |  |  | 	* Gets all aircraft types that have flown over by airline icao | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5192 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5193 |  |  | 	* @return Array the aircraft list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5194 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5195 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5196 |  |  | 	public function countAllAircraftTypesByAirport($airport_icao,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5197 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5198 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5199 |  |  | 		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5200 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5201 |  |  | 		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5202 |  |  | 				FROM spotter_output".$filter_query." spotter_output.aircraft_icao <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao)  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5203 |  |  | 				GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5204 |  |  | 				ORDER BY aircraft_icao_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5205 |  |  |   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5206 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5207 |  |  | 		$sth->execute(array(':airport_icao' => $airport_icao)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5208 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5209 |  |  | 		$aircraft_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5210 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5211 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5212 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5213 |  |  | 			$temp_array['aircraft_icao'] = $row['aircraft_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5214 |  |  | 			$temp_array['aircraft_name'] = $row['aircraft_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5215 |  |  | 			$temp_array['aircraft_icao_count'] = $row['aircraft_icao_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5216 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5217 |  |  | 			$aircraft_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5218 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5219 |  |  | 		return $aircraft_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5220 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5221 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5222 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5223 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5224 |  |  | 	* Gets all aircraft registration that have flown over by airport icao | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5225 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5226 |  |  | 	* @return Array the aircraft list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5227 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5228 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5229 |  |  | 	public function countAllAircraftRegistrationByAirport($airport_icao,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5230 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5231 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5232 |  |  | 		$Image = new Image($this->db); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5233 |  |  | 		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5234 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5235 |  |  | 		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5236 |  |  |                     FROM spotter_output".$filter_query." spotter_output.registration <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao)    | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5237 |  |  |                     GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5238 |  |  | 		    ORDER BY registration_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5239 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5240 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5241 |  |  | 		$sth->execute(array(':airport_icao' => $airport_icao)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5242 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5243 |  |  | 		$aircraft_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5244 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5245 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5246 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5247 |  |  | 			$temp_array['aircraft_icao'] = $row['aircraft_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5248 |  |  | 			$temp_array['aircraft_name'] = $row['aircraft_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5249 |  |  | 			$temp_array['registration'] = $row['registration']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5250 |  |  | 			$temp_array['airline_name'] = $row['airline_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5251 |  |  | 			$temp_array['image_thumbnail'] = ""; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5252 |  |  | 			if($row['registration'] != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5253 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5254 |  |  | 				$image_array = $Image->getSpotterImage($row['registration']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5255 |  |  | 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5256 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5257 |  |  | 			$temp_array['registration_count'] = $row['registration_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5258 |  |  | 			$aircraft_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5259 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5260 |  |  | 		return $aircraft_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5261 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5262 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5263 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5264 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5265 |  |  | 	* Gets all aircraft manufacturer that have flown over by airport icao | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5266 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5267 |  |  | 	* @return Array the aircraft list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5268 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5269 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5270 |  |  | 	public function countAllAircraftManufacturerByAirport($airport_icao,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5271 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5272 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5273 |  |  | 		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5274 |  |  | 		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5275 |  |  |                     FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao)   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5276 |  |  |                     GROUP BY spotter_output.aircraft_manufacturer  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5277 |  |  | 					ORDER BY aircraft_manufacturer_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5278 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5279 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5280 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5281 |  |  | 		$sth->execute(array(':airport_icao' => $airport_icao)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5282 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5283 |  |  | 		$aircraft_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5284 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5285 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5286 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5287 |  |  | 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5288 |  |  | 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5289 |  |  | 			$aircraft_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5290 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5291 |  |  | 		return $aircraft_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5292 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5293 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5294 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5295 |  |  | 	* Gets all aircraft types that have flown over by aircraft manufacturer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5296 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5297 |  |  | 	* @return Array the aircraft list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5298 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5299 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5300 |  |  | 	public function countAllAircraftTypesByManufacturer($aircraft_manufacturer,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5301 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5302 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5303 |  |  | 		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5304 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5305 |  |  | 		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5306 |  |  |                     FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer = :aircraft_manufacturer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5307 |  |  |                     GROUP BY spotter_output.aircraft_name  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5308 |  |  | 					ORDER BY aircraft_icao_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5309 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5310 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5311 |  |  | 		$sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5312 |  |  | 		$aircraft_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5313 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5314 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5315 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5316 |  |  | 			$temp_array['aircraft_icao'] = $row['aircraft_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5317 |  |  | 			$temp_array['aircraft_name'] = $row['aircraft_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5318 |  |  | 			$temp_array['aircraft_icao_count'] = $row['aircraft_icao_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5319 |  |  | 			$aircraft_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5320 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5321 |  |  | 		return $aircraft_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5322 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5323 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5324 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5325 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5326 |  |  | 	* Gets all aircraft registration that have flown over by aircaft manufacturer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5327 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5328 |  |  | 	* @return Array the aircraft list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5329 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5330 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5331 |  |  | 	public function countAllAircraftRegistrationByManufacturer($aircraft_manufacturer, $filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5332 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5333 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5334 |  |  | 		$Image = new Image($this->db); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5335 |  |  | 		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5336 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5337 |  |  | 		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name    | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5338 |  |  |                     FROM spotter_output".$filter_query." spotter_output.registration <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer    | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5339 |  |  |                     GROUP BY spotter_output.registration  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5340 |  |  | 					ORDER BY registration_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5341 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5342 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5343 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5344 |  |  | 		$sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5345 |  |  | 		$aircraft_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5346 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5347 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5348 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5349 |  |  | 			$temp_array['aircraft_icao'] = $row['aircraft_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5350 |  |  | 			$temp_array['aircraft_name'] = $row['aircraft_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5351 |  |  | 			$temp_array['registration'] = $row['registration']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5352 |  |  | 			$temp_array['airline_name'] = $row['airline_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5353 |  |  | 			$temp_array['image_thumbnail'] = ""; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5354 |  |  | 			if($row['registration'] != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5355 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5356 |  |  | 				$image_array = $Image->getSpotterImage($row['registration']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5357 |  |  | 				$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5358 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5359 |  |  | 			$temp_array['registration_count'] = $row['registration_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5360 |  |  | 			$aircraft_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5361 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5362 |  |  | 		return $aircraft_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5363 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5364 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5365 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5366 |  |  | 	* Gets all aircraft types that have flown over by date | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5367 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5368 |  |  | 	* @return Array the aircraft list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5369 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5370 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5371 |  |  | 	public function countAllAircraftTypesByDate($date,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5372 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5373 |  |  | 		global $globalTimezone, $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5374 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5375 |  |  | 		$date = filter_var($date,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5376 |  |  | 		if ($globalTimezone != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5377 |  |  | 			date_default_timezone_set($globalTimezone); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5378 |  |  | 			$datetime = new DateTime($date); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5379 |  |  | 			$offset = $datetime->format('P'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5380 |  |  | 		} else $offset = '+00:00'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5381 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5382 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5383 |  |  | 			$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5384 |  |  | 					FROM spotter_output".$filter_query." DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5385 |  |  | 					GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5386 |  |  | 					ORDER BY aircraft_icao_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5387 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5388 |  |  | 			$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5389 |  |  | 					FROM spotter_output".$filter_query." to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5390 |  |  | 					GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5391 |  |  | 					ORDER BY aircraft_icao_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5392 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5393 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5394 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5395 |  |  | 		$sth->execute(array(':date' => $date, ':offset' => $offset)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5396 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5397 |  |  | 		$aircraft_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5398 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5399 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5400 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5401 |  |  | 			$temp_array['aircraft_icao'] = $row['aircraft_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5402 |  |  | 			$temp_array['aircraft_name'] = $row['aircraft_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5403 |  |  | 			$temp_array['aircraft_icao_count'] = $row['aircraft_icao_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5404 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5405 |  |  | 			$aircraft_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5406 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5407 |  |  | 		return $aircraft_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5408 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5409 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5410 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5411 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5412 |  |  | 	* Gets all aircraft registration that have flown over by date | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5413 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5414 |  |  | 	* @return Array the aircraft list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5415 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5416 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5417 |  |  | 	public function countAllAircraftRegistrationByDate($date,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5418 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5419 |  |  | 		global $globalTimezone, $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5420 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5421 |  |  | 		$Image = new Image($this->db); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5422 |  |  | 		$date = filter_var($date,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5423 |  |  | 		if ($globalTimezone != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5424 |  |  | 			date_default_timezone_set($globalTimezone); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5425 |  |  | 			$datetime = new DateTime($date); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5426 |  |  | 			$offset = $datetime->format('P'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5427 |  |  | 		} else $offset = '+00:00'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5428 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5429 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5430 |  |  | 			$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5431 |  |  | 					FROM spotter_output".$filter_query." spotter_output.registration <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5432 |  |  | 					GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5433 |  |  | 					ORDER BY registration_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5434 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5435 |  |  | 			$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5436 |  |  | 					FROM spotter_output".$filter_query." spotter_output.registration <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5437 |  |  | 					GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5438 |  |  | 					ORDER BY registration_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5439 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5440 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5441 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5442 |  |  | 		$sth->execute(array(':date' => $date, ':offset' => $offset)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5443 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5444 |  |  | 		$aircraft_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5445 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5446 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5447 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5448 |  |  | 			$temp_array['aircraft_icao'] = $row['aircraft_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5449 |  |  | 			$temp_array['aircraft_name'] = $row['aircraft_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5450 |  |  | 			$temp_array['registration'] = $row['registration']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5451 |  |  | 			$temp_array['airline_name'] = $row['airline_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5452 |  |  | 			$temp_array['image_thumbnail'] = ""; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5453 |  |  | 			if($row['registration'] != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5454 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5455 |  |  | 				$image_array = $Image->getSpotterImage($row['registration']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5456 |  |  | 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5457 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5458 |  |  | 			$temp_array['registration_count'] = $row['registration_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5459 |  |  |   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5460 |  |  | 			$aircraft_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5461 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5462 |  |  | 		return $aircraft_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5463 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5464 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5465 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5466 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5467 |  |  | 	* Gets all aircraft manufacturer that have flown over by date | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5468 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5469 |  |  | 	* @return Array the aircraft manufacturer list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5470 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5471 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5472 |  |  | 	public function countAllAircraftManufacturerByDate($date,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5473 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5474 |  |  | 		global $globalTimezone, $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5475 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5476 |  |  | 		$date = filter_var($date,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5477 |  |  | 		if ($globalTimezone != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5478 |  |  | 			date_default_timezone_set($globalTimezone); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5479 |  |  | 			$datetime = new DateTime($date); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5480 |  |  | 			$offset = $datetime->format('P'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5481 |  |  | 		} else $offset = '+00:00'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5482 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5483 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5484 |  |  | 			$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5485 |  |  | 				FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5486 |  |  | 				GROUP BY spotter_output.aircraft_manufacturer  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5487 |  |  | 				ORDER BY aircraft_manufacturer_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5488 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5489 |  |  | 			$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5490 |  |  | 				FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5491 |  |  | 				GROUP BY spotter_output.aircraft_manufacturer  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5492 |  |  | 				ORDER BY aircraft_manufacturer_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5493 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5494 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5495 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5496 |  |  | 		$sth->execute(array(':date' => $date, ':offset' => $offset)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5497 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5498 |  |  | 		$aircraft_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5499 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5500 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5501 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5502 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5503 |  |  | 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5504 |  |  | 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5505 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5506 |  |  | 			$aircraft_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5507 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5508 |  |  | 		return $aircraft_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5509 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5510 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5511 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5512 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5513 |  |  | 	* Gets all aircraft types that have flown over by ident/callsign | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5514 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5515 |  |  | 	* @return Array the aircraft list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5516 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5517 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5518 |  |  | 	public function countAllAircraftTypesByIdent($ident,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5519 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5520 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5521 |  |  | 		$ident = filter_var($ident,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5522 |  |  | 		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5523 |  |  | 				FROM spotter_output".$filter_query." spotter_output.ident = :ident  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5524 |  |  | 				GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5525 |  |  | 				ORDER BY aircraft_icao_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5526 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5527 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5528 |  |  | 		$sth->execute(array(':ident' => $ident)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5529 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5530 |  |  | 		$aircraft_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5531 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5532 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5533 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5534 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5535 |  |  | 			$temp_array['aircraft_icao'] = $row['aircraft_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5536 |  |  | 			$temp_array['aircraft_name'] = $row['aircraft_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5537 |  |  | 			$temp_array['aircraft_icao_count'] = $row['aircraft_icao_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5538 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5539 |  |  | 			$aircraft_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5540 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5541 |  |  | 		return $aircraft_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5542 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5543 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5544 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5545 |  |  | 	* Gets all aircraft types that have flown over by pilot | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5546 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5547 |  |  | 	* @return Array the aircraft list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5548 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5549 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5550 |  |  | 	public function countAllAircraftTypesByPilot($pilot,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5551 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5552 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5553 |  |  | 		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5554 |  |  | 		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5555 |  |  | 				FROM spotter_output".$filter_query." (spotter_output.pilot_id = :pilot OR spotter_output.pilot_name = :pilot)  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5556 |  |  | 				GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5557 |  |  | 				ORDER BY aircraft_icao_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5558 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5559 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5560 |  |  | 		$sth->execute(array(':pilot' => $pilot)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5561 |  |  | 		return $sth->fetchAll(PDO::FETCH_ASSOC); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5562 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5563 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5564 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5565 |  |  | 	* Gets all aircraft types that have flown over by owner | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5566 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5567 |  |  | 	* @return Array the aircraft list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5568 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5569 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5570 |  |  | 	public function countAllAircraftTypesByOwner($owner,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5571 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5572 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5573 |  |  | 		$owner = filter_var($owner,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5574 |  |  | 		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5575 |  |  | 				FROM spotter_output".$filter_query." spotter_output.owner_name = :owner  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5576 |  |  | 				GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_manufacturer, spotter_output.aircraft_icao | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5577 |  |  | 				ORDER BY aircraft_icao_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5578 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5579 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5580 |  |  | 		$sth->execute(array(':owner' => $owner)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5581 |  |  | 		return $sth->fetchAll(PDO::FETCH_ASSOC); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5582 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5583 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5584 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5585 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5586 |  |  | 	* Gets all aircraft registration that have flown over by ident/callsign | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5587 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5588 |  |  | 	* @return Array the aircraft list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5589 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5590 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5591 |  |  | 	public function countAllAircraftRegistrationByIdent($ident,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5592 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5593 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5594 |  |  | 		$Image = new Image($this->db); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5595 |  |  | 		$ident = filter_var($ident,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5596 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5597 |  |  | 		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5598 |  |  |                     FROM spotter_output".$filter_query." spotter_output.registration <> '' AND spotter_output.ident = :ident    | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5599 |  |  |                     GROUP BY spotter_output.registration,spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5600 |  |  | 		    ORDER BY registration_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5601 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5602 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5603 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5604 |  |  | 		$sth->execute(array(':ident' => $ident)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5605 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5606 |  |  | 		$aircraft_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5607 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5608 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5609 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5610 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5611 |  |  | 			$temp_array['aircraft_icao'] = $row['aircraft_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5612 |  |  | 			$temp_array['aircraft_name'] = $row['aircraft_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5613 |  |  | 			$temp_array['registration'] = $row['registration']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5614 |  |  | 			$temp_array['airline_name'] = $row['airline_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5615 |  |  | 			$temp_array['image_thumbnail'] = ""; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5616 |  |  | 			if($row['registration'] != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5617 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5618 |  |  | 				$image_array = $Image->getSpotterImage($row['registration']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5619 |  |  | 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5620 |  |  | 				else $temp_array['image_thumbnail'] = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5621 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5622 |  |  | 			$temp_array['registration_count'] = $row['registration_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5623 |  |  | 			$aircraft_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5624 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5625 |  |  | 		return $aircraft_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5626 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5627 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5628 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5629 |  |  | 	* Gets all aircraft registration that have flown over by owner | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5630 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5631 |  |  | 	* @return Array the aircraft list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5632 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5633 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5634 |  |  | 	public function countAllAircraftRegistrationByOwner($owner,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5635 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5636 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5637 |  |  | 		$Image = new Image($this->db); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5638 |  |  | 		$owner = filter_var($owner,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5639 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5640 |  |  | 		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer, spotter_output.registration, spotter_output.airline_name   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5641 |  |  |                     FROM spotter_output".$filter_query." spotter_output.registration <> '' AND spotter_output.owner_name = :owner  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5642 |  |  |                     GROUP BY spotter_output.registration,spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer, spotter_output.airline_name | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5643 |  |  | 		    ORDER BY registration_count DESC LIMIT 100"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5644 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5645 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5646 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5647 |  |  | 		$sth->execute(array(':owner' => $owner)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5648 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5649 |  |  | 		$aircraft_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5650 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5651 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5652 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5653 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5654 |  |  | 			$temp_array['aircraft_icao'] = $row['aircraft_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5655 |  |  | 			$temp_array['aircraft_name'] = $row['aircraft_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5656 |  |  | 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5657 |  |  | 			$temp_array['registration'] = $row['registration']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5658 |  |  | 			$temp_array['airline_name'] = $row['airline_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5659 |  |  | 			$temp_array['image_thumbnail'] = ""; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5660 |  |  | 			if($row['registration'] != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5661 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5662 |  |  | 				$image_array = $Image->getSpotterImage($row['registration']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5663 |  |  | 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5664 |  |  | 				else $temp_array['image_thumbnail'] = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5665 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5666 |  |  | 			$temp_array['registration_count'] = $row['registration_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5667 |  |  | 			$aircraft_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5668 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5669 |  |  | 		return $aircraft_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5670 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5671 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5672 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5673 |  |  | 	* Gets all aircraft registration that have flown over by pilot | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5674 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5675 |  |  | 	* @return Array the aircraft list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5676 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5677 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5678 |  |  | 	public function countAllAircraftRegistrationByPilot($pilot,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5679 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5680 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5681 |  |  | 		$Image = new Image($this->db); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5682 |  |  | 		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5683 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5684 |  |  | 		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer, spotter_output.registration, spotter_output.airline_name   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5685 |  |  |                     FROM spotter_output".$filter_query." spotter_output.registration <> '' AND (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot)  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5686 |  |  |                     GROUP BY spotter_output.registration,spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer, spotter_output.airline_name | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5687 |  |  | 		    ORDER BY registration_count DESC LIMIT 100"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5688 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5689 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5690 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5691 |  |  | 		$sth->execute(array(':pilot' => $pilot)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5692 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5693 |  |  | 		$aircraft_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5694 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5695 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5696 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5697 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5698 |  |  | 			$temp_array['aircraft_icao'] = $row['aircraft_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5699 |  |  | 			$temp_array['aircraft_name'] = $row['aircraft_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5700 |  |  | 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5701 |  |  | 			$temp_array['registration'] = $row['registration']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5702 |  |  | 			$temp_array['airline_name'] = $row['airline_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5703 |  |  | 			$temp_array['image_thumbnail'] = ""; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5704 |  |  | 			if($row['registration'] != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5705 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5706 |  |  | 				$image_array = $Image->getSpotterImage($row['registration']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5707 |  |  | 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5708 |  |  | 				else $temp_array['image_thumbnail'] = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5709 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5710 |  |  | 			$temp_array['registration_count'] = $row['registration_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5711 |  |  | 			$aircraft_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5712 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5713 |  |  | 		return $aircraft_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5714 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5715 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5716 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5717 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5718 |  |  | 	* Gets all aircraft manufacturer that have flown over by ident/callsign | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5719 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5720 |  |  | 	* @return Array the aircraft manufacturer list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5721 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5722 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5723 |  |  | 	public function countAllAircraftManufacturerByIdent($ident,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5724 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5725 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5726 |  |  | 		$ident = filter_var($ident,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5727 |  |  | 		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5728 |  |  |                     FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND spotter_output.ident = :ident   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5729 |  |  |                     GROUP BY spotter_output.aircraft_manufacturer  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5730 |  |  | 					ORDER BY aircraft_manufacturer_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5731 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5732 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5733 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5734 |  |  | 		$sth->execute(array(':ident' => $ident)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5735 |  |  | 		$aircraft_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5736 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5737 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5738 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5739 |  |  | 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5740 |  |  | 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5741 |  |  | 			$aircraft_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5742 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5743 |  |  | 		return $aircraft_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5744 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5745 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5746 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5747 |  |  | 	* Gets all aircraft manufacturer that have flown over by owner | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5748 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5749 |  |  | 	* @return Array the aircraft manufacturer list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5750 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5751 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5752 |  |  | 	public function countAllAircraftManufacturerByOwner($owner,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5753 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5754 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5755 |  |  | 		$owner = filter_var($owner,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5756 |  |  | 		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5757 |  |  | 		    FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND spotter_output.owner_name = :owner  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5758 |  |  | 		    GROUP BY spotter_output.aircraft_manufacturer  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5759 |  |  | 		    ORDER BY aircraft_manufacturer_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5760 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5761 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5762 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5763 |  |  | 		$sth->execute(array(':owner' => $owner)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5764 |  |  | 		return $sth->fetchAll(PDO::FETCH_ASSOC); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5765 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5766 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5767 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5768 |  |  | 	* Gets all aircraft manufacturer that have flown over by pilot | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5769 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5770 |  |  | 	* @return Array the aircraft manufacturer list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5771 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5772 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5773 |  |  | 	public function countAllAircraftManufacturerByPilot($pilot,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5774 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5775 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5776 |  |  | 		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5777 |  |  | 		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5778 |  |  | 		    FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot)  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5779 |  |  | 		    GROUP BY spotter_output.aircraft_manufacturer  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5780 |  |  | 		    ORDER BY aircraft_manufacturer_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5781 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5782 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5783 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5784 |  |  | 		$sth->execute(array(':pilot' => $pilot)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5785 |  |  | 		return $sth->fetchAll(PDO::FETCH_ASSOC); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5786 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5787 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5788 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5789 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5790 |  |  | 	* Gets all aircraft types that have flown over by route | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5791 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5792 |  |  | 	* @return Array the aircraft list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5793 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5794 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5795 |  |  | 	public function countAllAircraftTypesByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5796 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5797 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5798 |  |  | 		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5799 |  |  | 		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5800 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5801 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5802 |  |  | 		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5803 |  |  |                     FROM spotter_output".$filter_query." (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5804 |  |  |                     GROUP BY spotter_output.aircraft_name  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5805 |  |  | 					ORDER BY aircraft_icao_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5806 |  |  |   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5807 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5808 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5809 |  |  | 		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5810 |  |  | 		$aircraft_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5811 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5812 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5813 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5814 |  |  | 			$temp_array['aircraft_icao'] = $row['aircraft_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5815 |  |  | 			$temp_array['aircraft_name'] = $row['aircraft_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5816 |  |  | 			$temp_array['aircraft_icao_count'] = $row['aircraft_icao_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5817 |  |  | 			$aircraft_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5818 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5819 |  |  | 		return $aircraft_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5820 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5821 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5822 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5823 |  |  | 	* Gets all aircraft registration that have flown over by route | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5824 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5825 |  |  | 	* @return Array the aircraft list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5826 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5827 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5828 |  |  | 	public function countAllAircraftRegistrationByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5829 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5830 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5831 |  |  | 		$Image = new Image($this->db); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5832 |  |  | 		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5833 |  |  | 		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5834 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5835 |  |  | 		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name    | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5836 |  |  |                     FROM spotter_output".$filter_query." spotter_output.registration <> '' AND (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao)    | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5837 |  |  |                     GROUP BY spotter_output.registration  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5838 |  |  | 					ORDER BY registration_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5839 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5840 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5841 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5842 |  |  | 		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5843 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5844 |  |  | 		$aircraft_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5845 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5846 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5847 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5848 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5849 |  |  | 			$temp_array['aircraft_icao'] = $row['aircraft_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5850 |  |  | 			$temp_array['aircraft_name'] = $row['aircraft_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5851 |  |  | 			$temp_array['registration'] = $row['registration']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5852 |  |  | 			$temp_array['airline_name'] = $row['airline_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5853 |  |  | 			$temp_array['image_thumbnail'] = ""; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5854 |  |  | 			if($row['registration'] != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5855 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5856 |  |  | 				$image_array = $Image->getSpotterImage($row['registration']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5857 |  |  | 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5858 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5859 |  |  | 			$temp_array['registration_count'] = $row['registration_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5860 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5861 |  |  | 			$aircraft_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5862 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5863 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5864 |  |  | 		return $aircraft_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5865 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5866 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5867 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5868 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5869 |  |  | 	* Gets all aircraft manufacturer that have flown over by route | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5870 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5871 |  |  | 	* @return Array the aircraft manufacturer list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5872 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5873 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5874 |  |  | 	public function countAllAircraftManufacturerByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5875 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5876 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5877 |  |  | 		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5878 |  |  | 		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5879 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5880 |  |  | 		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5881 |  |  |                     FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao)  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5882 |  |  |                     GROUP BY spotter_output.aircraft_manufacturer  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5883 |  |  | 					ORDER BY aircraft_manufacturer_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5884 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5885 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5886 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5887 |  |  | 		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5888 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5889 |  |  | 		$aircraft_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5890 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5891 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5892 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5893 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5894 |  |  | 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5895 |  |  | 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5896 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5897 |  |  | 			$aircraft_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5898 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5899 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5900 |  |  | 		return $aircraft_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5901 |  |  | 	}	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5902 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5903 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5904 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5905 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5906 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5907 |  |  | 	* Gets all aircraft types that have flown over by country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5908 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5909 |  |  | 	* @return Array the aircraft list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5910 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5911 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5912 |  |  | 	public function countAllAircraftTypesByCountry($country,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5913 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5914 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5915 |  |  | 		$country = filter_var($country,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5916 |  |  | 		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5917 |  |  | 			    FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5918 |  |  | 			    GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5919 |  |  | 			    ORDER BY aircraft_icao_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5920 |  |  |   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5921 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5922 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5923 |  |  | 		$sth->execute(array(':country' => $country)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5924 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5925 |  |  | 		$aircraft_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5926 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5927 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5928 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5929 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5930 |  |  | 			$temp_array['aircraft_icao'] = $row['aircraft_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5931 |  |  | 			$temp_array['aircraft_name'] = $row['aircraft_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5932 |  |  | 			$temp_array['aircraft_icao_count'] = $row['aircraft_icao_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5933 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5934 |  |  | 			$aircraft_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5935 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5936 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5937 |  |  | 		return $aircraft_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5938 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5939 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5940 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5941 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5942 |  |  | 	* Gets all aircraft registration that have flown over by country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5943 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5944 |  |  | 	* @return Array the aircraft list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5945 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5946 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5947 |  |  | 	public function countAllAircraftRegistrationByCountry($country,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5948 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5949 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5950 |  |  | 		$Image = new Image($this->db); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5951 |  |  | 		$country = filter_var($country,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5952 |  |  | 		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5953 |  |  | 			    FROM spotter_output".$filter_query." spotter_output.registration <> '' AND (((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country)     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5954 |  |  | 			    GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5955 |  |  | 			    ORDER BY registration_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5956 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5957 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5958 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5959 |  |  | 		$sth->execute(array(':country' => $country)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5960 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5961 |  |  | 		$aircraft_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5962 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5963 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5964 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5965 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5966 |  |  | 			$temp_array['aircraft_icao'] = $row['aircraft_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5967 |  |  | 			$temp_array['aircraft_name'] = $row['aircraft_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5968 |  |  | 			$temp_array['registration'] = $row['registration']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5969 |  |  | 			$temp_array['airline_name'] = $row['airline_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5970 |  |  | 			$temp_array['image_thumbnail'] = ""; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5971 |  |  | 			if($row['registration'] != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5972 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5973 |  |  | 				$image_array = $Image->getSpotterImage($row['registration']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5974 |  |  | 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5975 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5976 |  |  | 			$temp_array['registration_count'] = $row['registration_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5977 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5978 |  |  | 			$aircraft_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5979 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5980 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5981 |  |  | 		return $aircraft_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5982 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5983 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5984 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5985 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5986 |  |  | 	* Gets all aircraft manufacturer that have flown over by country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5987 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5988 |  |  | 	* @return Array the aircraft manufacturer list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5989 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5990 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5991 |  |  | 	public function countAllAircraftManufacturerByCountry($country,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5992 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5993 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5994 |  |  | 		$country = filter_var($country,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5995 |  |  | 		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5996 |  |  |                     FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND (((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country)  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5997 |  |  |                     GROUP BY spotter_output.aircraft_manufacturer  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5998 |  |  | 					ORDER BY aircraft_manufacturer_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5999 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6000 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6001 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6002 |  |  | 		$sth->execute(array(':country' => $country)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6003 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6004 |  |  | 		$aircraft_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6005 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6006 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6007 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6008 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6009 |  |  | 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6010 |  |  | 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6011 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6012 |  |  | 			$aircraft_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6013 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6014 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6015 |  |  | 		return $aircraft_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6016 |  |  | 	}	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6017 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6018 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6019 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6020 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6021 |  |  | 	* Gets all aircraft manufacturers that have flown over | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6022 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6023 |  |  | 	* @return Array the aircraft list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6024 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6025 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6026 |  |  | 	public function countAllAircraftManufacturers($filters = array(),$year = '',$month = '',$day = '') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6027 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6028 |  |  | 		global $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6029 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6030 |  |  | 		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6031 |  |  |                     FROM spotter_output ".$filter_query." spotter_output.aircraft_manufacturer <> '' AND spotter_output.aircraft_manufacturer <> 'Not Available'"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6032 |  |  |                 $query_values = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6033 |  |  | 		if ($year != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6034 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6035 |  |  | 				$query .= " AND YEAR(spotter_output.date) = :year"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6036 |  |  | 				$query_values = array_merge($query_values,array(':year' => $year)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6037 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6038 |  |  | 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6039 |  |  | 				$query_values = array_merge($query_values,array(':year' => $year)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6040 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6041 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6042 |  |  | 		if ($month != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6043 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6044 |  |  | 				$query .= " AND MONTH(spotter_output.date) = :month"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6045 |  |  | 				$query_values = array_merge($query_values,array(':month' => $month)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6046 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6047 |  |  | 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6048 |  |  | 				$query_values = array_merge($query_values,array(':month' => $month)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6049 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6050 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6051 |  |  | 		if ($day != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6052 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6053 |  |  | 				$query .= " AND DAY(spotter_output.date) = :day"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6054 |  |  | 				$query_values = array_merge($query_values,array(':day' => $day)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6055 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6056 |  |  | 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6057 |  |  | 				$query_values = array_merge($query_values,array(':day' => $day)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6058 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6059 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6060 |  |  | 		$query .= " GROUP BY spotter_output.aircraft_manufacturer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6061 |  |  | 					ORDER BY aircraft_manufacturer_count DESC | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6062 |  |  | 					LIMIT 10"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6063 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6064 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6065 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6066 |  |  | 		$sth->execute($query_values); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6067 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6068 |  |  | 		$manufacturer_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6069 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6070 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6071 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6072 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6073 |  |  | 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6074 |  |  | 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6075 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6076 |  |  | 			$manufacturer_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6077 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6078 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6079 |  |  | 		return $manufacturer_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6080 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6081 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6082 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6083 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6084 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6085 |  |  | 	* Gets all aircraft registrations that have flown over | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6086 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6087 |  |  | 	* @return Array the aircraft list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6088 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6089 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6090 |  |  | 	public function countAllAircraftRegistrations($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '', $month = '', $day = '') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6091 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6092 |  |  | 		global $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6093 |  |  | 		$Image = new Image($this->db); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6094 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6095 |  |  | 		$query  = "SELECT DISTINCT spotter_output.registration, COUNT(spotter_output.registration) AS aircraft_registration_count, spotter_output.aircraft_icao,  spotter_output.aircraft_name, spotter_output.airline_name     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6096 |  |  |                     FROM spotter_output ".$filter_query." spotter_output.registration <> '' AND spotter_output.registration <> 'NA'"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6097 |  |  |                 if ($olderthanmonths > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6098 |  |  |             		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6099 |  |  | 				$query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6100 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6101 |  |  | 				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6102 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6103 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6104 |  |  |                 if ($sincedate != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6105 |  |  |             		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6106 |  |  | 				$query .= " AND spotter_output.date > '".$sincedate."'"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6107 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6108 |  |  | 				$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6109 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6110 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6111 |  |  | 		$query_values = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6112 |  |  | 		if ($year != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6113 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6114 |  |  | 				$query .= " AND YEAR(spotter_output.date) = :year"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6115 |  |  | 				$query_values = array_merge($query_values,array(':year' => $year)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6116 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6117 |  |  | 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6118 |  |  | 				$query_values = array_merge($query_values,array(':year' => $year)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6119 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6120 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6121 |  |  | 		if ($month != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6122 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6123 |  |  | 				$query .= " AND MONTH(spotter_output.date) = :month"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6124 |  |  | 				$query_values = array_merge($query_values,array(':month' => $month)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6125 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6126 |  |  | 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6127 |  |  | 				$query_values = array_merge($query_values,array(':month' => $month)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6128 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6129 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6130 |  |  | 		if ($day != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6131 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6132 |  |  | 				$query .= " AND DAY(spotter_output.date) = :day"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6133 |  |  | 				$query_values = array_merge($query_values,array(':day' => $day)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6134 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6135 |  |  | 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6136 |  |  | 				$query_values = array_merge($query_values,array(':day' => $day)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6137 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6138 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6139 |  |  | 		$query .= " GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name ORDER BY aircraft_registration_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6140 |  |  | 		if ($limit) $query .= " LIMIT 10 OFFSET 0"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6141 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6142 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6143 |  |  | 		$sth->execute($query_values); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6144 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6145 |  |  | 		$aircraft_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6146 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6147 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6148 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6149 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6150 |  |  | 			$temp_array['registration'] = $row['registration']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6151 |  |  | 			$temp_array['aircraft_registration_count'] = $row['aircraft_registration_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6152 |  |  | 			$temp_array['aircraft_icao'] = $row['aircraft_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6153 |  |  | 			$temp_array['aircraft_name'] = $row['aircraft_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6154 |  |  | 			$temp_array['airline_name'] = $row['airline_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6155 |  |  | 			$temp_array['image_thumbnail'] = ""; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6156 |  |  | 			if($row['registration'] != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6157 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6158 |  |  | 				$image_array = $Image->getSpotterImage($row['registration']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6159 |  |  | 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6160 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6161 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6162 |  |  | 			$aircraft_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6163 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6164 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6165 |  |  | 		return $aircraft_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6166 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6167 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6168 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6169 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6170 |  |  | 	* Gets all aircraft registrations that have flown over | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6171 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6172 |  |  | 	* @return Array the aircraft list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6173 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6174 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6175 |  |  | 	public function countAllAircraftRegistrationsByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6176 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6177 |  |  | 		global $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6178 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6179 |  |  | 		$Image = new Image($this->db); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6180 |  |  | 		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.registration, COUNT(spotter_output.registration) AS aircraft_registration_count, spotter_output.aircraft_icao,  spotter_output.aircraft_name, spotter_output.airline_name     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6181 |  |  |                     FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.registration <> '' AND spotter_output.registration <> 'NA' "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6182 |  |  |                 if ($olderthanmonths > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6183 |  |  |             		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6184 |  |  | 				$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6185 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6186 |  |  | 				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6187 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6188 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6189 |  |  |                 if ($sincedate != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6190 |  |  |             		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6191 |  |  | 				$query .= "AND spotter_output.date > '".$sincedate."' "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6192 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6193 |  |  | 				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6194 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6195 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6196 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6197 |  |  | 		// if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6198 |  |  | 		//if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6199 |  |  |                 $query .= "GROUP BY spotter_output.airline_icao, spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name ORDER BY aircraft_registration_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6200 |  |  | 		if ($limit) $query .= " LIMIT 10 OFFSET 0"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6201 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6202 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6203 |  |  | 		$sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6204 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6205 |  |  | 		$aircraft_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6206 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6207 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6208 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6209 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6210 |  |  | 			$temp_array['registration'] = $row['registration']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6211 |  |  | 			$temp_array['aircraft_registration_count'] = $row['aircraft_registration_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6212 |  |  | 			$temp_array['airline_icao'] = $row['airline_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6213 |  |  | 			$temp_array['aircraft_icao'] = $row['aircraft_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6214 |  |  | 			$temp_array['aircraft_name'] = $row['aircraft_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6215 |  |  | 			$temp_array['airline_name'] = $row['airline_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6216 |  |  | 			$temp_array['image_thumbnail'] = ""; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6217 |  |  | 			if($row['registration'] != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6218 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6219 |  |  | 				$image_array = $Image->getSpotterImage($row['registration']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6220 |  |  | 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6221 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6222 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6223 |  |  | 			$aircraft_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6224 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6225 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6226 |  |  | 		return $aircraft_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6227 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6228 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6229 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6230 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6231 |  |  | 	* Gets all departure airports of the airplanes that have flown over | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6232 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6233 |  |  | 	* @return Array the airport list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6234 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6235 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6236 |  |  | 	public function countAllDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '',$month = '',$day = '') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6237 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6238 |  |  | 		global $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6239 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6240 |  |  | 		$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6241 |  |  | 				FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> ''"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6242 |  |  |                 if ($olderthanmonths > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6243 |  |  |             		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6244 |  |  | 				$query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6245 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6246 |  |  | 				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6247 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6248 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6249 |  |  |                 if ($sincedate != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6250 |  |  |             		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6251 |  |  | 				$query .= " AND spotter_output.date > '".$sincedate."'"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6252 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6253 |  |  | 				$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6254 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6255 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6256 |  |  | 		$query_values = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6257 |  |  | 		if ($year != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6258 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6259 |  |  | 				$query .= " AND YEAR(spotter_output.date) = :year"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6260 |  |  | 				$query_values = array_merge($query_values,array(':year' => $year)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6261 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6262 |  |  | 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6263 |  |  | 				$query_values = array_merge($query_values,array(':year' => $year)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6264 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6265 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6266 |  |  | 		if ($month != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6267 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6268 |  |  | 				$query .= " AND MONTH(spotter_output.date) = :month"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6269 |  |  | 				$query_values = array_merge($query_values,array(':month' => $month)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6270 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6271 |  |  | 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6272 |  |  | 				$query_values = array_merge($query_values,array(':month' => $month)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6273 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6274 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6275 |  |  | 		if ($day != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6276 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6277 |  |  | 				$query .= " AND DAY(spotter_output.date) = :day"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6278 |  |  | 				$query_values = array_merge($query_values,array(':day' => $day)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6279 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6280 |  |  | 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6281 |  |  | 				$query_values = array_merge($query_values,array(':day' => $day)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6282 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6283 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6284 |  |  |                 $query .= " GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6285 |  |  | 				ORDER BY airport_departure_icao_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6286 |  |  | 		if ($limit) $query .= " LIMIT 10 OFFSET 0"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6287 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6288 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6289 |  |  | 		$sth->execute($query_values); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6290 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6291 |  |  | 		$airport_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6292 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6293 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6294 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6295 |  |  | 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6296 |  |  | 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6297 |  |  | 			$temp_array['airport_departure_name'] = $row['departure_airport_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6298 |  |  | 			$temp_array['airport_departure_city'] = $row['departure_airport_city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6299 |  |  | 			$temp_array['airport_departure_country'] = $row['departure_airport_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6300 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6301 |  |  | 			$airport_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6302 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6303 |  |  | 		return $airport_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6304 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6305 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6306 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6307 |  |  | 	* Gets all departure airports of the airplanes that have flown over | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6308 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6309 |  |  | 	* @return Array the airport list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6310 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6311 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6312 |  |  | 	public function countAllDepartureAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6313 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6314 |  |  | 		global $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6315 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6316 |  |  | 		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6317 |  |  | 			FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> '' "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6318 |  |  |                 if ($olderthanmonths > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6319 |  |  |             		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6320 |  |  | 				$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6321 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6322 |  |  | 				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6323 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6324 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6325 |  |  |                 if ($sincedate != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6326 |  |  |             		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6327 |  |  | 				$query .= "AND spotter_output.date > '".$sincedate."' "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6328 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6329 |  |  | 				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6330 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6331 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6332 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6333 |  |  |             	//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6334 |  |  |                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6335 |  |  |                 $query .= "GROUP BY spotter_output.airline_icao, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6336 |  |  | 				ORDER BY airport_departure_icao_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6337 |  |  | 		if ($limit) $query .= " LIMIT 10 OFFSET 0"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6338 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6339 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6340 |  |  | 		$sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6341 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6342 |  |  | 		$airport_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6343 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6344 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6345 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6346 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6347 |  |  | 			$temp_array['airline_icao'] = $row['airline_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6348 |  |  | 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6349 |  |  | 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6350 |  |  | 			$temp_array['airport_departure_name'] = $row['departure_airport_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6351 |  |  | 			$temp_array['airport_departure_city'] = $row['departure_airport_city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6352 |  |  | 			$temp_array['airport_departure_country'] = $row['departure_airport_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6353 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6354 |  |  | 			$airport_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6355 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6356 |  |  | 		return $airport_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6357 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6358 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6359 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6360 |  |  | 	* Gets all detected departure airports of the airplanes that have flown over | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6361 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6362 |  |  | 	* @return Array the airport list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6363 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6364 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6365 |  |  | 	public function countAllDetectedDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '',$month = '',$day = '') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6366 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6367 |  |  | 		global $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6368 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6369 |  |  | 		$query  = "SELECT DISTINCT spotter_output.real_departure_airport_icao AS departure_airport_icao, COUNT(spotter_output.real_departure_airport_icao) AS airport_departure_icao_count, airport.name as departure_airport_name, airport.city as departure_airport_city, airport.country as departure_airport_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6370 |  |  | 				FROM airport, spotter_output".$filter_query." spotter_output.real_departure_airport_icao <> '' AND spotter_output.real_departure_airport_icao <> 'NA' AND airport.icao = spotter_output.real_departure_airport_icao"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6371 |  |  |                 if ($olderthanmonths > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6372 |  |  |             		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6373 |  |  | 				$query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6374 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6375 |  |  | 				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6376 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6377 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6378 |  |  |                 if ($sincedate != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6379 |  |  |             		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6380 |  |  | 				$query .= " AND spotter_output.date > '".$sincedate."'"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6381 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6382 |  |  | 				$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6383 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6384 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6385 |  |  | 		$query_values = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6386 |  |  | 		if ($year != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6387 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6388 |  |  | 				$query .= " AND YEAR(spotter_output.date) = :year"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6389 |  |  | 				$query_values = array_merge($query_values,array(':year' => $year)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6390 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6391 |  |  | 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6392 |  |  | 				$query_values = array_merge($query_values,array(':year' => $year)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6393 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6394 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6395 |  |  | 		if ($month != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6396 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6397 |  |  | 				$query .= " AND MONTH(spotter_output.date) = :month"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6398 |  |  | 				$query_values = array_merge($query_values,array(':month' => $month)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6399 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6400 |  |  | 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6401 |  |  | 				$query_values = array_merge($query_values,array(':month' => $month)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6402 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6403 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6404 |  |  | 		if ($day != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6405 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6406 |  |  | 				$query .= " AND DAY(spotter_output.date) = :day"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6407 |  |  | 				$query_values = array_merge($query_values,array(':day' => $day)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6408 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6409 |  |  | 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6410 |  |  | 				$query_values = array_merge($query_values,array(':day' => $day)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6411 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6412 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6413 |  |  |                 $query .= " GROUP BY spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6414 |  |  | 				ORDER BY airport_departure_icao_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6415 |  |  | 		if ($limit) $query .= " LIMIT 10 OFFSET 0"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6416 |  |  |     		//echo $query; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6417 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6418 |  |  | 		$sth->execute($query_values); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6419 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6420 |  |  | 		$airport_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6421 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6422 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6423 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6424 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6425 |  |  | 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6426 |  |  | 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6427 |  |  | 			$temp_array['airport_departure_name'] = $row['departure_airport_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6428 |  |  | 			$temp_array['airport_departure_city'] = $row['departure_airport_city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6429 |  |  | 			$temp_array['airport_departure_country'] = $row['departure_airport_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6430 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6431 |  |  | 			$airport_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6432 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6433 |  |  | 		return $airport_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6434 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6435 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6436 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6437 |  |  | 	* Gets all detected departure airports of the airplanes that have flown over | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6438 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6439 |  |  | 	* @return Array the airport list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6440 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6441 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6442 |  |  | 	public function countAllDetectedDepartureAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6443 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6444 |  |  | 		global $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6445 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6446 |  |  | 		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.real_departure_airport_icao AS departure_airport_icao, COUNT(spotter_output.real_departure_airport_icao) AS airport_departure_icao_count, airport.name as departure_airport_name, airport.city as departure_airport_city, airport.country as departure_airport_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6447 |  |  | 				FROM airport, spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.real_departure_airport_icao <> '' AND spotter_output.real_departure_airport_icao <> 'NA' AND airport.icao = spotter_output.real_departure_airport_icao "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6448 |  |  |                 if ($olderthanmonths > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6449 |  |  |             		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6450 |  |  | 				$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6451 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6452 |  |  | 				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6453 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6454 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6455 |  |  |                 if ($sincedate != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6456 |  |  |             		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6457 |  |  | 				$query .= "AND spotter_output.date > '".$sincedate."' "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6458 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6459 |  |  | 				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP) "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6460 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6461 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6462 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6463 |  |  |             	//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6464 |  |  |                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6465 |  |  |                 $query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6466 |  |  | 				ORDER BY airport_departure_icao_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6467 |  |  | 		if ($limit) $query .= " LIMIT 10 OFFSET 0"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6468 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6469 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6470 |  |  | 		$sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6471 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6472 |  |  | 		$airport_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6473 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6474 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6475 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6476 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6477 |  |  | 			$temp_array['airline_icao'] = $row['airline_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6478 |  |  | 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6479 |  |  | 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6480 |  |  | 			$temp_array['airport_departure_name'] = $row['departure_airport_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6481 |  |  | 			$temp_array['airport_departure_city'] = $row['departure_airport_city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6482 |  |  | 			$temp_array['airport_departure_country'] = $row['departure_airport_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6483 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6484 |  |  | 			$airport_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6485 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6486 |  |  | 		return $airport_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6487 |  |  | 	}	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6488 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6489 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6490 |  |  | 	* Gets all departure airports of the airplanes that have flown over based on an airline icao | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6491 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6492 |  |  | 	* @return Array the airport list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6493 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6494 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6495 |  |  | 	public function countAllDepartureAirportsByAirline($airline_icao,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6496 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6497 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6498 |  |  | 		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6499 |  |  | 		$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6500 |  |  | 			    FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.airline_icao = :airline_icao AND spotter_output.departure_airport_icao <> ''  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6501 |  |  | 			    GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6502 |  |  | 			    ORDER BY airport_departure_icao_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6503 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6504 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6505 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6506 |  |  | 		$sth->execute(array(':airline_icao' => $airline_icao)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6507 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6508 |  |  | 		$airport_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6509 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6510 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6511 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6512 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6513 |  |  | 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6514 |  |  | 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6515 |  |  | 			$temp_array['airport_departure_name'] = $row['departure_airport_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6516 |  |  | 			$temp_array['airport_departure_city'] = $row['departure_airport_city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6517 |  |  | 			$temp_array['airport_departure_country'] = $row['departure_airport_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6518 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6519 |  |  | 			$airport_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6520 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6521 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6522 |  |  | 		return $airport_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6523 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6524 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6525 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6526 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6527 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6528 |  |  | 	* Gets all departure airports by country of the airplanes that have flown over based on an airline icao | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6529 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6530 |  |  | 	* @return Array the airport list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6531 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6532 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6533 |  |  | 	public function countAllDepartureAirportCountriesByAirline($airline_icao,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6534 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6535 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6536 |  |  | 		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6537 |  |  | 		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6538 |  |  | 			FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.airline_icao = :airline_icao  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6539 |  |  |                     GROUP BY spotter_output.departure_airport_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6540 |  |  | 					ORDER BY airport_departure_country_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6541 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6542 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6543 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6544 |  |  | 		$sth->execute(array(':airline_icao' => $airline_icao)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6545 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6546 |  |  | 		$airport_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6547 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6548 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6549 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6550 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6551 |  |  | 			$temp_array['departure_airport_country'] = $row['departure_airport_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6552 |  |  | 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6553 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6554 |  |  | 			$airport_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6555 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6556 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6557 |  |  | 		return $airport_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6558 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6559 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6560 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6561 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6562 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6563 |  |  | 	* Gets all departure airports of the airplanes that have flown over based on an aircraft icao | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6564 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6565 |  |  | 	* @return Array the airport list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6566 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6567 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6568 |  |  | 	public function countAllDepartureAirportsByAircraft($aircraft_icao,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6569 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6570 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6571 |  |  | 		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6572 |  |  | 		$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6573 |  |  | 			    FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.aircraft_icao = :aircraft_icao AND spotter_output.departure_airport_icao <> ''  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6574 |  |  | 			    GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6575 |  |  | 			    ORDER BY airport_departure_icao_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6576 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6577 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6578 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6579 |  |  | 		$sth->execute(array(':aircraft_icao' => $aircraft_icao)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6580 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6581 |  |  | 		$airport_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6582 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6583 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6584 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6585 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6586 |  |  | 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6587 |  |  | 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6588 |  |  | 			$temp_array['airport_departure_name'] = $row['departure_airport_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6589 |  |  | 			$temp_array['airport_departure_city'] = $row['departure_airport_city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6590 |  |  | 			$temp_array['airport_departure_country'] = $row['departure_airport_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6591 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6592 |  |  | 			$airport_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6593 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6594 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6595 |  |  | 		return $airport_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6596 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6597 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6598 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6599 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6600 |  |  | 	* Gets all departure airports by country of the airplanes that have flown over based on an aircraft icao | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6601 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6602 |  |  | 	* @return Array the airport list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6603 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6604 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6605 |  |  | 	public function countAllDepartureAirportCountriesByAircraft($aircraft_icao,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6606 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6607 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6608 |  |  | 		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6609 |  |  | 		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6610 |  |  | 			FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.aircraft_icao = :aircraft_icao | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6611 |  |  |                     GROUP BY spotter_output.departure_airport_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6612 |  |  | 					ORDER BY airport_departure_country_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6613 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6614 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6615 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6616 |  |  | 		$sth->execute(array(':aircraft_icao' => $aircraft_icao)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6617 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6618 |  |  | 		$airport_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6619 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6620 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6621 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6622 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6623 |  |  | 			$temp_array['departure_airport_country'] = $row['departure_airport_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6624 |  |  | 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6625 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6626 |  |  | 			$airport_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6627 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6628 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6629 |  |  | 		return $airport_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6630 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6631 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6632 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6633 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6634 |  |  | 	* Gets all departure airports of the airplanes that have flown over based on an aircraft registration | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6635 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6636 |  |  | 	* @return Array the airport list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6637 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6638 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6639 |  |  | 	public function countAllDepartureAirportsByRegistration($registration,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6640 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6641 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6642 |  |  | 		$registration = filter_var($registration,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6643 |  |  | 		$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6644 |  |  | 			FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.registration = :registration AND spotter_output.departure_airport_icao <> ''  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6645 |  |  |                     GROUP BY spotter_output.departure_airport_icao | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6646 |  |  | 					ORDER BY airport_departure_icao_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6647 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6648 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6649 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6650 |  |  | 		$sth->execute(array(':registration' => $registration)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6651 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6652 |  |  | 		$airport_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6653 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6654 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6655 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6656 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6657 |  |  | 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6658 |  |  | 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6659 |  |  | 			$temp_array['airport_departure_name'] = $row['departure_airport_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6660 |  |  | 			$temp_array['airport_departure_city'] = $row['departure_airport_city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6661 |  |  | 			$temp_array['airport_departure_country'] = $row['departure_airport_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6662 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6663 |  |  | 			$airport_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6664 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6665 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6666 |  |  | 		return $airport_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6667 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6668 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6669 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6670 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6671 |  |  | 	* Gets all departure airports by country of the airplanes that have flown over based on an aircraft registration | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6672 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6673 |  |  | 	* @return Array the airport list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6674 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6675 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6676 |  |  | 	public function countAllDepartureAirportCountriesByRegistration($registration,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6677 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6678 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6679 |  |  | 		$registration = filter_var($registration,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6680 |  |  | 		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6681 |  |  | 			FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.registration = :registration  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6682 |  |  |                     GROUP BY spotter_output.departure_airport_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6683 |  |  | 					ORDER BY airport_departure_country_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6684 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6685 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6686 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6687 |  |  | 		$sth->execute(array(':registration' => $registration)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6688 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6689 |  |  | 		$airport_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6690 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6691 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6692 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6693 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6694 |  |  | 			$temp_array['departure_airport_country'] = $row['departure_airport_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6695 |  |  | 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6696 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6697 |  |  | 			$airport_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6698 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6699 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6700 |  |  | 		return $airport_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6701 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6702 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6703 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6704 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6705 |  |  | 	* Gets all departure airports of the airplanes that have flown over based on an arrivl airport icao | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6706 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6707 |  |  | 	* @return Array the airport list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6708 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6709 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6710 |  |  | 	public function countAllDepartureAirportsByAirport($airport_icao,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6711 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6712 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6713 |  |  | 		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6714 |  |  | 		$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6715 |  |  | 			    FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao = :airport_icao AND spotter_output.departure_airport_icao <> ''  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6716 |  |  | 			    GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6717 |  |  | 			    ORDER BY airport_departure_icao_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6718 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6719 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6720 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6721 |  |  | 		$sth->execute(array(':airport_icao' => $airport_icao)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6722 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6723 |  |  | 		$airport_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6724 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6725 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6726 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6727 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6728 |  |  | 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6729 |  |  | 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6730 |  |  | 			$temp_array['airport_departure_name'] = $row['departure_airport_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6731 |  |  | 			$temp_array['airport_departure_city'] = $row['departure_airport_city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6732 |  |  | 			$temp_array['airport_departure_country'] = $row['departure_airport_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6733 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6734 |  |  | 			$airport_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6735 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6736 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6737 |  |  | 		return $airport_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6738 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6739 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6740 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6741 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6742 |  |  | 	* Gets all departure airports by country of the airplanes that have flown over based on an airport icao | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6743 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6744 |  |  | 	* @return Array the airport list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6745 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6746 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6747 |  |  | 	public function countAllDepartureAirportCountriesByAirport($airport_icao,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6748 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6749 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6750 |  |  | 		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6751 |  |  | 		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6752 |  |  | 			FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.arrival_airport_icao = :airport_icao  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6753 |  |  |                     GROUP BY spotter_output.departure_airport_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6754 |  |  | 					ORDER BY airport_departure_country_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6755 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6756 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6757 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6758 |  |  | 		$sth->execute(array(':airport_icao' => $airport_icao)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6759 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6760 |  |  | 		$airport_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6761 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6762 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6763 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6764 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6765 |  |  | 			$temp_array['departure_airport_country'] = $row['departure_airport_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6766 |  |  | 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6767 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6768 |  |  | 			$airport_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6769 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6770 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6771 |  |  | 		return $airport_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6772 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6773 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6774 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6775 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6776 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6777 |  |  | 	* Gets all departure airports of the airplanes that have flown over based on an aircraft manufacturer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6778 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6779 |  |  | 	* @return Array the airport list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6780 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6781 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6782 |  |  | 	public function countAllDepartureAirportsByManufacturer($aircraft_manufacturer,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6783 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6784 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6785 |  |  | 		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6786 |  |  | 		$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6787 |  |  | 			FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer AND spotter_output.departure_airport_icao <> ''  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6788 |  |  |                     GROUP BY spotter_output.departure_airport_icao | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6789 |  |  | 					ORDER BY airport_departure_icao_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6790 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6791 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6792 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6793 |  |  | 		$sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6794 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6795 |  |  | 		$airport_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6796 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6797 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6798 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6799 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6800 |  |  | 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6801 |  |  | 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6802 |  |  | 			$temp_array['airport_departure_name'] = $row['departure_airport_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6803 |  |  | 			$temp_array['airport_departure_city'] = $row['departure_airport_city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6804 |  |  | 			$temp_array['airport_departure_country'] = $row['departure_airport_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6805 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6806 |  |  | 			$airport_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6807 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6808 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6809 |  |  | 		return $airport_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6810 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6811 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6812 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6813 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6814 |  |  | 	* Gets all departure airports by country of the airplanes that have flown over based on an aircraft manufacturer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6815 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6816 |  |  | 	* @return Array the airport list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6817 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6818 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6819 |  |  | 	public function countAllDepartureAirportCountriesByManufacturer($aircraft_manufacturer,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6820 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6821 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6822 |  |  | 		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6823 |  |  | 		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6824 |  |  | 			FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6825 |  |  |                     GROUP BY spotter_output.departure_airport_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6826 |  |  | 					ORDER BY airport_departure_country_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6827 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6828 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6829 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6830 |  |  | 		$sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6831 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6832 |  |  | 		$airport_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6833 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6834 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6835 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6836 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6837 |  |  | 			$temp_array['departure_airport_country'] = $row['departure_airport_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6838 |  |  | 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6839 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6840 |  |  | 			$airport_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6841 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6842 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6843 |  |  | 		return $airport_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6844 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6845 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6846 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6847 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6848 |  |  | 	* Gets all departure airports of the airplanes that have flown over based on a date | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6849 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6850 |  |  | 	* @return Array the airport list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6851 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6852 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6853 |  |  | 	public function countAllDepartureAirportsByDate($date,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6854 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6855 |  |  | 		global $globalTimezone, $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6856 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6857 |  |  | 		$date = filter_var($date,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6858 |  |  | 		if ($globalTimezone != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6859 |  |  | 			date_default_timezone_set($globalTimezone); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6860 |  |  | 			$datetime = new DateTime($date); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6861 |  |  | 			$offset = $datetime->format('P'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6862 |  |  | 		} else $offset = '+00:00'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6863 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6864 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6865 |  |  | 			$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6866 |  |  | 					FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6867 |  |  | 					GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6868 |  |  | 					ORDER BY airport_departure_icao_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6869 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6870 |  |  | 			$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6871 |  |  | 					FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6872 |  |  | 					GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6873 |  |  | 					ORDER BY airport_departure_icao_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6874 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6875 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6876 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6877 |  |  | 		$sth->execute(array(':date' => $date, ':offset' => $offset)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6878 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6879 |  |  | 		$airport_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6880 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6881 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6882 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6883 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6884 |  |  | 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6885 |  |  | 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6886 |  |  | 			$temp_array['airport_departure_name'] = $row['departure_airport_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6887 |  |  | 			$temp_array['airport_departure_city'] = $row['departure_airport_city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6888 |  |  | 			$temp_array['airport_departure_country'] = $row['departure_airport_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6889 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6890 |  |  | 			$airport_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6891 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6892 |  |  | 		return $airport_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6893 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6894 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6895 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6896 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6897 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6898 |  |  | 	* Gets all departure airports by country of the airplanes that have flown over based on a date | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6899 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6900 |  |  | 	* @return Array the airport list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6901 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6902 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6903 |  |  | 	public function countAllDepartureAirportCountriesByDate($date,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6904 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6905 |  |  | 		global $globalTimezone, $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6906 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6907 |  |  | 		$date = filter_var($date,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6908 |  |  | 		if ($globalTimezone != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6909 |  |  | 			date_default_timezone_set($globalTimezone); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6910 |  |  | 			$datetime = new DateTime($date); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6911 |  |  | 			$offset = $datetime->format('P'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6912 |  |  | 		} else $offset = '+00:00'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6913 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6914 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6915 |  |  | 			$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6916 |  |  | 					FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6917 |  |  | 					GROUP BY spotter_output.departure_airport_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6918 |  |  | 					ORDER BY airport_departure_country_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6919 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6920 |  |  | 			$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6921 |  |  | 					FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6922 |  |  | 					GROUP BY spotter_output.departure_airport_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6923 |  |  | 					ORDER BY airport_departure_country_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6924 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6925 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6926 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6927 |  |  | 		$sth->execute(array(':date' => $date, ':offset' => $offset)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6928 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6929 |  |  | 		$airport_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6930 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6931 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6932 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6933 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6934 |  |  | 			$temp_array['departure_airport_country'] = $row['departure_airport_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6935 |  |  | 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6936 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6937 |  |  | 			$airport_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6938 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6939 |  |  | 		return $airport_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6940 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6941 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6942 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6943 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6944 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6945 |  |  | 	* Gets all departure airports of the airplanes that have flown over based on a ident/callsign | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6946 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6947 |  |  | 	* @return Array the airport list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6948 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6949 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6950 |  |  | 	public function countAllDepartureAirportsByIdent($ident,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6951 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6952 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6953 |  |  | 		$ident = filter_var($ident,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6954 |  |  | 		$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6955 |  |  | 		    FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> '' AND spotter_output.ident = :ident  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6956 |  |  |                     GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6957 |  |  | 		    ORDER BY airport_departure_icao_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6958 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6959 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6960 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6961 |  |  | 		$sth->execute(array(':ident' => $ident)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6962 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6963 |  |  | 		$airport_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6964 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6965 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6966 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6967 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6968 |  |  | 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6969 |  |  | 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6970 |  |  | 			$temp_array['airport_departure_name'] = $row['departure_airport_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6971 |  |  | 			$temp_array['airport_departure_city'] = $row['departure_airport_city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6972 |  |  | 			$temp_array['airport_departure_country'] = $row['departure_airport_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6973 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6974 |  |  | 			$airport_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6975 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6976 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6977 |  |  | 		return $airport_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6978 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6979 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6980 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6981 |  |  | 	* Gets all departure airports of the airplanes that have flown over based on a owner | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6982 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6983 |  |  | 	* @return Array the airport list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6984 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6985 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6986 |  |  | 	public function countAllDepartureAirportsByOwner($owner,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6987 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6988 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6989 |  |  | 		$owner = filter_var($owner,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6990 |  |  | 		$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6991 |  |  | 		    FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> '' AND spotter_output.owner_name = :owner  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6992 |  |  |                     GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6993 |  |  | 		    ORDER BY airport_departure_icao_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6994 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6995 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6996 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6997 |  |  | 		$sth->execute(array(':owner' => $owner)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6998 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6999 |  |  | 		$airport_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7000 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7001 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7002 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7003 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7004 |  |  | 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7005 |  |  | 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7006 |  |  | 			$temp_array['airport_departure_name'] = $row['departure_airport_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7007 |  |  | 			$temp_array['airport_departure_city'] = $row['departure_airport_city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7008 |  |  | 			$temp_array['airport_departure_country'] = $row['departure_airport_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7009 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7010 |  |  | 			$airport_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7011 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7012 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7013 |  |  | 		return $airport_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7014 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7015 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7016 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7017 |  |  | 	* Gets all departure airports of the airplanes that have flown over based on a pilot | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7018 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7019 |  |  | 	* @return Array the airport list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7020 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7021 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7022 |  |  | 	public function countAllDepartureAirportsByPilot($pilot,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7023 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7024 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7025 |  |  | 		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7026 |  |  | 		$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7027 |  |  | 		    FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> '' AND (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot)  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7028 |  |  |                     GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7029 |  |  | 		    ORDER BY airport_departure_icao_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7030 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7031 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7032 |  |  | 		$sth->execute(array(':pilot' => $pilot)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7033 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7034 |  |  | 		$airport_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7035 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7036 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7037 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7038 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7039 |  |  | 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7040 |  |  | 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7041 |  |  | 			$temp_array['airport_departure_name'] = $row['departure_airport_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7042 |  |  | 			$temp_array['airport_departure_city'] = $row['departure_airport_city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7043 |  |  | 			$temp_array['airport_departure_country'] = $row['departure_airport_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7044 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7045 |  |  | 			$airport_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7046 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7047 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7048 |  |  | 		return $airport_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7049 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7050 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7051 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7052 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7053 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7054 |  |  | 	* Gets all departure airports by country of the airplanes that have flown over based on a callsign/ident | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7055 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7056 |  |  | 	* @return Array the airport list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7057 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7058 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7059 |  |  | 	public function countAllDepartureAirportCountriesByIdent($ident,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7060 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7061 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7062 |  |  | 		$ident = filter_var($ident,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7063 |  |  | 		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7064 |  |  | 			FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.ident = :ident  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7065 |  |  |                     GROUP BY spotter_output.departure_airport_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7066 |  |  | 					ORDER BY airport_departure_country_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7067 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7068 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7069 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7070 |  |  | 		$sth->execute(array(':ident' => $ident)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7071 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7072 |  |  | 		$airport_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7073 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7074 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7075 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7076 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7077 |  |  | 			$temp_array['departure_airport_country'] = $row['departure_airport_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7078 |  |  | 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7079 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7080 |  |  | 			$airport_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7081 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7082 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7083 |  |  | 		return $airport_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7084 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7085 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7086 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7087 |  |  | 	* Gets all departure airports by country of the airplanes that have flown over based on owner | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7088 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7089 |  |  | 	* @return Array the airport list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7090 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7091 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7092 |  |  | 	public function countAllDepartureAirportCountriesByOwner($owner,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7093 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7094 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7095 |  |  | 		$owner = filter_var($owner,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7096 |  |  | 		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7097 |  |  | 			FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.owner_name = :owner  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7098 |  |  | 			GROUP BY spotter_output.departure_airport_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7099 |  |  | 			ORDER BY airport_departure_country_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7100 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7101 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7102 |  |  | 		$sth->execute(array(':owner' => $owner)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7103 |  |  | 		return $sth->fetchAll(PDO::FETCH_ASSOC); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7104 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7105 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7106 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7107 |  |  | 	* Gets all departure airports by country of the airplanes that have flown over based on pilot | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7108 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7109 |  |  | 	* @return Array the airport list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7110 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7111 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7112 |  |  | 	public function countAllDepartureAirportCountriesByPilot($pilot,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7113 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7114 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7115 |  |  | 		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7116 |  |  | 		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7117 |  |  | 			FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot)  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7118 |  |  | 			GROUP BY spotter_output.departure_airport_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7119 |  |  | 			ORDER BY airport_departure_country_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7120 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7121 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7122 |  |  | 		$sth->execute(array(':pilot' => $pilot)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7123 |  |  | 		return $sth->fetchAll(PDO::FETCH_ASSOC); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7124 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7125 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7126 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7127 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7128 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7129 |  |  | 	* Gets all departure airports of the airplanes that have flown over based on a country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7130 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7131 |  |  | 	* @return Array the airport list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7132 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7133 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7134 |  |  | 	public function countAllDepartureAirportsByCountry($country,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7135 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7136 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7137 |  |  | 		$country = filter_var($country,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7138 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7139 |  |  | 		$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7140 |  |  | 			    FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7141 |  |  | 			    GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7142 |  |  | 			    ORDER BY airport_departure_icao_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7143 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7144 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7145 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7146 |  |  | 		$sth->execute(array(':country' => $country)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7147 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7148 |  |  | 		$airport_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7149 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7150 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7151 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7152 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7153 |  |  | 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7154 |  |  | 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7155 |  |  | 			$temp_array['airport_departure_name'] = $row['departure_airport_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7156 |  |  | 			$temp_array['airport_departure_city'] = $row['departure_airport_city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7157 |  |  | 			$temp_array['airport_departure_country'] = $row['departure_airport_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7158 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7159 |  |  | 			$airport_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7160 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7161 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7162 |  |  | 		return $airport_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7163 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7164 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7165 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7166 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7167 |  |  | 	* Gets all departure airports by country of the airplanes that have flown over based on an aircraft icao | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7168 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7169 |  |  | 	* @return Array the airport list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7170 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7171 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7172 |  |  | 	public function countAllDepartureAirportCountriesByCountry($country,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7173 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7174 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7175 |  |  | 		$country = filter_var($country,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7176 |  |  | 		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7177 |  |  | 			FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7178 |  |  |                     GROUP BY spotter_output.departure_airport_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7179 |  |  | 					ORDER BY airport_departure_country_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7180 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7181 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7182 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7183 |  |  | 		$sth->execute(array(':country' => $country)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7184 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7185 |  |  | 		$airport_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7186 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7187 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7188 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7189 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7190 |  |  | 			$temp_array['departure_airport_country'] = $row['departure_airport_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7191 |  |  | 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7192 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7193 |  |  | 			$airport_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7194 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7195 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7196 |  |  | 		return $airport_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7197 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7198 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7199 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7200 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7201 |  |  | 	* Gets all arrival airports of the airplanes that have flown over | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7202 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7203 |  |  | 	* @param Boolean $limit Limit result to 10 or not | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7204 |  |  | 	* @param Integer $olderthanmonths Only show result older than x months | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7205 |  |  | 	* @param String $sincedate Only show result since x date | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7206 |  |  | 	* @param Boolean $icaoaskey Show result by ICAO | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7207 |  |  | 	* @param Array $filters Filter used here | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7208 |  |  | 	* @return Array the airport list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7209 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7210 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7211 |  |  | 	public function countAllArrivalAirports($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false,$filters = array(),$year = '',$month = '',$day = '') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7212 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7213 |  |  | 		global $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7214 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7215 |  |  | 		$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7216 |  |  | 				FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> ''"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7217 |  |  |                 if ($olderthanmonths > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7218 |  |  |             		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7219 |  |  | 				$query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7220 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7221 |  |  | 				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7222 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7223 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7224 |  |  |                 if ($sincedate != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7225 |  |  |             		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7226 |  |  | 				$query .= " AND spotter_output.date > '".$sincedate."'"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7227 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7228 |  |  | 				$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7229 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7230 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7231 |  |  | 		$query_values = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7232 |  |  | 		if ($year != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7233 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7234 |  |  | 				$query .= " AND YEAR(spotter_output.date) = :year"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7235 |  |  | 				$query_values = array_merge($query_values,array(':year' => $year)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7236 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7237 |  |  | 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7238 |  |  | 				$query_values = array_merge($query_values,array(':year' => $year)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7239 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7240 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7241 |  |  | 		if ($month != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7242 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7243 |  |  | 				$query .= " AND MONTH(spotter_output.date) = :month"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7244 |  |  | 				$query_values = array_merge($query_values,array(':month' => $month)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7245 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7246 |  |  | 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7247 |  |  | 				$query_values = array_merge($query_values,array(':month' => $month)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7248 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7249 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7250 |  |  | 		if ($day != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7251 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7252 |  |  | 				$query .= " AND DAY(spotter_output.date) = :day"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7253 |  |  | 				$query_values = array_merge($query_values,array(':day' => $day)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7254 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7255 |  |  | 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7256 |  |  | 				$query_values = array_merge($query_values,array(':day' => $day)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7257 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7258 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7259 |  |  |                 $query .= " GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7260 |  |  | 					ORDER BY airport_arrival_icao_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7261 |  |  | 		if ($limit) $query .= " LIMIT 10"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7262 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7263 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7264 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7265 |  |  | 		$sth->execute($query_values); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7266 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7267 |  |  | 		$airport_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7268 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7269 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7270 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7271 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7272 |  |  | 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7273 |  |  | 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7274 |  |  | 			$temp_array['airport_arrival_name'] = $row['arrival_airport_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7275 |  |  | 			$temp_array['airport_arrival_city'] = $row['arrival_airport_city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7276 |  |  | 			$temp_array['airport_arrival_country'] = $row['arrival_airport_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7277 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7278 |  |  | 			if ($icaoaskey) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7279 |  |  | 				$icao = $row['arrival_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7280 |  |  | 				$airport_array[$icao] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7281 |  |  | 			} else $airport_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7282 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7283 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7284 |  |  | 		return $airport_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7285 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7286 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7287 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7288 |  |  | 	* Gets all arrival airports of the airplanes that have flown over | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7289 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7290 |  |  | 	* @return Array the airport list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7291 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7292 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7293 |  |  | 	public function countAllArrivalAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7294 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7295 |  |  | 		global $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7296 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7297 |  |  | 		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7298 |  |  | 			FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7299 |  |  |                 if ($olderthanmonths > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7300 |  |  |             		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7301 |  |  | 				$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7302 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7303 |  |  | 				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7304 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7305 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7306 |  |  |                 if ($sincedate != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7307 |  |  |             		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7308 |  |  | 				$query .= "AND spotter_output.date > '".$sincedate."' "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7309 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7310 |  |  | 				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7311 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7312 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7313 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7314 |  |  |             	//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7315 |  |  |                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7316 |  |  |                 $query .= "GROUP BY spotter_output.airline_icao,spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7317 |  |  | 					ORDER BY airport_arrival_icao_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7318 |  |  | 		if ($limit) $query .= " LIMIT 10"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7319 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7320 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7321 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7322 |  |  | 		$sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7323 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7324 |  |  | 		$airport_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7325 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7326 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7327 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7328 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7329 |  |  | 			$temp_array['airline_icao'] = $row['airline_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7330 |  |  | 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7331 |  |  | 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7332 |  |  | 			$temp_array['airport_arrival_name'] = $row['arrival_airport_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7333 |  |  | 			$temp_array['airport_arrival_city'] = $row['arrival_airport_city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7334 |  |  | 			$temp_array['airport_arrival_country'] = $row['arrival_airport_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7335 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7336 |  |  | 			if ($icaoaskey) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7337 |  |  | 				$icao = $row['arrival_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7338 |  |  | 				$airport_array[$icao] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7339 |  |  | 			} else $airport_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7340 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7341 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7342 |  |  | 		return $airport_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7343 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7344 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7345 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7346 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7347 |  |  | 	* Gets all detected arrival airports of the airplanes that have flown over | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7348 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7349 |  |  | 	* @return Array the airport list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7350 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7351 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7352 |  |  | 	public function countAllDetectedArrivalAirports($limit = true, $olderthanmonths = 0, $sincedate = '',$icaoaskey = false,$filters = array(),$year = '',$month = '',$day = '') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7353 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7354 |  |  | 		global $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7355 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7356 |  |  | 		$query  = "SELECT DISTINCT spotter_output.real_arrival_airport_icao as arrival_airport_icao, COUNT(spotter_output.real_arrival_airport_icao) AS airport_arrival_icao_count, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7357 |  |  | 			FROM airport,spotter_output".$filter_query." spotter_output.real_arrival_airport_icao <> '' AND spotter_output.real_arrival_airport_icao <> 'NA' AND airport.icao = spotter_output.real_arrival_airport_icao"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7358 |  |  |                 if ($olderthanmonths > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7359 |  |  |             		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7360 |  |  | 				$query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7361 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7362 |  |  | 				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7363 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7364 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7365 |  |  |                 if ($sincedate != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7366 |  |  |             		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7367 |  |  | 				$query .= " AND spotter_output.date > '".$sincedate."'"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7368 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7369 |  |  | 				$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7370 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7371 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7372 |  |  | 		$query_values = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7373 |  |  | 		if ($year != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7374 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7375 |  |  | 				$query .= " AND YEAR(spotter_output.date) = :year"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7376 |  |  | 				$query_values = array_merge($query_values,array(':year' => $year)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7377 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7378 |  |  | 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7379 |  |  | 				$query_values = array_merge($query_values,array(':year' => $year)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7380 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7381 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7382 |  |  | 		if ($month != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7383 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7384 |  |  | 				$query .= " AND MONTH(spotter_output.date) = :month"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7385 |  |  | 				$query_values = array_merge($query_values,array(':month' => $month)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7386 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7387 |  |  | 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7388 |  |  | 				$query_values = array_merge($query_values,array(':month' => $month)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7389 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7390 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7391 |  |  | 		if ($day != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7392 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7393 |  |  | 				$query .= " AND DAY(spotter_output.date) = :day"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7394 |  |  | 				$query_values = array_merge($query_values,array(':day' => $day)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7395 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7396 |  |  | 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7397 |  |  | 				$query_values = array_merge($query_values,array(':day' => $day)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7398 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7399 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7400 |  |  |                 $query .= " GROUP BY spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7401 |  |  | 					ORDER BY airport_arrival_icao_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7402 |  |  | 		if ($limit) $query .= " LIMIT 10"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7403 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7404 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7405 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7406 |  |  | 		$sth->execute($query_values); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7407 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7408 |  |  | 		$airport_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7409 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7410 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7411 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7412 |  |  | 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7413 |  |  | 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7414 |  |  | 			$temp_array['airport_arrival_name'] = $row['arrival_airport_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7415 |  |  | 			$temp_array['airport_arrival_city'] = $row['arrival_airport_city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7416 |  |  | 			$temp_array['airport_arrival_country'] = $row['arrival_airport_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7417 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7418 |  |  | 			if ($icaoaskey) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7419 |  |  | 				$icao = $row['arrival_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7420 |  |  | 				$airport_array[$icao] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7421 |  |  | 			} else $airport_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7422 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7423 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7424 |  |  | 		return $airport_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7425 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7426 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7427 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7428 |  |  | 	* Gets all detected arrival airports of the airplanes that have flown over | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7429 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7430 |  |  | 	* @return Array the airport list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7431 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7432 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7433 |  |  | 	public function countAllDetectedArrivalAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$icaoaskey = false,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7434 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7435 |  |  | 		global $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7436 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7437 |  |  | 		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.real_arrival_airport_icao as arrival_airport_icao, COUNT(spotter_output.real_arrival_airport_icao) AS airport_arrival_icao_count, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7438 |  |  | 			FROM airport,spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.real_arrival_airport_icao <> '' AND spotter_output.real_arrival_airport_icao <> 'NA' AND airport.icao = spotter_output.real_arrival_airport_icao "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7439 |  |  |                 if ($olderthanmonths > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7440 |  |  |             		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7441 |  |  | 				$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7442 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7443 |  |  | 				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7444 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7445 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7446 |  |  |                 if ($sincedate != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7447 |  |  |             		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7448 |  |  | 				$query .= "AND spotter_output.date > '".$sincedate."' "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7449 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7450 |  |  | 				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7451 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7452 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7453 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7454 |  |  |             	//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7455 |  |  |                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7456 |  |  |                 $query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7457 |  |  | 					ORDER BY airport_arrival_icao_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7458 |  |  | 		if ($limit) $query .= " LIMIT 10"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7459 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7460 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7461 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7462 |  |  | 		$sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7463 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7464 |  |  | 		$airport_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7465 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7466 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7467 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7468 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7469 |  |  | 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7470 |  |  | 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7471 |  |  | 			$temp_array['airport_arrival_name'] = $row['arrival_airport_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7472 |  |  | 			$temp_array['airport_arrival_city'] = $row['arrival_airport_city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7473 |  |  | 			$temp_array['airport_arrival_country'] = $row['arrival_airport_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7474 |  |  | 			$temp_array['airline_icao'] = $row['airline_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7475 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7476 |  |  | 			if ($icaoaskey) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7477 |  |  | 				$icao = $row['arrival_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7478 |  |  | 				$airport_array[$icao] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7479 |  |  | 			} else $airport_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7480 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7481 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7482 |  |  | 		return $airport_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7483 |  |  | 	}	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7484 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7485 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7486 |  |  | 	* Gets all arrival airports of the airplanes that have flown over based on an airline icao | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7487 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7488 |  |  | 	* @return Array the airport list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7489 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7490 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7491 |  |  | 	public function countAllArrivalAirportsByAirline($airline_icao, $filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7492 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7493 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7494 |  |  | 		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7495 |  |  | 		$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7496 |  |  | 			    FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' AND spotter_output.airline_icao = :airline_icao  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7497 |  |  | 			    GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7498 |  |  | 			    ORDER BY airport_arrival_icao_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7499 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7500 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7501 |  |  | 		$sth->execute(array(':airline_icao' => $airline_icao)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7502 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7503 |  |  | 		$airport_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7504 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7505 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7506 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7507 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7508 |  |  | 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7509 |  |  | 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7510 |  |  | 			$temp_array['airport_arrival_name'] = $row['arrival_airport_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7511 |  |  | 			$temp_array['airport_arrival_city'] = $row['arrival_airport_city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7512 |  |  | 			$temp_array['airport_arrival_country'] = $row['arrival_airport_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7513 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7514 |  |  | 			$airport_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7515 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7516 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7517 |  |  | 		return $airport_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7518 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7519 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7520 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7521 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7522 |  |  | 	* Gets all arrival airports by country of the airplanes that have flown over based on an airline icao | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7523 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7524 |  |  | 	* @return Array the airport list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7525 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7526 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7527 |  |  | 	public function countAllArrivalAirportCountriesByAirline($airline_icao,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7528 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7529 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7530 |  |  | 		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7531 |  |  | 					 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7532 |  |  | 		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7533 |  |  | 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.airline_icao = :airline_icao  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7534 |  |  |                     GROUP BY spotter_output.arrival_airport_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7535 |  |  | 					ORDER BY airport_arrival_country_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7536 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7537 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7538 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7539 |  |  | 		$sth->execute(array(':airline_icao' => $airline_icao)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7540 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7541 |  |  | 		$airport_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7542 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7543 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7544 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7545 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7546 |  |  | 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7547 |  |  | 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7548 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7549 |  |  | 			$airport_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7550 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7551 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7552 |  |  | 		return $airport_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7553 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7554 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7555 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7556 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7557 |  |  | 	* Gets all arrival airports of the airplanes that have flown over based on an aircraft icao | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7558 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7559 |  |  | 	* @return Array the airport list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7560 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7561 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7562 |  |  | 	public function countAllArrivalAirportsByAircraft($aircraft_icao,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7563 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7564 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7565 |  |  | 		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7566 |  |  | 		$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7567 |  |  | 			    FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' AND spotter_output.aircraft_icao = :aircraft_icao  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7568 |  |  | 			    GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7569 |  |  | 			    ORDER BY airport_arrival_icao_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7570 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7571 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7572 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7573 |  |  | 		$sth->execute(array(':aircraft_icao' => $aircraft_icao)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7574 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7575 |  |  | 		$airport_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7576 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7577 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7578 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7579 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7580 |  |  | 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7581 |  |  | 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7582 |  |  | 			$temp_array['airport_arrival_name'] = $row['arrival_airport_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7583 |  |  | 			$temp_array['airport_arrival_city'] = $row['arrival_airport_city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7584 |  |  | 			$temp_array['airport_arrival_country'] = $row['arrival_airport_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7585 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7586 |  |  | 			$airport_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7587 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7588 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7589 |  |  | 		return $airport_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7590 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7591 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7592 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7593 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7594 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7595 |  |  | 	* Gets all arrival airports by country of the airplanes that have flown over based on an aircraft icao | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7596 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7597 |  |  | 	* @return Array the airport list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7598 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7599 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7600 |  |  | 	public function countAllArrivalAirportCountriesByAircraft($aircraft_icao,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7601 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7602 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7603 |  |  | 		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7604 |  |  | 		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7605 |  |  | 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.aircraft_icao = :aircraft_icao | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7606 |  |  |                     GROUP BY spotter_output.arrival_airport_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7607 |  |  | 					ORDER BY airport_arrival_country_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7608 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7609 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7610 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7611 |  |  | 		$sth->execute(array(':aircraft_icao' => $aircraft_icao)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7612 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7613 |  |  | 		$airport_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7614 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7615 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7616 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7617 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7618 |  |  | 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7619 |  |  | 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7620 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7621 |  |  | 			$airport_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7622 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7623 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7624 |  |  | 		return $airport_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7625 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7626 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7627 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7628 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7629 |  |  | 	* Gets all arrival airports of the airplanes that have flown over based on an aircraft registration | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7630 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7631 |  |  | 	* @return Array the airport list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7632 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7633 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7634 |  |  | 	public function countAllArrivalAirportsByRegistration($registration,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7635 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7636 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7637 |  |  | 		$registration = filter_var($registration,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7638 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7639 |  |  | 		$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7640 |  |  | 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' AND spotter_output.registration = :registration  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7641 |  |  |                     GROUP BY spotter_output.arrival_airport_icao | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7642 |  |  | 					ORDER BY airport_arrival_icao_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7643 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7644 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7645 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7646 |  |  | 		$sth->execute(array(':registration' => $registration)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7647 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7648 |  |  | 		$airport_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7649 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7650 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7651 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7652 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7653 |  |  | 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7654 |  |  | 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7655 |  |  | 			$temp_array['airport_arrival_name'] = $row['arrival_airport_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7656 |  |  | 			$temp_array['airport_arrival_city'] = $row['arrival_airport_city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7657 |  |  | 			$temp_array['airport_arrival_country'] = $row['arrival_airport_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7658 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7659 |  |  | 			$airport_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7660 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7661 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7662 |  |  | 		return $airport_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7663 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7664 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7665 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7666 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7667 |  |  | 	* Gets all arrival airports by country of the airplanes that have flown over based on an aircraft registration | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7668 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7669 |  |  | 	* @return Array the airport list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7670 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7671 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7672 |  |  | 	public function countAllArrivalAirportCountriesByRegistration($registration,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7673 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7674 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7675 |  |  | 		$registration = filter_var($registration,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7676 |  |  | 		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7677 |  |  | 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.registration = :registration  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7678 |  |  |                     GROUP BY spotter_output.arrival_airport_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7679 |  |  | 					ORDER BY airport_arrival_country_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7680 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7681 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7682 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7683 |  |  | 		$sth->execute(array(':registration' => $registration)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7684 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7685 |  |  | 		$airport_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7686 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7687 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7688 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7689 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7690 |  |  | 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7691 |  |  | 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7692 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7693 |  |  | 			$airport_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7694 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7695 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7696 |  |  | 		return $airport_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7697 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7698 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7699 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7700 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7701 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7702 |  |  | 	* Gets all arrival airports of the airplanes that have flown over based on an departure airport | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7703 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7704 |  |  | 	* @return Array the airport list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7705 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7706 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7707 |  |  | 	public function countAllArrivalAirportsByAirport($airport_icao,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7708 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7709 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7710 |  |  | 		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7711 |  |  | 		$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7712 |  |  | 			    FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' AND spotter_output.departure_airport_icao = :airport_icao  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7713 |  |  | 			    GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7714 |  |  | 			    ORDER BY airport_arrival_icao_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7715 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7716 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7717 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7718 |  |  | 		$sth->execute(array(':airport_icao' => $airport_icao)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7719 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7720 |  |  | 		$airport_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7721 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7722 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7723 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7724 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7725 |  |  | 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7726 |  |  | 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7727 |  |  | 			$temp_array['airport_arrival_name'] = $row['arrival_airport_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7728 |  |  | 			$temp_array['airport_arrival_city'] = $row['arrival_airport_city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7729 |  |  | 			$temp_array['airport_arrival_country'] = $row['arrival_airport_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7730 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7731 |  |  | 			$airport_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7732 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7733 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7734 |  |  | 		return $airport_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7735 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7736 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7737 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7738 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7739 |  |  | 	* Gets all arrival airports by country of the airplanes that have flown over based on an airport icao | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7740 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7741 |  |  | 	* @return Array the airport list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7742 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7743 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7744 |  |  | 	public function countAllArrivalAirportCountriesByAirport($airport_icao,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7745 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7746 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7747 |  |  | 		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7748 |  |  | 		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7749 |  |  | 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.departure_airport_icao = :airport_icao  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7750 |  |  |                     GROUP BY spotter_output.arrival_airport_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7751 |  |  | 					ORDER BY airport_arrival_country_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7752 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7753 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7754 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7755 |  |  | 		$sth->execute(array(':airport_icao' => $airport_icao)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7756 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7757 |  |  | 		$airport_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7758 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7759 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7760 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7761 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7762 |  |  | 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7763 |  |  | 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7764 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7765 |  |  | 			$airport_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7766 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7767 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7768 |  |  | 		return $airport_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7769 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7770 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7771 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7772 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7773 |  |  | 	* Gets all arrival airports of the airplanes that have flown over based on a aircraft manufacturer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7774 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7775 |  |  | 	* @return Array the airport list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7776 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7777 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7778 |  |  | 	public function countAllArrivalAirportsByManufacturer($aircraft_manufacturer,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7779 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7780 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7781 |  |  | 		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7782 |  |  | 		$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7783 |  |  | 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7784 |  |  |                     GROUP BY spotter_output.arrival_airport_icao | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7785 |  |  | 					ORDER BY airport_arrival_icao_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7786 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7787 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7788 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7789 |  |  | 		$sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7790 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7791 |  |  | 		$airport_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7792 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7793 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7794 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7795 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7796 |  |  | 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7797 |  |  | 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7798 |  |  | 			$temp_array['airport_arrival_name'] = $row['arrival_airport_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7799 |  |  | 			$temp_array['airport_arrival_city'] = $row['arrival_airport_city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7800 |  |  | 			$temp_array['airport_arrival_country'] = $row['arrival_airport_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7801 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7802 |  |  | 			$airport_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7803 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7804 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7805 |  |  | 		return $airport_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7806 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7807 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7808 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7809 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7810 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7811 |  |  | 	* Gets all arrival airports by country of the airplanes that have flown over based on a aircraft manufacturer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7812 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7813 |  |  | 	* @return Array the airport list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7814 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7815 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7816 |  |  | 	public function countAllArrivalAirportCountriesByManufacturer($aircraft_manufacturer,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7817 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7818 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7819 |  |  | 		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7820 |  |  | 		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7821 |  |  | 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7822 |  |  |                     GROUP BY spotter_output.arrival_airport_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7823 |  |  | 					ORDER BY airport_arrival_country_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7824 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7825 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7826 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7827 |  |  | 		$sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7828 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7829 |  |  | 		$airport_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7830 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7831 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7832 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7833 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7834 |  |  | 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7835 |  |  | 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7836 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7837 |  |  | 			$airport_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7838 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7839 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7840 |  |  | 		return $airport_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7841 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7842 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7843 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7844 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7845 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7846 |  |  | 	* Gets all arrival airports of the airplanes that have flown over based on a date | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7847 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7848 |  |  | 	* @return Array the airport list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7849 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7850 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7851 |  |  | 	public function countAllArrivalAirportsByDate($date,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7852 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7853 |  |  | 		global $globalTimezone, $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7854 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7855 |  |  | 		$date = filter_var($date,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7856 |  |  | 		if ($globalTimezone != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7857 |  |  | 			date_default_timezone_set($globalTimezone); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7858 |  |  | 			$datetime = new DateTime($date); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7859 |  |  | 			$offset = $datetime->format('P'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7860 |  |  | 		} else $offset = '+00:00'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7861 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7862 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7863 |  |  | 			$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7864 |  |  | 					FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7865 |  |  | 					GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7866 |  |  | 					ORDER BY airport_arrival_icao_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7867 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7868 |  |  | 			$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7869 |  |  | 					FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7870 |  |  | 					GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7871 |  |  | 					ORDER BY airport_arrival_icao_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7872 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7873 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7874 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7875 |  |  | 		$sth->execute(array(':date' => $date, ':offset' => $offset)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7876 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7877 |  |  | 		$airport_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7878 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7879 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7880 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7881 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7882 |  |  | 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7883 |  |  | 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7884 |  |  | 			$temp_array['airport_arrival_name'] = $row['arrival_airport_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7885 |  |  | 			$temp_array['airport_arrival_city'] = $row['arrival_airport_city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7886 |  |  | 			$temp_array['airport_arrival_country'] = $row['arrival_airport_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7887 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7888 |  |  | 			$airport_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7889 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7890 |  |  | 		return $airport_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7891 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7892 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7893 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7894 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7895 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7896 |  |  | 	* Gets all arrival airports by country of the airplanes that have flown over based on a date | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7897 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7898 |  |  | 	* @return Array the airport list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7899 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7900 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7901 |  |  | 	public function countAllArrivalAirportCountriesByDate($date, $filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7902 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7903 |  |  | 		global $globalTimezone, $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7904 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7905 |  |  | 		$date = filter_var($date,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7906 |  |  | 		if ($globalTimezone != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7907 |  |  | 			date_default_timezone_set($globalTimezone); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7908 |  |  | 			$datetime = new DateTime($date); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7909 |  |  | 			$offset = $datetime->format('P'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7910 |  |  | 		} else $offset = '+00:00'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7911 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7912 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7913 |  |  | 			$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7914 |  |  | 					FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7915 |  |  | 					GROUP BY spotter_output.arrival_airport_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7916 |  |  | 					ORDER BY airport_arrival_country_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7917 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7918 |  |  | 			$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7919 |  |  | 					FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7920 |  |  | 					GROUP BY spotter_output.arrival_airport_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7921 |  |  | 					ORDER BY airport_arrival_country_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7922 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7923 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7924 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7925 |  |  | 		$sth->execute(array(':date' => $date, ':offset' => $offset)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7926 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7927 |  |  | 		$airport_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7928 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7929 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7930 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7931 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7932 |  |  | 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7933 |  |  | 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7934 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7935 |  |  | 			$airport_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7936 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7937 |  |  | 		return $airport_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7938 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7939 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7940 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7941 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7942 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7943 |  |  | 	* Gets all arrival airports of the airplanes that have flown over based on a ident/callsign | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7944 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7945 |  |  | 	* @return Array the airport list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7946 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7947 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7948 |  |  | 	public function countAllArrivalAirportsByIdent($ident,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7949 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7950 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7951 |  |  | 		$ident = filter_var($ident,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7952 |  |  | 		$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7953 |  |  | 		    FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' AND spotter_output.ident = :ident   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7954 |  |  |                     GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7955 |  |  | 		    ORDER BY airport_arrival_icao_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7956 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7957 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7958 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7959 |  |  | 		$sth->execute(array(':ident' => $ident)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7960 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7961 |  |  | 		$airport_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7962 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7963 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7964 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7965 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7966 |  |  | 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7967 |  |  | 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7968 |  |  | 			$temp_array['airport_arrival_name'] = $row['arrival_airport_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7969 |  |  | 			$temp_array['airport_arrival_city'] = $row['arrival_airport_city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7970 |  |  | 			$temp_array['airport_arrival_country'] = $row['arrival_airport_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7971 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7972 |  |  | 			$airport_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7973 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7974 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7975 |  |  | 		return $airport_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7976 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7977 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7978 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7979 |  |  | 	* Gets all arrival airports of the airplanes that have flown over based on a owner | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7980 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7981 |  |  | 	* @return Array the airport list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7982 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7983 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7984 |  |  | 	public function countAllArrivalAirportsByOwner($owner,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7985 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7986 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7987 |  |  | 		$owner = filter_var($owner,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7988 |  |  | 		$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7989 |  |  | 		    FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' AND spotter_output.owner_name = :owner  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7990 |  |  |                     GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7991 |  |  | 		    ORDER BY airport_arrival_icao_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7992 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7993 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7994 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7995 |  |  | 		$sth->execute(array(':owner' => $owner)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7996 |  |  | 		$airport_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7997 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7998 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7999 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8000 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8001 |  |  | 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8002 |  |  | 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8003 |  |  | 			$temp_array['airport_arrival_name'] = $row['arrival_airport_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8004 |  |  | 			$temp_array['airport_arrival_city'] = $row['arrival_airport_city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8005 |  |  | 			$temp_array['airport_arrival_country'] = $row['arrival_airport_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8006 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8007 |  |  | 			$airport_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8008 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8009 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8010 |  |  | 		return $airport_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8011 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8012 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8013 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8014 |  |  | 	* Gets all arrival airports of the airplanes that have flown over based on a pilot | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8015 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8016 |  |  | 	* @return Array the airport list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8017 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8018 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8019 |  |  | 	public function countAllArrivalAirportsByPilot($pilot,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8020 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8021 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8022 |  |  | 		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8023 |  |  | 		$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8024 |  |  | 		    FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' AND (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot)  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8025 |  |  |                     GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8026 |  |  | 		    ORDER BY airport_arrival_icao_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8027 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8028 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8029 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8030 |  |  | 		$sth->execute(array(':pilot' => $pilot)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8031 |  |  | 		$airport_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8032 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8033 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8034 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8035 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8036 |  |  | 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8037 |  |  | 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8038 |  |  | 			$temp_array['airport_arrival_name'] = $row['arrival_airport_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8039 |  |  | 			$temp_array['airport_arrival_city'] = $row['arrival_airport_city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8040 |  |  | 			$temp_array['airport_arrival_country'] = $row['arrival_airport_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8041 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8042 |  |  | 			$airport_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8043 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8044 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8045 |  |  | 		return $airport_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8046 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8047 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8048 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8049 |  |  | 	* Gets all arrival airports by country of the airplanes that have flown over based on a callsign/ident | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8050 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8051 |  |  | 	* @return Array the airport list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8052 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8053 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8054 |  |  | 	public function countAllArrivalAirportCountriesByIdent($ident, $filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8055 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8056 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8057 |  |  | 		$ident = filter_var($ident,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8058 |  |  | 		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8059 |  |  | 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.ident = :ident  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8060 |  |  |                     GROUP BY spotter_output.arrival_airport_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8061 |  |  | 					ORDER BY airport_arrival_country_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8062 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8063 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8064 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8065 |  |  | 		$sth->execute(array(':ident' => $ident)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8066 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8067 |  |  | 		$airport_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8068 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8069 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8070 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8071 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8072 |  |  | 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8073 |  |  | 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8074 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8075 |  |  | 			$airport_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8076 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8077 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8078 |  |  | 		return $airport_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8079 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8080 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8081 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8082 |  |  | 	* Gets all arrival airports by country of the airplanes that have flown over based on a owner | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8083 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8084 |  |  | 	* @return Array the airport list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8085 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8086 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8087 |  |  | 	public function countAllArrivalAirportCountriesByOwner($owner, $filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8088 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8089 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8090 |  |  | 		$owner = filter_var($owner,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8091 |  |  | 		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8092 |  |  | 		    FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.owner_name = :owner  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8093 |  |  |                     GROUP BY spotter_output.arrival_airport_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8094 |  |  | 		    ORDER BY airport_arrival_country_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8095 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8096 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8097 |  |  | 		$sth->execute(array(':owner' => $owner)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8098 |  |  | 		return $sth->fetchAll(PDO::FETCH_ASSOC); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8099 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8100 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8101 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8102 |  |  | 	* Gets all arrival airports by country of the airplanes that have flown over based on a pilot | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8103 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8104 |  |  | 	* @return Array the airport list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8105 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8106 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8107 |  |  | 	public function countAllArrivalAirportCountriesByPilot($pilot, $filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8108 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8109 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8110 |  |  | 		$owner = filter_var($owner,FILTER_SANITIZE_STRING); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8111 |  |  | 		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8112 |  |  | 		    FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot)  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8113 |  |  |                     GROUP BY spotter_output.arrival_airport_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8114 |  |  | 		    ORDER BY airport_arrival_country_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8115 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8116 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8117 |  |  | 		$sth->execute(array(':pilot' => $pilot)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8118 |  |  | 		return $sth->fetchAll(PDO::FETCH_ASSOC); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8119 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8120 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8121 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8122 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8123 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8124 |  |  | 	* Gets all arrival airports of the airplanes that have flown over based on a country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8125 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8126 |  |  | 	* @return Array the airport list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8127 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8128 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8129 |  |  | 	public function countAllArrivalAirportsByCountry($country,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8130 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8131 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8132 |  |  | 		$country = filter_var($country,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8133 |  |  | 		$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8134 |  |  | 			    FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8135 |  |  | 			    GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8136 |  |  | 			    ORDER BY airport_arrival_icao_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8137 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8138 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8139 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8140 |  |  | 		$sth->execute(array(':country' => $country)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8141 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8142 |  |  | 		$airport_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8143 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8144 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8145 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8146 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8147 |  |  | 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8148 |  |  | 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8149 |  |  | 			$temp_array['airport_arrival_name'] = $row['arrival_airport_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8150 |  |  | 			$temp_array['airport_arrival_city'] = $row['arrival_airport_city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8151 |  |  | 			$temp_array['airport_arrival_country'] = $row['arrival_airport_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8152 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8153 |  |  | 			$airport_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8154 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8155 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8156 |  |  | 		return $airport_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8157 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8158 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8159 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8160 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8161 |  |  | 	* Gets all arrival airports by country of the airplanes that have flown over based on a country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8162 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8163 |  |  | 	* @return Array the airport list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8164 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8165 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8166 |  |  | 	public function countAllArrivalAirportCountriesByCountry($country,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8167 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8168 |  |  | 		global $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8169 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8170 |  |  | 		$country = filter_var($country,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8171 |  |  | 		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8172 |  |  | 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8173 |  |  |                     GROUP BY spotter_output.arrival_airport_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8174 |  |  | 					ORDER BY airport_arrival_country_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8175 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8176 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8177 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8178 |  |  | 		$sth->execute(array(':country' => $country)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8179 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8180 |  |  | 		$airport_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8181 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8182 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8183 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8184 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8185 |  |  | 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8186 |  |  | 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8187 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8188 |  |  | 			$airport_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8189 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8190 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8191 |  |  | 		return $airport_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8192 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8193 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8194 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8195 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8196 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8197 |  |  | 	* Counts all airport departure countries | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8198 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8199 |  |  | 	* @return Array the airport departure list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8200 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8201 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8202 |  |  | 	public function countAllDepartureCountries($filters = array(),$year = '',$month = '', $day = '') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8203 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8204 |  |  | 		global $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8205 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8206 |  |  | 		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8207 |  |  | 				FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> ''"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8208 |  |  | 		$query_values = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8209 |  |  | 		if ($year != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8210 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8211 |  |  | 				$query .= " AND YEAR(spotter_output.date) = :year"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8212 |  |  | 				$query_values = array_merge($query_values,array(':year' => $year)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8213 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8214 |  |  | 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8215 |  |  | 				$query_values = array_merge($query_values,array(':year' => $year)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8216 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8217 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8218 |  |  | 		if ($month != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8219 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8220 |  |  | 				$query .= " AND MONTH(spotter_output.date) = :month"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8221 |  |  | 				$query_values = array_merge($query_values,array(':month' => $month)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8222 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8223 |  |  | 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8224 |  |  | 				$query_values = array_merge($query_values,array(':month' => $month)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8225 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8226 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8227 |  |  | 		if ($day != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8228 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8229 |  |  | 				$query .= " AND DAY(spotter_output.date) = :day"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8230 |  |  | 				$query_values = array_merge($query_values,array(':day' => $day)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8231 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8232 |  |  | 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8233 |  |  | 				$query_values = array_merge($query_values,array(':day' => $day)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8234 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8235 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8236 |  |  | 		$query .= " GROUP BY spotter_output.departure_airport_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8237 |  |  | 					ORDER BY airport_departure_country_count DESC | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8238 |  |  | 					LIMIT 10 OFFSET 0"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8239 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8240 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8241 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8242 |  |  | 		$sth->execute($query_values); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8243 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8244 |  |  | 		$airport_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8245 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8246 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8247 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8248 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8249 |  |  | 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8250 |  |  | 			$temp_array['airport_departure_country'] = $row['departure_airport_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8251 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8252 |  |  | 			$airport_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8253 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8254 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8255 |  |  | 		return $airport_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8256 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8257 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8258 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8259 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8260 |  |  | 	* Counts all airport arrival countries | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8261 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8262 |  |  | 	* @return Array the airport arrival list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8263 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8264 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8265 |  |  | 	public function countAllArrivalCountries($limit = true,$filters = array(),$year = '',$month = '',$day = '') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8266 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8267 |  |  | 		global $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8268 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8269 |  |  | 		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8270 |  |  | 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> ''"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8271 |  |  | 		$query_values = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8272 |  |  | 		if ($year != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8273 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8274 |  |  | 				$query .= " AND YEAR(spotter_output.date) = :year"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8275 |  |  | 				$query_values = array_merge($query_values,array(':year' => $year)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8276 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8277 |  |  | 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8278 |  |  | 				$query_values = array_merge($query_values,array(':year' => $year)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8279 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8280 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8281 |  |  | 		if ($month != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8282 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8283 |  |  | 				$query .= " AND MONTH(spotter_output.date) = :month"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8284 |  |  | 				$query_values = array_merge($query_values,array(':month' => $month)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8285 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8286 |  |  | 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8287 |  |  | 				$query_values = array_merge($query_values,array(':month' => $month)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8288 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8289 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8290 |  |  | 		if ($day != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8291 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8292 |  |  | 				$query .= " AND DAY(spotter_output.date) = :day"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8293 |  |  | 				$query_values = array_merge($query_values,array(':day' => $day)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8294 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8295 |  |  | 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8296 |  |  | 				$query_values = array_merge($query_values,array(':day' => $day)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8297 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8298 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8299 |  |  | 		$query .= " GROUP BY spotter_output.arrival_airport_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8300 |  |  | 					ORDER BY airport_arrival_country_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8301 |  |  | 		if ($limit) $query .= " LIMIT 10 OFFSET 0"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8302 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8303 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8304 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8305 |  |  | 		$sth->execute($query_values); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8306 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8307 |  |  | 		$airport_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8308 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8309 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8310 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8311 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8312 |  |  | 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8313 |  |  | 			$temp_array['airport_arrival_country'] = $row['arrival_airport_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8314 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8315 |  |  | 			$airport_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8316 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8317 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8318 |  |  | 		return $airport_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8319 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8320 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8321 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8322 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8323 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8324 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8325 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8326 |  |  | 	* Gets all route combinations | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8327 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8328 |  |  | 	* @return Array the route list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8329 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8330 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8331 |  |  | 	public function countAllRoutes($filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8332 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8333 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8334 |  |  | 		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8335 |  |  | 		    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8336 |  |  |                     GROUP BY route,spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8337 |  |  |                     ORDER BY route_count DESC | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8338 |  |  | 		    LIMIT 10 OFFSET 0"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8339 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8340 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8341 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8342 |  |  | 		$sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8343 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8344 |  |  | 		$routes_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8345 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8346 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8347 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8348 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8349 |  |  | 			$temp_array['route_count'] = $row['route_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8350 |  |  | 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8351 |  |  | 			$temp_array['airport_departure_name'] = $row['airport_departure_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8352 |  |  | 			$temp_array['airport_departure_city'] = $row['airport_departure_city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8353 |  |  | 			$temp_array['airport_departure_country'] = $row['airport_departure_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8354 |  |  | 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8355 |  |  | 			$temp_array['airport_arrival_name'] = $row['airport_arrival_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8356 |  |  | 			$temp_array['airport_arrival_city'] = $row['airport_arrival_city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8357 |  |  | 			$temp_array['airport_arrival_country'] = $row['airport_arrival_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8358 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8359 |  |  | 			$routes_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8360 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8361 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8362 |  |  | 		return $routes_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8363 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8364 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8365 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8366 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8367 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8368 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8369 |  |  | 	* Gets all route combinations based on an aircraft | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8370 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8371 |  |  | 	* @return Array the route list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8372 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8373 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8374 |  |  | 	public function countAllRoutesByAircraft($aircraft_icao,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8375 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8376 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8377 |  |  | 		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8378 |  |  | 		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8379 |  |  | 			    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.aircraft_icao = :aircraft_icao  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8380 |  |  | 			    GROUP BY route, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8381 |  |  | 			    ORDER BY route_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8382 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8383 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8384 |  |  | 		$sth->execute(array(':aircraft_icao' => $aircraft_icao)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8385 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8386 |  |  | 		$routes_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8387 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8388 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8389 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8390 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8391 |  |  | 			$temp_array['route_count'] = $row['route_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8392 |  |  | 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8393 |  |  | 			$temp_array['airport_departure_name'] = $row['airport_departure_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8394 |  |  | 			$temp_array['airport_departure_city'] = $row['airport_departure_city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8395 |  |  | 			$temp_array['airport_departure_country'] = $row['airport_departure_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8396 |  |  | 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8397 |  |  | 			$temp_array['airport_arrival_name'] = $row['airport_arrival_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8398 |  |  | 			$temp_array['airport_arrival_city'] = $row['airport_arrival_city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8399 |  |  | 			$temp_array['airport_arrival_country'] = $row['airport_arrival_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8400 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8401 |  |  | 			$routes_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8402 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8403 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8404 |  |  | 		return $routes_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8405 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8406 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8407 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8408 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8409 |  |  | 	* Gets all route combinations based on an aircraft registration | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8410 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8411 |  |  | 	* @return Array the route list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8412 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8413 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8414 |  |  | 	public function countAllRoutesByRegistration($registration, $filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8415 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8416 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8417 |  |  | 		$registration = filter_var($registration, FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8418 |  |  | 		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8419 |  |  | 			FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.registration = :registration  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8420 |  |  |                     GROUP BY route | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8421 |  |  |                     ORDER BY route_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8422 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8423 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8424 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8425 |  |  | 		$sth->execute(array(':registration' => $registration)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8426 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8427 |  |  | 		$routes_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8428 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8429 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8430 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8431 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8432 |  |  | 			$temp_array['route_count'] = $row['route_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8433 |  |  | 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8434 |  |  | 			$temp_array['airport_departure_name'] = $row['airport_departure_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8435 |  |  | 			$temp_array['airport_departure_city'] = $row['airport_departure_city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8436 |  |  | 			$temp_array['airport_departure_country'] = $row['airport_departure_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8437 |  |  | 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8438 |  |  | 			$temp_array['airport_arrival_name'] = $row['airport_arrival_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8439 |  |  | 			$temp_array['airport_arrival_city'] = $row['airport_arrival_city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8440 |  |  | 			$temp_array['airport_arrival_country'] = $row['airport_arrival_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8441 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8442 |  |  | 			$routes_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8443 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8444 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8445 |  |  | 		return $routes_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8446 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8447 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8448 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8449 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8450 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8451 |  |  | 	* Gets all route combinations based on an airline | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8452 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8453 |  |  | 	* @return Array the route list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8454 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8455 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8456 |  |  | 	public function countAllRoutesByAirline($airline_icao, $filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8457 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8458 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8459 |  |  | 		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8460 |  |  | 		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8461 |  |  | 			    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.airline_icao = :airline_icao  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8462 |  |  | 			    GROUP BY route, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8463 |  |  | 			    ORDER BY route_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8464 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8465 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8466 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8467 |  |  | 		$sth->execute(array(':airline_icao' => $airline_icao)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8468 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8469 |  |  | 		$routes_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8470 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8471 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8472 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8473 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8474 |  |  | 			$temp_array['route_count'] = $row['route_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8475 |  |  | 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8476 |  |  | 			$temp_array['airport_departure_name'] = $row['airport_departure_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8477 |  |  | 			$temp_array['airport_departure_city'] = $row['airport_departure_city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8478 |  |  | 			$temp_array['airport_departure_country'] = $row['airport_departure_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8479 |  |  | 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8480 |  |  | 			$temp_array['airport_arrival_name'] = $row['airport_arrival_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8481 |  |  | 			$temp_array['airport_arrival_city'] = $row['airport_arrival_city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8482 |  |  | 			$temp_array['airport_arrival_country'] = $row['airport_arrival_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8483 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8484 |  |  | 			$routes_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8485 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8486 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8487 |  |  | 		return $routes_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8488 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8489 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8490 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8491 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8492 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8493 |  |  | 	* Gets all route combinations based on an airport | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8494 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8495 |  |  | 	* @return Array the route list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8496 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8497 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8498 |  |  | 	public function countAllRoutesByAirport($airport_icao, $filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8499 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8500 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8501 |  |  | 		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8502 |  |  | 		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8503 |  |  | 			    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8504 |  |  | 			    GROUP BY route, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8505 |  |  | 			    ORDER BY route_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8506 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8507 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8508 |  |  | 		$sth->execute(array(':airport_icao' => $airport_icao)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8509 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8510 |  |  | 		$routes_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8511 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8512 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8513 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8514 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8515 |  |  | 			$temp_array['route_count'] = $row['route_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8516 |  |  | 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8517 |  |  | 			$temp_array['airport_departure_name'] = $row['airport_departure_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8518 |  |  | 			$temp_array['airport_departure_city'] = $row['airport_departure_city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8519 |  |  | 			$temp_array['airport_departure_country'] = $row['airport_departure_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8520 |  |  | 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8521 |  |  | 			$temp_array['airport_arrival_name'] = $row['airport_arrival_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8522 |  |  | 			$temp_array['airport_arrival_city'] = $row['airport_arrival_city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8523 |  |  | 			$temp_array['airport_arrival_country'] = $row['airport_arrival_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8524 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8525 |  |  | 			$routes_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8526 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8527 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8528 |  |  | 		return $routes_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8529 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8530 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8531 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8532 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8533 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8534 |  |  | 	* Gets all route combinations based on an country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8535 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8536 |  |  | 	* @return Array the route list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8537 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8538 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8539 |  |  | 	public function countAllRoutesByCountry($country, $filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8540 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8541 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8542 |  |  | 		$country = filter_var($country,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8543 |  |  | 		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8544 |  |  | 			    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8545 |  |  | 			    GROUP BY route, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8546 |  |  | 			    ORDER BY route_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8547 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8548 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8549 |  |  | 		$sth->execute(array(':country' => $country)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8550 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8551 |  |  | 		$routes_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8552 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8553 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8554 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8555 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8556 |  |  | 			$temp_array['route_count'] = $row['route_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8557 |  |  | 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8558 |  |  | 			$temp_array['airport_departure_name'] = $row['airport_departure_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8559 |  |  | 			$temp_array['airport_departure_city'] = $row['airport_departure_city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8560 |  |  | 			$temp_array['airport_departure_country'] = $row['airport_departure_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8561 |  |  | 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8562 |  |  | 			$temp_array['airport_arrival_name'] = $row['airport_arrival_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8563 |  |  | 			$temp_array['airport_arrival_city'] = $row['airport_arrival_city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8564 |  |  | 			$temp_array['airport_arrival_country'] = $row['airport_arrival_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8565 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8566 |  |  | 			$routes_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8567 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8568 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8569 |  |  | 		return $routes_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8570 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8571 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8572 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8573 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8574 |  |  | 	* Gets all route combinations based on an date | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8575 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8576 |  |  | 	* @return Array the route list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8577 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8578 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8579 |  |  | 	public function countAllRoutesByDate($date, $filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8580 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8581 |  |  | 		global $globalTimezone, $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8582 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8583 |  |  | 		$date = filter_var($date,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8584 |  |  | 		if ($globalTimezone != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8585 |  |  | 			date_default_timezone_set($globalTimezone); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8586 |  |  | 			$datetime = new DateTime($date); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8587 |  |  | 			$offset = $datetime->format('P'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8588 |  |  | 		} else $offset = '+00:00'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8589 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8590 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8591 |  |  | 			$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8592 |  |  | 				    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8593 |  |  | 				    GROUP BY route, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8594 |  |  | 				    ORDER BY route_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8595 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8596 |  |  | 			$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8597 |  |  | 				    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8598 |  |  | 				    GROUP BY route, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8599 |  |  | 				    ORDER BY route_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8600 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8601 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8602 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8603 |  |  | 		$sth->execute(array(':date' => $date, ':offset' => $offset)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8604 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8605 |  |  | 		$routes_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8606 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8607 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8608 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8609 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8610 |  |  | 			$temp_array['route_count'] = $row['route_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8611 |  |  | 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8612 |  |  | 			$temp_array['airport_departure_name'] = $row['airport_departure_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8613 |  |  | 			$temp_array['airport_departure_city'] = $row['airport_departure_city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8614 |  |  | 			$temp_array['airport_departure_country'] = $row['airport_departure_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8615 |  |  | 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8616 |  |  | 			$temp_array['airport_arrival_name'] = $row['airport_arrival_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8617 |  |  | 			$temp_array['airport_arrival_city'] = $row['airport_arrival_city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8618 |  |  | 			$temp_array['airport_arrival_country'] = $row['airport_arrival_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8619 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8620 |  |  | 			$routes_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8621 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8622 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8623 |  |  | 		return $routes_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8624 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8625 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8626 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8627 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8628 |  |  | 	* Gets all route combinations based on an ident/callsign | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8629 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8630 |  |  | 	* @return Array the route list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8631 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8632 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8633 |  |  | 	public function countAllRoutesByIdent($ident, $filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8634 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8635 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8636 |  |  | 		$ident = filter_var($ident,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8637 |  |  | 		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8638 |  |  | 		    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.ident = :ident    | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8639 |  |  |                     GROUP BY route, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8640 |  |  |                     ORDER BY route_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8641 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8642 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8643 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8644 |  |  | 		$sth->execute(array(':ident' => $ident)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8645 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8646 |  |  | 		$routes_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8647 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8648 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8649 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8650 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8651 |  |  | 			$temp_array['route_count'] = $row['route_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8652 |  |  | 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8653 |  |  | 			$temp_array['airport_departure_name'] = $row['airport_departure_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8654 |  |  | 			$temp_array['airport_departure_city'] = $row['airport_departure_city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8655 |  |  | 			$temp_array['airport_departure_country'] = $row['airport_departure_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8656 |  |  | 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8657 |  |  | 			$temp_array['airport_arrival_name'] = $row['airport_arrival_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8658 |  |  | 			$temp_array['airport_arrival_city'] = $row['airport_arrival_city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8659 |  |  | 			$temp_array['airport_arrival_country'] = $row['airport_arrival_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8660 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8661 |  |  | 			$routes_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8662 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8663 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8664 |  |  | 		return $routes_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8665 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8666 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8667 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8668 |  |  | 	* Gets all route combinations based on an owner | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8669 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8670 |  |  | 	* @return Array the route list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8671 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8672 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8673 |  |  | 	public function countAllRoutesByOwner($owner,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8674 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8675 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8676 |  |  | 		$owner = filter_var($owner,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8677 |  |  | 		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8678 |  |  | 		    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.owner_name = :owner  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8679 |  |  |                     GROUP BY route, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8680 |  |  |                     ORDER BY route_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8681 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8682 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8683 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8684 |  |  | 		$sth->execute(array(':owner' => $owner)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8685 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8686 |  |  | 		$routes_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8687 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8688 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8689 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8690 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8691 |  |  | 			$temp_array['route_count'] = $row['route_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8692 |  |  | 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8693 |  |  | 			$temp_array['airport_departure_name'] = $row['airport_departure_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8694 |  |  | 			$temp_array['airport_departure_city'] = $row['airport_departure_city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8695 |  |  | 			$temp_array['airport_departure_country'] = $row['airport_departure_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8696 |  |  | 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8697 |  |  | 			$temp_array['airport_arrival_name'] = $row['airport_arrival_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8698 |  |  | 			$temp_array['airport_arrival_city'] = $row['airport_arrival_city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8699 |  |  | 			$temp_array['airport_arrival_country'] = $row['airport_arrival_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8700 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8701 |  |  | 			$routes_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8702 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8703 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8704 |  |  | 		return $routes_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8705 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8706 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8707 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8708 |  |  | 	* Gets all route combinations based on a pilot | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8709 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8710 |  |  | 	* @return Array the route list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8711 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8712 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8713 |  |  | 	public function countAllRoutesByPilot($pilot,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8714 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8715 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8716 |  |  | 		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8717 |  |  | 		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8718 |  |  | 		    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot)  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8719 |  |  |                     GROUP BY route, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8720 |  |  |                     ORDER BY route_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8721 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8722 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8723 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8724 |  |  | 		$sth->execute(array(':pilot' => $pilot)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8725 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8726 |  |  | 		$routes_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8727 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8728 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8729 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8730 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8731 |  |  | 			$temp_array['route_count'] = $row['route_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8732 |  |  | 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8733 |  |  | 			$temp_array['airport_departure_name'] = $row['airport_departure_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8734 |  |  | 			$temp_array['airport_departure_city'] = $row['airport_departure_city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8735 |  |  | 			$temp_array['airport_departure_country'] = $row['airport_departure_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8736 |  |  | 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8737 |  |  | 			$temp_array['airport_arrival_name'] = $row['airport_arrival_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8738 |  |  | 			$temp_array['airport_arrival_city'] = $row['airport_arrival_city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8739 |  |  | 			$temp_array['airport_arrival_country'] = $row['airport_arrival_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8740 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8741 |  |  | 			$routes_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8742 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8743 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8744 |  |  | 		return $routes_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8745 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8746 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8747 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8748 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8749 |  |  | 	* Gets all route combinations based on an manufacturer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8750 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8751 |  |  | 	* @return Array the route list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8752 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8753 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8754 |  |  | 	public function countAllRoutesByManufacturer($aircraft_manufacturer, $filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8755 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8756 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8757 |  |  | 		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8758 |  |  | 		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8759 |  |  | 		    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer    | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8760 |  |  |                     GROUP BY route | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8761 |  |  |                     ORDER BY route_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8762 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8763 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8764 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8765 |  |  | 		$sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8766 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8767 |  |  | 		$routes_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8768 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8769 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8770 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8771 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8772 |  |  | 			$temp_array['route_count'] = $row['route_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8773 |  |  | 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8774 |  |  | 			$temp_array['airport_departure_name'] = $row['airport_departure_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8775 |  |  | 			$temp_array['airport_departure_city'] = $row['airport_departure_city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8776 |  |  | 			$temp_array['airport_departure_country'] = $row['airport_departure_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8777 |  |  | 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8778 |  |  | 			$temp_array['airport_arrival_name'] = $row['airport_arrival_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8779 |  |  | 			$temp_array['airport_arrival_city'] = $row['airport_arrival_city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8780 |  |  | 			$temp_array['airport_arrival_country'] = $row['airport_arrival_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8781 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8782 |  |  | 			$routes_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8783 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8784 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8785 |  |  | 		return $routes_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8786 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8787 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8788 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8789 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8790 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8791 |  |  | 	* Gets all route combinations with waypoints | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8792 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8793 |  |  | 	* @return Array the route list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8794 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8795 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8796 |  |  | 	public function countAllRoutesWithWaypoints($filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8797 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8798 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8799 |  |  | 		$query  = "SELECT DISTINCT spotter_output.waypoints AS route, count(spotter_output.waypoints) AS route_count, spotter_output.spotter_id, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8800 |  |  | 		    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.waypoints <> ''  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8801 |  |  |                     GROUP BY route, spotter_output.spotter_id, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8802 |  |  |                     ORDER BY route_count DESC | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8803 |  |  | 		    LIMIT 10 OFFSET 0"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8804 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8805 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8806 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8807 |  |  | 		$sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8808 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8809 |  |  | 		$routes_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8810 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8811 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8812 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8813 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8814 |  |  | 			$temp_array['spotter_id'] = $row['spotter_id']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8815 |  |  | 			$temp_array['route_count'] = $row['route_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8816 |  |  | 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8817 |  |  | 			$temp_array['airport_departure_name'] = $row['airport_departure_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8818 |  |  | 			$temp_array['airport_departure_city'] = $row['airport_departure_city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8819 |  |  | 			$temp_array['airport_departure_country'] = $row['airport_departure_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8820 |  |  | 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8821 |  |  | 			$temp_array['airport_arrival_name'] = $row['airport_arrival_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8822 |  |  | 			$temp_array['airport_arrival_city'] = $row['airport_arrival_city']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8823 |  |  | 			$temp_array['airport_arrival_country'] = $row['airport_arrival_country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8824 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8825 |  |  | 			$routes_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8826 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8827 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8828 |  |  | 		return $routes_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8829 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8830 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8831 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8832 |  |  | 	* Gets all callsigns that have flown over | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8833 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8834 |  |  | 	* @return Array the callsign list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8835 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8836 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8837 |  |  | 	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8838 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8839 |  |  | 		global $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8840 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8841 |  |  | 		$query  = "SELECT DISTINCT spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name, spotter_output.airline_icao   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8842 |  |  |                     FROM spotter_output".$filter_query." spotter_output.ident <> '' "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8843 |  |  | 		 if ($olderthanmonths > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8844 |  |  | 			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8845 |  |  | 			else $query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8846 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8847 |  |  | 		if ($sincedate != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8848 |  |  | 			if ($globalDBdriver == 'mysql') $query .= " AND spotter_output.date > '".$sincedate."'"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8849 |  |  | 			else $query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8850 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8851 |  |  | 		$query_values = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8852 |  |  | 		if ($year != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8853 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8854 |  |  | 				$query .= " AND YEAR(spotter_output.date) = :year"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8855 |  |  | 				$query_values = array_merge($query_values,array(':year' => $year)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8856 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8857 |  |  | 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8858 |  |  | 				$query_values = array_merge($query_values,array(':year' => $year)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8859 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8860 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8861 |  |  | 		if ($month != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8862 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8863 |  |  | 				$query .= " AND MONTH(spotter_output.date) = :month"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8864 |  |  | 				$query_values = array_merge($query_values,array(':month' => $month)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8865 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8866 |  |  | 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8867 |  |  | 				$query_values = array_merge($query_values,array(':month' => $month)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8868 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8869 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8870 |  |  | 		if ($day != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8871 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8872 |  |  | 				$query .= " AND DAY(spotter_output.date) = :day"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8873 |  |  | 				$query_values = array_merge($query_values,array(':day' => $day)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8874 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8875 |  |  | 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8876 |  |  | 				$query_values = array_merge($query_values,array(':day' => $day)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8877 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8878 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8879 |  |  | 		$query .= " GROUP BY spotter_output.ident, spotter_output.airline_name, spotter_output.airline_icao ORDER BY callsign_icao_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8880 |  |  | 		if ($limit) $query .= " LIMIT 10 OFFSET 0"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8881 |  |  |       		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8882 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8883 |  |  | 		$sth->execute($query_values); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8884 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8885 |  |  | 		$callsign_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8886 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8887 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8888 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8889 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8890 |  |  | 			$temp_array['callsign_icao'] = $row['ident']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8891 |  |  | 			$temp_array['airline_name'] = $row['airline_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8892 |  |  | 			$temp_array['airline_icao'] = $row['airline_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8893 |  |  | 			$temp_array['callsign_icao_count'] = $row['callsign_icao_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8894 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8895 |  |  | 			$callsign_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8896 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8897 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8898 |  |  | 		return $callsign_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8899 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8900 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8901 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8902 |  |  | 	* Gets all callsigns that have flown over | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8903 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8904 |  |  | 	* @return Array the callsign list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8905 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8906 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8907 |  |  | 	public function countAllCallsignsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8908 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8909 |  |  | 		global $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8910 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8911 |  |  | 		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8912 |  |  |                     FROM spotter_output".$filter_query." spotter_output.ident <> ''  AND spotter_output.airline_icao <> '' "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8913 |  |  | 		 if ($olderthanmonths > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8914 |  |  | 			if ($globalDBdriver == 'mysql') $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8915 |  |  | 			else $query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8916 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8917 |  |  | 		if ($sincedate != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8918 |  |  | 			if ($globalDBdriver == 'mysql') $query .= "AND spotter_output.date > '".$sincedate."' "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8919 |  |  | 			else $query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP) "; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8920 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8921 |  |  | 		$query .= "GROUP BY spotter_output.airline_icao, spotter_output.ident, spotter_output.airline_name, spotter_output.airline_icao ORDER BY callsign_icao_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8922 |  |  | 		if ($limit) $query .= " LIMIT 10 OFFSET 0"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8923 |  |  |       		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8924 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8925 |  |  | 		$sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8926 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8927 |  |  | 		$callsign_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8928 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8929 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8930 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8931 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8932 |  |  | 			$temp_array['callsign_icao'] = $row['ident']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8933 |  |  | 			$temp_array['airline_name'] = $row['airline_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8934 |  |  | 			$temp_array['airline_icao'] = $row['airline_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8935 |  |  | 			$temp_array['callsign_icao_count'] = $row['callsign_icao_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8936 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8937 |  |  | 			$callsign_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8938 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8939 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8940 |  |  | 		return $callsign_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8941 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8942 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8943 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8944 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8945 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8946 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8947 |  |  | 	* Counts all dates | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8948 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8949 |  |  | 	* @return Array the date list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8950 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8951 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8952 |  |  | 	public function countAllDates($filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8953 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8954 |  |  | 		global $globalTimezone, $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8955 |  |  | 		if ($globalTimezone != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8956 |  |  | 			date_default_timezone_set($globalTimezone); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8957 |  |  | 			$datetime = new DateTime(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8958 |  |  | 			$offset = $datetime->format('P'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8959 |  |  | 		} else $offset = '+00:00'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8960 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8961 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8962 |  |  | 			$query  = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8963 |  |  | 								FROM spotter_output"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8964 |  |  | 			$query .= $this->getFilter($filters); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8965 |  |  | 			$query .= " GROUP BY date_name  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8966 |  |  | 								ORDER BY date_count DESC | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8967 |  |  | 								LIMIT 10 OFFSET 0"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8968 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8969 |  |  | 			$query  = "SELECT to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') AS date_name, count(*) as date_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8970 |  |  | 								FROM spotter_output"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8971 |  |  | 			$query .= $this->getFilter($filters); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8972 |  |  | 			$query .= " GROUP BY date_name  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8973 |  |  | 								ORDER BY date_count DESC | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8974 |  |  | 								LIMIT 10 OFFSET 0"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8975 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8976 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8977 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8978 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8979 |  |  | 		$sth->execute(array(':offset' => $offset)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8980 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8981 |  |  | 		$date_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8982 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8983 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8984 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8985 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8986 |  |  | 			$temp_array['date_name'] = $row['date_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8987 |  |  | 			$temp_array['date_count'] = $row['date_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8988 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8989 |  |  | 			$date_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8990 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8991 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8992 |  |  | 		return $date_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8993 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8994 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8995 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8996 |  |  | 	* Counts all dates | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8997 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8998 |  |  | 	* @return Array the date list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8999 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9000 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9001 |  |  | 	public function countAllDatesByAirlines($filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9002 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9003 |  |  | 		global $globalTimezone, $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9004 |  |  | 		if ($globalTimezone != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9005 |  |  | 			date_default_timezone_set($globalTimezone); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9006 |  |  | 			$datetime = new DateTime(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9007 |  |  | 			$offset = $datetime->format('P'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9008 |  |  | 		} else $offset = '+00:00'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9009 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9010 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9011 |  |  | 			$query  = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9012 |  |  | 								FROM spotter_output".$filter_query." spotter_output.airline_icao <> ''  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9013 |  |  | 								GROUP BY spotter_output.airline_icao, date_name  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9014 |  |  | 								ORDER BY date_count DESC | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9015 |  |  | 								LIMIT 10 OFFSET 0"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9016 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9017 |  |  | 			$query  = "SELECT spotter_output.airline_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') AS date_name, count(*) as date_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9018 |  |  | 								FROM spotter_output  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9019 |  |  | 								WHERE spotter_output.airline_icao <> ''  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9020 |  |  | 								GROUP BY spotter_output.airline_icao, date_name  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9021 |  |  | 								ORDER BY date_count DESC | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9022 |  |  | 								LIMIT 10 OFFSET 0"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9023 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9024 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9025 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9026 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9027 |  |  | 		$sth->execute(array(':offset' => $offset)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9028 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9029 |  |  | 		$date_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9030 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9031 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9032 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9033 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9034 |  |  | 			$temp_array['date_name'] = $row['date_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9035 |  |  | 			$temp_array['date_count'] = $row['date_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9036 |  |  | 			$temp_array['airline_icao'] = $row['airline_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9037 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9038 |  |  | 			$date_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9039 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9040 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9041 |  |  | 		return $date_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9042 |  |  | 	}	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9043 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9044 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9045 |  |  | 	* Counts all dates during the last 7 days | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9046 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9047 |  |  | 	* @return Array the date list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9048 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9049 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9050 |  |  | 	public function countAllDatesLast7Days($filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9051 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9052 |  |  | 		global $globalTimezone, $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9053 |  |  | 		if ($globalTimezone != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9054 |  |  | 			date_default_timezone_set($globalTimezone); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9055 |  |  | 			$datetime = new DateTime(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9056 |  |  | 			$offset = $datetime->format('P'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9057 |  |  | 		} else $offset = '+00:00'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9058 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9059 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9060 |  |  | 			$query  = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9061 |  |  | 								FROM spotter_output".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9062 |  |  | 			$query .= " GROUP BY date_name  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9063 |  |  | 								ORDER BY spotter_output.date ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9064 |  |  | 			$query_data = array(':offset' => $offset); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9065 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9066 |  |  | 			$query  = "SELECT to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') AS date_name, count(*) as date_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9067 |  |  | 								FROM spotter_output".$filter_query." spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE INTERVAL :offset - INTERVAL '7 DAYS'"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9068 |  |  | 			$query .= " GROUP BY date_name  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9069 |  |  | 								ORDER BY date_name ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9070 |  |  | 			$query_data = array(':offset' => $offset); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9071 |  |  |     		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9072 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9073 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9074 |  |  | 		$sth->execute($query_data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9075 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9076 |  |  | 		$date_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9077 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9078 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9079 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9080 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9081 |  |  | 			$temp_array['date_name'] = $row['date_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9082 |  |  | 			$temp_array['date_count'] = $row['date_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9083 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9084 |  |  | 			$date_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9085 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9086 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9087 |  |  | 		return $date_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9088 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9089 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9090 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9091 |  |  | 	* Counts all dates during the last month | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9092 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9093 |  |  | 	* @return Array the date list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9094 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9095 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9096 |  |  | 	public function countAllDatesLastMonth($filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9097 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9098 |  |  | 		global $globalTimezone, $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9099 |  |  | 		if ($globalTimezone != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9100 |  |  | 			date_default_timezone_set($globalTimezone); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9101 |  |  | 			$datetime = new DateTime(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9102 |  |  | 			$offset = $datetime->format('P'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9103 |  |  | 		} else $offset = '+00:00'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9104 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9105 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9106 |  |  | 			$query  = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9107 |  |  | 								FROM spotter_output".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9108 |  |  | 			$query .= " GROUP BY date_name  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9109 |  |  | 								ORDER BY spotter_output.date ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9110 |  |  | 			$query_data = array(':offset' => $offset); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9111 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9112 |  |  | 			$query  = "SELECT to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') AS date_name, count(*) as date_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9113 |  |  | 								FROM spotter_output".$filter_query." spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE INTERVAL :offset - INTERVAL '1 MONTHS'"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9114 |  |  | 			$query .= " GROUP BY date_name  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9115 |  |  | 								ORDER BY date_name ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9116 |  |  | 			$query_data = array(':offset' => $offset); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9117 |  |  |     		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9118 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9119 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9120 |  |  | 		$sth->execute($query_data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9121 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9122 |  |  | 		$date_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9123 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9124 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9125 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9126 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9127 |  |  | 			$temp_array['date_name'] = $row['date_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9128 |  |  | 			$temp_array['date_count'] = $row['date_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9129 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9130 |  |  | 			$date_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9131 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9132 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9133 |  |  | 		return $date_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9134 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9135 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9136 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9137 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9138 |  |  | 	* Counts all dates during the last month | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9139 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9140 |  |  | 	* @return Array the date list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9141 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9142 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9143 |  |  | 	public function countAllDatesLastMonthByAirlines($filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9144 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9145 |  |  | 		global $globalTimezone, $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9146 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9147 |  |  | 		if ($globalTimezone != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9148 |  |  | 			date_default_timezone_set($globalTimezone); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9149 |  |  | 			$datetime = new DateTime(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9150 |  |  | 			$offset = $datetime->format('P'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9151 |  |  | 		} else $offset = '+00:00'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9152 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9153 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9154 |  |  | 			$query  = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9155 |  |  | 								FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9156 |  |  | 								GROUP BY spotter_output.airline_icao, date_name  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9157 |  |  | 								ORDER BY spotter_output.date ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9158 |  |  | 			$query_data = array(':offset' => $offset); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9159 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9160 |  |  | 			$query  = "SELECT spotter_output.airline_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') AS date_name, count(*) as date_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9161 |  |  | 								FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE INTERVAL :offset - INTERVAL '1 MONTHS' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9162 |  |  | 								GROUP BY spotter_output.airline_icao, date_name  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9163 |  |  | 								ORDER BY date_name ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9164 |  |  | 			$query_data = array(':offset' => $offset); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9165 |  |  |     		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9166 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9167 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9168 |  |  | 		$sth->execute($query_data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9169 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9170 |  |  | 		$date_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9171 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9172 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9173 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9174 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9175 |  |  | 			$temp_array['date_name'] = $row['date_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9176 |  |  | 			$temp_array['date_count'] = $row['date_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9177 |  |  | 			$temp_array['airline_icao'] = $row['airline_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9178 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9179 |  |  | 			$date_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9180 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9181 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9182 |  |  | 		return $date_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9183 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9184 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9185 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9186 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9187 |  |  | 	* Counts all month | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9188 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9189 |  |  | 	* @return Array the month list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9190 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9191 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9192 |  |  | 	public function countAllMonths($filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9193 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9194 |  |  | 		global $globalTimezone, $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9195 |  |  | 		if ($globalTimezone != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9196 |  |  | 			date_default_timezone_set($globalTimezone); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9197 |  |  | 			$datetime = new DateTime(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9198 |  |  | 			$offset = $datetime->format('P'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9199 |  |  | 		} else $offset = '+00:00'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9200 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9201 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9202 |  |  | 			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9203 |  |  | 								FROM spotter_output"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9204 |  |  | 			$query .= $this->getFilter($filters); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9205 |  |  | 			$query .= " GROUP BY year_name, month_name ORDER BY date_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9206 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9207 |  |  | 			$query  = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(*) as date_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9208 |  |  | 								FROM spotter_output"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9209 |  |  | 			$query .= $this->getFilter($filters); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9210 |  |  | 			$query .= " GROUP BY year_name, month_name ORDER BY date_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9211 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9212 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9213 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9214 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9215 |  |  | 		$sth->execute(array(':offset' => $offset)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9216 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9217 |  |  | 		$date_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9218 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9219 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9220 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9221 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9222 |  |  | 			$temp_array['month_name'] = $row['month_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9223 |  |  | 			$temp_array['year_name'] = $row['year_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9224 |  |  | 			$temp_array['date_count'] = $row['date_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9225 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9226 |  |  | 			$date_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9227 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9228 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9229 |  |  | 		return $date_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9230 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9231 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9232 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9233 |  |  | 	* Counts all month | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9234 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9235 |  |  | 	* @return Array the month list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9236 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9237 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9238 |  |  | 	public function countAllMonthsByAirlines($filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9239 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9240 |  |  | 		global $globalTimezone, $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9241 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9242 |  |  | 		if ($globalTimezone != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9243 |  |  | 			date_default_timezone_set($globalTimezone); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9244 |  |  | 			$datetime = new DateTime(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9245 |  |  | 			$offset = $datetime->format('P'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9246 |  |  | 		} else $offset = '+00:00'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9247 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9248 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9249 |  |  | 			$query  = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9250 |  |  | 								FROM spotter_output".$filter_query." spotter_output.airline_icao <> ''  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9251 |  |  | 								GROUP BY spotter_output.airline_icao, year_name, month_name  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9252 |  |  | 								ORDER BY date_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9253 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9254 |  |  | 			$query  = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(*) as date_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9255 |  |  | 								FROM spotter_output  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9256 |  |  | 								WHERE spotter_output.airline_icao <> ''  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9257 |  |  | 								GROUP BY spotter_output.airline_icao, year_name, month_name  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9258 |  |  | 								ORDER BY date_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9259 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9260 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9261 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9262 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9263 |  |  | 		$sth->execute(array(':offset' => $offset)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9264 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9265 |  |  | 		$date_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9266 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9267 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9268 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9269 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9270 |  |  | 			$temp_array['month_name'] = $row['month_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9271 |  |  | 			$temp_array['year_name'] = $row['year_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9272 |  |  | 			$temp_array['date_count'] = $row['date_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9273 |  |  | 			$temp_array['airline_icao'] = $row['airline_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9274 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9275 |  |  | 			$date_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9276 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9277 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9278 |  |  | 		return $date_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9279 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9280 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9281 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9282 |  |  | 	* Counts all military month | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9283 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9284 |  |  | 	* @return Array the month list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9285 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9286 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9287 |  |  | 	public function countAllMilitaryMonths($filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9288 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9289 |  |  | 		global $globalTimezone, $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9290 |  |  | 		if ($globalTimezone != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9291 |  |  | 			date_default_timezone_set($globalTimezone); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9292 |  |  | 			$datetime = new DateTime(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9293 |  |  | 			$offset = $datetime->format('P'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9294 |  |  | 		} else $offset = '+00:00'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9295 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9296 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9297 |  |  | 			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9298 |  |  | 								FROM spotter_output".$filter_query." spotter_output.airline_type = 'military' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9299 |  |  | 								GROUP BY year_name, month_name  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9300 |  |  | 								ORDER BY date_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9301 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9302 |  |  | 			$query  = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(*) as date_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9303 |  |  | 								FROM spotter_output".$filter_query." spotter_output.airline_type = 'military' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9304 |  |  | 								GROUP BY year_name, month_name  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9305 |  |  | 								ORDER BY date_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9306 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9307 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9308 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9309 |  |  | 		$sth->execute(array(':offset' => $offset)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9310 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9311 |  |  | 		$date_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9312 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9313 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9314 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9315 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9316 |  |  | 			$temp_array['month_name'] = $row['month_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9317 |  |  | 			$temp_array['year_name'] = $row['year_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9318 |  |  | 			$temp_array['date_count'] = $row['date_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9319 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9320 |  |  | 			$date_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9321 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9322 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9323 |  |  | 		return $date_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9324 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9325 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9326 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9327 |  |  | 	* Counts all month owners | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9328 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9329 |  |  | 	* @return Array the month list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9330 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9331 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9332 |  |  | 	public function countAllMonthsOwners($filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9333 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9334 |  |  | 		global $globalTimezone, $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9335 |  |  | 		if ($globalTimezone != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9336 |  |  | 			date_default_timezone_set($globalTimezone); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9337 |  |  | 			$datetime = new DateTime(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9338 |  |  | 			$offset = $datetime->format('P'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9339 |  |  | 		} else $offset = '+00:00'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9340 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9341 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9342 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9343 |  |  | 			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct owner_name) as date_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9344 |  |  | 								FROM spotter_output".$filter_query." owner_name <> '' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9345 |  |  | 								GROUP BY year_name, month_name | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9346 |  |  | 								ORDER BY date_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9347 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9348 |  |  | 			$query  = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct owner_name) as date_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9349 |  |  | 								FROM spotter_output".$filter_query." owner_name <> '' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9350 |  |  | 								GROUP BY year_name, month_name | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9351 |  |  | 								ORDER BY date_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9352 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9353 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9354 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9355 |  |  | 		$sth->execute(array(':offset' => $offset)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9356 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9357 |  |  | 		$date_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9358 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9359 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9360 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9361 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9362 |  |  | 			$temp_array['month_name'] = $row['month_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9363 |  |  | 			$temp_array['year_name'] = $row['year_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9364 |  |  | 			$temp_array['date_count'] = $row['date_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9365 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9366 |  |  | 			$date_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9367 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9368 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9369 |  |  | 		return $date_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9370 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9371 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9372 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9373 |  |  | 	* Counts all month owners | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9374 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9375 |  |  | 	* @return Array the month list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9376 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9377 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9378 |  |  | 	public function countAllMonthsOwnersByAirlines($filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9379 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9380 |  |  | 		global $globalTimezone, $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9381 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9382 |  |  | 		if ($globalTimezone != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9383 |  |  | 			date_default_timezone_set($globalTimezone); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9384 |  |  | 			$datetime = new DateTime(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9385 |  |  | 			$offset = $datetime->format('P'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9386 |  |  | 		} else $offset = '+00:00'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9387 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9388 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9389 |  |  | 			$query  = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct owner_name) as date_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9390 |  |  | 								FROM spotter_output".$filter_query." owner_name <> '' AND spotter_output.airline_icao <> ''  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9391 |  |  | 								GROUP BY spotter_output.airline_icao, year_name, month_name | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9392 |  |  | 								ORDER BY date_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9393 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9394 |  |  | 			$query  = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct owner_name) as date_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9395 |  |  | 								FROM spotter_output".$filter_query." owner_name <> '' AND spotter_output.airline_icao <> ''  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9396 |  |  | 								GROUP BY spotter_output.airline_icao, year_name, month_name | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9397 |  |  | 								ORDER BY date_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9398 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9399 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9400 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9401 |  |  | 		$sth->execute(array(':offset' => $offset)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9402 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9403 |  |  | 		$date_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9404 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9405 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9406 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9407 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9408 |  |  | 			$temp_array['month_name'] = $row['month_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9409 |  |  | 			$temp_array['year_name'] = $row['year_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9410 |  |  | 			$temp_array['date_count'] = $row['date_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9411 |  |  | 			$temp_array['airline_icao'] = $row['airline_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9412 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9413 |  |  | 			$date_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9414 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9415 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9416 |  |  | 		return $date_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9417 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9418 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9419 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9420 |  |  | 	* Counts all month pilot | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9421 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9422 |  |  | 	* @return Array the month list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9423 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9424 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9425 |  |  | 	public function countAllMonthsPilots($filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9426 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9427 |  |  | 		global $globalTimezone, $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9428 |  |  | 		if ($globalTimezone != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9429 |  |  | 			date_default_timezone_set($globalTimezone); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9430 |  |  | 			$datetime = new DateTime(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9431 |  |  | 			$offset = $datetime->format('P'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9432 |  |  | 		} else $offset = '+00:00'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9433 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9434 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9435 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9436 |  |  | 			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct pilot_id) as date_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9437 |  |  | 								FROM spotter_output".$filter_query." pilot_id <> '' AND pilot_id IS NOT NULL | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9438 |  |  | 								GROUP BY year_name, month_name | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9439 |  |  | 								ORDER BY date_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9440 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9441 |  |  | 			$query  = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct pilot_id) as date_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9442 |  |  | 								FROM spotter_output".$filter_query." pilot_id <> '' AND pilot_id IS NOT NULL | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9443 |  |  | 								GROUP BY year_name, month_name | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9444 |  |  | 								ORDER BY date_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9445 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9446 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9447 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9448 |  |  | 		$sth->execute(array(':offset' => $offset)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9449 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9450 |  |  | 		$date_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9451 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9452 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9453 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9454 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9455 |  |  | 			$temp_array['month_name'] = $row['month_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9456 |  |  | 			$temp_array['year_name'] = $row['year_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9457 |  |  | 			$temp_array['date_count'] = $row['date_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9458 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9459 |  |  | 			$date_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9460 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9461 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9462 |  |  | 		return $date_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9463 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9464 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9465 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9466 |  |  | 	* Counts all month pilot | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9467 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9468 |  |  | 	* @return Array the month list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9469 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9470 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9471 |  |  | 	public function countAllMonthsPilotsByAirlines($filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9472 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9473 |  |  | 		global $globalTimezone, $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9474 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9475 |  |  | 		if ($globalTimezone != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9476 |  |  | 			date_default_timezone_set($globalTimezone); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9477 |  |  | 			$datetime = new DateTime(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9478 |  |  | 			$offset = $datetime->format('P'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9479 |  |  | 		} else $offset = '+00:00'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9480 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9481 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9482 |  |  | 			$query  = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct pilot_id) as date_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9483 |  |  | 								FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND pilot_id <> '' AND pilot_id IS NOT NULL | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9484 |  |  | 								GROUP BY spotter_output.airline_icao,year_name, month_name | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9485 |  |  | 								ORDER BY date_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9486 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9487 |  |  | 			$query  = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct pilot_id) as date_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9488 |  |  | 								FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND pilot_id <> '' AND pilot_id IS NOT NULL | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9489 |  |  | 								GROUP BY spotter_output.airline_icao, year_name, month_name | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9490 |  |  | 								ORDER BY date_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9491 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9492 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9493 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9494 |  |  | 		$sth->execute(array(':offset' => $offset)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9495 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9496 |  |  | 		$date_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9497 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9498 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9499 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9500 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9501 |  |  | 			$temp_array['month_name'] = $row['month_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9502 |  |  | 			$temp_array['year_name'] = $row['year_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9503 |  |  | 			$temp_array['date_count'] = $row['date_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9504 |  |  | 			$temp_array['airline_icao'] = $row['airline_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9505 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9506 |  |  | 			$date_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9507 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9508 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9509 |  |  | 		return $date_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9510 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9511 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9512 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9513 |  |  | 	* Counts all month airline | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9514 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9515 |  |  | 	* @return Array the month list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9516 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9517 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9518 |  |  | 	public function countAllMonthsAirlines($filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9519 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9520 |  |  | 		global $globalTimezone, $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9521 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9522 |  |  | 		if ($globalTimezone != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9523 |  |  | 			date_default_timezone_set($globalTimezone); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9524 |  |  | 			$datetime = new DateTime(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9525 |  |  | 			$offset = $datetime->format('P'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9526 |  |  | 		} else $offset = '+00:00'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9527 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9528 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9529 |  |  | 			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct airline_icao) as date_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9530 |  |  | 								FROM spotter_output".$filter_query." airline_icao <> ''  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9531 |  |  | 								GROUP BY year_name, month_name | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9532 |  |  | 								ORDER BY date_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9533 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9534 |  |  | 			$query  = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct airline_icao) as date_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9535 |  |  | 								FROM spotter_output".$filter_query." airline_icao <> ''  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9536 |  |  | 								GROUP BY year_name, month_name | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9537 |  |  | 								ORDER BY date_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9538 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9539 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9540 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9541 |  |  | 		$sth->execute(array(':offset' => $offset)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9542 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9543 |  |  | 		$date_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9544 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9545 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9546 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9547 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9548 |  |  | 			$temp_array['month_name'] = $row['month_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9549 |  |  | 			$temp_array['year_name'] = $row['year_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9550 |  |  | 			$temp_array['date_count'] = $row['date_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9551 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9552 |  |  | 			$date_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9553 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9554 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9555 |  |  | 		return $date_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9556 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9557 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9558 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9559 |  |  | 	* Counts all month aircraft | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9560 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9561 |  |  | 	* @return Array the month list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9562 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9563 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9564 |  |  | 	public function countAllMonthsAircrafts($filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9565 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9566 |  |  | 		global $globalTimezone, $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9567 |  |  | 		if ($globalTimezone != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9568 |  |  | 			date_default_timezone_set($globalTimezone); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9569 |  |  | 			$datetime = new DateTime(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9570 |  |  | 			$offset = $datetime->format('P'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9571 |  |  | 		} else $offset = '+00:00'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9572 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9573 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9574 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9575 |  |  | 			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct aircraft_icao) as date_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9576 |  |  | 								FROM spotter_output".$filter_query." aircraft_icao <> ''  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9577 |  |  | 								GROUP BY year_name, month_name | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9578 |  |  | 								ORDER BY date_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9579 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9580 |  |  | 			$query  = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct aircraft_icao) as date_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9581 |  |  | 								FROM spotter_output".$filter_query." aircraft_icao <> ''  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9582 |  |  | 								GROUP BY year_name, month_name | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9583 |  |  | 								ORDER BY date_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9584 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9585 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9586 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9587 |  |  | 		$sth->execute(array(':offset' => $offset)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9588 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9589 |  |  | 		$date_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9590 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9591 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9592 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9593 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9594 |  |  | 			$temp_array['month_name'] = $row['month_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9595 |  |  | 			$temp_array['year_name'] = $row['year_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9596 |  |  | 			$temp_array['date_count'] = $row['date_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9597 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9598 |  |  | 			$date_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9599 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9600 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9601 |  |  | 		return $date_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9602 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9603 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9604 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9605 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9606 |  |  | 	* Counts all month aircraft | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9607 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9608 |  |  | 	* @return Array the month list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9609 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9610 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9611 |  |  | 	public function countAllMonthsAircraftsByAirlines($filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9612 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9613 |  |  | 		global $globalTimezone, $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9614 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9615 |  |  | 		if ($globalTimezone != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9616 |  |  | 			date_default_timezone_set($globalTimezone); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9617 |  |  | 			$datetime = new DateTime(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9618 |  |  | 			$offset = $datetime->format('P'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9619 |  |  | 		} else $offset = '+00:00'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9620 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9621 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9622 |  |  | 			$query  = "SELECT spotter_output.airline_icao,YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct aircraft_icao) as date_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9623 |  |  | 								FROM spotter_output".$filter_query." aircraft_icao <> ''  AND spotter_output.airline_icao <> ''  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9624 |  |  | 								GROUP BY spotter_output.airline_icao, year_name, month_name | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9625 |  |  | 								ORDER BY date_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9626 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9627 |  |  | 			$query  = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct aircraft_icao) as date_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9628 |  |  | 								FROM spotter_output".$filter_query." aircraft_icao <> '' AND spotter_output.airline_icao <> ''  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9629 |  |  | 								GROUP BY spotter_output.airline_icao, year_name, month_name | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9630 |  |  | 								ORDER BY date_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9631 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9632 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9633 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9634 |  |  | 		$sth->execute(array(':offset' => $offset)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9635 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9636 |  |  | 		$date_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9637 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9638 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9639 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9640 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9641 |  |  | 			$temp_array['month_name'] = $row['month_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9642 |  |  | 			$temp_array['year_name'] = $row['year_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9643 |  |  | 			$temp_array['date_count'] = $row['date_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9644 |  |  | 			$temp_array['airline_icao'] = $row['airline_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9645 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9646 |  |  | 			$date_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9647 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9648 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9649 |  |  | 		return $date_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9650 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9651 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9652 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9653 |  |  | 	* Counts all month real arrival | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9654 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9655 |  |  | 	* @return Array the month list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9656 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9657 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9658 |  |  | 	public function countAllMonthsRealArrivals($filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9659 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9660 |  |  | 		global $globalTimezone, $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9661 |  |  | 		if ($globalTimezone != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9662 |  |  | 			date_default_timezone_set($globalTimezone); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9663 |  |  | 			$datetime = new DateTime(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9664 |  |  | 			$offset = $datetime->format('P'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9665 |  |  | 		} else $offset = '+00:00'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9666 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9667 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9668 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9669 |  |  | 			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(real_arrival_airport_icao) as date_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9670 |  |  | 								FROM spotter_output".$filter_query." real_arrival_airport_icao <> ''  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9671 |  |  | 								GROUP BY year_name, month_name | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9672 |  |  | 								ORDER BY date_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9673 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9674 |  |  | 			$query  = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(real_arrival_airport_icao) as date_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9675 |  |  | 								FROM spotter_output".$filter_query." real_arrival_airport_icao <> ''  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9676 |  |  | 								GROUP BY year_name, month_name | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9677 |  |  | 								ORDER BY date_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9678 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9679 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9680 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9681 |  |  | 		$sth->execute(array(':offset' => $offset)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9682 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9683 |  |  | 		$date_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9684 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9685 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9686 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9687 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9688 |  |  | 			$temp_array['month_name'] = $row['month_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9689 |  |  | 			$temp_array['year_name'] = $row['year_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9690 |  |  | 			$temp_array['date_count'] = $row['date_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9691 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9692 |  |  | 			$date_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9693 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9694 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9695 |  |  | 		return $date_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9696 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9697 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9698 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9699 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9700 |  |  | 	* Counts all month real arrival | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9701 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9702 |  |  | 	* @return Array the month list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9703 |  |  | 	* | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 9704 |  |  | 	*/ | 
            
                                                                        
                            
            
                                    
            
            
                | 9705 |  |  | 	public function countAllMonthsRealArrivalsByAirlines($filters = array()) | 
            
                                                                        
                            
            
                                    
            
            
                | 9706 |  |  | 	{ | 
            
                                                                        
                            
            
                                    
            
            
                | 9707 |  |  | 		global $globalTimezone, $globalDBdriver; | 
            
                                                                        
                            
            
                                    
            
            
                | 9708 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                        
                            
            
                                    
            
            
                | 9709 |  |  | 		if ($globalTimezone != '') { | 
            
                                                                        
                            
            
                                    
            
            
                | 9710 |  |  | 			date_default_timezone_set($globalTimezone); | 
            
                                                                        
                            
            
                                    
            
            
                | 9711 |  |  | 			$datetime = new DateTime(); | 
            
                                                                        
                            
            
                                    
            
            
                | 9712 |  |  | 			$offset = $datetime->format('P'); | 
            
                                                                        
                            
            
                                    
            
            
                | 9713 |  |  | 		} else $offset = '+00:00'; | 
            
                                                                        
                            
            
                                    
            
            
                | 9714 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 9715 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                        
                            
            
                                    
            
            
                | 9716 |  |  | 			$query  = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(real_arrival_airport_icao) as date_count | 
            
                                                                        
                            
            
                                    
            
            
                | 9717 |  |  | 								FROM spotter_output".$filter_query." real_arrival_airport_icao <> '' AND spotter_output.airline_icao <> ''  | 
            
                                                                        
                            
            
                                    
            
            
                | 9718 |  |  | 								GROUP BY spotter_output.airline_icao, year_name, month_name | 
            
                                                                        
                            
            
                                    
            
            
                | 9719 |  |  | 								ORDER BY date_count DESC"; | 
            
                                                                        
                            
            
                                    
            
            
                | 9720 |  |  | 		} else { | 
            
                                                                        
                            
            
                                    
            
            
                | 9721 |  |  | 			$query  = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(real_arrival_airport_icao) as date_count | 
            
                                                                        
                            
            
                                    
            
            
                | 9722 |  |  | 								FROM spotter_output".$filter_query." real_arrival_airport_icao <> '' AND spotter_output.airline_icao <> ''  | 
            
                                                                        
                            
            
                                    
            
            
                | 9723 |  |  | 								GROUP BY spotter_output.airline_icao, year_name, month_name | 
            
                                                                        
                            
            
                                    
            
            
                | 9724 |  |  | 								ORDER BY date_count DESC"; | 
            
                                                                        
                            
            
                                    
            
            
                | 9725 |  |  | 		} | 
            
                                                                        
                            
            
                                    
            
            
                | 9726 |  |  | 		 | 
            
                                                                        
                            
            
                                    
            
            
                | 9727 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                        
                            
            
                                    
            
            
                | 9728 |  |  | 		$sth->execute(array(':offset' => $offset)); | 
            
                                                                        
                            
            
                                    
            
            
                | 9729 |  |  |        | 
            
                                                                        
                            
            
                                    
            
            
                | 9730 |  |  | 		$date_array = array(); | 
            
                                                                        
                            
            
                                    
            
            
                | 9731 |  |  | 		$temp_array = array(); | 
            
                                                                        
                            
            
                                    
            
            
                | 9732 |  |  |          | 
            
                                                                        
                            
            
                                    
            
            
                | 9733 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                        
                            
            
                                    
            
            
                | 9734 |  |  | 		{ | 
            
                                                                        
                            
            
                                    
            
            
                | 9735 |  |  | 			$temp_array['month_name'] = $row['month_name']; | 
            
                                                                        
                            
            
                                    
            
            
                | 9736 |  |  | 			$temp_array['year_name'] = $row['year_name']; | 
            
                                                                        
                            
            
                                    
            
            
                | 9737 |  |  | 			$temp_array['date_count'] = $row['date_count']; | 
            
                                                                        
                            
            
                                    
            
            
                | 9738 |  |  | 			$temp_array['airline_icao'] = $row['airline_icao']; | 
            
                                                                        
                            
            
                                    
            
            
                | 9739 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 9740 |  |  | 			$date_array[] = $temp_array; | 
            
                                                                        
                            
            
                                    
            
            
                | 9741 |  |  | 		} | 
            
                                                                        
                            
            
                                    
            
            
                | 9742 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 9743 |  |  | 		return $date_array; | 
            
                                                                        
                            
            
                                    
            
            
                | 9744 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9745 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9746 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9747 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9748 |  |  | 	* Counts all dates during the last year | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9749 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9750 |  |  | 	* @return Array the date list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9751 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9752 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9753 |  |  | 	public function countAllMonthsLastYear($filters) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9754 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9755 |  |  | 		global $globalTimezone, $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9756 |  |  | 		if ($globalTimezone != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9757 |  |  | 			date_default_timezone_set($globalTimezone); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9758 |  |  | 			$datetime = new DateTime(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9759 |  |  | 			$offset = $datetime->format('P'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9760 |  |  | 		} else $offset = '+00:00'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9761 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9762 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9763 |  |  | 			$query  = "SELECT MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9764 |  |  | 								FROM spotter_output".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9765 |  |  | 			$query .= " GROUP BY year_name, month_name | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9766 |  |  | 								ORDER BY year_name, month_name ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9767 |  |  | 			$query_data = array(':offset' => $offset); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9768 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9769 |  |  | 			$query  = "SELECT EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name, count(*) as date_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9770 |  |  | 								FROM spotter_output".$filter_query." spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE INTERVAL :offset - INTERVAL '1 YEARS'"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9771 |  |  | 			$query .= " GROUP BY year_name, month_name | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9772 |  |  | 								ORDER BY year_name, month_name ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9773 |  |  | 			$query_data = array(':offset' => $offset); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9774 |  |  |     		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9775 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9776 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9777 |  |  | 		$sth->execute($query_data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9778 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9779 |  |  | 		$date_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9780 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9781 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9782 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9783 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9784 |  |  | 			$temp_array['year_name'] = $row['year_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9785 |  |  | 			$temp_array['month_name'] = $row['month_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9786 |  |  | 			$temp_array['date_count'] = $row['date_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9787 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9788 |  |  | 			$date_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9789 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9790 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9791 |  |  | 		return $date_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9792 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9793 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9794 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9795 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9796 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9797 |  |  | 	* Counts all hours | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9798 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9799 |  |  | 	* @return Array the hour list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9800 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9801 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9802 |  |  | 	public function countAllHours($orderby,$filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9803 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9804 |  |  | 		global $globalTimezone, $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9805 |  |  | 		if ($globalTimezone != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9806 |  |  | 			date_default_timezone_set($globalTimezone); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9807 |  |  | 			$datetime = new DateTime(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9808 |  |  | 			$offset = $datetime->format('P'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9809 |  |  | 		} else $offset = '+00:00'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9810 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9811 |  |  | 		$orderby_sql = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9812 |  |  | 		if ($orderby == "hour") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9813 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9814 |  |  | 			$orderby_sql = "ORDER BY hour_name ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9815 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9816 |  |  | 		if ($orderby == "count") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9817 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9818 |  |  | 			$orderby_sql = "ORDER BY hour_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9819 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9820 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9821 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9822 |  |  | 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9823 |  |  | 								FROM spotter_output"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9824 |  |  | 			$query .= $this->getFilter($filters); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9825 |  |  | 			$query .= " GROUP BY hour_name  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9826 |  |  | 								".$orderby_sql; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9827 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9828 |  |  | /*		$query  = "SELECT HOUR(spotter_output.date) AS hour_name, count(*) as hour_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9829 |  |  | 								FROM spotter_output  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9830 |  |  | 								GROUP BY hour_name  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9831 |  |  | 								".$orderby_sql." | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9832 |  |  | 								LIMIT 10 OFFSET 00"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9833 |  |  |   */     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9834 |  |  | 		$query_data = array(':offset' => $offset); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9835 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9836 |  |  | 			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9837 |  |  | 								FROM spotter_output"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9838 |  |  | 			$query .= $this->getFilter($filters); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9839 |  |  | 			$query .= " GROUP BY hour_name  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9840 |  |  | 								".$orderby_sql; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9841 |  |  | 			$query_data = array(':offset' => $offset); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9842 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9843 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9844 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9845 |  |  | 		$sth->execute($query_data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9846 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9847 |  |  | 		$hour_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9848 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9849 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9850 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9851 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9852 |  |  | 			$temp_array['hour_name'] = $row['hour_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9853 |  |  | 			$temp_array['hour_count'] = $row['hour_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9854 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9855 |  |  | 			$hour_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9856 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9857 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9858 |  |  | 		return $hour_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9859 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9860 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9861 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9862 |  |  | 	* Counts all hours | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9863 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9864 |  |  | 	* @return Array the hour list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9865 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9866 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9867 |  |  | 	public function countAllHoursByAirlines($orderby, $filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9868 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9869 |  |  | 		global $globalTimezone, $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9870 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9871 |  |  | 		if ($globalTimezone != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9872 |  |  | 			date_default_timezone_set($globalTimezone); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9873 |  |  | 			$datetime = new DateTime(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9874 |  |  | 			$offset = $datetime->format('P'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9875 |  |  | 		} else $offset = '+00:00'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9876 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9877 |  |  | 		$orderby_sql = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9878 |  |  | 		if ($orderby == "hour") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9879 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9880 |  |  | 			$orderby_sql = "ORDER BY hour_name ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9881 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9882 |  |  | 		if ($orderby == "count") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9883 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9884 |  |  | 			$orderby_sql = "ORDER BY hour_count DESC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9885 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9886 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9887 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9888 |  |  | 			$query  = "SELECT spotter_output.airline_icao, HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9889 |  |  | 								FROM spotter_output".$filter_query." spotter_output.airline_icao <> ''  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9890 |  |  | 								GROUP BY spotter_output.airline_icao, hour_name  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9891 |  |  | 								".$orderby_sql; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9892 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9893 |  |  | /*		$query  = "SELECT HOUR(spotter_output.date) AS hour_name, count(*) as hour_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9894 |  |  | 								FROM spotter_output  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9895 |  |  | 								GROUP BY hour_name  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9896 |  |  | 								".$orderby_sql." | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9897 |  |  | 								LIMIT 10 OFFSET 00"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9898 |  |  |   */     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9899 |  |  | 		$query_data = array(':offset' => $offset); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9900 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9901 |  |  | 			$query  = "SELECT spotter_output.airline_icao, EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9902 |  |  | 								FROM spotter_output".$filter_query." spotter_output.airline_icao <> ''  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9903 |  |  | 								GROUP BY spotter_output.airline_icao, hour_name  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9904 |  |  | 								".$orderby_sql; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9905 |  |  | 			$query_data = array(':offset' => $offset); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9906 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9907 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9908 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9909 |  |  | 		$sth->execute($query_data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9910 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9911 |  |  | 		$hour_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9912 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9913 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9914 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9915 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9916 |  |  | 			$temp_array['hour_name'] = $row['hour_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9917 |  |  | 			$temp_array['hour_count'] = $row['hour_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9918 |  |  | 			$temp_array['airline_icao'] = $row['airline_icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9919 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9920 |  |  | 			$hour_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9921 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9922 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9923 |  |  | 		return $hour_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9924 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9925 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9926 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9927 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9928 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9929 |  |  | 	* Counts all hours by airline | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9930 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9931 |  |  | 	* @return Array the hour list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9932 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9933 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9934 |  |  | 	public function countAllHoursByAirline($airline_icao, $filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9935 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9936 |  |  | 		global $globalTimezone, $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9937 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9938 |  |  | 		if ($globalTimezone != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9939 |  |  | 			date_default_timezone_set($globalTimezone); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9940 |  |  | 			$datetime = new DateTime(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9941 |  |  | 			$offset = $datetime->format('P'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9942 |  |  | 		} else $offset = '+00:00'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9943 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9944 |  |  | 		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9945 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9946 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9947 |  |  | 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9948 |  |  | 								FROM spotter_output".$filter_query." spotter_output.airline_icao = :airline_icao | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9949 |  |  | 								GROUP BY hour_name  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9950 |  |  | 								ORDER BY hour_name ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9951 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9952 |  |  | 			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9953 |  |  | 								FROM spotter_output".$filter_query." spotter_output.airline_icao = :airline_icao | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9954 |  |  | 								GROUP BY hour_name  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9955 |  |  | 								ORDER BY hour_name ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9956 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9957 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9958 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9959 |  |  | 		$sth->execute(array(':airline_icao' => $airline_icao,':offset' => $offset)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9960 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9961 |  |  | 		$hour_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9962 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9963 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9964 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9965 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9966 |  |  | 			$temp_array['hour_name'] = $row['hour_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9967 |  |  | 			$temp_array['hour_count'] = $row['hour_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9968 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9969 |  |  | 			$hour_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9970 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9971 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9972 |  |  | 		return $hour_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9973 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9974 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9975 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9976 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9977 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9978 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9979 |  |  | 	* Counts all hours by aircraft | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9980 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9981 |  |  | 	* @return Array the hour list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9982 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9983 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9984 |  |  | 	public function countAllHoursByAircraft($aircraft_icao, $filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9985 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9986 |  |  | 		global $globalTimezone, $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9987 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9988 |  |  | 		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9989 |  |  | 		if ($globalTimezone != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9990 |  |  | 			date_default_timezone_set($globalTimezone); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9991 |  |  | 			$datetime = new DateTime(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9992 |  |  | 			$offset = $datetime->format('P'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9993 |  |  | 		} else $offset = '+00:00'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9994 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9995 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9996 |  |  | 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9997 |  |  | 								FROM spotter_output".$filter_query." spotter_output.aircraft_icao = :aircraft_icao | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9998 |  |  | 								GROUP BY hour_name  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9999 |  |  | 								ORDER BY hour_name ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10000 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10001 |  |  | 			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10002 |  |  | 								FROM spotter_output".$filter_query." spotter_output.aircraft_icao = :aircraft_icao | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10003 |  |  | 								GROUP BY hour_name  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10004 |  |  | 								ORDER BY hour_name ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10005 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10006 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10007 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10008 |  |  | 		$sth->execute(array(':aircraft_icao' => $aircraft_icao,':offset' => $offset)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10009 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10010 |  |  | 		$hour_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10011 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10012 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10013 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10014 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10015 |  |  | 			$temp_array['hour_name'] = $row['hour_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10016 |  |  | 			$temp_array['hour_count'] = $row['hour_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10017 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10018 |  |  | 			$hour_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10019 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10020 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10021 |  |  | 		return $hour_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10022 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10023 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10024 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10025 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10026 |  |  | 	* Counts all hours by aircraft registration | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10027 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10028 |  |  | 	* @return Array the hour list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10029 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10030 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10031 |  |  | 	public function countAllHoursByRegistration($registration, $filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10032 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10033 |  |  | 		global $globalTimezone, $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10034 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10035 |  |  | 		$registration = filter_var($registration,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10036 |  |  | 		if ($globalTimezone != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10037 |  |  | 			date_default_timezone_set($globalTimezone); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10038 |  |  | 			$datetime = new DateTime(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10039 |  |  | 			$offset = $datetime->format('P'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10040 |  |  | 		} else $offset = '+00:00'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10041 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10042 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10043 |  |  | 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10044 |  |  | 								FROM spotter_output".$filter_query." spotter_output.registration = :registration | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10045 |  |  | 								GROUP BY hour_name  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10046 |  |  | 								ORDER BY hour_name ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10047 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10048 |  |  | 			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10049 |  |  | 								FROM spotter_output".$filter_query." spotter_output.registration = :registration | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10050 |  |  | 								GROUP BY hour_name  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10051 |  |  | 								ORDER BY hour_name ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10052 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10053 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10054 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10055 |  |  | 		$sth->execute(array(':registration' => $registration,':offset' => $offset)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10056 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10057 |  |  | 		$hour_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10058 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10059 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10060 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10061 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10062 |  |  | 			$temp_array['hour_name'] = $row['hour_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10063 |  |  | 			$temp_array['hour_count'] = $row['hour_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10064 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10065 |  |  | 			$hour_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10066 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10067 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10068 |  |  | 		return $hour_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10069 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10070 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10071 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10072 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10073 |  |  | 	* Counts all hours by airport | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10074 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10075 |  |  | 	* @return Array the hour list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10076 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10077 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10078 |  |  | 	public function countAllHoursByAirport($airport_icao, $filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10079 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10080 |  |  | 		global $globalTimezone, $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10081 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10082 |  |  | 		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10083 |  |  | 		if ($globalTimezone != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10084 |  |  | 			date_default_timezone_set($globalTimezone); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10085 |  |  | 			$datetime = new DateTime(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10086 |  |  | 			$offset = $datetime->format('P'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10087 |  |  | 		} else $offset = '+00:00'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10088 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10089 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10090 |  |  | 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10091 |  |  | 								FROM spotter_output".$filter_query." (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10092 |  |  | 								GROUP BY hour_name  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10093 |  |  | 								ORDER BY hour_name ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10094 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10095 |  |  | 			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10096 |  |  | 								FROM spotter_output".$filter_query." (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10097 |  |  | 								GROUP BY hour_name  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10098 |  |  | 								ORDER BY hour_name ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10099 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10100 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10101 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10102 |  |  | 		$sth->execute(array(':airport_icao' => $airport_icao,':offset' => $offset)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10103 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10104 |  |  | 		$hour_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10105 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10106 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10107 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10108 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10109 |  |  | 			$temp_array['hour_name'] = $row['hour_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10110 |  |  | 			$temp_array['hour_count'] = $row['hour_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10111 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10112 |  |  | 			$hour_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10113 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10114 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10115 |  |  | 		return $hour_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10116 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10117 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10118 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10119 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10120 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10121 |  |  | 	* Counts all hours by manufacturer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10122 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10123 |  |  | 	* @return Array the hour list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10124 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10125 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10126 |  |  | 	public function countAllHoursByManufacturer($aircraft_manufacturer,$filters =array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10127 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10128 |  |  | 		global $globalTimezone, $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10129 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10130 |  |  | 		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10131 |  |  | 		if ($globalTimezone != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10132 |  |  | 			date_default_timezone_set($globalTimezone); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10133 |  |  | 			$datetime = new DateTime(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10134 |  |  | 			$offset = $datetime->format('P'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10135 |  |  | 		} else $offset = '+00:00'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10136 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10137 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10138 |  |  | 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10139 |  |  | 								FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer = :aircraft_manufacturer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10140 |  |  | 								GROUP BY hour_name  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10141 |  |  | 								ORDER BY hour_name ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10142 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10143 |  |  | 			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10144 |  |  | 								FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer = :aircraft_manufacturer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10145 |  |  | 								GROUP BY hour_name  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10146 |  |  | 								ORDER BY hour_name ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10147 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10148 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10149 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10150 |  |  | 		$sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer,':offset' => $offset)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10151 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10152 |  |  | 		$hour_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10153 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10154 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10155 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10156 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10157 |  |  | 			$temp_array['hour_name'] = $row['hour_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10158 |  |  | 			$temp_array['hour_count'] = $row['hour_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10159 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10160 |  |  | 			$hour_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10161 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10162 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10163 |  |  | 		return $hour_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10164 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10165 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10166 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10167 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10168 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10169 |  |  | 	* Counts all hours by date | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10170 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10171 |  |  | 	* @return Array the hour list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10172 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10173 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10174 |  |  | 	public function countAllHoursByDate($date, $filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10175 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10176 |  |  | 		global $globalTimezone, $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10177 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10178 |  |  | 		$date = filter_var($date,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10179 |  |  | 		if ($globalTimezone != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10180 |  |  | 			date_default_timezone_set($globalTimezone); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10181 |  |  | 			$datetime = new DateTime($date); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10182 |  |  | 			$offset = $datetime->format('P'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10183 |  |  | 		} else $offset = '+00:00'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10184 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10185 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10186 |  |  | 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10187 |  |  | 								FROM spotter_output".$filter_query." DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10188 |  |  | 								GROUP BY hour_name  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10189 |  |  | 								ORDER BY hour_name ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10190 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10191 |  |  | 			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10192 |  |  | 								FROM spotter_output".$filter_query." to_char(spotter_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10193 |  |  | 								GROUP BY hour_name  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10194 |  |  | 								ORDER BY hour_name ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10195 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10196 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10197 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10198 |  |  | 		$sth->execute(array(':date' => $date, ':offset' => $offset)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10199 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10200 |  |  | 		$hour_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10201 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10202 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10203 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10204 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10205 |  |  | 			$temp_array['hour_name'] = $row['hour_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10206 |  |  | 			$temp_array['hour_count'] = $row['hour_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10207 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10208 |  |  | 			$hour_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10209 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10210 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10211 |  |  | 		return $hour_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10212 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10213 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10214 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10215 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10216 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10217 |  |  | 	* Counts all hours by a ident/callsign | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10218 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10219 |  |  | 	* @return Array the hour list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10220 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10221 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10222 |  |  | 	public function countAllHoursByIdent($ident, $filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10223 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10224 |  |  | 		global $globalTimezone, $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10225 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10226 |  |  | 		$ident = filter_var($ident,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10227 |  |  | 		if ($globalTimezone != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10228 |  |  | 			date_default_timezone_set($globalTimezone); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10229 |  |  | 			$datetime = new DateTime(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10230 |  |  | 			$offset = $datetime->format('P'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10231 |  |  | 		} else $offset = '+00:00'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10232 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10233 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10234 |  |  | 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10235 |  |  | 								FROM spotter_output".$filter_query." spotter_output.ident = :ident  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10236 |  |  | 								GROUP BY hour_name  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10237 |  |  | 								ORDER BY hour_name ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10238 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10239 |  |  | 			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10240 |  |  | 								FROM spotter_output".$filter_query." spotter_output.ident = :ident  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10241 |  |  | 								GROUP BY hour_name  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10242 |  |  | 								ORDER BY hour_name ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10243 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10244 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10245 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10246 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10247 |  |  | 		$sth->execute(array(':ident' => $ident,':offset' => $offset)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10248 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10249 |  |  | 		$hour_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10250 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10251 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10252 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10253 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10254 |  |  | 			$temp_array['hour_name'] = $row['hour_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10255 |  |  | 			$temp_array['hour_count'] = $row['hour_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10256 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10257 |  |  | 			$hour_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10258 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10259 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10260 |  |  | 		return $hour_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10261 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10262 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10263 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10264 |  |  | 	* Counts all hours by a owner | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10265 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10266 |  |  | 	* @return Array the hour list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10267 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10268 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10269 |  |  | 	public function countAllHoursByOwner($owner, $filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10270 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10271 |  |  | 		global $globalTimezone, $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10272 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10273 |  |  | 		$owner = filter_var($owner,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10274 |  |  | 		if ($globalTimezone != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10275 |  |  | 			date_default_timezone_set($globalTimezone); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10276 |  |  | 			$datetime = new DateTime(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10277 |  |  | 			$offset = $datetime->format('P'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10278 |  |  | 		} else $offset = '+00:00'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10279 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10280 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10281 |  |  | 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10282 |  |  | 								FROM spotter_output".$filter_query." spotter_output.owner_name = :owner  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10283 |  |  | 								GROUP BY hour_name  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10284 |  |  | 								ORDER BY hour_name ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10285 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10286 |  |  | 			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10287 |  |  | 								FROM spotter_output".$filter_query." spotter_output.owner_name = :owner  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10288 |  |  | 								GROUP BY hour_name  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10289 |  |  | 								ORDER BY hour_name ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10290 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10291 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10292 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10293 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10294 |  |  | 		$sth->execute(array(':owner' => $owner,':offset' => $offset)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10295 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10296 |  |  | 		$hour_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10297 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10298 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10299 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10300 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10301 |  |  | 			$temp_array['hour_name'] = $row['hour_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10302 |  |  | 			$temp_array['hour_count'] = $row['hour_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10303 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10304 |  |  | 			$hour_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10305 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10306 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10307 |  |  | 		return $hour_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10308 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10309 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10310 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10311 |  |  | 	* Counts all hours by a pilot | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10312 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10313 |  |  | 	* @return Array the hour list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10314 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10315 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10316 |  |  | 	public function countAllHoursByPilot($pilot, $filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10317 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10318 |  |  | 		global $globalTimezone, $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10319 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10320 |  |  | 		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10321 |  |  | 		if ($globalTimezone != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10322 |  |  | 			date_default_timezone_set($globalTimezone); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10323 |  |  | 			$datetime = new DateTime(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10324 |  |  | 			$offset = $datetime->format('P'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10325 |  |  | 		} else $offset = '+00:00'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10326 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10327 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10328 |  |  | 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10329 |  |  | 								FROM spotter_output".$filter_query." (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot)  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10330 |  |  | 								GROUP BY hour_name  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10331 |  |  | 								ORDER BY hour_name ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10332 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10333 |  |  | 			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10334 |  |  | 								FROM spotter_output".$filter_query." (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot)  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10335 |  |  | 								GROUP BY hour_name  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10336 |  |  | 								ORDER BY hour_name ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10337 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10338 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10339 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10340 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10341 |  |  | 		$sth->execute(array(':pilot' => $pilot,':offset' => $offset)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10342 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10343 |  |  | 		$hour_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10344 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10345 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10346 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10347 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10348 |  |  | 			$temp_array['hour_name'] = $row['hour_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10349 |  |  | 			$temp_array['hour_count'] = $row['hour_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10350 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10351 |  |  | 			$hour_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10352 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10353 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10354 |  |  | 		return $hour_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10355 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10356 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10357 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10358 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10359 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10360 |  |  | 	* Counts all hours by route | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10361 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10362 |  |  | 	* @return Array the hour list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10363 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10364 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10365 |  |  | 	public function countAllHoursByRoute($departure_airport_icao, $arrival_airport_icao, $filters =array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10366 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10367 |  |  | 		global $globalTimezone, $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10368 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10369 |  |  | 		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10370 |  |  | 		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10371 |  |  | 		if ($globalTimezone != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10372 |  |  | 			date_default_timezone_set($globalTimezone); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10373 |  |  | 			$datetime = new DateTime(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10374 |  |  | 			$offset = $datetime->format('P'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10375 |  |  | 		} else $offset = '+00:00'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10376 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10377 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10378 |  |  | 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10379 |  |  | 								FROM spotter_output".$filter_query." (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10380 |  |  | 								GROUP BY hour_name  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10381 |  |  | 								ORDER BY hour_name ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10382 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10383 |  |  | 			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10384 |  |  | 								FROM spotter_output".$filter_query." (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10385 |  |  | 								GROUP BY hour_name  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10386 |  |  | 								ORDER BY hour_name ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10387 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10388 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10389 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10390 |  |  | 		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':offset' => $offset)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10391 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10392 |  |  | 		$hour_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10393 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10394 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10395 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10396 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10397 |  |  | 			$temp_array['hour_name'] = $row['hour_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10398 |  |  | 			$temp_array['hour_count'] = $row['hour_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10399 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10400 |  |  | 			$hour_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10401 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10402 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10403 |  |  | 		return $hour_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10404 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10405 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10406 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10407 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10408 |  |  | 	* Counts all hours by country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10409 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10410 |  |  | 	* @return Array the hour list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10411 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10412 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10413 |  |  | 	public function countAllHoursByCountry($country, $filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10414 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10415 |  |  | 		global $globalTimezone, $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10416 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10417 |  |  | 		$country = filter_var($country,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10418 |  |  | 		if ($globalTimezone != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10419 |  |  | 			date_default_timezone_set($globalTimezone); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10420 |  |  | 			$datetime = new DateTime(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10421 |  |  | 			$offset = $datetime->format('P'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10422 |  |  | 		} else $offset = '+00:00'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10423 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10424 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10425 |  |  | 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10426 |  |  | 								FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10427 |  |  | 								GROUP BY hour_name  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10428 |  |  | 								ORDER BY hour_name ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10429 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10430 |  |  | 			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10431 |  |  | 								FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10432 |  |  | 								GROUP BY hour_name  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10433 |  |  | 								ORDER BY hour_name ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10434 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10435 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10436 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10437 |  |  | 		$sth->execute(array(':country' => $country,':offset' => $offset)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10438 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10439 |  |  | 		$hour_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10440 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10441 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10442 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10443 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10444 |  |  | 			$temp_array['hour_name'] = $row['hour_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10445 |  |  | 			$temp_array['hour_count'] = $row['hour_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10446 |  |  |            | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10447 |  |  | 			$hour_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10448 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10449 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10450 |  |  | 		return $hour_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10451 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10452 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10453 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10454 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10455 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10456 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10457 |  |  | 	* Counts all aircraft that have flown over | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10458 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10459 |  |  | 	* @return Integer the number of aircrafts | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10460 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10461 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10462 |  |  | 	public function countOverallAircrafts($filters = array(),$year = '',$month = '') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10463 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10464 |  |  | 		global $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10465 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10466 |  |  | 		$query  = "SELECT COUNT(DISTINCT spotter_output.aircraft_icao) AS aircraft_count   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10467 |  |  |                     FROM spotter_output".$filter_query." spotter_output.ident <> ''"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10468 |  |  | 		$query_values = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10469 |  |  | 		if ($year != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10470 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10471 |  |  | 				$query .= " AND YEAR(spotter_output.date) = :year"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10472 |  |  | 				$query_values = array_merge($query_values,array(':year' => $year)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10473 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10474 |  |  | 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10475 |  |  | 				$query_values = array_merge($query_values,array(':year' => $year)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10476 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10477 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10478 |  |  | 		if ($month != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10479 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10480 |  |  | 				$query .= " AND MONTH(spotter_output.date) = :month"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10481 |  |  | 				$query_values = array_merge($query_values,array(':month' => $month)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10482 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10483 |  |  | 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10484 |  |  | 				$query_values = array_merge($query_values,array(':month' => $month)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10485 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10486 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10487 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10488 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10489 |  |  | 		$sth->execute($query_values); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10490 |  |  | 		return $sth->fetchColumn(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10491 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10492 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10493 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10494 |  |  | 	* Counts all flight that really arrival | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10495 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10496 |  |  | 	* @return Integer the number of aircrafts | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10497 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10498 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10499 |  |  | 	public function countOverallArrival($filters = array(),$year = '',$month = '') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10500 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10501 |  |  | 		global $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10502 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10503 |  |  | 		$query  = "SELECT COUNT(spotter_output.real_arrival_airport_icao) AS arrival_count   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10504 |  |  |                     FROM spotter_output".$filter_query." spotter_output.arrival_airport_icao <> ''"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10505 |  |  | 		$query_values = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10506 |  |  | 		if ($year != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10507 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10508 |  |  | 				$query .= " AND YEAR(spotter_output.date) = :year"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10509 |  |  | 				$query_values = array_merge($query_values,array(':year' => $year)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10510 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10511 |  |  | 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10512 |  |  | 				$query_values = array_merge($query_values,array(':year' => $year)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10513 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10514 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10515 |  |  | 		if ($month != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10516 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10517 |  |  | 				$query .= " AND MONTH(spotter_output.date) = :month"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10518 |  |  | 				$query_values = array_merge($query_values,array(':month' => $month)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10519 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10520 |  |  | 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10521 |  |  | 				$query_values = array_merge($query_values,array(':month' => $month)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10522 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10523 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10524 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10525 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10526 |  |  | 		$sth->execute($query_values); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10527 |  |  | 		return $sth->fetchColumn(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10528 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10529 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10530 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10531 |  |  | 	* Counts all pilots that have flown over | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10532 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10533 |  |  | 	* @return Integer the number of pilots | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10534 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10535 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10536 |  |  | 	public function countOverallPilots($filters = array(),$year = '',$month = '') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10537 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10538 |  |  | 		global $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10539 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10540 |  |  | 		$query  = "SELECT COUNT(DISTINCT spotter_output.pilot_id) AS pilot_count   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10541 |  |  |                     FROM spotter_output".$filter_query." spotter_output.pilot_id <> ''"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10542 |  |  | 		$query_values = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10543 |  |  | 		if ($year != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10544 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10545 |  |  | 				$query .= " AND YEAR(spotter_output.date) = :year"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10546 |  |  | 				$query_values = array_merge($query_values,array(':year' => $year)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10547 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10548 |  |  | 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10549 |  |  | 				$query_values = array_merge($query_values,array(':year' => $year)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10550 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10551 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10552 |  |  | 		if ($month != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10553 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10554 |  |  | 				$query .= " AND MONTH(spotter_output.date) = :month"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10555 |  |  | 				$query_values = array_merge($query_values,array(':month' => $month)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10556 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10557 |  |  | 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10558 |  |  | 				$query_values = array_merge($query_values,array(':month' => $month)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10559 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10560 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10561 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10562 |  |  | 		$sth->execute($query_values); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10563 |  |  | 		return $sth->fetchColumn(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10564 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10565 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10566 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10567 |  |  | 	* Counts all owners that have flown over | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10568 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10569 |  |  | 	* @return Integer the number of owners | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10570 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10571 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10572 |  |  | 	public function countOverallOwners($filters = array(),$year = '',$month = '') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10573 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10574 |  |  | 		global $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10575 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10576 |  |  | 		$query  = "SELECT COUNT(DISTINCT spotter_output.owner_name) AS owner_count   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10577 |  |  |                     FROM spotter_output".$filter_query." spotter_output.owner_name <> ''"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10578 |  |  | 		$query_values = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10579 |  |  | 		if ($year != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10580 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10581 |  |  | 				$query .= " AND YEAR(spotter_output.date) = :year"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10582 |  |  | 				$query_values = array_merge($query_values,array(':year' => $year)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10583 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10584 |  |  | 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10585 |  |  | 				$query_values = array_merge($query_values,array(':year' => $year)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10586 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10587 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10588 |  |  | 		if ($month != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10589 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10590 |  |  | 				$query .= " AND MONTH(spotter_output.date) = :month"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10591 |  |  | 				$query_values = array_merge($query_values,array(':month' => $month)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10592 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10593 |  |  | 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10594 |  |  | 				$query_values = array_merge($query_values,array(':month' => $month)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10595 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10596 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10597 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10598 |  |  | 		$sth->execute($query_values); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10599 |  |  | 		return $sth->fetchColumn(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10600 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10601 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10602 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10603 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10604 |  |  | 	* Counts all flights that have flown over | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10605 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10606 |  |  | 	* @return Integer the number of flights | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10607 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10608 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10609 |  |  | 	public function countOverallFlights($filters = array(),$year = '',$month = '') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10610 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10611 |  |  | 		global $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10612 |  |  | 		$queryi  = "SELECT COUNT(spotter_output.spotter_id) AS flight_count FROM spotter_output"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10613 |  |  | 		$query_values = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10614 |  |  | 		$query = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10615 |  |  | 		if ($year != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10616 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10617 |  |  | 				$query .= " AND YEAR(spotter_output.date) = :year"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10618 |  |  | 				$query_values = array_merge($query_values,array(':year' => $year)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10619 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10620 |  |  | 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10621 |  |  | 				$query_values = array_merge($query_values,array(':year' => $year)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10622 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10623 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10624 |  |  | 		if ($month != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10625 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10626 |  |  | 				$query .= " AND MONTH(spotter_output.date) = :month"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10627 |  |  | 				$query_values = array_merge($query_values,array(':month' => $month)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10628 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10629 |  |  | 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10630 |  |  | 				$query_values = array_merge($query_values,array(':month' => $month)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10631 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10632 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10633 |  |  | 		if (empty($query_values)) $queryi .= $this->getFilter($filters); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10634 |  |  | 		else $queryi .= $this->getFilter($filters,true,true).substr($query,4); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10635 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10636 |  |  | 		//echo $query; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10637 |  |  | 		$sth = $this->db->prepare($queryi); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10638 |  |  | 		$sth->execute($query_values); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10639 |  |  | 		return $sth->fetchColumn(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10640 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10641 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10642 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10643 |  |  | 	* Counts all military flights that have flown over | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10644 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10645 |  |  | 	* @return Integer the number of flights | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10646 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10647 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10648 |  |  | 	public function countOverallMilitaryFlights($filters = array(),$year = '',$month = '') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10649 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10650 |  |  | 		global $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10651 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10652 |  |  | 		$query  = "SELECT COUNT(spotter_output.spotter_id) AS flight_count   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10653 |  |  |                     FROM airlines,spotter_output".$filter_query." spotter_output.airline_icao = airlines.icao AND airlines.type = 'military'"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10654 |  |  | 		$query_values = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10655 |  |  | 		if ($year != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10656 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10657 |  |  | 				$query .= " AND YEAR(spotter_output.date) = :year"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10658 |  |  | 				$query_values = array_merge($query_values,array(':year' => $year)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10659 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10660 |  |  | 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10661 |  |  | 				$query_values = array_merge($query_values,array(':year' => $year)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10662 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10663 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10664 |  |  | 		if ($month != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10665 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10666 |  |  | 				$query .= " AND MONTH(spotter_output.date) = :month"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10667 |  |  | 				$query_values = array_merge($query_values,array(':month' => $month)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10668 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10669 |  |  | 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10670 |  |  | 				$query_values = array_merge($query_values,array(':month' => $month)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10671 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10672 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10673 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10674 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10675 |  |  | 		$sth->execute($query_values); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10676 |  |  | 		return $sth->fetchColumn(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10677 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10678 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10679 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10680 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10681 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10682 |  |  | 	* Counts all airlines that have flown over | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10683 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10684 |  |  | 	* @return Integer the number of airlines | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10685 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10686 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10687 |  |  | 	public function countOverallAirlines($filters = array(),$year = '',$month = '') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10688 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10689 |  |  | 		global $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10690 |  |  | 		$queryi  = "SELECT COUNT(DISTINCT spotter_output.airline_name) AS airline_count  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10691 |  |  | 							FROM spotter_output"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10692 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10693 |  |  | 		$query_values = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10694 |  |  | 		$query = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10695 |  |  | 		if ($year != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10696 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10697 |  |  | 				$query .= " AND YEAR(spotter_output.date) = :year"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10698 |  |  | 				$query_values = array_merge($query_values,array(':year' => $year)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10699 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10700 |  |  | 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10701 |  |  | 				$query_values = array_merge($query_values,array(':year' => $year)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10702 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10703 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10704 |  |  | 		if ($month != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10705 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10706 |  |  | 				$query .= " AND MONTH(spotter_output.date) = :month"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10707 |  |  | 				$query_values = array_merge($query_values,array(':month' => $month)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10708 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10709 |  |  | 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10710 |  |  | 				$query_values = array_merge($query_values,array(':month' => $month)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10711 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10712 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10713 |  |  |                 if ($query == '') $queryi .= $this->getFilter($filters); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10714 |  |  |                 else $queryi .= $this->getFilter($filters,true,true).substr($query,4); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10715 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10716 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10717 |  |  | 		$sth = $this->db->prepare($queryi); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10718 |  |  | 		$sth->execute($query_values); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10719 |  |  | 		return $sth->fetchColumn(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10720 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10721 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10722 |  |  |    | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10723 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10724 |  |  | 	* Counts all hours of today | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10725 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10726 |  |  | 	* @return Array the hour list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10727 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10728 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10729 |  |  | 	public function countAllHoursFromToday($filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10730 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10731 |  |  | 		global $globalTimezone, $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10732 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10733 |  |  | 		if ($globalTimezone != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10734 |  |  | 			date_default_timezone_set($globalTimezone); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10735 |  |  | 			$datetime = new DateTime(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10736 |  |  | 			$offset = $datetime->format('P'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10737 |  |  | 		} else $offset = '+00:00'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10738 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10739 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10740 |  |  | 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10741 |  |  | 								FROM spotter_output".$filter_query." DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = CURDATE() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10742 |  |  | 								GROUP BY hour_name  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10743 |  |  | 								ORDER BY hour_name ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10744 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10745 |  |  | 			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10746 |  |  | 								FROM spotter_output".$filter_query." to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10747 |  |  | 								GROUP BY hour_name  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10748 |  |  | 								ORDER BY hour_name ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10749 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10750 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10751 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10752 |  |  | 		$sth->execute(array(':offset' => $offset)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10753 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10754 |  |  | 		$hour_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10755 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10756 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10757 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10758 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10759 |  |  | 			$temp_array['hour_name'] = $row['hour_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10760 |  |  | 			$temp_array['hour_count'] = $row['hour_count']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10761 |  |  | 			$hour_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10762 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10763 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10764 |  |  | 		return $hour_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10765 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10766 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10767 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10768 |  |  | 	* Gets all the spotter information based on calculated upcoming flights | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10769 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10770 |  |  | 	* @return Array the spotter information | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10771 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10772 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10773 |  |  | 	public function getUpcomingFlights($limit = '', $sort = '', $filters = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10774 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10775 |  |  | 		global $global_query, $globalDBdriver, $globalTimezone; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10776 |  |  | 		$filter_query = $this->getFilter($filters,true,true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10777 |  |  | 		date_default_timezone_set('UTC'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10778 |  |  | 		$limit_query = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10779 |  |  | 		if ($limit != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10780 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10781 |  |  | 			$limit_array = explode(",", $limit); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10782 |  |  | 			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10783 |  |  | 			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10784 |  |  | 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10785 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10786 |  |  | 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10787 |  |  | 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10788 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10789 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10790 |  |  | 		$currentHour = date("G"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10791 |  |  | 		$next3Hours = date("G", strtotime("+3 hour")); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10792 |  |  | 		//if the next 3 hours is already equal to/past midnight, we limit it to stay there, otherwise the query will fail | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10793 |  |  | 		if ($currentHour >= 21 && $next3Hours >= 00) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10794 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10795 |  |  | 			$next3Hours = 24; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10796 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10797 |  |  | 		$currentDayofWeek = date("l"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10798 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10799 |  |  | 			if ($sort != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10800 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10801 |  |  | 				$search_orderby_array = $this->getOrderBy(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10802 |  |  | 				$orderby_query = $search_orderby_array[$sort]['sql']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10803 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10804 |  |  | 				$orderby_query = " ORDER BY HOUR(spotter_output.date) ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10805 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10806 |  |  | /* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10807 |  |  | 			$query = "SELECT spotter_output.*, count(spotter_output.ident) as ident_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10808 |  |  | 			    FROM spotter_output | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10809 |  |  | 			    WHERE DAYNAME(spotter_output.date) = '$currentDayofWeek' AND HOUR(spotter_output.date) >= '$currentHour' AND HOUR(spotter_output.date) <= '$next3Hours' AND spotter_output.ident <> '' AND format_source <> 'aprs' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10810 |  |  | 			    GROUP BY spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time HAVING count(spotter_output.ident) > 10 $orderby_query"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10811 |  |  | */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10812 |  |  | /*			$query = "SELECT spotter_output.ident, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time, count(spotter_output.ident) as ident_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10813 |  |  | 			    FROM spotter_output | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10814 |  |  | 			    WHERE DAYNAME(spotter_output.date) = '$currentDayofWeek' AND HOUR(spotter_output.date) >= '$currentHour' AND HOUR(spotter_output.date) <= '$next3Hours' AND spotter_output.ident <> '' AND format_source <> 'aprs' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10815 |  |  | 			    GROUP BY spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time HAVING count(spotter_output.ident) > 10 $orderby_query"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10816 |  |  | */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10817 |  |  | 			$query = "SELECT spotter_output.ident, spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time, count(spotter_output.ident) as ident_count  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10818 |  |  | 			    FROM spotter_output".$filter_query." DAYNAME(spotter_output.date) = '$currentDayofWeek' AND HOUR(spotter_output.date) >= '$currentHour' AND HOUR(spotter_output.date) <= '$next3Hours' AND spotter_output.ident <> '' AND format_source <> 'aprs' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10819 |  |  | 			    GROUP BY spotter_output.ident,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10820 |  |  | 			    HAVING count(spotter_output.ident) > 5$orderby_query"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10821 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10822 |  |  | 			$spotter_array = $this->getDataFromDB($query.$limit_query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10823 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10824 |  |  | 			if ($sort != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10825 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10826 |  |  | 				$search_orderby_array = $this->getOrderBy(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10827 |  |  | 				$orderby_query = $search_orderby_array[$sort]['sql']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10828 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10829 |  |  | 				$orderby_query = " ORDER BY to_char(spotter_output.date,'HH') ASC"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10830 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10831 |  |  | 			$query = "SELECT spotter_output.ident, spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time, count(spotter_output.ident) as ident_count, to_char(spotter_output.date,'HH')  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10832 |  |  | 			    FROM spotter_output".$filter_query." DATE_PART('dow', spotter_output.date) = DATE_PART('dow', date 'now' AT TIME ZONE :timezone) AND EXTRACT (HOUR FROM spotter_output.date AT TIME ZONE :timezone) >= '$currentHour' AND EXTRACT (HOUR FROM spotter_output.date AT TIME ZONE :timezone) <= '$next3Hours' AND ident <> ''  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10833 |  |  | 			    GROUP BY spotter_output.ident,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time, to_char(spotter_output.date,'HH') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10834 |  |  | 			    HAVING count(spotter_output.ident) > 5$orderby_query"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10835 |  |  | 			//echo $query; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10836 |  |  | 			$spotter_array = $this->getDataFromDB($query.$limit_query,array(':timezone' => $globalTimezone)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10837 |  |  | 			/* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10838 |  |  | 			$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10839 |  |  | 			$sth->execute(array(':timezone' => $globalTimezone)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10840 |  |  | 			return $sth->fetchAll(PDO::FETCH_ASSOC); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10841 |  |  | 			*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10842 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10843 |  |  | 		return $spotter_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10844 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10845 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10846 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10847 |  |  |      /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10848 |  |  | 	* Gets the Barrie Spotter ID based on the FlightAware ID | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10849 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10850 |  |  | 	* @return Integer the Barrie Spotter ID | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10851 |  |  | q	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10852 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10853 |  |  | 	public function getSpotterIDBasedOnFlightAwareID($flightaware_id) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10854 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10855 |  |  | 		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10856 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10857 |  |  | 		$query  = "SELECT spotter_output.spotter_id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10858 |  |  | 								FROM spotter_output  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10859 |  |  | 								WHERE spotter_output.flightaware_id = '".$flightaware_id."'"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10860 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10861 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10862 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10863 |  |  | 		$sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10864 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10865 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10866 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10867 |  |  | 			return $row['spotter_id']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10868 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10869 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10870 |  |  |    | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10871 |  |  |   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10872 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10873 |  |  | 	* Parses a date string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10874 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10875 |  |  | 	* @param String $dateString the date string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10876 |  |  | 	* @param String $timezone the timezone of a user | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10877 |  |  | 	* @return Array the time information | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10878 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10879 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10880 |  |  | 	public function parseDateString($dateString, $timezone = '') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10881 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10882 |  |  | 		$time_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10883 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10884 |  |  | 		if ($timezone != "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10885 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10886 |  |  | 			date_default_timezone_set($timezone); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10887 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10888 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10889 |  |  | 		$current_date = date("Y-m-d H:i:s"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10890 |  |  | 		$date = date("Y-m-d H:i:s",strtotime($dateString." UTC")); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10891 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10892 |  |  | 		$diff = abs(strtotime($current_date) - strtotime($date)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10893 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10894 |  |  | 		$time_array['years'] = floor($diff / (365*60*60*24));  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10895 |  |  | 		$years = $time_array['years']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10896 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10897 |  |  | 		$time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10898 |  |  | 		$months = $time_array['months']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10899 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10900 |  |  | 		$time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10901 |  |  | 		$days = $time_array['days']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10902 |  |  | 		$time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10903 |  |  | 		$hours = $time_array['hours']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10904 |  |  | 		$time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10905 |  |  | 		$minutes = $time_array['minutes']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10906 |  |  | 		$time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10907 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10908 |  |  | 		return $time_array;	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10909 |  |  | 	}	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10910 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10911 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10912 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10913 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10914 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10915 |  |  | 	* Parses the direction degrees to working | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10916 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10917 |  |  | 	* @param Float $direction the direction in degrees | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10918 |  |  | 	* @return Array the direction information | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10919 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10920 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10921 |  |  | 	public function parseDirection($direction = 0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10922 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10923 |  |  | 		if ($direction == '') $direction = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10924 |  |  | 		$direction_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10925 |  |  | 		$temp_array = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10926 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10927 |  |  | 		if ($direction == 360 || ($direction >= 0 && $direction < 22.5)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10928 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10929 |  |  | 			$temp_array['direction_degree'] = $direction; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10930 |  |  | 			$temp_array['direction_shortname'] = "N"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10931 |  |  | 			$temp_array['direction_fullname'] = "North"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10932 |  |  | 		} elseif ($direction >= 22.5 && $direction < 45){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10933 |  |  | 			$temp_array['direction_degree'] = $direction; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10934 |  |  | 			$temp_array['direction_shortname'] = "NNE"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10935 |  |  | 			$temp_array['direction_fullname'] = "North-Northeast"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10936 |  |  | 		} elseif ($direction >= 45 && $direction < 67.5){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10937 |  |  | 			$temp_array['direction_degree'] = $direction; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10938 |  |  | 			$temp_array['direction_shortname'] = "NE"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10939 |  |  | 			$temp_array['direction_fullname'] = "Northeast"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10940 |  |  | 		} elseif ($direction >= 67.5 && $direction < 90){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10941 |  |  | 			$temp_array['direction_degree'] = $direction; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10942 |  |  | 			$temp_array['direction_shortname'] = "ENE"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10943 |  |  | 			$temp_array['direction_fullname'] = "East-Northeast"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10944 |  |  | 		} elseif ($direction >= 90 && $direction < 112.5){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10945 |  |  | 			$temp_array['direction_degree'] = $direction; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10946 |  |  | 			$temp_array['direction_shortname'] = "E"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10947 |  |  | 			$temp_array['direction_fullname'] = "East"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10948 |  |  | 		} elseif ($direction >= 112.5 && $direction < 135){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10949 |  |  | 			$temp_array['direction_degree'] = $direction; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10950 |  |  | 			$temp_array['direction_shortname'] = "ESE"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10951 |  |  | 			$temp_array['direction_fullname'] = "East-Southeast"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10952 |  |  | 		} elseif ($direction >= 135 && $direction < 157.5){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10953 |  |  | 			$temp_array['direction_degree'] = $direction; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10954 |  |  | 			$temp_array['direction_shortname'] = "SE"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10955 |  |  | 			$temp_array['direction_fullname'] = "Southeast"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10956 |  |  | 		} elseif ($direction >= 157.5 && $direction < 180){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10957 |  |  | 			$temp_array['direction_degree'] = $direction; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10958 |  |  | 			$temp_array['direction_shortname'] = "SSE"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10959 |  |  | 			$temp_array['direction_fullname'] = "South-Southeast"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10960 |  |  | 		} elseif ($direction >= 180 && $direction < 202.5){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10961 |  |  | 			$temp_array['direction_degree'] = $direction; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10962 |  |  | 			$temp_array['direction_shortname'] = "S"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10963 |  |  | 			$temp_array['direction_fullname'] = "South"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10964 |  |  | 		} elseif ($direction >= 202.5 && $direction < 225){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10965 |  |  | 			$temp_array['direction_degree'] = $direction; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10966 |  |  | 			$temp_array['direction_shortname'] = "SSW"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10967 |  |  | 			$temp_array['direction_fullname'] = "South-Southwest"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10968 |  |  | 		} elseif ($direction >= 225 && $direction < 247.5){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10969 |  |  | 			$temp_array['direction_degree'] = $direction; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10970 |  |  | 			$temp_array['direction_shortname'] = "SW"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10971 |  |  | 			$temp_array['direction_fullname'] = "Southwest"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10972 |  |  | 		} elseif ($direction >= 247.5 && $direction < 270){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10973 |  |  | 			$temp_array['direction_degree'] = $direction; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10974 |  |  | 			$temp_array['direction_shortname'] = "WSW"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10975 |  |  | 			$temp_array['direction_fullname'] = "West-Southwest"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10976 |  |  | 		} elseif ($direction >= 270 && $direction < 292.5){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10977 |  |  | 			$temp_array['direction_degree'] = $direction; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10978 |  |  | 			$temp_array['direction_shortname'] = "W"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10979 |  |  | 			$temp_array['direction_fullname'] = "West"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10980 |  |  | 		} elseif ($direction >= 292.5 && $direction < 315){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10981 |  |  | 			$temp_array['direction_degree'] = $direction; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10982 |  |  | 			$temp_array['direction_shortname'] = "WNW"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10983 |  |  | 			$temp_array['direction_fullname'] = "West-Northwest"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10984 |  |  | 		} elseif ($direction >= 315 && $direction < 337.5){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10985 |  |  | 			$temp_array['direction_degree'] = $direction; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10986 |  |  | 			$temp_array['direction_shortname'] = "NW"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10987 |  |  | 			$temp_array['direction_fullname'] = "Northwest"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10988 |  |  | 		} elseif ($direction >= 337.5 && $direction < 360){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10989 |  |  | 			$temp_array['direction_degree'] = $direction; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10990 |  |  | 			$temp_array['direction_shortname'] = "NNW"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10991 |  |  | 			$temp_array['direction_fullname'] = "North-Northwest"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10992 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10993 |  |  | 		$direction_array[] = $temp_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10994 |  |  | 		return $direction_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10995 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10996 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10997 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10998 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10999 |  |  | 	* Gets the aircraft registration | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11000 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11001 |  |  | 	* @param String $flightaware_id the flight aware id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11002 |  |  | 	* @return String the aircraft registration | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11003 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11004 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11005 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11006 |  |  | 	public function getAircraftRegistration($flightaware_id) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11007 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11008 |  |  | 		global $globalFlightAwareUsername, $globalFlightAwarePassword; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11009 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11010 |  |  | 		$options = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11011 |  |  | 			'trace' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11012 |  |  | 			'exceptions' => 0, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11013 |  |  | 			'login' => $globalFlightAwareUsername, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11014 |  |  | 			'password' => $globalFlightAwarePassword, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11015 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11016 |  |  | 		$client = new SoapClient('http://flightxml.flightaware.com/soap/FlightXML2/wsdl', $options); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11017 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11018 |  |  | 		$params = array('faFlightID' => $flightaware_id); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11019 |  |  | 		$result = $client->AirlineFlightInfo($params); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11020 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11021 |  |  | 		if (isset($result->AirlineFlightInfoResult)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11022 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11023 |  |  | 			$registration = $result->AirlineFlightInfoResult->tailnumber; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11024 |  |  | 		} else return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11025 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11026 |  |  | 		$registration = $this->convertAircraftRegistration($registration); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11027 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11028 |  |  | 		return $registration; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11029 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11030 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11031 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11032 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11033 |  |  | 	* Gets the aircraft registration from ModeS | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11034 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11035 |  |  | 	* @param String $aircraft_modes the flight ModeS in hex | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11036 |  |  | 	* @return String the aircraft registration | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11037 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11038 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11039 |  |  | 	public function getAircraftRegistrationBymodeS($aircraft_modes) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11040 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11041 |  |  | 		$aircraft_modes = filter_var($aircraft_modes,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11042 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11043 |  |  | 		$query  = "SELECT aircraft_modes.Registration FROM aircraft_modes WHERE aircraft_modes.ModeS = :aircraft_modes ORDER BY FirstCreated DESC LIMIT 1"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11044 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11045 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11046 |  |  | 		$sth->execute(array(':aircraft_modes' => $aircraft_modes)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11047 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11048 |  |  | 		$row = $sth->fetch(PDO::FETCH_ASSOC); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11049 |  |  | 		$sth->closeCursor(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11050 |  |  | 		if (count($row) > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11051 |  |  | 		    //return $row['Registration']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11052 |  |  | 		    return $row['registration']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11053 |  |  | 		} else return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11054 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11055 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11056 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11057 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11058 |  |  | 	* Gets the aircraft type from ModeS | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11059 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11060 |  |  | 	* @param String $aircraft_modes the flight ModeS in hex | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11061 |  |  | 	* @return String the aircraft type | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11062 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11063 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11064 |  |  | 	public function getAircraftTypeBymodeS($aircraft_modes) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11065 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11066 |  |  | 		$aircraft_modes = filter_var($aircraft_modes,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11067 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11068 |  |  | 		$query  = "SELECT aircraft_modes.type_flight FROM aircraft_modes WHERE aircraft_modes.ModeS = :aircraft_modes ORDER BY FirstCreated DESC LIMIT 1"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11069 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11070 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11071 |  |  | 		$sth->execute(array(':aircraft_modes' => $aircraft_modes)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11072 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11073 |  |  | 		$row = $sth->fetch(PDO::FETCH_ASSOC); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11074 |  |  | 		$sth->closeCursor(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11075 |  |  | 		if (count($row) > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11076 |  |  | 		    if ($row['type_flight'] == null) return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11077 |  |  | 		    else return $row['type_flight']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11078 |  |  | 		} else return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11079 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11080 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11081 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11082 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11083 |  |  | 	* Gets Country from latitude/longitude | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11084 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11085 |  |  | 	* @param Float $latitude latitute of the flight | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11086 |  |  | 	* @param Float $longitude longitute of the flight | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11087 |  |  | 	* @return String the countrie | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11088 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11089 |  |  | 	public function getCountryFromLatitudeLongitude($latitude,$longitude) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11090 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11091 |  |  | 		global $globalDBdriver, $globalDebug; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11092 |  |  | 		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11093 |  |  | 		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11094 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11095 |  |  | 		$Connection = new Connection($this->db); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11096 |  |  | 		if (!$Connection->tableExists('countries')) return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11097 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11098 |  |  | 		try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11099 |  |  | 			/* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11100 |  |  | 			if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11101 |  |  | 				//$query  = "SELECT name, iso2, iso3 FROM countries WHERE Within(GeomFromText('POINT(:latitude :longitude)'), ogc_geom) LIMIT 1"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11102 |  |  | 				$query = "SELECT name, iso2, iso3 FROM countries WHERE Within(GeomFromText('POINT(".$longitude.' '.$latitude.")'), ogc_geom) LIMIT 1"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11103 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11104 |  |  | 			*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11105 |  |  | 			// This query seems to work both for MariaDB and PostgreSQL | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11106 |  |  | 			$query = "SELECT name,iso2,iso3 FROM countries WHERE ST_Within(ST_GeomFromText('POINT(".$longitude." ".$latitude.")',4326), ogc_geom) LIMIT 1"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11107 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11108 |  |  | 			$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11109 |  |  | 			//$sth->execute(array(':latitude' => $latitude,':longitude' => $longitude)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11110 |  |  | 			$sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11111 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11112 |  |  | 			$row = $sth->fetch(PDO::FETCH_ASSOC); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11113 |  |  | 			$sth->closeCursor(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11114 |  |  | 			if (count($row) > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11115 |  |  | 				return $row; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11116 |  |  | 			} else return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11117 |  |  | 		} catch (PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11118 |  |  | 			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11119 |  |  | 			return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11120 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11121 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11122 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11123 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11124 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11125 |  |  | 	* Gets Country from iso2 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11126 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11127 |  |  | 	* @param String $iso2 ISO2 country code | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11128 |  |  | 	* @return String the countrie | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11129 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11130 |  |  | 	public function getCountryFromISO2($iso2) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11131 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11132 |  |  | 		global $globalDBdriver, $globalDebug; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11133 |  |  | 		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11134 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11135 |  |  | 		$Connection = new Connection($this->db); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11136 |  |  | 		if (!$Connection->tableExists('countries')) return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11137 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11138 |  |  | 		try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11139 |  |  | 			$query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11140 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11141 |  |  | 			$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11142 |  |  | 			$sth->execute(array(':iso2' => $iso2)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11143 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11144 |  |  | 			$row = $sth->fetch(PDO::FETCH_ASSOC); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11145 |  |  | 			$sth->closeCursor(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11146 |  |  | 			if (count($row) > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11147 |  |  | 				return $row; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11148 |  |  | 			} else return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11149 |  |  | 		} catch (PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11150 |  |  | 			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11151 |  |  | 			return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11152 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11153 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11154 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11155 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11156 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11157 |  |  | 	* converts the registration code using the country prefix | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11158 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11159 |  |  | 	* @param String $registration the aircraft registration | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11160 |  |  | 	* @return String the aircraft registration | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11161 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11162 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11163 |  |  | 	public function convertAircraftRegistration($registration) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11164 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11165 |  |  | 		$registration = filter_var($registration,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11166 |  |  | 		$registration_prefix = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11167 |  |  | 		$registration_1 = substr($registration, 0, 1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11168 |  |  | 		$registration_2 = substr($registration, 0, 2); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11169 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11170 |  |  | 		//first get the prefix based on two characters | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11171 |  |  | 		$query  = "SELECT aircraft_registration.registration_prefix FROM aircraft_registration WHERE registration_prefix = :registration_2"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11172 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11173 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11174 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11175 |  |  | 		$sth->execute(array(':registration_2' => $registration_2)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11176 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11177 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11178 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11179 |  |  | 			$registration_prefix = $row['registration_prefix']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11180 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11181 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11182 |  |  | 		//if we didn't find a two chracter prefix lets just search the one with one character | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11183 |  |  | 		if ($registration_prefix == '') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11184 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11185 |  |  | 			$query  = "SELECT aircraft_registration.registration_prefix FROM aircraft_registration WHERE registration_prefix = :registration_1"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11186 |  |  | 			$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11187 |  |  | 			$sth->execute(array(':registration_1' => $registration_1)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11188 |  |  | 	         | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11189 |  |  | 			while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11190 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11191 |  |  | 				$registration_prefix = $row['registration_prefix']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11192 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11193 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11194 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11195 |  |  | 		//determine which characters are being used and convert the registration code appropiately | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11196 |  |  | 		if (strlen($registration_prefix) == 1) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11197 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11198 |  |  | 			if (0 === strpos($registration, 'N')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11199 |  |  | 				$registration = preg_replace("/^(.{1})/", "$1", $registration); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11200 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11201 |  |  | 				$registration = preg_replace("/^(.{1})/", "$1-", $registration); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11202 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11203 |  |  | 		} else if(strlen($registration_prefix) == 2){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11204 |  |  | 			if (0 === strpos($registration, 'N')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11205 |  |  | 				$registration = preg_replace("/^(.{2})/", "$1", $registration); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11206 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11207 |  |  | 				$registration = preg_replace("/^(.{2})/", "$1-", $registration); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11208 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11209 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11210 |  |  | 		return $registration; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11211 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11212 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11213 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11214 |  |  | 	* Country from the registration code | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11215 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11216 |  |  | 	* @param String $registration the aircraft registration | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11217 |  |  | 	* @return String the country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11218 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11219 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11220 |  |  | 	public function countryFromAircraftRegistration($registration) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11221 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11222 |  |  | 		$registration = filter_var($registration,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11223 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11224 |  |  | 		$registration_prefix = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11225 |  |  | 		$registration_test = explode('-',$registration); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11226 |  |  | 		$country = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11227 |  |  | 		if ($registration_test[0] != $registration) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11228 |  |  | 			$query  = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_1 LIMIT 1"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11229 |  |  | 	       | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11230 |  |  | 			$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11231 |  |  | 			$sth->execute(array(':registration_1' => $registration_test[0])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11232 |  |  | 			while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11233 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11234 |  |  | 				//$registration_prefix = $row['registration_prefix']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11235 |  |  | 				$country = $row['country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11236 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11237 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11238 |  |  |     			$registration_1 = substr($registration, 0, 1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11239 |  |  | 		        $registration_2 = substr($registration, 0, 2); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11240 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11241 |  |  | 			$country = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11242 |  |  | 			//first get the prefix based on two characters | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11243 |  |  | 			$query  = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_2 LIMIT 1"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11244 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11245 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11246 |  |  | 			$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11247 |  |  | 			$sth->execute(array(':registration_2' => $registration_2)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11248 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11249 |  |  | 			while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11250 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11251 |  |  | 				$registration_prefix = $row['registration_prefix']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11252 |  |  | 				$country = $row['country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11253 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11254 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11255 |  |  | 			//if we didn't find a two chracter prefix lets just search the one with one character | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11256 |  |  | 			if ($registration_prefix == "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11257 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11258 |  |  | 				$query  = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_1 LIMIT 1"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11259 |  |  | 	       | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11260 |  |  | 				$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11261 |  |  | 				$sth->execute(array(':registration_1' => $registration_1)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11262 |  |  | 	         | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11263 |  |  | 				while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11264 |  |  | 				{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11265 |  |  | 					//$registration_prefix = $row['registration_prefix']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11266 |  |  | 					$country = $row['country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11267 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11268 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11269 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11270 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11271 |  |  | 		return $country; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11272 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11273 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11274 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11275 |  |  | 	* Registration prefix from the registration code | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11276 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11277 |  |  | 	* @param String $registration the aircraft registration | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11278 |  |  | 	* @return String the registration prefix | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11279 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11280 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11281 |  |  | 	public function registrationPrefixFromAircraftRegistration($registration) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11282 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11283 |  |  | 		$registration = filter_var($registration,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11284 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11285 |  |  | 		$registration_prefix = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11286 |  |  | 		$registration_test = explode('-',$registration); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11287 |  |  | 		//$country = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11288 |  |  | 		if ($registration_test[0] != $registration) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11289 |  |  | 			$query  = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_1 LIMIT 1"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11290 |  |  | 	       | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11291 |  |  | 			$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11292 |  |  | 			$sth->execute(array(':registration_1' => $registration_test[0])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11293 |  |  | 			while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11294 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11295 |  |  | 				$registration_prefix = $row['registration_prefix']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11296 |  |  | 				//$country = $row['country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11297 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11298 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11299 |  |  |     			$registration_1 = substr($registration, 0, 1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11300 |  |  | 		        $registration_2 = substr($registration, 0, 2); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11301 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11302 |  |  | 			//first get the prefix based on two characters | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11303 |  |  | 			$query  = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_2 LIMIT 1"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11304 |  |  |        | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11305 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11306 |  |  | 			$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11307 |  |  | 			$sth->execute(array(':registration_2' => $registration_2)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11308 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11309 |  |  | 			while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11310 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11311 |  |  | 				$registration_prefix = $row['registration_prefix']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11312 |  |  | 				//$country = $row['country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11313 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11314 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11315 |  |  | 			//if we didn't find a two chracter prefix lets just search the one with one character | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11316 |  |  | 			if ($registration_prefix == "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11317 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11318 |  |  | 				$query  = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_1 LIMIT 1"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11319 |  |  | 	       | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11320 |  |  | 				$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11321 |  |  | 				$sth->execute(array(':registration_1' => $registration_1)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11322 |  |  | 	         | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11323 |  |  | 				while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11324 |  |  | 				{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11325 |  |  | 					$registration_prefix = $row['registration_prefix']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11326 |  |  | 					//$country = $row['country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11327 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11328 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11329 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11330 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11331 |  |  | 		return $registration_prefix; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11332 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11333 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11334 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11335 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11336 |  |  | 	* Country from the registration code | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11337 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11338 |  |  | 	* @param String $registration the aircraft registration | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11339 |  |  | 	* @return String the country | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11340 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11341 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11342 |  |  | 	public function countryFromAircraftRegistrationCode($registration) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11343 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11344 |  |  | 		$registration = filter_var($registration,FILTER_SANITIZE_STRING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11345 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11346 |  |  | 		$country = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11347 |  |  | 		$query  = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration LIMIT 1"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11348 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11349 |  |  | 		$sth->execute(array(':registration' => $registration)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11350 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11351 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11352 |  |  | 			$country = $row['country']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11353 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11354 |  |  | 		return $country; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11355 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11356 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11357 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11358 |  |  | 	* Set a new highlight value for a flight | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11359 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11360 |  |  | 	* @param String $flightaware_id flightaware_id from spotter_output table | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11361 |  |  | 	* @param String $highlight New highlight value | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11362 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11363 |  |  | 	public function setHighlightFlight($flightaware_id,$highlight) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11364 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11365 |  |  | 		$query  = "UPDATE spotter_output SET highlight = :highlight WHERE flightaware_id = :flightaware_id"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11366 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11367 |  |  | 		$sth->execute(array(':flightaware_id' => $flightaware_id, ':highlight' => $highlight)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11368 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11369 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11370 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11371 |  |  | 	* Set a new highlight value for a flight by Registration | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11372 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11373 |  |  | 	* @param String $registration Registration of the aircraft | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11374 |  |  | 	* @param String $date Date of spotted aircraft | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11375 |  |  | 	* @param String $highlight New highlight value | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11376 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11377 |  |  | 	public function setHighlightFlightByRegistration($registration,$highlight, $date = '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11378 |  |  | 		if ($date == '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11379 |  |  | 			$query  = "UPDATE spotter_output SET highlight = :highlight WHERE spotter_id IN (SELECT MAX(spotter_id) FROM spotter_output WHERE registration = :registration)"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11380 |  |  | 			$query_values = array(':registration' => $registration, ':highlight' => $highlight); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11381 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11382 |  |  | 			$query  = "UPDATE spotter_output SET highlight = :highlight WHERE registration = :registration AND date(date) = :date"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11383 |  |  | 			$query_values = array(':registration' => $registration, ':highlight' => $highlight,':date' => $date); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11384 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11385 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11386 |  |  | 		$sth->execute($query_values); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11387 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11388 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11389 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11390 |  |  | 	* Gets the short url from bit.ly | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11391 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11392 |  |  | 	* @param String $url the full url | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11393 |  |  | 	* @return String the bit.ly url | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11394 |  |  | 	* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11395 |  |  | 	*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11396 |  |  | 	public function getBitlyURL($url) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11397 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11398 |  |  | 		global $globalBitlyAccessToken; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11399 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11400 |  |  | 		if ($globalBitlyAccessToken == '') return $url; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11401 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11402 |  |  | 		$google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11403 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11404 |  |  | 		$ch = curl_init(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11405 |  |  | 		curl_setopt($ch, CURLOPT_HEADER, 0); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11406 |  |  | 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11407 |  |  | 		curl_setopt($ch, CURLOPT_URL, $google_url); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11408 |  |  | 		$bitly_data = curl_exec($ch); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11409 |  |  | 		curl_close($ch); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11410 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11411 |  |  | 		$bitly_data = json_decode($bitly_data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11412 |  |  | 		$bitly_url = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11413 |  |  | 		if ($bitly_data->status_txt = "OK"){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11414 |  |  | 			$bitly_url = $bitly_data->data->url; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11415 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11416 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11417 |  |  | 		return $bitly_url; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11418 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11419 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11420 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11421 |  |  | 	public function getOrderBy() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11422 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11423 |  |  | 		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_output.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_output.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_output.date DESC"),"distance_asc" => array("key" => "distance_asc","value" => "Distance - ASC","sql" => "ORDER BY distance ASC"),"distance_desc" => array("key" => "distance_desc","value" => "Distance - DESC","sql" => "ORDER BY distance DESC")); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11424 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11425 |  |  | 		return $orderby; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11426 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11427 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11428 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11429 |  |  | /* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11430 |  |  | 	public function importFromFlightAware() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11431 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11432 |  |  | 		global $globalFlightAwareUsername, $globalFlightAwarePassword, $globalLatitudeMax, $globalLatitudeMin, $globalLongitudeMax, $globalLongitudeMin, $globalAirportIgnore; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11433 |  |  | 		$Spotter = new Spotter($this->db); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11434 |  |  | 		$SpotterLive = new SpotterLive($this->db); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11435 |  |  | 		$options = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11436 |  |  | 		            'trace' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11437 |  |  | 		            'exceptions' => 0, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11438 |  |  | 		            'login' => $globalFlightAwareUsername, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11439 |  |  | 		            'password' => $globalFlightAwarePassword, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11440 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11441 |  |  | 		$client = new SoapClient('http://flightxml.flightaware.com/soap/FlightXML2/wsdl', $options); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11442 |  |  | 		$params = array('query' => '{range lat '.$globalLatitudeMin.' '.$globalLatitudeMax.'} {range lon '.$globalLongitudeMax.' '.$globalLongitudeMin.'} {true inAir}', 'howMany' => '15', 'offset' => '0'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11443 |  |  | 		$result = $client->SearchBirdseyeInFlight($params); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11444 |  |  | 		$dataFound = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11445 |  |  | 		$ignoreImport = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11446 |  |  | 		if (isset($result->SearchBirdseyeInFlightResult)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11447 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11448 |  |  | 			if (is_array($result->SearchBirdseyeInFlightResult->aircraft)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11449 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11450 |  |  | 				foreach($result->SearchBirdseyeInFlightResult->aircraft as $aircraft) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11451 |  |  | 				{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11452 |  |  | 					if (!strstr($aircraft->origin, 'L ') && !strstr($aircraft->destination, 'L ')) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11453 |  |  | 					{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11454 |  |  | 						foreach($globalAirportIgnore as $airportIgnore) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11455 |  |  | 						{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11456 |  |  | 							if ($aircraft->origin == $airportIgnore || $aircraft->destination == $airportIgnore) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11457 |  |  | 							{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11458 |  |  | 								$ignoreImport = true;  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11459 |  |  | 							} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11460 |  |  | 						} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11461 |  |  | 						if ($ignoreImport == false) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11462 |  |  | 						{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11463 |  |  | 							$flightaware_id = $aircraft->faFlightID; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11464 |  |  | 							$ident = $aircraft->ident; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11465 |  |  | 							$aircraft_type = $aircraft->type; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11466 |  |  | 							$departure_airport = $aircraft->origin; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11467 |  |  | 							$arrival_airport = $aircraft->destination; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11468 |  |  | 							$latitude = $aircraft->latitude; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11469 |  |  | 							$longitude = $aircraft->longitude; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11470 |  |  | 							$waypoints = $aircraft->waypoints; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11471 |  |  | 							$altitude = $aircraft->altitude; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11472 |  |  | 							$heading = $aircraft->heading; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11473 |  |  | 							$groundspeed = $aircraft->groundspeed; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11474 |  |  | 							$dataFound = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11475 |  |  | 							//gets the callsign from the last hour | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11476 |  |  | 							$last_hour_ident = $this->getIdentFromLastHour($ident); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11477 |  |  | 							//change the departure/arrival airport to NA if its not available | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11478 |  |  | 							if ($departure_airport == "" || $departure_airport == "---" || $departure_airport == "ZZZ" || $departure_airport == "ZZZZ") { $departure_airport = "NA"; } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11479 |  |  | 							if ($arrival_airport == "" || $arrival_airport == "---" || $arrival_airport == "ZZZ" || $arrival_airport == "ZZZZ") { $arrival_airport = "NA"; } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11480 |  |  | 							//if there was no aircraft with the same callsign within the last hour and go post it into the archive | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11481 |  |  | 							if($last_hour_ident == "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11482 |  |  | 							{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11483 |  |  | 								//adds the spotter data for the archive | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11484 |  |  | 								$Spotter->addSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11485 |  |  | 							} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11486 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11487 |  |  | 							//adds the spotter LIVE data | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11488 |  |  | 							$SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11489 |  |  | 						} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11490 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11491 |  |  | 					$ignoreImport = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11492 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11493 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11494 |  |  | 				if (!strstr($result->SearchBirdseyeInFlightResult->aircraft->origin, 'L ') && !strstr($result->SearchBirdseyeInFlightResult->aircraft->destination, 'L ')) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11495 |  |  | 				{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11496 |  |  | 					foreach($globalAirportIgnore as $airportIgnore) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11497 |  |  | 					{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11498 |  |  | 						foreach($globalAirportIgnore as $airportIgnore) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11499 |  |  | 						{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11500 |  |  | 							if ($aircraft->origin == $airportIgnore || $aircraft->destination == $airportIgnore) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11501 |  |  | 							{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11502 |  |  | 								$ignoreImport = true;  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11503 |  |  | 							} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11504 |  |  | 						} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11505 |  |  | 						if ($ignoreImport == false) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11506 |  |  | 						{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11507 |  |  | 							$flightaware_id = $result->SearchBirdseyeInFlightResult->aircraft->faFlightID; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11508 |  |  | 							$ident = $result->SearchBirdseyeInFlightResult->aircraft->ident; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11509 |  |  | 							$aircraft_type = $result->SearchBirdseyeInFlightResult->aircraft->type; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11510 |  |  | 							$departure_airport = $result->SearchBirdseyeInFlightResult->aircraft->origin; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11511 |  |  | 							$arrival_airport = $result->SearchBirdseyeInFlightResult->aircraft->destination; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11512 |  |  | 							$latitude = $result->SearchBirdseyeInFlightResult->aircraft->latitude; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11513 |  |  | 							$longitude = $result->SearchBirdseyeInFlightResult->aircraft->longitude; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11514 |  |  | 							$waypoints = $result->SearchBirdseyeInFlightResult->aircraft->waypoints; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11515 |  |  | 							$altitude = $result->SearchBirdseyeInFlightResult->aircraft->altitude; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11516 |  |  | 							$heading = $result->SearchBirdseyeInFlightResult->aircraft->heading; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11517 |  |  | 							$groundspeed = $result->SearchBirdseyeInFlightResult->aircraft->groundspeed; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11518 |  |  | 							$dataFound = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11519 |  |  | 							//gets the callsign from the last hour | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11520 |  |  | 							$last_hour_ident = $this->getIdentFromLastHour($ident); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11521 |  |  | 							//change the departure/arrival airport to NA if its not available | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11522 |  |  | 							if ($departure_airport == "" || $departure_airport == "---" || $departure_airport == "ZZZ" || $departure_airport == "ZZZZ") { $departure_airport = "NA"; } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11523 |  |  | 							if ($arrival_airport == "" || $arrival_airport == "---" || $arrival_airport == "ZZZ" || $arrival_airport == "ZZZZ") { $arrival_airport = "NA"; } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11524 |  |  | 							//if there was no aircraft with the same callsign within the last hour and go post it into the archive | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11525 |  |  | 							if($last_hour_ident == "") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11526 |  |  | 							{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11527 |  |  | 								//adds the spotter data for the archive | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11528 |  |  | 								$Spotter->addSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11529 |  |  | 							} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11530 |  |  | 							//adds the spotter LIVE data | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11531 |  |  | 							$SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11532 |  |  | 						} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11533 |  |  | 						$ignoreImport = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11534 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11535 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11536 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11537 |  |  | 		}  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11538 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11539 |  |  | */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11540 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11541 |  |  | 	// Update flights data when new data in DB | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11542 |  |  | 	public function updateFieldsFromOtherTables() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11543 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11544 |  |  | 		global $globalDebug, $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11545 |  |  | 		$Image = new Image($this->db); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11546 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11547 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11548 |  |  | 		// routes | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11549 |  |  | 		if ($globalDebug) print "Routes...\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11550 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11551 |  |  | 			$query = "SELECT spotter_output.spotter_id, routes.FromAirport_ICAO, routes.ToAirport_ICAO FROM spotter_output, routes WHERE spotter_output.ident = routes.CallSign AND ( spotter_output.departure_airport_icao != routes.FromAirport_ICAO OR spotter_output.arrival_airport_icao != routes.ToAirport_ICAO) AND routes.FromAirport_ICAO != '' AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 DAY)"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11552 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11553 |  |  | 			$query = "SELECT spotter_output.spotter_id, routes.FromAirport_ICAO, routes.ToAirport_ICAO FROM spotter_output, routes WHERE spotter_output.ident = routes.CallSign AND ( spotter_output.departure_airport_icao != routes.FromAirport_ICAO OR spotter_output.arrival_airport_icao != routes.ToAirport_ICAO) AND routes.FromAirport_ICAO != '' AND spotter_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '15 DAYS'"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11554 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11555 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11556 |  |  | 		$sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11557 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11558 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11559 |  |  | 			$departure_airport_array = $this->getAllAirportInfo($row['fromairport_icao']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11560 |  |  | 			$arrival_airport_array = $this->getAllAirportInfo($row['toairport_icao']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11561 |  |  | 			if (count($departure_airport_array) > 0 && count($arrival_airport_array) > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11562 |  |  | 				$update_query="UPDATE spotter_output SET departure_airport_icao = :fromicao, arrival_airport_icao = :toicao, departure_airport_name = :departure_airport_name, departure_airport_city = :departure_airport_city, departure_airport_country = :departure_airport_country, arrival_airport_name = :arrival_airport_name, arrival_airport_city = :arrival_airport_city, arrival_airport_country = :arrival_airport_country WHERE spotter_id = :spotter_id"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11563 |  |  | 				$sthu = $this->db->prepare($update_query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11564 |  |  | 				$sthu->execute(array(':fromicao' => $row['fromairport_icao'],':toicao' => $row['toairport_icao'],':spotter_id' => $row['spotter_id'],':departure_airport_name' => $departure_airport_array[0]['name'],':departure_airport_city' => $departure_airport_array[0]['city'],':departure_airport_country' => $departure_airport_array[0]['country'],':arrival_airport_name' => $arrival_airport_array[0]['name'],':arrival_airport_city' => $arrival_airport_array[0]['city'],':arrival_airport_country' => $arrival_airport_array[0]['country'])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11565 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11566 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11567 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11568 |  |  | 		if ($globalDebug) print "Airlines...\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11569 |  |  | 		//airlines | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11570 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11571 |  |  | 			$query  = "SELECT spotter_output.spotter_id, spotter_output.ident FROM spotter_output WHERE (spotter_output.airline_name = '' OR spotter_output.airline_name = 'Not Available') AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 DAY)"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11572 |  |  | 		} elseif ($globalDBdriver == 'pgsql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11573 |  |  | 			$query  = "SELECT spotter_output.spotter_id, spotter_output.ident FROM spotter_output WHERE (spotter_output.airline_name = '' OR spotter_output.airline_name = 'Not Available') AND spotter_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '15 DAYS'"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11574 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11575 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11576 |  |  | 		$sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11577 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11578 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11579 |  |  | 			if (is_numeric(substr($row['ident'], -1, 1))) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11580 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11581 |  |  | 				$fromsource = NULL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11582 |  |  | 				if (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11583 |  |  | 				elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') $fromsource = 'ivao'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11584 |  |  | 				elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11585 |  |  | 				elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11586 |  |  | 				$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 3),$fromsource); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11587 |  |  | 				if (isset($airline_array[0]['name'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11588 |  |  | 					$update_query  = "UPDATE spotter_output SET spotter_output.airline_name = :airline_name, spotter_output.airline_icao = :airline_icao, spotter_output.airline_country = :airline_country, spotter_output.airline_type = :airline_type WHERE spotter_output.spotter_id = :spotter_id"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11589 |  |  | 					$sthu = $this->db->prepare($update_query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11590 |  |  | 					$sthu->execute(array(':airline_name' => $airline_array[0]['name'],':airline_icao' => $airline_array[0]['icao'], ':airline_country' => $airline_array[0]['country'], ':airline_type' => $airline_array[0]['type'], ':spotter_id' => $row['spotter_id'])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11591 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11592 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11593 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11594 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11595 |  |  | 		if ($globalDebug) print "Remove Duplicate in aircraft_modes...\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11596 |  |  | 		//duplicate modes | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11597 |  |  | 		$query = "DELETE aircraft_modes FROM aircraft_modes LEFT OUTER JOIN (SELECT max(`AircraftID`) as `AircraftID`,`ModeS` FROM `aircraft_modes` group by ModeS) as KeepRows ON aircraft_modes.AircraftID = KeepRows.AircraftID WHERE KeepRows.AircraftID IS NULL"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11598 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11599 |  |  | 		$sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11600 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11601 |  |  | 		if ($globalDebug) print "Aircraft...\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11602 |  |  | 		//aircraft | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11603 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11604 |  |  | 			$query  = "SELECT spotter_output.spotter_id, spotter_output.aircraft_icao, spotter_output.registration FROM spotter_output WHERE (spotter_output.aircraft_name = '' OR spotter_output.aircraft_name = 'Not Available') AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11605 |  |  | 		} elseif ($globalDBdriver == 'pgsql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11606 |  |  | 			$query  = "SELECT spotter_output.spotter_id, spotter_output.aircraft_icao, spotter_output.registration FROM spotter_output WHERE (spotter_output.aircraft_name = '' OR spotter_output.aircraft_name = 'Not Available') AND spotter_output.date >= now() AT TIME ZONE 'UTC' - INERVAL '15 DAYS'"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11607 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11608 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11609 |  |  | 		$sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11610 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11611 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11612 |  |  | 			if ($row['aircraft_icao'] != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11613 |  |  | 				$aircraft_name = $this->getAllAircraftInfo($row['aircraft_icao']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11614 |  |  | 				if ($row['registration'] != ""){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11615 |  |  | 					$image_array = $Image->getSpotterImage($row['registration']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11616 |  |  | 					if (!isset($image_array[0]['registration'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11617 |  |  | 						$Image->addSpotterImage($row['registration']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11618 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11619 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11620 |  |  | 				if (count($aircraft_name) > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11621 |  |  | 					$update_query  = "UPDATE spotter_output SET spotter_output.aircraft_name = :aircraft_name, spotter_output.aircraft_manufacturer = :aircraft_manufacturer WHERE spotter_output.spotter_id = :spotter_id"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11622 |  |  | 					$sthu = $this->db->prepare($update_query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11623 |  |  | 					$sthu->execute(array(':aircraft_name' => $aircraft_name[0]['type'], ':aircraft_manufacturer' => $aircraft_name[0]['manufacturer'], ':spotter_id' => $row['spotter_id'])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11624 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11625 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11626 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11627 |  |  | 	}	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11628 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11629 |  |  | 	// Update arrival airports for data already in DB | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11630 |  |  | 	public function updateArrivalAirports() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11631 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11632 |  |  | 		global $globalDebug, $globalDBdriver, $globalClosestMinDist; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11633 |  |  | 		$query = "SELECT spotter_output.spotter_id, spotter_output.last_latitude, spotter_output.last_longitude, spotter_output.last_altitude, spotter_output.arrival_airport_icao, spotter_output.real_arrival_airport_icao FROM spotter_output"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11634 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11635 |  |  | 		$sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11636 |  |  | 		while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11637 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11638 |  |  | 			if ($row['last_latitude'] != '' && $row['last_longitude'] != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11639 |  |  | 				$closestAirports = $this->closestAirports($row['last_latitude'],$row['last_longitude'],$globalClosestMinDist); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11640 |  |  | 				$airport_icao = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11641 |  |  | 				 if (isset($closestAirports[0])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11642 |  |  | 					if ($row['arrival_airport_icao'] == $closestAirports[0]['icao']) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11643 |  |  | 						$airport_icao = $closestAirports[0]['icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11644 |  |  | 						if ($globalDebug) echo "\o/ 1st ---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11645 |  |  | 					} elseif (count($closestAirports > 1) && $row['arrival_airport_icao'] != '' && $row['arrival_airport_icao'] != 'NA') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11646 |  |  | 						foreach ($closestAirports as $airport) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11647 |  |  | 							if ($row['arrival_airport_icao'] == $airport['icao']) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11648 |  |  | 								$airport_icao = $airport['icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11649 |  |  | 								if ($globalDebug) echo "\o/ try --++ Find arrival airport. airport_icao : ".$airport_icao."\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11650 |  |  | 								break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11651 |  |  | 							} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11652 |  |  | 						} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11653 |  |  | 					} elseif ($row['last_altitude'] == 0 || ($row['last_altitude'] != '' && ($closestAirports[0]['altitude'] <= $row['last_altitude']*100+1000 && $row['last_altitude']*100 < $closestAirports[0]['altitude']+5000))) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11654 |  |  | 						$airport_icao = $closestAirports[0]['icao']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11655 |  |  | 						if ($globalDebug) echo "\o/ NP --++ Find arrival airport. Airport ICAO : ".$airport_icao." !  Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11656 |  |  | 					} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11657 |  |  | 						if ($globalDebug) echo "----- Can't find arrival airport. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11658 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11659 |  |  | 				} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11660 |  |  | 					if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist."\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11661 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11662 |  |  | 				if ($row['real_arrival_airport_icao'] != $airport_icao) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11663 |  |  | 					if ($globalDebug) echo "Updating airport to ".$airport_icao."...\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11664 |  |  | 					$update_query="UPDATE spotter_output SET real_arrival_airport_icao = :airport_icao WHERE spotter_id = :spotter_id"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11665 |  |  | 					$sthu = $this->db->prepare($update_query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11666 |  |  | 					$sthu->execute(array(':airport_icao' => $airport_icao,':spotter_id' => $row['spotter_id'])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11667 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11668 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11669 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11670 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11671 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11672 |  |  | 	public function closestAirports($origLat,$origLon,$dist = 10) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11673 |  |  | 		global $globalDBdriver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11674 |  |  | 		$dist = number_format($dist*0.621371,2,'.',''); // convert km to mile | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11675 |  |  | /* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11676 |  |  | 		$query="SELECT name, icao, latitude, longitude, altitude, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - abs(latitude))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(abs(latitude)*pi()/180)*POWER(SIN(($origLon-longitude)*pi()/180/2),2))) as distance  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11677 |  |  |                       FROM airport WHERE longitude between ($origLon-$dist/abs(cos(radians($origLat))*69)) and ($origLon+$dist/abs(cos(radians($origLat))*69)) and latitude between ($origLat-($dist/69)) and ($origLat+($dist/69))  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11678 |  |  |                       having distance < $dist ORDER BY distance limit 100;"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11679 |  |  | */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11680 |  |  | 		if ($globalDBdriver == 'mysql') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11681 |  |  | 			$query="SELECT name, icao, latitude, longitude, altitude, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(latitude*pi()/180)*POWER(SIN(($origLon-longitude)*pi()/180/2),2))) as distance  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11682 |  |  | 	                      FROM airport WHERE longitude between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat)*69)) and latitude between ($origLat-($dist/69)) and ($origLat+($dist/69))  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11683 |  |  | 	                      AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(latitude*pi()/180)*POWER(SIN(($origLon-longitude)*pi()/180/2),2)))) < $dist ORDER BY distance limit 100;"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11684 |  |  |                 } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11685 |  |  | 			$query="SELECT name, icao, latitude, longitude, altitude, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(longitude as double precision))*pi()/180/2),2))) as distance  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11686 |  |  | 	                      FROM airport WHERE CAST(longitude as double precision) between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat))*69) and CAST(latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69))  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11687 |  |  | 	                      AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(longitude as double precision))*pi()/180/2),2)))) < $dist ORDER BY distance limit 100;"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11688 |  |  |     		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11689 |  |  | 		$sth = $this->db->prepare($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11690 |  |  | 		$sth->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11691 |  |  | 		return $sth->fetchAll(PDO::FETCH_ASSOC); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11692 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11693 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11694 |  |  | /* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11695 |  |  | $Spotter = new Spotter(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11696 |  |  | print_r($Spotter->closestAirports('-19.9813','-47.8286',10)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11697 |  |  | */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11698 |  |  | /* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11699 |  |  | $Spotter = new Spotter(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11700 |  |  | $da = $Spotter->countAllDetectedArrivalAirports(true,0,'',true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11701 |  |  | $aa = $Spotter->countAllArrivalAirports(true,0,'',true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11702 |  |  | print_r($da); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11703 |  |  | print_r($aa); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11704 |  |  | print_r(array_merge($da,$aa)); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 11705 |  |  | */ | 
            
                                                        
            
                                    
            
            
                | 11706 |  |  | ?> | 
            
                        
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.