| @@ -8,7 +8,9 @@ discard block | ||
| 8 | 8 |  	public function __construct($dbc = null) { | 
| 9 | 9 | $Connection = new Connection($dbc); | 
| 10 | 10 | $this->db = $Connection->db(); | 
| 11 | -		if ($this->db === null) die('Error: No DB connection. (Marine)'); | |
| 11 | +		if ($this->db === null) { | |
| 12 | +			die('Error: No DB connection. (Marine)'); | |
| 13 | + } | |
| 12 | 14 | } | 
| 13 | 15 | |
| 14 | 16 | /** | 
| @@ -30,7 +32,9 @@ discard block | ||
| 30 | 32 |  		if (isset($filter[0]['source'])) { | 
| 31 | 33 | $filters = array_merge($filters,$filter); | 
| 32 | 34 | } | 
| 33 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); | |
| 35 | +		if (is_array($globalFilter)) { | |
| 36 | + $filter = array_merge($filter,$globalFilter); | |
| 37 | + } | |
| 34 | 38 | $filter_query_join = ''; | 
| 35 | 39 | $filter_query_where = ''; | 
| 36 | 40 |  		foreach($filters as $flt) { | 
| @@ -72,8 +76,11 @@ discard block | ||
| 72 | 76 | $filter_query_where .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'"; | 
| 73 | 77 | } | 
| 74 | 78 | } | 
| 75 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; | |
| 76 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; | |
| 79 | +		if ($filter_query_where == '' && $where) { | |
| 80 | + $filter_query_where = ' WHERE'; | |
| 81 | +		} elseif ($filter_query_where != '' && $and) { | |
| 82 | + $filter_query_where .= ' AND'; | |
| 83 | + } | |
| 77 | 84 |  		if ($filter_query_where != '') { | 
| 78 | 85 |  			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); | 
| 79 | 86 | } | 
| @@ -127,32 +134,54 @@ discard block | ||
| 127 | 134 | $temp_array['spotter_id'] = $row['spotter_archive_id']; | 
| 128 | 135 |  			} elseif (isset($row['spotter_archive_output_id'])) { | 
| 129 | 136 | $temp_array['spotter_id'] = $row['spotter_archive_output_id']; | 
| 130 | - */} | |
| 131 | -			elseif (isset($row['marineid'])) { | |
| 137 | +			*/} elseif (isset($row['marineid'])) { | |
| 132 | 138 | $temp_array['marine_id'] = $row['marineid']; | 
| 133 | 139 |  			} else { | 
| 134 | 140 | $temp_array['marine_id'] = ''; | 
| 135 | 141 | } | 
| 136 | - if (isset($row['fammarine_id'])) $temp_array['fammarine_id'] = $row['fammarine_id']; | |
| 137 | - if (isset($row['mmsi'])) $temp_array['mmsi'] = $row['mmsi']; | |
| 138 | - if (isset($row['type'])) $temp_array['type'] = $row['type']; | |
| 139 | - if (isset($row['type_id'])) $temp_array['type_id'] = $row['type_id']; | |
| 140 | - if (isset($row['ident'])) $temp_array['ident'] = $row['ident']; | |
| 141 | - if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude']; | |
| 142 | - if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude']; | |
| 143 | - if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source']; | |
| 142 | +			if (isset($row['fammarine_id'])) { | |
| 143 | + $temp_array['fammarine_id'] = $row['fammarine_id']; | |
| 144 | + } | |
| 145 | +			if (isset($row['mmsi'])) { | |
| 146 | + $temp_array['mmsi'] = $row['mmsi']; | |
| 147 | + } | |
| 148 | +			if (isset($row['type'])) { | |
| 149 | + $temp_array['type'] = $row['type']; | |
| 150 | + } | |
| 151 | +			if (isset($row['type_id'])) { | |
| 152 | + $temp_array['type_id'] = $row['type_id']; | |
| 153 | + } | |
| 154 | +			if (isset($row['ident'])) { | |
| 155 | + $temp_array['ident'] = $row['ident']; | |
| 156 | + } | |
| 157 | +			if (isset($row['latitude'])) { | |
| 158 | + $temp_array['latitude'] = $row['latitude']; | |
| 159 | + } | |
| 160 | +			if (isset($row['longitude'])) { | |
| 161 | + $temp_array['longitude'] = $row['longitude']; | |
| 162 | + } | |
| 163 | +			if (isset($row['format_source'])) { | |
| 164 | + $temp_array['format_source'] = $row['format_source']; | |
| 165 | + } | |
| 144 | 166 |  			if (isset($row['heading'])) { | 
| 145 | 167 | $temp_array['heading'] = $row['heading']; | 
| 146 | 168 | $heading_direction = $this->parseDirection($row['heading']); | 
| 147 | - if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; | |
| 169 | +				if (isset($heading_direction[0]['direction_fullname'])) { | |
| 170 | + $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; | |
| 171 | + } | |
| 172 | + } | |
| 173 | +			if (isset($row['ground_speed'])) { | |
| 174 | + $temp_array['ground_speed'] = $row['ground_speed']; | |
| 148 | 175 | } | 
| 149 | - if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; | |
| 150 | 176 | |
| 151 | 177 | if(isset($temp_array['mmsi']) && $temp_array['mmsi'] != "") | 
| 152 | 178 |  			{ | 
| 153 | 179 | $Image = new Image($this->db); | 
| 154 | - if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); | |
| 155 | - else $image_array = $Image->getMarineImage($temp_array['mmsi']); | |
| 180 | +				if (isset($temp_array['ident']) && $temp_array['ident'] != '') { | |
| 181 | + $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); | |
| 182 | +				} else { | |
| 183 | + $image_array = $Image->getMarineImage($temp_array['mmsi']); | |
| 184 | + } | |
| 156 | 185 | unset($Image); | 
| 157 | 186 |  				if (count($image_array) > 0) { | 
| 158 | 187 | $temp_array['image'] = $image_array[0]['image']; | 
| @@ -204,13 +233,21 @@ discard block | ||
| 204 | 233 | } | 
| 205 | 234 | |
| 206 | 235 | $fromsource = NULL; | 
| 207 | - if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name']; | |
| 208 | - if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country']; | |
| 209 | - if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance']; | |
| 236 | +			if (isset($row['source_name']) && $row['source_name'] != '') { | |
| 237 | + $temp_array['source_name'] = $row['source_name']; | |
| 238 | + } | |
| 239 | +			if (isset($row['over_country']) && $row['over_country'] != '') { | |
| 240 | + $temp_array['over_country'] = $row['over_country']; | |
| 241 | + } | |
| 242 | +			if (isset($row['distance']) && $row['distance'] != '') { | |
| 243 | + $temp_array['distance'] = $row['distance']; | |
| 244 | + } | |
| 210 | 245 | $temp_array['query_number_rows'] = $num_rows; | 
| 211 | 246 | $spotter_array[] = $temp_array; | 
| 212 | 247 | } | 
| 213 | - if ($num_rows == 0) return array(); | |
| 248 | +		if ($num_rows == 0) { | |
| 249 | + return array(); | |
| 250 | + } | |
| 214 | 251 | $spotter_array[0]['query_number_rows'] = $num_rows; | 
| 215 | 252 | return $spotter_array; | 
| 216 | 253 | } | 
| @@ -236,8 +273,12 @@ discard block | ||
| 236 | 273 |  			{ | 
| 237 | 274 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; | 
| 238 | 275 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; | 
| 239 | - } else $limit_query = ""; | |
| 240 | - } else $limit_query = ""; | |
| 276 | +			} else { | |
| 277 | + $limit_query = ""; | |
| 278 | + } | |
| 279 | +		} else { | |
| 280 | + $limit_query = ""; | |
| 281 | + } | |
| 241 | 282 | if ($sort != "") | 
| 242 | 283 |  		{ | 
| 243 | 284 | $search_orderby_array = $this->getOrderBy(); | 
| @@ -261,7 +302,9 @@ discard block | ||
| 261 | 302 | global $global_query; | 
| 262 | 303 | |
| 263 | 304 |  		date_default_timezone_set('UTC'); | 
| 264 | - if ($id == '') return array(); | |
| 305 | +		if ($id == '') { | |
| 306 | + return array(); | |
| 307 | + } | |
| 265 | 308 | $additional_query = "marine_output.fammarine_id = :id"; | 
| 266 | 309 |  		$query_values = array(':id' => $id); | 
| 267 | 310 | $query = $global_query." WHERE ".$additional_query." "; | 
| @@ -404,8 +447,11 @@ discard block | ||
| 404 | 447 | $query .= " ORDER BY marine_output.source_name ASC"; | 
| 405 | 448 | |
| 406 | 449 | $sth = $this->db->prepare($query); | 
| 407 | - if (!empty($query_values)) $sth->execute($query_values); | |
| 408 | - else $sth->execute(); | |
| 450 | +		if (!empty($query_values)) { | |
| 451 | + $sth->execute($query_values); | |
| 452 | +		} else { | |
| 453 | + $sth->execute(); | |
| 454 | + } | |
| 409 | 455 | |
| 410 | 456 | $source_array = array(); | 
| 411 | 457 | $temp_array = array(); | 
| @@ -460,8 +506,11 @@ discard block | ||
| 460 | 506 | $sth = $this->db->prepare($query); | 
| 461 | 507 |  		$sth->execute(array(':mmsi' => $mmsi)); | 
| 462 | 508 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); | 
| 463 | - if (isset($result[0])) return $result[0]; | |
| 464 | - else return array(); | |
| 509 | +		if (isset($result[0])) { | |
| 510 | + return $result[0]; | |
| 511 | +		} else { | |
| 512 | + return array(); | |
| 513 | + } | |
| 465 | 514 | } | 
| 466 | 515 | |
| 467 | 516 | /** | 
| @@ -495,7 +544,9 @@ discard block | ||
| 495 | 544 | date_default_timezone_set($globalTimezone); | 
| 496 | 545 | $datetime = new DateTime(); | 
| 497 | 546 |  			$offset = $datetime->format('P'); | 
| 498 | - } else $offset = '+00:00'; | |
| 547 | +		} else { | |
| 548 | + $offset = '+00:00'; | |
| 549 | + } | |
| 499 | 550 | |
| 500 | 551 |  		if ($globalDBdriver == 'mysql') { | 
| 501 | 552 | $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date | 
| @@ -720,9 +771,15 @@ discard block | ||
| 720 | 771 | $latitude = 0; | 
| 721 | 772 | $longitude = 0; | 
| 722 | 773 | } | 
| 723 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; | |
| 724 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; | |
| 725 | - if ($arrival_date == '') $arrival_date = NULL; | |
| 774 | +                if ($heading == '' || $Common->isInteger($heading) === false) { | |
| 775 | + $heading = 0; | |
| 776 | + } | |
| 777 | +                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) { | |
| 778 | + $groundspeed = 0; | |
| 779 | + } | |
| 780 | +                if ($arrival_date == '') { | |
| 781 | + $arrival_date = NULL; | |
| 782 | + } | |
| 726 | 783 | $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) | 
| 727 | 784 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)"; | 
| 728 | 785 | |
| @@ -830,7 +887,9 @@ discard block | ||
| 830 | 887 | global $globalDBdriver, $globalArchive; | 
| 831 | 888 | //$filter_query = $this->getFilter($filters,true,true); | 
| 832 | 889 | $Connection= new Connection($this->db); | 
| 833 | -		if (!$Connection->tableExists('countries')) return array(); | |
| 890 | +		if (!$Connection->tableExists('countries')) { | |
| 891 | + return array(); | |
| 892 | + } | |
| 834 | 893 |  		require_once('class.SpotterLive.php'); | 
| 835 | 894 |  		if (!isset($globalArchive) || $globalArchive !== TRUE) { | 
| 836 | 895 | $MarineLive = new MarineLive($this->db); | 
| @@ -874,7 +933,9 @@ discard block | ||
| 874 | 933 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT fammarine_id,over_country FROM marine_archive".$filter_query.") l ON c.iso2 = l.over_country "; | 
| 875 | 934 | } | 
| 876 | 935 | $query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC"; | 
| 877 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; | |
| 936 | +		if ($limit) { | |
| 937 | + $query .= " LIMIT 10 OFFSET 0"; | |
| 938 | + } | |
| 878 | 939 | |
| 879 | 940 | $sth = $this->db->prepare($query); | 
| 880 | 941 | $sth->execute(); | 
| @@ -908,12 +969,18 @@ discard block | ||
| 908 | 969 | $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count | 
| 909 | 970 | FROM marine_output".$filter_query." marine_output.ident <> ''"; | 
| 910 | 971 |  		 if ($olderthanmonths > 0) { | 
| 911 | - if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; | |
| 912 | - else $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; | |
| 972 | +			if ($globalDBdriver == 'mysql') { | |
| 973 | + $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; | |
| 974 | +			} else { | |
| 975 | + $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; | |
| 976 | + } | |
| 913 | 977 | } | 
| 914 | 978 |  		if ($sincedate != '') { | 
| 915 | - if ($globalDBdriver == 'mysql') $query .= " AND marine_output.date > '".$sincedate."'"; | |
| 916 | -			else $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; | |
| 979 | +			if ($globalDBdriver == 'mysql') { | |
| 980 | + $query .= " AND marine_output.date > '".$sincedate."'"; | |
| 981 | +			} else { | |
| 982 | +				$query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; | |
| 983 | + } | |
| 917 | 984 | } | 
| 918 | 985 | $query_values = array(); | 
| 919 | 986 |  		if ($year != '') { | 
| @@ -944,7 +1011,9 @@ discard block | ||
| 944 | 1011 | } | 
| 945 | 1012 | } | 
| 946 | 1013 | $query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC"; | 
| 947 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; | |
| 1014 | +		if ($limit) { | |
| 1015 | + $query .= " LIMIT 10 OFFSET 0"; | |
| 1016 | + } | |
| 948 | 1017 | |
| 949 | 1018 | $sth = $this->db->prepare($query); | 
| 950 | 1019 | $sth->execute($query_values); | 
| @@ -979,7 +1048,9 @@ discard block | ||
| 979 | 1048 | date_default_timezone_set($globalTimezone); | 
| 980 | 1049 | $datetime = new DateTime(); | 
| 981 | 1050 |  			$offset = $datetime->format('P'); | 
| 982 | - } else $offset = '+00:00'; | |
| 1051 | +		} else { | |
| 1052 | + $offset = '+00:00'; | |
| 1053 | + } | |
| 983 | 1054 | |
| 984 | 1055 |  		if ($globalDBdriver == 'mysql') { | 
| 985 | 1056 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count | 
| @@ -1029,7 +1100,9 @@ discard block | ||
| 1029 | 1100 | date_default_timezone_set($globalTimezone); | 
| 1030 | 1101 | $datetime = new DateTime(); | 
| 1031 | 1102 |  			$offset = $datetime->format('P'); | 
| 1032 | - } else $offset = '+00:00'; | |
| 1103 | +		} else { | |
| 1104 | + $offset = '+00:00'; | |
| 1105 | + } | |
| 1033 | 1106 | $filter_query = $this->getFilter($filters,true,true); | 
| 1034 | 1107 |  		if ($globalDBdriver == 'mysql') { | 
| 1035 | 1108 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count | 
| @@ -1075,7 +1148,9 @@ discard block | ||
| 1075 | 1148 | date_default_timezone_set($globalTimezone); | 
| 1076 | 1149 | $datetime = new DateTime(); | 
| 1077 | 1150 |  			$offset = $datetime->format('P'); | 
| 1078 | - } else $offset = '+00:00'; | |
| 1151 | +		} else { | |
| 1152 | + $offset = '+00:00'; | |
| 1153 | + } | |
| 1079 | 1154 | $filter_query = $this->getFilter($filters,true,true); | 
| 1080 | 1155 |  		if ($globalDBdriver == 'mysql') { | 
| 1081 | 1156 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count | 
| @@ -1123,7 +1198,9 @@ discard block | ||
| 1123 | 1198 | date_default_timezone_set($globalTimezone); | 
| 1124 | 1199 | $datetime = new DateTime(); | 
| 1125 | 1200 |  			$offset = $datetime->format('P'); | 
| 1126 | - } else $offset = '+00:00'; | |
| 1201 | +		} else { | |
| 1202 | + $offset = '+00:00'; | |
| 1203 | + } | |
| 1127 | 1204 | |
| 1128 | 1205 |  		if ($globalDBdriver == 'mysql') { | 
| 1129 | 1206 | $query = "SELECT YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count | 
| @@ -1172,7 +1249,9 @@ discard block | ||
| 1172 | 1249 | date_default_timezone_set($globalTimezone); | 
| 1173 | 1250 | $datetime = new DateTime(); | 
| 1174 | 1251 |  			$offset = $datetime->format('P'); | 
| 1175 | - } else $offset = '+00:00'; | |
| 1252 | +		} else { | |
| 1253 | + $offset = '+00:00'; | |
| 1254 | + } | |
| 1176 | 1255 | $filter_query = $this->getFilter($filters,true,true); | 
| 1177 | 1256 |  		if ($globalDBdriver == 'mysql') { | 
| 1178 | 1257 | $query = "SELECT MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count | 
| @@ -1221,7 +1300,9 @@ discard block | ||
| 1221 | 1300 | date_default_timezone_set($globalTimezone); | 
| 1222 | 1301 | $datetime = new DateTime(); | 
| 1223 | 1302 |  			$offset = $datetime->format('P'); | 
| 1224 | - } else $offset = '+00:00'; | |
| 1303 | +		} else { | |
| 1304 | + $offset = '+00:00'; | |
| 1305 | + } | |
| 1225 | 1306 | |
| 1226 | 1307 | $orderby_sql = ''; | 
| 1227 | 1308 | if ($orderby == "hour") | 
| @@ -1290,7 +1371,9 @@ discard block | ||
| 1290 | 1371 | date_default_timezone_set($globalTimezone); | 
| 1291 | 1372 | $datetime = new DateTime($date); | 
| 1292 | 1373 |  			$offset = $datetime->format('P'); | 
| 1293 | - } else $offset = '+00:00'; | |
| 1374 | +		} else { | |
| 1375 | + $offset = '+00:00'; | |
| 1376 | + } | |
| 1294 | 1377 | |
| 1295 | 1378 |  		if ($globalDBdriver == 'mysql') { | 
| 1296 | 1379 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count | 
| @@ -1338,7 +1421,9 @@ discard block | ||
| 1338 | 1421 | date_default_timezone_set($globalTimezone); | 
| 1339 | 1422 | $datetime = new DateTime(); | 
| 1340 | 1423 |  			$offset = $datetime->format('P'); | 
| 1341 | - } else $offset = '+00:00'; | |
| 1424 | +		} else { | |
| 1425 | + $offset = '+00:00'; | |
| 1426 | + } | |
| 1342 | 1427 | |
| 1343 | 1428 |  		if ($globalDBdriver == 'mysql') { | 
| 1344 | 1429 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count | 
| @@ -1403,8 +1488,11 @@ discard block | ||
| 1403 | 1488 |  				$query_values = array_merge($query_values,array(':month' => $month)); | 
| 1404 | 1489 | } | 
| 1405 | 1490 | } | 
| 1406 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); | |
| 1407 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); | |
| 1491 | +		if (empty($query_values)) { | |
| 1492 | + $queryi .= $this->getFilter($filters); | |
| 1493 | +		} else { | |
| 1494 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); | |
| 1495 | + } | |
| 1408 | 1496 | |
| 1409 | 1497 | $sth = $this->db->prepare($queryi); | 
| 1410 | 1498 | $sth->execute($query_values); | 
| @@ -1441,8 +1529,11 @@ discard block | ||
| 1441 | 1529 |  				$query_values = array_merge($query_values,array(':month' => $month)); | 
| 1442 | 1530 | } | 
| 1443 | 1531 | } | 
| 1444 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); | |
| 1445 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); | |
| 1532 | +		if (empty($query_values)) { | |
| 1533 | + $queryi .= $this->getFilter($filters); | |
| 1534 | +		} else { | |
| 1535 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); | |
| 1536 | + } | |
| 1446 | 1537 | |
| 1447 | 1538 | $sth = $this->db->prepare($queryi); | 
| 1448 | 1539 | $sth->execute($query_values); | 
| @@ -1464,7 +1555,9 @@ discard block | ||
| 1464 | 1555 | date_default_timezone_set($globalTimezone); | 
| 1465 | 1556 | $datetime = new DateTime(); | 
| 1466 | 1557 |  			$offset = $datetime->format('P'); | 
| 1467 | - } else $offset = '+00:00'; | |
| 1558 | +		} else { | |
| 1559 | + $offset = '+00:00'; | |
| 1560 | + } | |
| 1468 | 1561 | |
| 1469 | 1562 |  		if ($globalDBdriver == 'mysql') { | 
| 1470 | 1563 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count | 
| @@ -1568,7 +1661,9 @@ discard block | ||
| 1568 | 1661 | */ | 
| 1569 | 1662 | public function parseDirection($direction = 0) | 
| 1570 | 1663 |  	{ | 
| 1571 | - if ($direction == '') $direction = 0; | |
| 1664 | +		if ($direction == '') { | |
| 1665 | + $direction = 0; | |
| 1666 | + } | |
| 1572 | 1667 | $direction_array = array(); | 
| 1573 | 1668 | $temp_array = array(); | 
| 1574 | 1669 | |
| @@ -1657,7 +1752,9 @@ discard block | ||
| 1657 | 1752 | $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); | 
| 1658 | 1753 | |
| 1659 | 1754 | $Connection = new Connection($this->db); | 
| 1660 | -		if (!$Connection->tableExists('countries')) return ''; | |
| 1755 | +		if (!$Connection->tableExists('countries')) { | |
| 1756 | + return ''; | |
| 1757 | + } | |
| 1661 | 1758 | |
| 1662 | 1759 |  		try { | 
| 1663 | 1760 | /* | 
| @@ -1677,9 +1774,13 @@ discard block | ||
| 1677 | 1774 | $sth->closeCursor(); | 
| 1678 | 1775 |  			if (count($row) > 0) { | 
| 1679 | 1776 | return $row; | 
| 1680 | - } else return ''; | |
| 1777 | +			} else { | |
| 1778 | + return ''; | |
| 1779 | + } | |
| 1681 | 1780 |  		} catch (PDOException $e) { | 
| 1682 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; | |
| 1781 | +			if (isset($globalDebug) && $globalDebug) { | |
| 1782 | + echo 'Error : '.$e->getMessage()."\n"; | |
| 1783 | + } | |
| 1683 | 1784 | return ''; | 
| 1684 | 1785 | } | 
| 1685 | 1786 | |
| @@ -1697,7 +1798,9 @@ discard block | ||
| 1697 | 1798 | $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); | 
| 1698 | 1799 | |
| 1699 | 1800 | $Connection = new Connection($this->db); | 
| 1700 | -		if (!$Connection->tableExists('countries')) return ''; | |
| 1801 | +		if (!$Connection->tableExists('countries')) { | |
| 1802 | + return ''; | |
| 1803 | + } | |
| 1701 | 1804 | |
| 1702 | 1805 |  		try { | 
| 1703 | 1806 | $query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1"; | 
| @@ -1709,9 +1812,13 @@ discard block | ||
| 1709 | 1812 | $sth->closeCursor(); | 
| 1710 | 1813 |  			if (count($row) > 0) { | 
| 1711 | 1814 | return $row; | 
| 1712 | - } else return ''; | |
| 1815 | +			} else { | |
| 1816 | + return ''; | |
| 1817 | + } | |
| 1713 | 1818 |  		} catch (PDOException $e) { | 
| 1714 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; | |
| 1819 | +			if (isset($globalDebug) && $globalDebug) { | |
| 1820 | + echo 'Error : '.$e->getMessage()."\n"; | |
| 1821 | + } | |
| 1715 | 1822 | return ''; | 
| 1716 | 1823 | } | 
| 1717 | 1824 | |
| @@ -1729,7 +1836,9 @@ discard block | ||
| 1729 | 1836 |  	{ | 
| 1730 | 1837 | global $globalBitlyAccessToken; | 
| 1731 | 1838 | |
| 1732 | - if ($globalBitlyAccessToken == '') return $url; | |
| 1839 | +		if ($globalBitlyAccessToken == '') { | |
| 1840 | + return $url; | |
| 1841 | + } | |
| 1733 | 1842 | |
| 1734 | 1843 | $google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url; | 
| 1735 | 1844 | |
| @@ -1805,7 +1914,9 @@ discard block | ||
| 1805 | 1914 | } | 
| 1806 | 1915 | } | 
| 1807 | 1916 | $query .= " GROUP BY marine_output.type ORDER BY marine_type_count DESC"; | 
| 1808 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; | |
| 1917 | +		if ($limit) { | |
| 1918 | + $query .= " LIMIT 10 OFFSET 0"; | |
| 1919 | + } | |
| 1809 | 1920 | $sth = $this->db->prepare($query); | 
| 1810 | 1921 | $sth->execute($query_values); | 
| 1811 | 1922 | $marine_array = array(); | 
| @@ -1842,9 +1953,15 @@ discard block | ||
| 1842 | 1953 |  				foreach ($q_array as $q_item){ | 
| 1843 | 1954 | $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); | 
| 1844 | 1955 |  					$additional_query .= " AND ("; | 
| 1845 | - if (is_int($q_item)) $additional_query .= "(marine_output.marine_id = '".$q_item."') OR "; | |
| 1846 | - if (is_int($q_item)) $additional_query .= "(marine_output.mmsi = '".$q_item."') OR "; | |
| 1847 | - if (is_int($q_item)) $additional_query .= "(marine_output.imo = '".$q_item."') OR "; | |
| 1956 | +					if (is_int($q_item)) { | |
| 1957 | + $additional_query .= "(marine_output.marine_id = '".$q_item."') OR "; | |
| 1958 | + } | |
| 1959 | +					if (is_int($q_item)) { | |
| 1960 | + $additional_query .= "(marine_output.mmsi = '".$q_item."') OR "; | |
| 1961 | + } | |
| 1962 | +					if (is_int($q_item)) { | |
| 1963 | + $additional_query .= "(marine_output.imo = '".$q_item."') OR "; | |
| 1964 | + } | |
| 1848 | 1965 | $additional_query .= "(marine_output.ident like '%".$q_item."%') OR "; | 
| 1849 | 1966 | $additional_query .= ")"; | 
| 1850 | 1967 | } | 
| @@ -1892,7 +2009,9 @@ discard block | ||
| 1892 | 2009 | date_default_timezone_set($globalTimezone); | 
| 1893 | 2010 | $datetime = new DateTime(); | 
| 1894 | 2011 |  				$offset = $datetime->format('P'); | 
| 1895 | - } else $offset = '+00:00'; | |
| 2012 | +			} else { | |
| 2013 | + $offset = '+00:00'; | |
| 2014 | + } | |
| 1896 | 2015 | if ($date_array[1] != "") | 
| 1897 | 2016 |  			{ | 
| 1898 | 2017 |  				$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); | 
| @@ -1919,8 +2038,12 @@ discard block | ||
| 1919 | 2038 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) | 
| 1920 | 2039 |  			{ | 
| 1921 | 2040 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; | 
| 1922 | - } else $limit_query = ""; | |
| 1923 | - } else $limit_query = ""; | |
| 2041 | +			} else { | |
| 2042 | + $limit_query = ""; | |
| 2043 | + } | |
| 2044 | +		} else { | |
| 2045 | + $limit_query = ""; | |
| 2046 | + } | |
| 1924 | 2047 | if ($sort != "") | 
| 1925 | 2048 |  		{ | 
| 1926 | 2049 | $search_orderby_array = $this->getOrderBy(); | 
| @@ -12,10 +12,10 @@ discard block | ||
| 12 | 12 | } | 
| 13 | 13 | |
| 14 | 14 | /** | 
| 15 | - * Get SQL query part for filter used | |
| 16 | - * @param Array $filter the filter | |
| 17 | - * @return Array the SQL part | |
| 18 | - */ | |
| 15 | + * Get SQL query part for filter used | |
| 16 | + * @param Array $filter the filter | |
| 17 | + * @return Array the SQL part | |
| 18 | + */ | |
| 19 | 19 | |
| 20 | 20 |  	public function getFilter($filter = array(),$where = false,$and = false) { | 
| 21 | 21 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; | 
| @@ -82,14 +82,14 @@ discard block | ||
| 82 | 82 | } | 
| 83 | 83 | |
| 84 | 84 | /** | 
| 85 | - * Executes the SQL statements to get the spotter information | |
| 86 | - * | |
| 87 | - * @param String $query the SQL query | |
| 88 | - * @param Array $params parameter of the query | |
| 89 | - * @param String $limitQuery the limit query | |
| 90 | - * @return Array the spotter information | |
| 91 | - * | |
| 92 | - */ | |
| 85 | + * Executes the SQL statements to get the spotter information | |
| 86 | + * | |
| 87 | + * @param String $query the SQL query | |
| 88 | + * @param Array $params parameter of the query | |
| 89 | + * @param String $limitQuery the limit query | |
| 90 | + * @return Array the spotter information | |
| 91 | + * | |
| 92 | + */ | |
| 93 | 93 | public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false) | 
| 94 | 94 |  	{ | 
| 95 | 95 |  		date_default_timezone_set('UTC'); | 
| @@ -217,11 +217,11 @@ discard block | ||
| 217 | 217 | |
| 218 | 218 | |
| 219 | 219 | /** | 
| 220 | - * Gets all the spotter information based on the latest data entry | |
| 221 | - * | |
| 222 | - * @return Array the spotter information | |
| 223 | - * | |
| 224 | - */ | |
| 220 | + * Gets all the spotter information based on the latest data entry | |
| 221 | + * | |
| 222 | + * @return Array the spotter information | |
| 223 | + * | |
| 224 | + */ | |
| 225 | 225 | public function getLatestMarineData($limit = '', $sort = '', $filter = array()) | 
| 226 | 226 |  	{ | 
| 227 | 227 | global $global_query; | 
| @@ -270,11 +270,11 @@ discard block | ||
| 270 | 270 | } | 
| 271 | 271 | |
| 272 | 272 | /** | 
| 273 | - * Gets all the spotter information based on the callsign | |
| 274 | - * | |
| 275 | - * @return Array the spotter information | |
| 276 | - * | |
| 277 | - */ | |
| 273 | + * Gets all the spotter information based on the callsign | |
| 274 | + * | |
| 275 | + * @return Array the spotter information | |
| 276 | + * | |
| 277 | + */ | |
| 278 | 278 | public function getMarineDataByIdent($ident = '', $limit = '', $sort = '', $filter = array()) | 
| 279 | 279 |  	{ | 
| 280 | 280 | global $global_query; | 
| @@ -385,12 +385,12 @@ discard block | ||
| 385 | 385 | |
| 386 | 386 | |
| 387 | 387 | /** | 
| 388 | - * Gets all source name | |
| 389 | - * | |
| 390 | - * @param String type format of source | |
| 391 | - * @return Array list of source name | |
| 392 | - * | |
| 393 | - */ | |
| 388 | + * Gets all source name | |
| 389 | + * | |
| 390 | + * @param String type format of source | |
| 391 | + * @return Array list of source name | |
| 392 | + * | |
| 393 | + */ | |
| 394 | 394 | public function getAllSourceName($type = '',$filters = array()) | 
| 395 | 395 |  	{ | 
| 396 | 396 | $filter_query = $this->getFilter($filters,true,true); | 
| @@ -420,11 +420,11 @@ discard block | ||
| 420 | 420 | |
| 421 | 421 | |
| 422 | 422 | /** | 
| 423 | - * Gets a list of all idents/callsigns | |
| 424 | - * | |
| 425 | - * @return Array list of ident/callsign names | |
| 426 | - * | |
| 427 | - */ | |
| 423 | + * Gets a list of all idents/callsigns | |
| 424 | + * | |
| 425 | + * @return Array list of ident/callsign names | |
| 426 | + * | |
| 427 | + */ | |
| 428 | 428 | public function getAllIdents($filters = array()) | 
| 429 | 429 |  	{ | 
| 430 | 430 | $filter_query = $this->getFilter($filters,true,true); | 
| @@ -448,11 +448,11 @@ discard block | ||
| 448 | 448 | } | 
| 449 | 449 | |
| 450 | 450 | /** | 
| 451 | - * Gets all info from a mmsi | |
| 452 | - * | |
| 453 | - * @return Array ident | |
| 454 | - * | |
| 455 | - */ | |
| 451 | + * Gets all info from a mmsi | |
| 452 | + * | |
| 453 | + * @return Array ident | |
| 454 | + * | |
| 455 | + */ | |
| 456 | 456 | public function getIdentity($mmsi) | 
| 457 | 457 |  	{ | 
| 458 | 458 | $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); | 
| @@ -465,9 +465,9 @@ discard block | ||
| 465 | 465 | } | 
| 466 | 466 | |
| 467 | 467 | /** | 
| 468 | - * Add identity | |
| 469 | - * | |
| 470 | - */ | |
| 468 | + * Add identity | |
| 469 | + * | |
| 470 | + */ | |
| 471 | 471 | public function addIdentity($mmsi,$imo,$ident,$callsign,$type) | 
| 472 | 472 |  	{ | 
| 473 | 473 | $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); | 
| @@ -533,13 +533,13 @@ discard block | ||
| 533 | 533 | } | 
| 534 | 534 | |
| 535 | 535 | /** | 
| 536 | - * Update ident tracker data | |
| 537 | - * | |
| 538 | - * @param String $fammarine_id the ID | |
| 539 | - * @param String $ident the marine ident | |
| 540 | - * @return String success or false | |
| 541 | - * | |
| 542 | - */ | |
| 536 | + * Update ident tracker data | |
| 537 | + * | |
| 538 | + * @param String $fammarine_id the ID | |
| 539 | + * @param String $ident the marine ident | |
| 540 | + * @return String success or false | |
| 541 | + * | |
| 542 | + */ | |
| 543 | 543 | public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL) | 
| 544 | 544 |  	{ | 
| 545 | 545 | $query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id'; | 
| @@ -554,19 +554,19 @@ discard block | ||
| 554 | 554 | } | 
| 555 | 555 | |
| 556 | 556 | /** | 
| 557 | - * Update Status data | |
| 558 | - * | |
| 559 | - * @param String $fammarine_id the ID | |
| 560 | - * @param String $status_id the marine status id | |
| 561 | - * @param String $status the marine status | |
| 562 | - * @return String success or false | |
| 563 | - * | |
| 564 | - */ | |
| 557 | + * Update Status data | |
| 558 | + * | |
| 559 | + * @param String $fammarine_id the ID | |
| 560 | + * @param String $status_id the marine status id | |
| 561 | + * @param String $status the marine status | |
| 562 | + * @return String success or false | |
| 563 | + * | |
| 564 | + */ | |
| 565 | 565 | public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '') | 
| 566 | 566 |  	{ | 
| 567 | 567 | |
| 568 | 568 | $query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id'; | 
| 569 | -                $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id); | |
| 569 | +				$query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id); | |
| 570 | 570 | |
| 571 | 571 |  		try { | 
| 572 | 572 | $sth = $this->db->prepare($query); | 
| @@ -579,17 +579,17 @@ discard block | ||
| 579 | 579 | |
| 580 | 580 | } | 
| 581 | 581 | /** | 
| 582 | - * Update latest marine data | |
| 583 | - * | |
| 584 | - * @param String $fammarine_id the ID | |
| 585 | - * @param String $ident the marine ident | |
| 586 | - * @return String success or false | |
| 587 | - * | |
| 588 | - */ | |
| 582 | + * Update latest marine data | |
| 583 | + * | |
| 584 | + * @param String $fammarine_id the ID | |
| 585 | + * @param String $ident the marine ident | |
| 586 | + * @return String success or false | |
| 587 | + * | |
| 588 | + */ | |
| 589 | 589 | public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '') | 
| 590 | 590 |  	{ | 
| 591 | 591 | $query = 'UPDATE marine_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE fammarine_id = :fammarine_id'; | 
| 592 | -                $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); | |
| 592 | +				$query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); | |
| 593 | 593 | |
| 594 | 594 |  		try { | 
| 595 | 595 | $sth = $this->db->prepare($query); | 
| @@ -603,30 +603,30 @@ discard block | ||
| 603 | 603 | } | 
| 604 | 604 | |
| 605 | 605 | /** | 
| 606 | - * Adds a new spotter data | |
| 607 | - * | |
| 608 | - * @param String $fammarine_id the ID | |
| 609 | - * @param String $ident the marine ident | |
| 610 | - * @param String $departure_airport_icao the departure airport | |
| 611 | - * @param String $arrival_airport_icao the arrival airport | |
| 612 | - * @param String $latitude latitude of flight | |
| 613 | - * @param String $longitude latitude of flight | |
| 614 | - * @param String $waypoints waypoints of flight | |
| 615 | - * @param String $heading heading of flight | |
| 616 | - * @param String $groundspeed speed of flight | |
| 617 | - * @param String $date date of flight | |
| 618 | - * @param String $departure_airport_time departure time of flight | |
| 619 | - * @param String $arrival_airport_time arrival time of flight | |
| 620 | - * @param String $squawk squawk code of flight | |
| 621 | - * @param String $route_stop route stop of flight | |
| 622 | - * @param String $highlight highlight or not | |
| 623 | - * @param String $ModeS ModesS code of flight | |
| 624 | - * @param String $registration registration code of flight | |
| 625 | - * @param String $pilot_id pilot id of flight (for virtual airlines) | |
| 626 | - * @param String $pilot_name pilot name of flight (for virtual airlines) | |
| 627 | - * @param String $verticalrate vertival rate of flight | |
| 628 | - * @return String success or false | |
| 629 | - */ | |
| 606 | + * Adds a new spotter data | |
| 607 | + * | |
| 608 | + * @param String $fammarine_id the ID | |
| 609 | + * @param String $ident the marine ident | |
| 610 | + * @param String $departure_airport_icao the departure airport | |
| 611 | + * @param String $arrival_airport_icao the arrival airport | |
| 612 | + * @param String $latitude latitude of flight | |
| 613 | + * @param String $longitude latitude of flight | |
| 614 | + * @param String $waypoints waypoints of flight | |
| 615 | + * @param String $heading heading of flight | |
| 616 | + * @param String $groundspeed speed of flight | |
| 617 | + * @param String $date date of flight | |
| 618 | + * @param String $departure_airport_time departure time of flight | |
| 619 | + * @param String $arrival_airport_time arrival time of flight | |
| 620 | + * @param String $squawk squawk code of flight | |
| 621 | + * @param String $route_stop route stop of flight | |
| 622 | + * @param String $highlight highlight or not | |
| 623 | + * @param String $ModeS ModesS code of flight | |
| 624 | + * @param String $registration registration code of flight | |
| 625 | + * @param String $pilot_id pilot id of flight (for virtual airlines) | |
| 626 | + * @param String $pilot_name pilot name of flight (for virtual airlines) | |
| 627 | + * @param String $verticalrate vertival rate of flight | |
| 628 | + * @return String success or false | |
| 629 | + */ | |
| 630 | 630 | public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$format_source = '', $source_name = '') | 
| 631 | 631 |  	{ | 
| 632 | 632 | global $globalURL, $globalMarineImageFetch; | 
| @@ -723,13 +723,13 @@ discard block | ||
| 723 | 723 | unset($Image); | 
| 724 | 724 | } | 
| 725 | 725 | |
| 726 | -                if ($latitude == '' && $longitude == '') { | |
| 727 | - $latitude = 0; | |
| 728 | - $longitude = 0; | |
| 729 | - } | |
| 730 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; | |
| 731 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; | |
| 732 | - if ($arrival_date == '') $arrival_date = NULL; | |
| 726 | +				if ($latitude == '' && $longitude == '') { | |
| 727 | + $latitude = 0; | |
| 728 | + $longitude = 0; | |
| 729 | + } | |
| 730 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; | |
| 731 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; | |
| 732 | + if ($arrival_date == '') $arrival_date = NULL; | |
| 733 | 733 | $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) | 
| 734 | 734 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)"; | 
| 735 | 735 | |
| @@ -740,7 +740,7 @@ discard block | ||
| 740 | 740 | $sth->execute($query_values); | 
| 741 | 741 | $this->db = null; | 
| 742 | 742 |  		} catch (PDOException $e) { | 
| 743 | - return "error : ".$e->getMessage(); | |
| 743 | + return "error : ".$e->getMessage(); | |
| 744 | 744 | } | 
| 745 | 745 | |
| 746 | 746 | return "success"; | 
| @@ -749,11 +749,11 @@ discard block | ||
| 749 | 749 | |
| 750 | 750 | |
| 751 | 751 | /** | 
| 752 | - * Gets the aircraft ident within the last hour | |
| 753 | - * | |
| 754 | - * @return String the ident | |
| 755 | - * | |
| 756 | - */ | |
| 752 | + * Gets the aircraft ident within the last hour | |
| 753 | + * | |
| 754 | + * @return String the ident | |
| 755 | + * | |
| 756 | + */ | |
| 757 | 757 | public function getIdentFromLastHour($ident) | 
| 758 | 758 |  	{ | 
| 759 | 759 | global $globalDBdriver, $globalTimezone; | 
| @@ -769,11 +769,11 @@ discard block | ||
| 769 | 769 | AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' | 
| 770 | 770 | AND marine_output.date < now() AT TIME ZONE 'UTC'"; | 
| 771 | 771 |  			$query_data = array(':ident' => $ident); | 
| 772 | - } | |
| 772 | + } | |
| 773 | 773 | |
| 774 | 774 | $sth = $this->db->prepare($query); | 
| 775 | 775 | $sth->execute($query_data); | 
| 776 | - $ident_result=''; | |
| 776 | + $ident_result=''; | |
| 777 | 777 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) | 
| 778 | 778 |  		{ | 
| 779 | 779 | $ident_result = $row['ident']; | 
| @@ -784,11 +784,11 @@ discard block | ||
| 784 | 784 | |
| 785 | 785 | |
| 786 | 786 | /** | 
| 787 | - * Gets the aircraft data from the last 20 seconds | |
| 788 | - * | |
| 789 | - * @return Array the spotter data | |
| 790 | - * | |
| 791 | - */ | |
| 787 | + * Gets the aircraft data from the last 20 seconds | |
| 788 | + * | |
| 789 | + * @return Array the spotter data | |
| 790 | + * | |
| 791 | + */ | |
| 792 | 792 | public function getRealTimeData($q = '') | 
| 793 | 793 |  	{ | 
| 794 | 794 | global $globalDBdriver; | 
| @@ -826,11 +826,11 @@ discard block | ||
| 826 | 826 | |
| 827 | 827 | |
| 828 | 828 | /** | 
| 829 | - * Gets all number of flight over countries | |
| 830 | - * | |
| 831 | - * @return Array the airline country list | |
| 832 | - * | |
| 833 | - */ | |
| 829 | + * Gets all number of flight over countries | |
| 830 | + * | |
| 831 | + * @return Array the airline country list | |
| 832 | + * | |
| 833 | + */ | |
| 834 | 834 | |
| 835 | 835 | public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) | 
| 836 | 836 |  	{ | 
| @@ -903,11 +903,11 @@ discard block | ||
| 903 | 903 | |
| 904 | 904 | |
| 905 | 905 | /** | 
| 906 | - * Gets all callsigns that have flown over | |
| 907 | - * | |
| 908 | - * @return Array the callsign list | |
| 909 | - * | |
| 910 | - */ | |
| 906 | + * Gets all callsigns that have flown over | |
| 907 | + * | |
| 908 | + * @return Array the callsign list | |
| 909 | + * | |
| 910 | + */ | |
| 911 | 911 | public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') | 
| 912 | 912 |  	{ | 
| 913 | 913 | global $globalDBdriver; | 
| @@ -974,11 +974,11 @@ discard block | ||
| 974 | 974 | |
| 975 | 975 | |
| 976 | 976 | /** | 
| 977 | - * Counts all dates | |
| 978 | - * | |
| 979 | - * @return Array the date list | |
| 980 | - * | |
| 981 | - */ | |
| 977 | + * Counts all dates | |
| 978 | + * | |
| 979 | + * @return Array the date list | |
| 980 | + * | |
| 981 | + */ | |
| 982 | 982 | public function countAllDates($filters = array()) | 
| 983 | 983 |  	{ | 
| 984 | 984 | global $globalTimezone, $globalDBdriver; | 
| @@ -1024,11 +1024,11 @@ discard block | ||
| 1024 | 1024 | |
| 1025 | 1025 | |
| 1026 | 1026 | /** | 
| 1027 | - * Counts all dates during the last 7 days | |
| 1028 | - * | |
| 1029 | - * @return Array the date list | |
| 1030 | - * | |
| 1031 | - */ | |
| 1027 | + * Counts all dates during the last 7 days | |
| 1028 | + * | |
| 1029 | + * @return Array the date list | |
| 1030 | + * | |
| 1031 | + */ | |
| 1032 | 1032 | public function countAllDatesLast7Days($filters = array()) | 
| 1033 | 1033 |  	{ | 
| 1034 | 1034 | global $globalTimezone, $globalDBdriver; | 
| @@ -1050,7 +1050,7 @@ discard block | ||
| 1050 | 1050 | $query .= " GROUP BY date_name | 
| 1051 | 1051 | ORDER BY date_name ASC"; | 
| 1052 | 1052 |  			$query_data = array(':offset' => $offset); | 
| 1053 | - } | |
| 1053 | + } | |
| 1054 | 1054 | |
| 1055 | 1055 | $sth = $this->db->prepare($query); | 
| 1056 | 1056 | $sth->execute($query_data); | 
| @@ -1070,11 +1070,11 @@ discard block | ||
| 1070 | 1070 | } | 
| 1071 | 1071 | |
| 1072 | 1072 | /** | 
| 1073 | - * Counts all dates during the last month | |
| 1074 | - * | |
| 1075 | - * @return Array the date list | |
| 1076 | - * | |
| 1077 | - */ | |
| 1073 | + * Counts all dates during the last month | |
| 1074 | + * | |
| 1075 | + * @return Array the date list | |
| 1076 | + * | |
| 1077 | + */ | |
| 1078 | 1078 | public function countAllDatesLastMonth($filters = array()) | 
| 1079 | 1079 |  	{ | 
| 1080 | 1080 | global $globalTimezone, $globalDBdriver; | 
| @@ -1096,7 +1096,7 @@ discard block | ||
| 1096 | 1096 | $query .= " GROUP BY date_name | 
| 1097 | 1097 | ORDER BY date_name ASC"; | 
| 1098 | 1098 |  			$query_data = array(':offset' => $offset); | 
| 1099 | - } | |
| 1099 | + } | |
| 1100 | 1100 | |
| 1101 | 1101 | $sth = $this->db->prepare($query); | 
| 1102 | 1102 | $sth->execute($query_data); | 
| @@ -1118,11 +1118,11 @@ discard block | ||
| 1118 | 1118 | |
| 1119 | 1119 | |
| 1120 | 1120 | /** | 
| 1121 | - * Counts all month | |
| 1122 | - * | |
| 1123 | - * @return Array the month list | |
| 1124 | - * | |
| 1125 | - */ | |
| 1121 | + * Counts all month | |
| 1122 | + * | |
| 1123 | + * @return Array the month list | |
| 1124 | + * | |
| 1125 | + */ | |
| 1126 | 1126 | public function countAllMonths($filters = array()) | 
| 1127 | 1127 |  	{ | 
| 1128 | 1128 | global $globalTimezone, $globalDBdriver; | 
| @@ -1167,11 +1167,11 @@ discard block | ||
| 1167 | 1167 | |
| 1168 | 1168 | |
| 1169 | 1169 | /** | 
| 1170 | - * Counts all dates during the last year | |
| 1171 | - * | |
| 1172 | - * @return Array the date list | |
| 1173 | - * | |
| 1174 | - */ | |
| 1170 | + * Counts all dates during the last year | |
| 1171 | + * | |
| 1172 | + * @return Array the date list | |
| 1173 | + * | |
| 1174 | + */ | |
| 1175 | 1175 | public function countAllMonthsLastYear($filters) | 
| 1176 | 1176 |  	{ | 
| 1177 | 1177 | global $globalTimezone, $globalDBdriver; | 
| @@ -1193,7 +1193,7 @@ discard block | ||
| 1193 | 1193 | $query .= " GROUP BY year_name, month_name | 
| 1194 | 1194 | ORDER BY year_name, month_name ASC"; | 
| 1195 | 1195 |  			$query_data = array(':offset' => $offset); | 
| 1196 | - } | |
| 1196 | + } | |
| 1197 | 1197 | |
| 1198 | 1198 | $sth = $this->db->prepare($query); | 
| 1199 | 1199 | $sth->execute($query_data); | 
| @@ -1216,11 +1216,11 @@ discard block | ||
| 1216 | 1216 | |
| 1217 | 1217 | |
| 1218 | 1218 | /** | 
| 1219 | - * Counts all hours | |
| 1220 | - * | |
| 1221 | - * @return Array the hour list | |
| 1222 | - * | |
| 1223 | - */ | |
| 1219 | + * Counts all hours | |
| 1220 | + * | |
| 1221 | + * @return Array the hour list | |
| 1222 | + * | |
| 1223 | + */ | |
| 1224 | 1224 | public function countAllHours($orderby,$filters = array()) | 
| 1225 | 1225 |  	{ | 
| 1226 | 1226 | global $globalTimezone, $globalDBdriver; | 
| @@ -1283,11 +1283,11 @@ discard block | ||
| 1283 | 1283 | |
| 1284 | 1284 | |
| 1285 | 1285 | /** | 
| 1286 | - * Counts all hours by date | |
| 1287 | - * | |
| 1288 | - * @return Array the hour list | |
| 1289 | - * | |
| 1290 | - */ | |
| 1286 | + * Counts all hours by date | |
| 1287 | + * | |
| 1288 | + * @return Array the hour list | |
| 1289 | + * | |
| 1290 | + */ | |
| 1291 | 1291 | public function countAllHoursByDate($date, $filters = array()) | 
| 1292 | 1292 |  	{ | 
| 1293 | 1293 | global $globalTimezone, $globalDBdriver; | 
| @@ -1331,11 +1331,11 @@ discard block | ||
| 1331 | 1331 | |
| 1332 | 1332 | |
| 1333 | 1333 | /** | 
| 1334 | - * Counts all hours by a ident/callsign | |
| 1335 | - * | |
| 1336 | - * @return Array the hour list | |
| 1337 | - * | |
| 1338 | - */ | |
| 1334 | + * Counts all hours by a ident/callsign | |
| 1335 | + * | |
| 1336 | + * @return Array the hour list | |
| 1337 | + * | |
| 1338 | + */ | |
| 1339 | 1339 | public function countAllHoursByIdent($ident, $filters = array()) | 
| 1340 | 1340 |  	{ | 
| 1341 | 1341 | global $globalTimezone, $globalDBdriver; | 
| @@ -1380,11 +1380,11 @@ discard block | ||
| 1380 | 1380 | |
| 1381 | 1381 | |
| 1382 | 1382 | /** | 
| 1383 | - * Counts all vessels | |
| 1384 | - * | |
| 1385 | - * @return Integer the number of vessels | |
| 1386 | - * | |
| 1387 | - */ | |
| 1383 | + * Counts all vessels | |
| 1384 | + * | |
| 1385 | + * @return Integer the number of vessels | |
| 1386 | + * | |
| 1387 | + */ | |
| 1388 | 1388 | public function countOverallMarine($filters = array(),$year = '',$month = '') | 
| 1389 | 1389 |  	{ | 
| 1390 | 1390 | global $globalDBdriver; | 
| @@ -1419,11 +1419,11 @@ discard block | ||
| 1419 | 1419 | } | 
| 1420 | 1420 | |
| 1421 | 1421 | /** | 
| 1422 | - * Counts all vessel type | |
| 1423 | - * | |
| 1424 | - * @return Integer the number of vessels | |
| 1425 | - * | |
| 1426 | - */ | |
| 1422 | + * Counts all vessel type | |
| 1423 | + * | |
| 1424 | + * @return Integer the number of vessels | |
| 1425 | + * | |
| 1426 | + */ | |
| 1427 | 1427 | public function countOverallMarineTypes($filters = array(),$year = '',$month = '') | 
| 1428 | 1428 |  	{ | 
| 1429 | 1429 | global $globalDBdriver; | 
| @@ -1458,11 +1458,11 @@ discard block | ||
| 1458 | 1458 | |
| 1459 | 1459 | |
| 1460 | 1460 | /** | 
| 1461 | - * Counts all hours of today | |
| 1462 | - * | |
| 1463 | - * @return Array the hour list | |
| 1464 | - * | |
| 1465 | - */ | |
| 1461 | + * Counts all hours of today | |
| 1462 | + * | |
| 1463 | + * @return Array the hour list | |
| 1464 | + * | |
| 1465 | + */ | |
| 1466 | 1466 | public function countAllHoursFromToday($filters = array()) | 
| 1467 | 1467 |  	{ | 
| 1468 | 1468 | global $globalTimezone, $globalDBdriver; | 
| @@ -1502,12 +1502,12 @@ discard block | ||
| 1502 | 1502 | } | 
| 1503 | 1503 | |
| 1504 | 1504 | |
| 1505 | - /** | |
| 1506 | - * Gets the Barrie Spotter ID based on the FlightAware ID | |
| 1507 | - * | |
| 1508 | - * @return Integer the Barrie Spotter ID | |
| 1505 | + /** | |
| 1506 | + * Gets the Barrie Spotter ID based on the FlightAware ID | |
| 1507 | + * | |
| 1508 | + * @return Integer the Barrie Spotter ID | |
| 1509 | 1509 | q * | 
| 1510 | - */ | |
| 1510 | + */ | |
| 1511 | 1511 | public function getMarineIDBasedOnFamMarineID($fammarine_id) | 
| 1512 | 1512 |  	{ | 
| 1513 | 1513 | $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); | 
| @@ -1528,13 +1528,13 @@ discard block | ||
| 1528 | 1528 | |
| 1529 | 1529 | |
| 1530 | 1530 | /** | 
| 1531 | - * Parses a date string | |
| 1532 | - * | |
| 1533 | - * @param String $dateString the date string | |
| 1534 | - * @param String $timezone the timezone of a user | |
| 1535 | - * @return Array the time information | |
| 1536 | - * | |
| 1537 | - */ | |
| 1531 | + * Parses a date string | |
| 1532 | + * | |
| 1533 | + * @param String $dateString the date string | |
| 1534 | + * @param String $timezone the timezone of a user | |
| 1535 | + * @return Array the time information | |
| 1536 | + * | |
| 1537 | + */ | |
| 1538 | 1538 | public function parseDateString($dateString, $timezone = '') | 
| 1539 | 1539 |  	{ | 
| 1540 | 1540 | $time_array = array(); | 
| @@ -1567,12 +1567,12 @@ discard block | ||
| 1567 | 1567 | } | 
| 1568 | 1568 | |
| 1569 | 1569 | /** | 
| 1570 | - * Parses the direction degrees to working | |
| 1571 | - * | |
| 1572 | - * @param Float $direction the direction in degrees | |
| 1573 | - * @return Array the direction information | |
| 1574 | - * | |
| 1575 | - */ | |
| 1570 | + * Parses the direction degrees to working | |
| 1571 | + * | |
| 1572 | + * @param Float $direction the direction in degrees | |
| 1573 | + * @return Array the direction information | |
| 1574 | + * | |
| 1575 | + */ | |
| 1576 | 1576 | public function parseDirection($direction = 0) | 
| 1577 | 1577 |  	{ | 
| 1578 | 1578 | if ($direction == '') $direction = 0; | 
| @@ -1651,12 +1651,12 @@ discard block | ||
| 1651 | 1651 | |
| 1652 | 1652 | |
| 1653 | 1653 | /** | 
| 1654 | - * Gets Country from latitude/longitude | |
| 1655 | - * | |
| 1656 | - * @param Float $latitude latitute of the flight | |
| 1657 | - * @param Float $longitude longitute of the flight | |
| 1658 | - * @return String the countrie | |
| 1659 | - */ | |
| 1654 | + * Gets Country from latitude/longitude | |
| 1655 | + * | |
| 1656 | + * @param Float $latitude latitute of the flight | |
| 1657 | + * @param Float $longitude longitute of the flight | |
| 1658 | + * @return String the countrie | |
| 1659 | + */ | |
| 1660 | 1660 | public function getCountryFromLatitudeLongitude($latitude,$longitude) | 
| 1661 | 1661 |  	{ | 
| 1662 | 1662 | global $globalDBdriver, $globalDebug; | 
| @@ -1693,11 +1693,11 @@ discard block | ||
| 1693 | 1693 | } | 
| 1694 | 1694 | |
| 1695 | 1695 | /** | 
| 1696 | - * Gets Country from iso2 | |
| 1697 | - * | |
| 1698 | - * @param String $iso2 ISO2 country code | |
| 1699 | - * @return String the countrie | |
| 1700 | - */ | |
| 1696 | + * Gets Country from iso2 | |
| 1697 | + * | |
| 1698 | + * @param String $iso2 ISO2 country code | |
| 1699 | + * @return String the countrie | |
| 1700 | + */ | |
| 1701 | 1701 | public function getCountryFromISO2($iso2) | 
| 1702 | 1702 |  	{ | 
| 1703 | 1703 | global $globalDBdriver, $globalDebug; | 
| @@ -1726,12 +1726,12 @@ discard block | ||
| 1726 | 1726 | |
| 1727 | 1727 | |
| 1728 | 1728 | /** | 
| 1729 | - * Gets the short url from bit.ly | |
| 1730 | - * | |
| 1731 | - * @param String $url the full url | |
| 1732 | - * @return String the bit.ly url | |
| 1733 | - * | |
| 1734 | - */ | |
| 1729 | + * Gets the short url from bit.ly | |
| 1730 | + * | |
| 1731 | + * @param String $url the full url | |
| 1732 | + * @return String the bit.ly url | |
| 1733 | + * | |
| 1734 | + */ | |
| 1735 | 1735 | public function getBitlyURL($url) | 
| 1736 | 1736 |  	{ | 
| 1737 | 1737 | global $globalBitlyAccessToken; | 
| @@ -1758,11 +1758,11 @@ discard block | ||
| 1758 | 1758 | |
| 1759 | 1759 | |
| 1760 | 1760 | /** | 
| 1761 | - * Gets all vessels types that have flown over | |
| 1762 | - * | |
| 1763 | - * @return Array the vessel type list | |
| 1764 | - * | |
| 1765 | - */ | |
| 1761 | + * Gets all vessels types that have flown over | |
| 1762 | + * | |
| 1763 | + * @return Array the vessel type list | |
| 1764 | + * | |
| 1765 | + */ | |
| 1766 | 1766 | public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '') | 
| 1767 | 1767 |  	{ | 
| 1768 | 1768 | global $globalDBdriver; | 
| @@ -1827,11 +1827,11 @@ discard block | ||
| 1827 | 1827 | } | 
| 1828 | 1828 | |
| 1829 | 1829 | /** | 
| 1830 | - * Gets all the tracker information | |
| 1831 | - * | |
| 1832 | - * @return Array the tracker information | |
| 1833 | - * | |
| 1834 | - */ | |
| 1830 | + * Gets all the tracker information | |
| 1831 | + * | |
| 1832 | + * @return Array the tracker information | |
| 1833 | + * | |
| 1834 | + */ | |
| 1835 | 1835 | public function searchMarineData($q = '', $callsign = '',$mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$filters = array()) | 
| 1836 | 1836 |  	{ | 
| 1837 | 1837 | global $globalTimezone, $globalDBdriver; |