@@ -29,31 +29,31 @@ discard block |
||
29 | 29 | |
30 | 30 | private function make_latf($temp) { // unsigned long |
31 | 31 | $flat = 0.0; // float |
32 | - $temp = $temp & 0x07FFFFFF; |
|
33 | - if ($temp & 0x04000000) { |
|
34 | - $temp = $temp ^ 0x07FFFFFF; |
|
32 | + $temp = $temp&0x07FFFFFF; |
|
33 | + if ($temp&0x04000000) { |
|
34 | + $temp = $temp^0x07FFFFFF; |
|
35 | 35 | $temp += 1; |
36 | - $flat = (float)($temp / (60.0 * 10000.0)); |
|
36 | + $flat = (float) ($temp/(60.0*10000.0)); |
|
37 | 37 | $flat *= -1.0; |
38 | - } else $flat = (float)($temp / (60.0 * 10000.0)); |
|
38 | + } else $flat = (float) ($temp/(60.0*10000.0)); |
|
39 | 39 | return $flat; // float |
40 | 40 | } |
41 | 41 | |
42 | 42 | private function make_lonf($temp) { // unsigned long |
43 | 43 | $flon = 0.0; // float |
44 | - $temp = $temp & 0x0FFFFFFF; |
|
45 | - if ($temp & 0x08000000) { |
|
46 | - $temp = $temp ^ 0x0FFFFFFF; |
|
44 | + $temp = $temp&0x0FFFFFFF; |
|
45 | + if ($temp&0x08000000) { |
|
46 | + $temp = $temp^0x0FFFFFFF; |
|
47 | 47 | $temp += 1; |
48 | - $flon = (float)($temp / (60.0 * 10000.0)); |
|
48 | + $flon = (float) ($temp/(60.0*10000.0)); |
|
49 | 49 | $flon *= -1.0; |
50 | - } else $flon = (float)($temp / (60.0 * 10000.0)); |
|
50 | + } else $flon = (float) ($temp/(60.0*10000.0)); |
|
51 | 51 | return $flon; |
52 | 52 | } |
53 | 53 | |
54 | 54 | private function ascii_2_dec($chr) { |
55 | - $dec=ord($chr);//get decimal ascii code |
|
56 | - $hex=dechex($dec);//convert decimal to hex |
|
55 | + $dec = ord($chr); //get decimal ascii code |
|
56 | + $hex = dechex($dec); //convert decimal to hex |
|
57 | 57 | return ($dec); |
58 | 58 | } |
59 | 59 | |
@@ -72,15 +72,15 @@ discard block |
||
72 | 72 | //only process in the following range: 48-87, 96-119 |
73 | 73 | if ($ascii < 48) { } |
74 | 74 | else { |
75 | - if($ascii>119) { } |
|
75 | + if ($ascii > 119) { } |
|
76 | 76 | else { |
77 | - if ($ascii>87 && $ascii<96) ; |
|
77 | + if ($ascii > 87 && $ascii < 96); |
|
78 | 78 | else { |
79 | - $ascii=$ascii+40; |
|
80 | - if ($ascii>128){ |
|
81 | - $ascii=$ascii+32; |
|
79 | + $ascii = $ascii + 40; |
|
80 | + if ($ascii > 128) { |
|
81 | + $ascii = $ascii + 32; |
|
82 | 82 | } else { |
83 | - $ascii=$ascii+40; |
|
83 | + $ascii = $ascii + 40; |
|
84 | 84 | } |
85 | 85 | } |
86 | 86 | } |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | } |
90 | 90 | |
91 | 91 | private function dec_2_6bit($dec) { |
92 | - $bin=decbin($dec); |
|
92 | + $bin = decbin($dec); |
|
93 | 93 | return(substr($bin, -6)); |
94 | 94 | } |
95 | 95 | |
@@ -107,11 +107,11 @@ discard block |
||
107 | 107 | ); |
108 | 108 | // " |
109 | 109 | $rv = ''; |
110 | - if ($_size % 6 == 0) { |
|
111 | - $len = $_size / 6; |
|
112 | - for ($i=0; $i<$len; $i++) { |
|
113 | - $offset = $i * 6; |
|
114 | - $rv .= $ais_chars[ bindec(substr($_str,$_start + $offset,6)) ]; |
|
110 | + if ($_size%6 == 0) { |
|
111 | + $len = $_size/6; |
|
112 | + for ($i = 0; $i < $len; $i++) { |
|
113 | + $offset = $i*6; |
|
114 | + $rv .= $ais_chars[bindec(substr($_str, $_start + $offset, 6))]; |
|
115 | 115 | } |
116 | 116 | } |
117 | 117 | return $rv; |
@@ -138,93 +138,93 @@ discard block |
||
138 | 138 | $ro->eta_hour = ''; |
139 | 139 | $ro->eta_minute = ''; |
140 | 140 | $ro->ts = time(); |
141 | - $ro->id = bindec(substr($_aisdata,0,6)); |
|
142 | - $ro->mmsi = bindec(substr($_aisdata,8,30)); |
|
141 | + $ro->id = bindec(substr($_aisdata, 0, 6)); |
|
142 | + $ro->mmsi = bindec(substr($_aisdata, 8, 30)); |
|
143 | 143 | if ($ro->id >= 1 && $ro->id <= 3) { |
144 | - $ro->cog = bindec(substr($_aisdata,116,12))/10; |
|
145 | - $ro->sog = bindec(substr($_aisdata,50,10))/10; |
|
146 | - $ro->lon = $this->make_lonf(bindec(substr($_aisdata,61,28))); |
|
147 | - $ro->lat = $this->make_latf(bindec(substr($_aisdata,89,27))); |
|
144 | + $ro->cog = bindec(substr($_aisdata, 116, 12))/10; |
|
145 | + $ro->sog = bindec(substr($_aisdata, 50, 10))/10; |
|
146 | + $ro->lon = $this->make_lonf(bindec(substr($_aisdata, 61, 28))); |
|
147 | + $ro->lat = $this->make_latf(bindec(substr($_aisdata, 89, 27))); |
|
148 | 148 | $ro->cls = 1; // class A |
149 | 149 | } else if ($ro->id == 4) { |
150 | - $ro->lon = $this->make_lonf(bindec(substr($_aisdata,79,28))); |
|
151 | - $ro->lat = $this->make_latf(bindec(substr($_aisdata,107,27))); |
|
150 | + $ro->lon = $this->make_lonf(bindec(substr($_aisdata, 79, 28))); |
|
151 | + $ro->lat = $this->make_latf(bindec(substr($_aisdata, 107, 27))); |
|
152 | 152 | $ro->cls = 1; // class A |
153 | 153 | } else if ($ro->id == 5) { |
154 | - $ro->imo = bindec(substr($_aisdata,40,30)); |
|
155 | - $ro->callsign = $this->binchar($_aisdata,70,42); |
|
156 | - $ro->name = $this->binchar($_aisdata,112,120); |
|
157 | - $ro->typeid = bindec(substr($_aisdata,232,8)); |
|
154 | + $ro->imo = bindec(substr($_aisdata, 40, 30)); |
|
155 | + $ro->callsign = $this->binchar($_aisdata, 70, 42); |
|
156 | + $ro->name = $this->binchar($_aisdata, 112, 120); |
|
157 | + $ro->typeid = bindec(substr($_aisdata, 232, 8)); |
|
158 | 158 | $ro->type = $this->getShipType($ro->typeid); |
159 | 159 | //$ro->to_bow = bindec(substr($_aisdata,240,9)); |
160 | 160 | //$ro->to_stern = bindec(substr($_aisdata,249,9)); |
161 | 161 | //$ro->to_port = bindec(substr($_aisdata,258,6)); |
162 | 162 | //$ro->to_starboard = bindec(substr($_aisdata,264,6)); |
163 | - $ro->eta_month = bindec(substr($_aisdata,274,4)); |
|
164 | - $ro->eta_day = bindec(substr($_aisdata,278,5)); |
|
165 | - $ro->eta_hour = bindec(substr($_aisdata,283,5)); |
|
166 | - $ro->eta_minute = bindec(substr($_aisdata,288,6)); |
|
163 | + $ro->eta_month = bindec(substr($_aisdata, 274, 4)); |
|
164 | + $ro->eta_day = bindec(substr($_aisdata, 278, 5)); |
|
165 | + $ro->eta_hour = bindec(substr($_aisdata, 283, 5)); |
|
166 | + $ro->eta_minute = bindec(substr($_aisdata, 288, 6)); |
|
167 | 167 | //$ro->draught = bindec(substr($_aisdata,294,8)); |
168 | - $ro->destination = $this->binchar($_aisdata,302,120); |
|
168 | + $ro->destination = $this->binchar($_aisdata, 302, 120); |
|
169 | 169 | $ro->cls = 1; // class A |
170 | 170 | } else if ($ro->id == 9) { |
171 | 171 | // Search and Rescue aircraft position report |
172 | 172 | } else if ($ro->id == 18) { |
173 | - $ro->cog = bindec(substr($_aisdata,112,12))/10; |
|
174 | - $ro->sog = bindec(substr($_aisdata,46,10))/10; |
|
175 | - $ro->lon = $this->make_lonf(bindec(substr($_aisdata,57,28))); |
|
176 | - $ro->lat = $this->make_latf(bindec(substr($_aisdata,85,27))); |
|
177 | - $ro->heading = bindec(substr($_aisdata,124,9)); |
|
173 | + $ro->cog = bindec(substr($_aisdata, 112, 12))/10; |
|
174 | + $ro->sog = bindec(substr($_aisdata, 46, 10))/10; |
|
175 | + $ro->lon = $this->make_lonf(bindec(substr($_aisdata, 57, 28))); |
|
176 | + $ro->lat = $this->make_latf(bindec(substr($_aisdata, 85, 27))); |
|
177 | + $ro->heading = bindec(substr($_aisdata, 124, 9)); |
|
178 | 178 | if ($ro->heading == 511) $ro->heading = ''; |
179 | 179 | $ro->cls = 2; // class B |
180 | 180 | } else if ($ro->id == 19) { |
181 | - $ro->cog = bindec(substr($_aisdata,112,12))/10; |
|
182 | - $ro->sog = bindec(substr($_aisdata,46,10))/10; |
|
183 | - $ro->lon = $this->make_lonf(bindec(substr($_aisdata,61,28))); |
|
184 | - $ro->lat = $this->make_latf(bindec(substr($_aisdata,89,27))); |
|
185 | - $ro->name = $this->binchar($_aisdata,143,120); |
|
181 | + $ro->cog = bindec(substr($_aisdata, 112, 12))/10; |
|
182 | + $ro->sog = bindec(substr($_aisdata, 46, 10))/10; |
|
183 | + $ro->lon = $this->make_lonf(bindec(substr($_aisdata, 61, 28))); |
|
184 | + $ro->lat = $this->make_latf(bindec(substr($_aisdata, 89, 27))); |
|
185 | + $ro->name = $this->binchar($_aisdata, 143, 120); |
|
186 | 186 | $ro->cls = 2; // class B |
187 | - $ro->heading = bindec(substr($_aisdata,124,9)); |
|
187 | + $ro->heading = bindec(substr($_aisdata, 124, 9)); |
|
188 | 188 | if ($ro->heading == 511) $ro->heading = ''; |
189 | - $ro->typeid = bindec(substr($_aisdata,263,8)); |
|
189 | + $ro->typeid = bindec(substr($_aisdata, 263, 8)); |
|
190 | 190 | $ro->type = $this->getShipType($ro->typeid); |
191 | 191 | //$ro->to_bow = bindec(substr($_aisdata,271,9)); |
192 | 192 | //$ro->to_stern = bindec(substr($_aisdata,280,9)); |
193 | 193 | //$ro->to_port = bindec(substr($_aisdata,289,6)); |
194 | 194 | //$ro->to_starboard = bindec(substr($_aisdata,295,6)); |
195 | 195 | } else if ($ro->id == 21) { |
196 | - $ro->lon = $this->make_lonf(bindec(substr($_aisdata,164,28))); |
|
197 | - $ro->lat = $this->make_latf(bindec(substr($_aisdata,192,27))); |
|
198 | - $ro->name = $this->binchar($_aisdata,43,120); |
|
196 | + $ro->lon = $this->make_lonf(bindec(substr($_aisdata, 164, 28))); |
|
197 | + $ro->lat = $this->make_latf(bindec(substr($_aisdata, 192, 27))); |
|
198 | + $ro->name = $this->binchar($_aisdata, 43, 120); |
|
199 | 199 | //$ro->to_bow = bindec(substr($_aisdata,219,9)); |
200 | 200 | //$ro->to_stern = bindec(substr($_aisdata,228,9)); |
201 | 201 | //$ro->to_port = bindec(substr($_aisdata,237,6)); |
202 | 202 | //$ro->to_starboard = bindec(substr($_aisdata,243,6)); |
203 | 203 | $ro->cls = 2; // class B |
204 | 204 | } else if ($ro->id == 24) { |
205 | - $pn = bindec(substr($_aisdata,38,2)); |
|
205 | + $pn = bindec(substr($_aisdata, 38, 2)); |
|
206 | 206 | if ($pn == 0) { |
207 | - $ro->name = $this->binchar($_aisdata,40,120); |
|
207 | + $ro->name = $this->binchar($_aisdata, 40, 120); |
|
208 | 208 | } |
209 | - $ro->typeid = bindec(substr($_aisdata,40,8)); |
|
209 | + $ro->typeid = bindec(substr($_aisdata, 40, 8)); |
|
210 | 210 | $ro->type = $this->getShipType($ro->typeid); |
211 | - $ro->callsign = $this->binchar($_aisdata,90,42); |
|
211 | + $ro->callsign = $this->binchar($_aisdata, 90, 42); |
|
212 | 212 | //$ro->to_bow = bindec(substr($_aisdata,132,9)); |
213 | 213 | //$ro->to_stern = bindec(substr($_aisdata,141,9)); |
214 | 214 | //$ro->to_port = bindec(substr($_aisdata,150,6)); |
215 | 215 | //$ro->to_starboard = bindec(substr($_aisdata,156,6)); |
216 | 216 | $ro->cls = 2; // class B |
217 | 217 | } else if ($ro->id == 27) { |
218 | - $ro->cog = bindec(substr($_aisdata,85,9)); |
|
218 | + $ro->cog = bindec(substr($_aisdata, 85, 9)); |
|
219 | 219 | if ($ro->cog == 511) $ro->cog = 0.0; |
220 | - $ro->sog = bindec(substr($_aisdata,79,6)); |
|
220 | + $ro->sog = bindec(substr($_aisdata, 79, 6)); |
|
221 | 221 | if ($ro->sog == 63) $ro->sog = 0.0; |
222 | - $ro->lon = $this->make_lonf(bindec(substr($_aisdata,44,18))*10); |
|
223 | - $ro->lat = $this->make_latf(bindec(substr($_aisdata,62,17))*10); |
|
222 | + $ro->lon = $this->make_lonf(bindec(substr($_aisdata, 44, 18))*10); |
|
223 | + $ro->lat = $this->make_latf(bindec(substr($_aisdata, 62, 17))*10); |
|
224 | 224 | $ro->cls = 1; // class A |
225 | 225 | |
226 | 226 | } |
227 | - $ro->statusid = bindec(substr($_aisdata,38,4)); |
|
227 | + $ro->statusid = bindec(substr($_aisdata, 38, 4)); |
|
228 | 228 | $ro->status = $this->getStatus($ro->statusid); |
229 | 229 | //var_dump($ro); // dump results here for demo purpose |
230 | 230 | return $ro; |
@@ -355,14 +355,14 @@ discard block |
||
355 | 355 | global $port; // tcpip port... |
356 | 356 | |
357 | 357 | static $debug_counter = 0; |
358 | - $aisdata168='';//six bit array of ascii characters |
|
358 | + $aisdata168 = ''; //six bit array of ascii characters |
|
359 | 359 | $ais_nmea_array = str_split($_itu); // convert to an array |
360 | 360 | foreach ($ais_nmea_array as $value) { |
361 | 361 | $dec = $this->ascii_2_dec($value); |
362 | 362 | $bit8 = $this->asciidec_2_8bit($dec); |
363 | 363 | $bit6 = $this->dec_2_6bit($bit8); |
364 | 364 | //echo $value ."-" .$bit6 .""; |
365 | - $aisdata168 .=$bit6; |
|
365 | + $aisdata168 .= $bit6; |
|
366 | 366 | } |
367 | 367 | //echo $aisdata168 . "<br/>"; |
368 | 368 | //return $this->decode_ais($aisdata168, $aux); |
@@ -385,20 +385,20 @@ discard block |
||
385 | 385 | // calculate checksum after ! till * |
386 | 386 | // assume 1st ! is valid |
387 | 387 | // find * ensure that it is at correct position |
388 | - $end = strrpos ( $rawdata , '*' ); |
|
388 | + $end = strrpos($rawdata, '*'); |
|
389 | 389 | if ($end === FALSE) return -1; // check for NULLS!!! |
390 | - $cs = substr( $rawdata, $end + 1 ); |
|
391 | - if ( strlen($cs) != 2 ) return -1; // correct cs length |
|
392 | - $dcs = (int)hexdec( $cs ); |
|
393 | - for ( $alias=1; $alias<$end; $alias++) $chksum ^= ord( $rawdata[$alias] ); // perform XOR for NMEA checksum |
|
394 | - if ( $chksum == $dcs ) { // NMEA checksum pass |
|
390 | + $cs = substr($rawdata, $end + 1); |
|
391 | + if (strlen($cs) != 2) return -1; // correct cs length |
|
392 | + $dcs = (int) hexdec($cs); |
|
393 | + for ($alias = 1; $alias < $end; $alias++) $chksum ^= ord($rawdata[$alias]); // perform XOR for NMEA checksum |
|
394 | + if ($chksum == $dcs) { // NMEA checksum pass |
|
395 | 395 | $pcs = explode(',', $rawdata); |
396 | 396 | // !AI??? identifier |
397 | - $num_seq = (int)$pcs[1]; // number of sequences |
|
398 | - $seq = (int)$pcs[2]; // get sequence |
|
397 | + $num_seq = (int) $pcs[1]; // number of sequences |
|
398 | + $seq = (int) $pcs[2]; // get sequence |
|
399 | 399 | // get msg sequence id |
400 | 400 | if ($pcs[3] == '') $msg_sid = -1; // non-multipart message, set to -1 |
401 | - else $msg_sid = (int)$pcs[3]; // multipart message |
|
401 | + else $msg_sid = (int) $pcs[3]; // multipart message |
|
402 | 402 | $ais_ch = $pcs[4]; // get AIS channel |
403 | 403 | // message sequence checking |
404 | 404 | if ($num_seq < 1 || $num_seq > 9) { |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | } |
432 | 432 | } |
433 | 433 | $itu = $itu.$pcs[5]; // get itu message |
434 | - $filler += (int)$pcs[6][0]; // get filler |
|
434 | + $filler += (int) $pcs[6][0]; // get filler |
|
435 | 435 | if ($num_seq == 1 // valid single message |
436 | 436 | || $num_seq == $pseq // valid multi-part message |
437 | 437 | ) { |
@@ -451,13 +451,13 @@ discard block |
||
451 | 451 | $cbuf = $cbuf.$ibuf; |
452 | 452 | $last_pos = 0; |
453 | 453 | $result = new stdClass(); |
454 | - while ( ($start = strpos($cbuf,"VDM",$last_pos)) !== FALSE) { |
|
454 | + while (($start = strpos($cbuf, "VDM", $last_pos)) !== FALSE) { |
|
455 | 455 | //while ( ($start = strpos($cbuf,"!AI",$last_pos)) !== FALSE) { |
456 | 456 | //DEBUG echo $cbuf; |
457 | - if ( ($end = strpos($cbuf,"\r\n", $start)) !== FALSE) { //TBD need to trim? |
|
457 | + if (($end = strpos($cbuf, "\r\n", $start)) !== FALSE) { //TBD need to trim? |
|
458 | 458 | $tst = substr($cbuf, $start - 3, ($end - $start + 3)); |
459 | 459 | //DEBUG echo "[$start $end $tst]\n"; |
460 | - $result = $this->process_ais_raw( $tst, "" ); |
|
460 | + $result = $this->process_ais_raw($tst, ""); |
|
461 | 461 | $last_pos = $end + 1; |
462 | 462 | } else break; |
463 | 463 | } |
@@ -469,41 +469,41 @@ discard block |
||
469 | 469 | // incoming data from serial or IP comms |
470 | 470 | public function process_ais_line($cbuf) { |
471 | 471 | $result = new stdClass(); |
472 | - $start = strpos($cbuf,"VDM"); |
|
472 | + $start = strpos($cbuf, "VDM"); |
|
473 | 473 | $tst = substr($cbuf, $start - 3); |
474 | - $result = $this->process_ais_raw( $tst, "" ); |
|
474 | + $result = $this->process_ais_raw($tst, ""); |
|
475 | 475 | return $result; |
476 | 476 | } |
477 | 477 | |
478 | 478 | /* AIS Encoding |
479 | 479 | */ |
480 | - private function mk_ais_lat( $lat ) { |
|
480 | + private function mk_ais_lat($lat) { |
|
481 | 481 | //$lat = 1.2569; |
482 | - if ($lat<0.0) { |
|
482 | + if ($lat < 0.0) { |
|
483 | 483 | $lat = -$lat; |
484 | - $neg=true; |
|
485 | - } else $neg=false; |
|
484 | + $neg = true; |
|
485 | + } else $neg = false; |
|
486 | 486 | $latd = 0x00000000; |
487 | - $latd = intval ($lat * 600000.0); |
|
488 | - if ($neg==true) { |
|
487 | + $latd = intval($lat*600000.0); |
|
488 | + if ($neg == true) { |
|
489 | 489 | $latd = ~$latd; |
490 | - $latd+=1; |
|
490 | + $latd += 1; |
|
491 | 491 | $latd &= 0x07FFFFFF; |
492 | 492 | } |
493 | 493 | return $latd; |
494 | 494 | } |
495 | 495 | |
496 | - private function mk_ais_lon( $lon ) { |
|
496 | + private function mk_ais_lon($lon) { |
|
497 | 497 | //$lon = 103.851; |
498 | - if ($lon<0.0) { |
|
498 | + if ($lon < 0.0) { |
|
499 | 499 | $lon = -$lon; |
500 | - $neg=true; |
|
501 | - } else $neg=false; |
|
500 | + $neg = true; |
|
501 | + } else $neg = false; |
|
502 | 502 | $lond = 0x00000000; |
503 | - $lond = intval ($lon * 600000.0); |
|
504 | - if ($neg==true) { |
|
503 | + $lond = intval($lon*600000.0); |
|
504 | + if ($neg == true) { |
|
505 | 505 | $lond = ~$lond; |
506 | - $lond+=1; |
|
506 | + $lond += 1; |
|
507 | 507 | $lond &= 0x0FFFFFFF; |
508 | 508 | } |
509 | 509 | return $lond; |
@@ -511,8 +511,8 @@ discard block |
||
511 | 511 | |
512 | 512 | private function char2bin($name, $max_len) { |
513 | 513 | $len = strlen($name); |
514 | - if ($len > $max_len) $name = substr($name,0,$max_len); |
|
515 | - if ($len < $max_len) $pad = str_repeat('0', ($max_len - $len) * 6); |
|
514 | + if ($len > $max_len) $name = substr($name, 0, $max_len); |
|
515 | + if ($len < $max_len) $pad = str_repeat('0', ($max_len - $len)*6); |
|
516 | 516 | else $pad = ''; |
517 | 517 | $rv = ''; |
518 | 518 | $ais_chars = array( |
@@ -529,26 +529,26 @@ discard block |
||
529 | 529 | if ($_a) foreach ($_a as $_1) { |
530 | 530 | if (isset($ais_chars[$_1])) $dec = $ais_chars[$_1]; |
531 | 531 | else $dec = 0; |
532 | - $bin = str_pad(decbin( $dec ), 6, '0', STR_PAD_LEFT); |
|
532 | + $bin = str_pad(decbin($dec), 6, '0', STR_PAD_LEFT); |
|
533 | 533 | $rv .= $bin; |
534 | 534 | //echo "$_1 $dec ($bin)<br/>"; |
535 | 535 | } |
536 | 536 | return $rv.$pad; |
537 | 537 | } |
538 | 538 | |
539 | - private function mk_ais($_enc, $_part=1,$_total=1,$_seq='',$_ch='A') { |
|
539 | + private function mk_ais($_enc, $_part = 1, $_total = 1, $_seq = '', $_ch = 'A') { |
|
540 | 540 | $len_bit = strlen($_enc); |
541 | - $rem6 = $len_bit % 6; |
|
541 | + $rem6 = $len_bit%6; |
|
542 | 542 | $pad6_len = 0; |
543 | 543 | if ($rem6) $pad6_len = 6 - $rem6; |
544 | 544 | //echo $pad6_len.'<br>'; |
545 | 545 | $_enc .= str_repeat("0", $pad6_len); // pad the text... |
546 | - $len_enc = strlen($_enc) / 6; |
|
546 | + $len_enc = strlen($_enc)/6; |
|
547 | 547 | //echo $_enc.' '.$len_enc.'<br/>'; |
548 | 548 | $itu = ''; |
549 | - for ($i=0; $i<$len_enc; $i++) { |
|
550 | - $offset = $i * 6; |
|
551 | - $dec = bindec(substr($_enc,$offset,6)); |
|
549 | + for ($i = 0; $i < $len_enc; $i++) { |
|
550 | + $offset = $i*6; |
|
551 | + $dec = bindec(substr($_enc, $offset, 6)); |
|
552 | 552 | if ($dec < 40) $dec += 48; |
553 | 553 | else $dec += 56; |
554 | 554 | //echo chr($dec)." $dec<br/>"; |
@@ -558,15 +558,15 @@ discard block |
||
558 | 558 | $chksum = 0; |
559 | 559 | $itu = "AIVDM,$_part,$_total,$_seq,$_ch,".$itu.",0"; |
560 | 560 | $len_itu = strlen($itu); |
561 | - for ($i=0; $i<$len_itu; $i++) { |
|
562 | - $chksum ^= ord( $itu[$i] ); |
|
561 | + for ($i = 0; $i < $len_itu; $i++) { |
|
562 | + $chksum ^= ord($itu[$i]); |
|
563 | 563 | } |
564 | - $hex_arr = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'); |
|
565 | - $lsb = $chksum & 0x0F; |
|
566 | - if ($lsb >=0 && $lsb <= 15 ) $lsbc = $hex_arr[$lsb]; |
|
564 | + $hex_arr = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'); |
|
565 | + $lsb = $chksum&0x0F; |
|
566 | + if ($lsb >= 0 && $lsb <= 15) $lsbc = $hex_arr[$lsb]; |
|
567 | 567 | else $lsbc = '0'; |
568 | - $msb = (($chksum & 0xF0) >> 4) & 0x0F; |
|
569 | - if ($msb >=0 && $msb <= 15 ) $msbc = $hex_arr[$msb]; |
|
568 | + $msb = (($chksum&0xF0) >> 4)&0x0F; |
|
569 | + if ($msb >= 0 && $msb <= 15) $msbc = $hex_arr[$msb]; |
|
570 | 570 | else $msbc = '0'; |
571 | 571 | $itu = '!'.$itu."*{$msbc}{$lsbc}\r\n"; |
572 | 572 | return $itu; |
@@ -591,14 +591,14 @@ discard block |
||
591 | 591 | |
592 | 592 | public function mmsitype($mmsi) { |
593 | 593 | if (strlen($mmsi) == 9) { |
594 | - if (substr($mmsi,0,3) == '974') return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS'; |
|
595 | - elseif (substr($mmsi,0,3) == '972') return 'MOB (Man Overboard) device'; |
|
596 | - elseif (substr($mmsi,0,3) == '970') return 'AIS SART (Search and Rescue Transmitter)'; |
|
597 | - elseif (substr($mmsi,0,3) == '111') return 'SAR (Search and Rescue) aircraft'; |
|
598 | - elseif (substr($mmsi,0,2) == '98') return 'Auxiliary craft associated with a parent ship'; |
|
599 | - elseif (substr($mmsi,0,2) == '99') return 'Aids to Navigation'; |
|
600 | - elseif (substr($mmsi,0,2) == '00') return 'Coastal stations'; |
|
601 | - elseif (substr($mmsi,0,1) == '0') return 'Group of ships'; |
|
594 | + if (substr($mmsi, 0, 3) == '974') return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS'; |
|
595 | + elseif (substr($mmsi, 0, 3) == '972') return 'MOB (Man Overboard) device'; |
|
596 | + elseif (substr($mmsi, 0, 3) == '970') return 'AIS SART (Search and Rescue Transmitter)'; |
|
597 | + elseif (substr($mmsi, 0, 3) == '111') return 'SAR (Search and Rescue) aircraft'; |
|
598 | + elseif (substr($mmsi, 0, 2) == '98') return 'Auxiliary craft associated with a parent ship'; |
|
599 | + elseif (substr($mmsi, 0, 2) == '99') return 'Aids to Navigation'; |
|
600 | + elseif (substr($mmsi, 0, 2) == '00') return 'Coastal stations'; |
|
601 | + elseif (substr($mmsi, 0, 1) == '0') return 'Group of ships'; |
|
602 | 602 | else return 'Ship'; |
603 | 603 | } |
604 | 604 | |
@@ -609,19 +609,19 @@ discard block |
||
609 | 609 | global $globalDebug; |
610 | 610 | $result = array(); |
611 | 611 | $data = new stdClass(); |
612 | - $start = strpos($buffer,"VDM"); |
|
612 | + $start = strpos($buffer, "VDM"); |
|
613 | 613 | $tst = substr($buffer, $start - 3); |
614 | - $data = $this->process_ais_raw( $tst, "" ); |
|
614 | + $data = $this->process_ais_raw($tst, ""); |
|
615 | 615 | if (!is_object($data)) { |
616 | 616 | //if ($globalDebug) echo '==== Line format not supported : '.$buffer."\n"; |
617 | 617 | return array(); |
618 | 618 | } |
619 | 619 | if ($data->lon != 0) $result['longitude'] = $data->lon; |
620 | 620 | if ($data->lat != 0) $result['latitude'] = $data->lat; |
621 | - $result['ident'] = trim(str_replace('@','',$data->name)); |
|
621 | + $result['ident'] = trim(str_replace('@', '', $data->name)); |
|
622 | 622 | $result['timestamp'] = $data->ts; |
623 | 623 | $result['mmsi'] = $data->mmsi; |
624 | - if (strlen($result['mmsi']) == 8 && susbtr($result['mmsi'],0,3) == '669') $result['mmsi'] = '3'.$result['mmsi']; |
|
624 | + if (strlen($result['mmsi']) == 8 && susbtr($result['mmsi'], 0, 3) == '669') $result['mmsi'] = '3'.$result['mmsi']; |
|
625 | 625 | $result['mmsi_type'] = $this->mmsitype($result['mmsi']); |
626 | 626 | if ($data->sog != -1.0) $result['speed'] = $data->sog; |
627 | 627 | if ($data->heading != '') $result['heading'] = $data->heading; |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | if (isset($this->all_tracked[$key]['id'])) { |
51 | 51 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
52 | 52 | $Marine = new Marine($this->db); |
53 | - $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
53 | + $Marine->updateLatestMarineData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['speed'], $this->all_tracked[$key]['datetime']); |
|
54 | 54 | } |
55 | 55 | } |
56 | 56 | } |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
62 | 62 | foreach ($this->all_tracked as $key => $flight) { |
63 | 63 | if (isset($flight['lastupdate'])) { |
64 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
64 | + if ($flight['lastupdate'] < (time() - 3000)) { |
|
65 | 65 | if (isset($this->all_tracked[$key]['id'])) { |
66 | 66 | if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
67 | 67 | /* |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | //$real_arrival = $this->arrival($key); |
73 | 73 | $Marine = new Marine($this->db); |
74 | 74 | if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
75 | - $result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed']); |
|
75 | + $result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['speed']); |
|
76 | 76 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
77 | 77 | } |
78 | 78 | // Put in archive |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | $send = false; |
93 | 93 | |
94 | 94 | // SBS format is CSV format |
95 | - if(is_array($line) && isset($line['mmsi'])) { |
|
95 | + if (is_array($line) && isset($line['mmsi'])) { |
|
96 | 96 | //print_r($line); |
97 | 97 | if (isset($line['mmsi'])) { |
98 | 98 | |
@@ -116,18 +116,18 @@ discard block |
||
116 | 116 | |
117 | 117 | if (!isset($this->all_tracked[$id])) { |
118 | 118 | $this->all_tracked[$id] = array(); |
119 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0)); |
|
120 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '')); |
|
121 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
119 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('addedMarine' => 0)); |
|
120 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'heading' => '', 'format_source' => '', 'source_name' => '', 'comment'=> '', 'type' => '', 'typeid' => '', 'noarchive' => false, 'putinarchive' => true, 'over_country' => '', 'mmsi' => '', 'status' => '', 'imo' => '', 'callsign' => '', 'arrival_code' => '', 'arrival_date' => '')); |
|
121 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('lastupdate' => time())); |
|
122 | 122 | if (!isset($line['id'])) { |
123 | 123 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
124 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
125 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
124 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
125 | + } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $line['id'])); |
|
126 | 126 | if ($globalAllTracked !== FALSE) $dataFound = true; |
127 | 127 | } |
128 | 128 | |
129 | 129 | if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) { |
130 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi'])); |
|
130 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('mmsi' => $line['mmsi'])); |
|
131 | 131 | $Marine = new Marine($this->db); |
132 | 132 | $identity = $Marine->getIdentity($line['mmsi']); |
133 | 133 | if (!empty($identity)) { |
@@ -139,59 +139,59 @@ discard block |
||
139 | 139 | //$dataFound = true; |
140 | 140 | } |
141 | 141 | if (isset($line['type_id']) && $line['type_id'] != '') { |
142 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id']))); |
|
142 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $AIS->getShipType($line['type_id']))); |
|
143 | 143 | } |
144 | 144 | if (isset($line['type']) && $line['type'] != '') { |
145 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
145 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $line['type'])); |
|
146 | 146 | } |
147 | 147 | if (isset($line['imo']) && $line['imo'] != '') { |
148 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
148 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('imo' => $line['imo'])); |
|
149 | 149 | } |
150 | 150 | if (isset($line['callsign']) && $line['callsign'] != '') { |
151 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
151 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('callsign' => $line['callsign'])); |
|
152 | 152 | } |
153 | 153 | if (isset($line['arrival_code']) && $line['arrival_code'] != '') { |
154 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
|
154 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_code' => $line['arrival_code'])); |
|
155 | 155 | } |
156 | 156 | if (isset($line['arrival_date']) && $line['arrival_date'] != '') { |
157 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
157 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_date' => $line['arrival_date'])); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | |
161 | 161 | //if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) { |
162 | 162 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) { |
163 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
163 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => trim($line['ident']))); |
|
164 | 164 | if ($this->all_tracked[$id]['addedMarine'] == 1) { |
165 | 165 | $timeelapsed = microtime(true); |
166 | 166 | $Marine = new Marine($this->db); |
167 | 167 | $fromsource = NULL; |
168 | - $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
|
168 | + $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $fromsource); |
|
169 | 169 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
170 | 170 | $Marine->db = null; |
171 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
171 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
172 | 172 | } |
173 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
173 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident'])); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | if (isset($line['speed']) && $line['speed'] != '') { |
177 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
178 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
177 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($line['speed']))); |
|
178 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed_fromsrc' => true)); |
|
179 | 179 | } else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
180 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
180 | + $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm'); |
|
181 | 181 | if ($distance > 1000 && $distance < 10000) { |
182 | 182 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
183 | 183 | $speed = $speed*3.6; |
184 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
184 | + if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($speed))); |
|
185 | 185 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
186 | 186 | } |
187 | 187 | } |
188 | 188 | |
189 | 189 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
190 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
190 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time() - $this->all_tracked[$id]['time_last_coord']); |
|
191 | 191 | else unset($timediff); |
192 | - if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
|
192 | + if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')))) { |
|
193 | 193 | if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) { |
194 | - if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
194 | + if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['livedb_latitude'], $this->all_tracked[$id]['livedb_longitude'], $line['latitude'], $line['longitude'])) { |
|
195 | 195 | $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
196 | 196 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
197 | 197 | $this->all_tracked[$id]['putinarchive'] = true; |
@@ -199,10 +199,10 @@ discard block |
||
199 | 199 | if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
200 | 200 | $timeelapsed = microtime(true); |
201 | 201 | $Marine = new Marine($this->db); |
202 | - $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
202 | + $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']); |
|
203 | 203 | if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
204 | 204 | $Marine->db = null; |
205 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
205 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
206 | 206 | $this->tmd = 0; |
207 | 207 | if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
208 | 208 | } |
@@ -210,66 +210,66 @@ discard block |
||
210 | 210 | |
211 | 211 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
212 | 212 | if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
213 | - if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
213 | + if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
214 | 214 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
215 | 215 | $dataFound = true; |
216 | 216 | $this->all_tracked[$id]['time_last_coord'] = time(); |
217 | 217 | } |
218 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
|
218 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('latitude' => $line['latitude'])); |
|
219 | 219 | } |
220 | 220 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
221 | 221 | if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
222 | 222 | if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
223 | - if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
223 | + if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
224 | 224 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
225 | 225 | $dataFound = true; |
226 | 226 | $this->all_tracked[$id]['time_last_coord'] = time(); |
227 | 227 | } |
228 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
|
228 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('longitude' => $line['longitude'])); |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | } else if ($globalDebug && $timediff > 20) { |
232 | 232 | $this->tmd = $this->tmd + 1; |
233 | 233 | echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n"; |
234 | - echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -"; |
|
235 | - echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
|
234 | + echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')."m -"; |
|
235 | + echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - "; |
|
236 | 236 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n"; |
237 | 237 | } |
238 | 238 | } |
239 | 239 | if (isset($line['last_update']) && $line['last_update'] != '') { |
240 | 240 | if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
241 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
241 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('last_update' => $line['last_update'])); |
|
242 | 242 | } |
243 | 243 | if (isset($line['format_source']) && $line['format_source'] != '') { |
244 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
244 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('format_source' => $line['format_source'])); |
|
245 | 245 | } |
246 | 246 | if (isset($line['source_name']) && $line['source_name'] != '') { |
247 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
247 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('source_name' => $line['source_name'])); |
|
248 | 248 | } |
249 | 249 | if (isset($line['status']) && $line['status'] != '') { |
250 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
250 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('status' => $line['status'])); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
254 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
254 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('noarchive' => true)); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | if (isset($line['heading']) && $line['heading'] != '') { |
258 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
259 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
260 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
258 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading'] - round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
259 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($line['heading']))); |
|
260 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading_fromsrc' => true)); |
|
261 | 261 | //$dataFound = true; |
262 | 262 | } elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) { |
263 | - $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
264 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
265 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
263 | + $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']); |
|
264 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($heading))); |
|
265 | + if (abs($this->all_tracked[$id]['heading'] - round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
266 | 266 | if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
267 | 267 | } |
268 | 268 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
269 | 269 | |
270 | 270 | if (isset($line['datetime'])) { |
271 | 271 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
272 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
|
272 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => $line['datetime'])); |
|
273 | 273 | } else { |
274 | 274 | if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
275 | 275 | elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
@@ -277,48 +277,48 @@ discard block |
||
277 | 277 | } |
278 | 278 | } else { |
279 | 279 | date_default_timezone_set('UTC'); |
280 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
280 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => date('Y-m-d H:i:s'))); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | |
284 | 284 | if ($dataFound === true && isset($this->all_tracked[$id]['mmsi'])) { |
285 | 285 | $this->all_tracked[$id]['lastupdate'] = time(); |
286 | 286 | if ($this->all_tracked[$id]['addedMarine'] == 0) { |
287 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
287 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
288 | 288 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
289 | 289 | if ($globalDebug) echo "Check if aircraft is already in DB..."; |
290 | 290 | $timeelapsed = microtime(true); |
291 | 291 | $MarineLive = new MarineLive($this->db); |
292 | 292 | if (isset($line['id'])) { |
293 | 293 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
294 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
294 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
295 | 295 | } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
296 | 296 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
297 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
297 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
298 | 298 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
299 | 299 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
300 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
300 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
301 | 301 | } else $recent_ident = ''; |
302 | - $MarineLive->db=null; |
|
302 | + $MarineLive->db = null; |
|
303 | 303 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
304 | 304 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
305 | 305 | } else { |
306 | 306 | $recent_ident = ''; |
307 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
|
307 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('forcenew' => 0)); |
|
308 | 308 | } |
309 | 309 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
310 | - if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
310 | + if ($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
311 | 311 | { |
312 | 312 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
313 | 313 | //adds the spotter data for the archive |
314 | 314 | $highlight = ''; |
315 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
315 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
316 | 316 | $timeelapsed = microtime(true); |
317 | 317 | $Marine = new Marine($this->db); |
318 | - $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
|
318 | + $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['typeid'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['arrival_code'], $this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name']); |
|
319 | 319 | $Marine->db = null; |
320 | 320 | if ($globalDebug && isset($result)) echo $result."\n"; |
321 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
321 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
322 | 322 | |
323 | 323 | /* |
324 | 324 | // Add source stat in DB |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | //MarineLive->deleteLiveMarineDataNotUpdated(); |
357 | 357 | $MarineLive = new MarineLive($this->db); |
358 | 358 | $MarineLive->deleteLiveMarineData(); |
359 | - $MarineLive->db=null; |
|
359 | + $MarineLive->db = null; |
|
360 | 360 | if ($globalDebug) echo " Done\n"; |
361 | 361 | $this->last_delete = time(); |
362 | 362 | } |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | $this->all_tracked[$id]['addedMarine'] = 1; |
366 | 366 | if (isset($globalDaemon) && !$globalDaemon) { |
367 | 367 | $Marine = new Marine($this->db); |
368 | - $Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime']); |
|
368 | + $Marine->updateLatestMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime']); |
|
369 | 369 | $Marine->db = null; |
370 | 370 | } |
371 | 371 | |
@@ -379,14 +379,14 @@ discard block |
||
379 | 379 | $ignoreImport = false; |
380 | 380 | |
381 | 381 | if (!$ignoreImport) { |
382 | - if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
382 | + if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
383 | 383 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
384 | 384 | $timeelapsed = microtime(true); |
385 | 385 | $MarineLive = new MarineLive($this->db); |
386 | - $result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
|
386 | + $result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['typeid'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['arrival_code'], $this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country']); |
|
387 | 387 | $MarineLive->db = null; |
388 | 388 | $this->all_tracked[$id]['putinarchive'] = false; |
389 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
389 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
390 | 390 | |
391 | 391 | // Put statistics in $this->stats variable |
392 | 392 | /* |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | $this->all_tracked[$id]['lastupdate'] = time(); |
446 | 446 | if ($this->all_tracked[$id]['putinarchive']) $send = true; |
447 | 447 | if ($globalDebug) echo $result."\n"; |
448 | - } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
448 | + } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n"; |
|
449 | 449 | //$this->del(); |
450 | 450 | |
451 | 451 |
@@ -16,33 +16,33 @@ discard block |
||
16 | 16 | * @param Array $filter the filter |
17 | 17 | * @return Array the SQL part |
18 | 18 | */ |
19 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
19 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
21 | 21 | $filters = array(); |
22 | 22 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
23 | 23 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
24 | 24 | $filters = $globalStatsFilters[$globalFilterName]; |
25 | 25 | } else { |
26 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
26 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
27 | 27 | } |
28 | 28 | } |
29 | 29 | if (isset($filter[0]['source'])) { |
30 | - $filters = array_merge($filters,$filter); |
|
30 | + $filters = array_merge($filters, $filter); |
|
31 | 31 | } |
32 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
32 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
33 | 33 | $filter_query_join = ''; |
34 | 34 | $filter_query_where = ''; |
35 | - foreach($filters as $flt) { |
|
35 | + foreach ($filters as $flt) { |
|
36 | 36 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
37 | 37 | if (isset($flt['source'])) { |
38 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND marine_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
38 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND marine_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
39 | 39 | } else { |
40 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
40 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
41 | 41 | } |
42 | 42 | } |
43 | 43 | } |
44 | 44 | if (isset($filter['source']) && !empty($filter['source'])) { |
45 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
45 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
46 | 46 | } |
47 | 47 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
48 | 48 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -71,15 +71,15 @@ discard block |
||
71 | 71 | $filter_query_date .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'"; |
72 | 72 | } |
73 | 73 | } |
74 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.fammarine_id = marine_live.fammarine_id"; |
|
74 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.fammarine_id = marine_live.fammarine_id"; |
|
75 | 75 | } |
76 | 76 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
77 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
77 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
78 | 78 | } |
79 | 79 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
80 | 80 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
81 | 81 | if ($filter_query_where != '') { |
82 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
82 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
83 | 83 | } |
84 | 84 | $filter_query = $filter_query_join.$filter_query_where; |
85 | 85 | return $filter_query; |
@@ -102,8 +102,8 @@ discard block |
||
102 | 102 | if ($limit != '') |
103 | 103 | { |
104 | 104 | $limit_array = explode(',', $limit); |
105 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
106 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
105 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
106 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
107 | 107 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
108 | 108 | { |
109 | 109 | $limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0]; |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | } else { |
127 | 127 | $query = "SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate".$filter_query.$orderby_query; |
128 | 128 | } |
129 | - $spotter_array = $Marine->getDataFromDB($query.$limit_query,array(),'',true); |
|
129 | + $spotter_array = $Marine->getDataFromDB($query.$limit_query, array(), '', true); |
|
130 | 130 | |
131 | 131 | return $spotter_array; |
132 | 132 | } |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | global $globalDBdriver, $globalLiveInterval; |
143 | 143 | date_default_timezone_set('UTC'); |
144 | 144 | |
145 | - $filter_query = $this->getFilter($filter,true,true); |
|
145 | + $filter_query = $this->getFilter($filter, true, true); |
|
146 | 146 | |
147 | 147 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
148 | 148 | if ($globalDBdriver == 'mysql') { |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | try { |
157 | 157 | $sth = $this->db->prepare($query); |
158 | 158 | $sth->execute(); |
159 | - } catch(PDOException $e) { |
|
159 | + } catch (PDOException $e) { |
|
160 | 160 | echo $e->getMessage(); |
161 | 161 | die; |
162 | 162 | } |
@@ -176,15 +176,15 @@ discard block |
||
176 | 176 | global $globalDBdriver, $globalLiveInterval; |
177 | 177 | date_default_timezone_set('UTC'); |
178 | 178 | |
179 | - $filter_query = $this->getFilter($filter,true,true); |
|
179 | + $filter_query = $this->getFilter($filter, true, true); |
|
180 | 180 | |
181 | 181 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
182 | 182 | if ($globalDBdriver == 'mysql') { |
183 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
183 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
184 | 184 | FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' |
185 | 185 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
186 | 186 | } else { |
187 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
187 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
188 | 188 | FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' |
189 | 189 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
190 | 190 | } |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | try { |
193 | 193 | $sth = $this->db->prepare($query); |
194 | 194 | $sth->execute(); |
195 | - } catch(PDOException $e) { |
|
195 | + } catch (PDOException $e) { |
|
196 | 196 | echo $e->getMessage(); |
197 | 197 | die; |
198 | 198 | } |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | public function getLiveMarineCount($filter = array()) |
210 | 210 | { |
211 | 211 | global $globalDBdriver, $globalLiveInterval; |
212 | - $filter_query = $this->getFilter($filter,true,true); |
|
212 | + $filter_query = $this->getFilter($filter, true, true); |
|
213 | 213 | |
214 | 214 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
215 | 215 | if ($globalDBdriver == 'mysql') { |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | try { |
221 | 221 | $sth = $this->db->prepare($query); |
222 | 222 | $sth->execute(); |
223 | - } catch(PDOException $e) { |
|
223 | + } catch (PDOException $e) { |
|
224 | 224 | echo $e->getMessage(); |
225 | 225 | die; |
226 | 226 | } |
@@ -243,10 +243,10 @@ discard block |
||
243 | 243 | $filter_query = $this->getFilter($filter); |
244 | 244 | |
245 | 245 | if (is_array($coord)) { |
246 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
247 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
248 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
249 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
246 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
247 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
248 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
249 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
250 | 250 | } else return array(); |
251 | 251 | if ($globalDBdriver == 'mysql') { |
252 | 252 | $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY marine_live.fammarine_id'.$filter_query; |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | if ($interval == '1m') |
299 | 299 | { |
300 | 300 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
301 | - } else if ($interval == '15m'){ |
|
301 | + } else if ($interval == '15m') { |
|
302 | 302 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date '; |
303 | 303 | } |
304 | 304 | } |
@@ -306,14 +306,14 @@ discard block |
||
306 | 306 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
307 | 307 | } |
308 | 308 | |
309 | - $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
309 | + $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
310 | 310 | WHERE marine_live.latitude <> '' |
311 | 311 | AND marine_live.longitude <> '' |
312 | 312 | ".$additional_query." |
313 | 313 | HAVING distance < :radius |
314 | 314 | ORDER BY distance"; |
315 | 315 | |
316 | - $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
316 | + $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius)); |
|
317 | 317 | |
318 | 318 | return $spotter_array; |
319 | 319 | } |
@@ -331,9 +331,9 @@ discard block |
||
331 | 331 | date_default_timezone_set('UTC'); |
332 | 332 | |
333 | 333 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
334 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
334 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
335 | 335 | |
336 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true); |
|
336 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident), '', true); |
|
337 | 337 | |
338 | 338 | return $spotter_array; |
339 | 339 | } |
@@ -344,16 +344,16 @@ discard block |
||
344 | 344 | * @return Array the spotter information |
345 | 345 | * |
346 | 346 | */ |
347 | - public function getDateLiveMarineDataByIdent($ident,$date) |
|
347 | + public function getDateLiveMarineDataByIdent($ident, $date) |
|
348 | 348 | { |
349 | 349 | $Marine = new Marine($this->db); |
350 | 350 | date_default_timezone_set('UTC'); |
351 | 351 | |
352 | 352 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
353 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
353 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
354 | 354 | |
355 | - $date = date('c',$date); |
|
356 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
355 | + $date = date('c', $date); |
|
356 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
357 | 357 | |
358 | 358 | return $spotter_array; |
359 | 359 | } |
@@ -370,9 +370,9 @@ discard block |
||
370 | 370 | date_default_timezone_set('UTC'); |
371 | 371 | |
372 | 372 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
373 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
373 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
374 | 374 | |
375 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true); |
|
375 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id), '', true); |
|
376 | 376 | |
377 | 377 | return $spotter_array; |
378 | 378 | } |
@@ -383,15 +383,15 @@ discard block |
||
383 | 383 | * @return Array the spotter information |
384 | 384 | * |
385 | 385 | */ |
386 | - public function getDateLiveMarineDataById($id,$date) |
|
386 | + public function getDateLiveMarineDataById($id, $date) |
|
387 | 387 | { |
388 | 388 | $Marine = new Marine($this->db); |
389 | 389 | date_default_timezone_set('UTC'); |
390 | 390 | |
391 | 391 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
392 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
393 | - $date = date('c',$date); |
|
394 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
|
392 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
393 | + $date = date('c', $date); |
|
394 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true); |
|
395 | 395 | |
396 | 396 | return $spotter_array; |
397 | 397 | } |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | * @return Array the spotter information |
404 | 404 | * |
405 | 405 | */ |
406 | - public function getAllLiveMarineDataById($id,$liveinterval = false) |
|
406 | + public function getAllLiveMarineDataById($id, $liveinterval = false) |
|
407 | 407 | { |
408 | 408 | global $globalDBdriver, $globalLiveInterval; |
409 | 409 | date_default_timezone_set('UTC'); |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | try { |
423 | 423 | $sth = $this->db->prepare($query); |
424 | 424 | $sth->execute(array(':id' => $id)); |
425 | - } catch(PDOException $e) { |
|
425 | + } catch (PDOException $e) { |
|
426 | 426 | echo $e->getMessage(); |
427 | 427 | die; |
428 | 428 | } |
@@ -440,12 +440,12 @@ discard block |
||
440 | 440 | { |
441 | 441 | date_default_timezone_set('UTC'); |
442 | 442 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
443 | - $query = self::$global_query.' WHERE marine_live.ident = :ident'; |
|
443 | + $query = self::$global_query.' WHERE marine_live.ident = :ident'; |
|
444 | 444 | try { |
445 | 445 | |
446 | 446 | $sth = $this->db->prepare($query); |
447 | 447 | $sth->execute(array(':ident' => $ident)); |
448 | - } catch(PDOException $e) { |
|
448 | + } catch (PDOException $e) { |
|
449 | 449 | echo $e->getMessage(); |
450 | 450 | die; |
451 | 451 | } |
@@ -475,7 +475,7 @@ discard block |
||
475 | 475 | |
476 | 476 | $sth = $this->db->prepare($query); |
477 | 477 | $sth->execute(); |
478 | - } catch(PDOException $e) { |
|
478 | + } catch (PDOException $e) { |
|
479 | 479 | return "error"; |
480 | 480 | } |
481 | 481 | |
@@ -498,14 +498,14 @@ discard block |
||
498 | 498 | |
499 | 499 | $sth = $this->db->prepare($query); |
500 | 500 | $sth->execute(); |
501 | - } catch(PDOException $e) { |
|
501 | + } catch (PDOException $e) { |
|
502 | 502 | return "error"; |
503 | 503 | } |
504 | 504 | $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
505 | 505 | $i = 0; |
506 | - $j =0; |
|
506 | + $j = 0; |
|
507 | 507 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
508 | - foreach($all as $row) |
|
508 | + foreach ($all as $row) |
|
509 | 509 | { |
510 | 510 | $i++; |
511 | 511 | $j++; |
@@ -513,9 +513,9 @@ discard block |
||
513 | 513 | if ($globalDebug) echo "."; |
514 | 514 | try { |
515 | 515 | |
516 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
516 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
517 | 517 | $sth->execute(); |
518 | - } catch(PDOException $e) { |
|
518 | + } catch (PDOException $e) { |
|
519 | 519 | return "error"; |
520 | 520 | } |
521 | 521 | $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
@@ -526,9 +526,9 @@ discard block |
||
526 | 526 | if ($i > 0) { |
527 | 527 | try { |
528 | 528 | |
529 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
529 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
530 | 530 | $sth->execute(); |
531 | - } catch(PDOException $e) { |
|
531 | + } catch (PDOException $e) { |
|
532 | 532 | return "error"; |
533 | 533 | } |
534 | 534 | } |
@@ -541,7 +541,7 @@ discard block |
||
541 | 541 | |
542 | 542 | $sth = $this->db->prepare($query); |
543 | 543 | $sth->execute(); |
544 | - } catch(PDOException $e) { |
|
544 | + } catch (PDOException $e) { |
|
545 | 545 | return "error"; |
546 | 546 | } |
547 | 547 | /* $query_delete = "DELETE FROM marine_live WHERE fammarine_id IN ("; |
@@ -589,13 +589,13 @@ discard block |
||
589 | 589 | public function deleteLiveMarineDataByIdent($ident) |
590 | 590 | { |
591 | 591 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
592 | - $query = 'DELETE FROM marine_live WHERE ident = :ident'; |
|
592 | + $query = 'DELETE FROM marine_live WHERE ident = :ident'; |
|
593 | 593 | |
594 | 594 | try { |
595 | 595 | |
596 | 596 | $sth = $this->db->prepare($query); |
597 | 597 | $sth->execute(array(':ident' => $ident)); |
598 | - } catch(PDOException $e) { |
|
598 | + } catch (PDOException $e) { |
|
599 | 599 | return "error"; |
600 | 600 | } |
601 | 601 | |
@@ -611,13 +611,13 @@ discard block |
||
611 | 611 | public function deleteLiveMarineDataById($id) |
612 | 612 | { |
613 | 613 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
614 | - $query = 'DELETE FROM marine_live WHERE fammarine_id = :id'; |
|
614 | + $query = 'DELETE FROM marine_live WHERE fammarine_id = :id'; |
|
615 | 615 | |
616 | 616 | try { |
617 | 617 | |
618 | 618 | $sth = $this->db->prepare($query); |
619 | 619 | $sth->execute(array(':id' => $id)); |
620 | - } catch(PDOException $e) { |
|
620 | + } catch (PDOException $e) { |
|
621 | 621 | return "error"; |
622 | 622 | } |
623 | 623 | |
@@ -635,13 +635,13 @@ discard block |
||
635 | 635 | { |
636 | 636 | global $globalDBdriver, $globalTimezone; |
637 | 637 | if ($globalDBdriver == 'mysql') { |
638 | - $query = 'SELECT marine_live.ident FROM marine_live |
|
638 | + $query = 'SELECT marine_live.ident FROM marine_live |
|
639 | 639 | WHERE marine_live.ident = :ident |
640 | 640 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
641 | 641 | AND marine_live.date < UTC_TIMESTAMP()'; |
642 | 642 | $query_data = array(':ident' => $ident); |
643 | 643 | } else { |
644 | - $query = "SELECT marine_live.ident FROM marine_live |
|
644 | + $query = "SELECT marine_live.ident FROM marine_live |
|
645 | 645 | WHERE marine_live.ident = :ident |
646 | 646 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
647 | 647 | AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -650,8 +650,8 @@ discard block |
||
650 | 650 | |
651 | 651 | $sth = $this->db->prepare($query); |
652 | 652 | $sth->execute($query_data); |
653 | - $ident_result=''; |
|
654 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
653 | + $ident_result = ''; |
|
654 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
655 | 655 | { |
656 | 656 | $ident_result = $row['ident']; |
657 | 657 | } |
@@ -668,13 +668,13 @@ discard block |
||
668 | 668 | { |
669 | 669 | global $globalDBdriver, $globalTimezone; |
670 | 670 | if ($globalDBdriver == 'mysql') { |
671 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
671 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
672 | 672 | WHERE marine_live.ident = :ident |
673 | 673 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
674 | 674 | // AND marine_live.date < UTC_TIMESTAMP()"; |
675 | 675 | $query_data = array(':ident' => $ident); |
676 | 676 | } else { |
677 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
677 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
678 | 678 | WHERE marine_live.ident = :ident |
679 | 679 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'"; |
680 | 680 | // AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -683,8 +683,8 @@ discard block |
||
683 | 683 | |
684 | 684 | $sth = $this->db->prepare($query); |
685 | 685 | $sth->execute($query_data); |
686 | - $ident_result=''; |
|
687 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
686 | + $ident_result = ''; |
|
687 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
688 | 688 | { |
689 | 689 | $ident_result = $row['fammarine_id']; |
690 | 690 | } |
@@ -701,13 +701,13 @@ discard block |
||
701 | 701 | { |
702 | 702 | global $globalDBdriver, $globalTimezone; |
703 | 703 | if ($globalDBdriver == 'mysql') { |
704 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
704 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
705 | 705 | WHERE marine_live.fammarine_id = :id |
706 | 706 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
707 | 707 | // AND marine_live.date < UTC_TIMESTAMP()"; |
708 | 708 | $query_data = array(':id' => $id); |
709 | 709 | } else { |
710 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
710 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
711 | 711 | WHERE marine_live.fammarine_id = :id |
712 | 712 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
713 | 713 | // AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -716,8 +716,8 @@ discard block |
||
716 | 716 | |
717 | 717 | $sth = $this->db->prepare($query); |
718 | 718 | $sth->execute($query_data); |
719 | - $ident_result=''; |
|
720 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
719 | + $ident_result = ''; |
|
720 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
721 | 721 | { |
722 | 722 | $ident_result = $row['fammarine_id']; |
723 | 723 | } |
@@ -734,13 +734,13 @@ discard block |
||
734 | 734 | { |
735 | 735 | global $globalDBdriver, $globalTimezone; |
736 | 736 | if ($globalDBdriver == 'mysql') { |
737 | - $query = 'SELECT marine_live.fammarine_id FROM marine_live |
|
737 | + $query = 'SELECT marine_live.fammarine_id FROM marine_live |
|
738 | 738 | WHERE marine_live.mmsi = :mmsi |
739 | 739 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
740 | 740 | // AND marine_live.date < UTC_TIMESTAMP()"; |
741 | 741 | $query_data = array(':mmsi' => $mmsi); |
742 | 742 | } else { |
743 | - $query = "SELECT marine_live.fammarine_id FROM marine_live |
|
743 | + $query = "SELECT marine_live.fammarine_id FROM marine_live |
|
744 | 744 | WHERE marine_live.mmsi = :mmsi |
745 | 745 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
746 | 746 | // AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -749,8 +749,8 @@ discard block |
||
749 | 749 | |
750 | 750 | $sth = $this->db->prepare($query); |
751 | 751 | $sth->execute($query_data); |
752 | - $ident_result=''; |
|
753 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
752 | + $ident_result = ''; |
|
753 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
754 | 754 | { |
755 | 755 | $ident_result = $row['fammarine_id']; |
756 | 756 | } |
@@ -768,7 +768,7 @@ discard block |
||
768 | 768 | * @return String success or false |
769 | 769 | * |
770 | 770 | */ |
771 | - public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') |
|
771 | + public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '') |
|
772 | 772 | { |
773 | 773 | global $globalURL, $globalArchive, $globalDebug; |
774 | 774 | $Common = new Common(); |
@@ -820,36 +820,36 @@ discard block |
||
820 | 820 | if ($date == '') $date = date("Y-m-d H:i:s", time()); |
821 | 821 | |
822 | 822 | |
823 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
824 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
825 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
826 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
827 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
828 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
829 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
830 | - $source_name = filter_var($source_name,FILTER_SANITIZE_STRING); |
|
831 | - $over_country = filter_var($over_country,FILTER_SANITIZE_STRING); |
|
832 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
833 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
834 | - $status = filter_var($status,FILTER_SANITIZE_STRING); |
|
835 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
836 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
837 | - $arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING); |
|
838 | - $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
|
823 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
824 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
825 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
826 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
827 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
828 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
829 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
830 | + $source_name = filter_var($source_name, FILTER_SANITIZE_STRING); |
|
831 | + $over_country = filter_var($over_country, FILTER_SANITIZE_STRING); |
|
832 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
833 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
834 | + $status = filter_var($status, FILTER_SANITIZE_STRING); |
|
835 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
836 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
837 | + $arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING); |
|
838 | + $arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING); |
|
839 | 839 | |
840 | 840 | |
841 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
842 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
841 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
842 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
843 | 843 | if ($arrival_date == '') $arrival_date = NULL; |
844 | - $query = 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date) |
|
844 | + $query = 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date) |
|
845 | 845 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)'; |
846 | 846 | |
847 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country,':mmsi' => $mmsi,':type' => $type,':status' => $status,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date); |
|
847 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country, ':mmsi' => $mmsi, ':type' => $type, ':status' => $status, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date); |
|
848 | 848 | try { |
849 | 849 | |
850 | 850 | $sth = $this->db->prepare($query); |
851 | 851 | $sth->execute($query_values); |
852 | - } catch(PDOException $e) { |
|
852 | + } catch (PDOException $e) { |
|
853 | 853 | return "error : ".$e->getMessage(); |
854 | 854 | } |
855 | 855 | /* |
@@ -866,7 +866,7 @@ discard block |
||
866 | 866 | |
867 | 867 | public function getOrderBy() |
868 | 868 | { |
869 | - $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_live.date DESC")); |
|
869 | + $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_live.date DESC")); |
|
870 | 870 | return $orderby; |
871 | 871 | } |
872 | 872 |
@@ -14,12 +14,12 @@ discard block |
||
14 | 14 | * @param Array $headers header to submit with the form |
15 | 15 | * @return String the result |
16 | 16 | */ |
17 | - public function getData($url, $type = 'get', $data = '', $headers = '',$cookie = '',$referer = '',$timeout = '',$useragent = '') { |
|
17 | + public function getData($url, $type = 'get', $data = '', $headers = '', $cookie = '', $referer = '', $timeout = '', $useragent = '') { |
|
18 | 18 | global $globalProxy, $globalForceIPv4; |
19 | 19 | $ch = curl_init(); |
20 | 20 | curl_setopt($ch, CURLOPT_URL, $url); |
21 | 21 | if (isset($globalForceIPv4) && $globalForceIPv4) { |
22 | - if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')){ |
|
22 | + if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')) { |
|
23 | 23 | curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); |
24 | 24 | } |
25 | 25 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
30 | 30 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
31 | 31 | curl_setopt($ch, CURLINFO_HEADER_OUT, true); |
32 | - curl_setopt($ch,CURLOPT_ENCODING , "gzip"); |
|
32 | + curl_setopt($ch, CURLOPT_ENCODING, "gzip"); |
|
33 | 33 | //curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5'); |
34 | 34 | // curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Linux x86_64; rv:42.0) Gecko/20100101 Firefox/42.0'); |
35 | 35 | if ($useragent == '') { |
@@ -39,13 +39,13 @@ discard block |
||
39 | 39 | } |
40 | 40 | if ($timeout == '') curl_setopt($ch, CURLOPT_TIMEOUT, 10); |
41 | 41 | else curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); |
42 | - curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common',"curlResponseHeaderCallback")); |
|
42 | + curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common', "curlResponseHeaderCallback")); |
|
43 | 43 | if ($type == 'post') { |
44 | 44 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); |
45 | 45 | if (is_array($data)) { |
46 | 46 | curl_setopt($ch, CURLOPT_POST, count($data)); |
47 | 47 | $data_string = ''; |
48 | - foreach($data as $key=>$value) { $data_string .= $key.'='.$value.'&'; } |
|
48 | + foreach ($data as $key=>$value) { $data_string .= $key.'='.$value.'&'; } |
|
49 | 49 | rtrim($data_string, '&'); |
50 | 50 | curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); |
51 | 51 | } else { |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | } |
58 | 58 | if ($cookie != '') { |
59 | 59 | if (is_array($cookie)) { |
60 | - curl_setopt($ch, CURLOPT_COOKIE, implode($cookie,';')); |
|
60 | + curl_setopt($ch, CURLOPT_COOKIE, implode($cookie, ';')); |
|
61 | 61 | } else { |
62 | 62 | curl_setopt($ch, CURLOPT_COOKIE, $cookie); |
63 | 63 | } |
@@ -69,13 +69,13 @@ discard block |
||
69 | 69 | $info = curl_getinfo($ch); |
70 | 70 | //var_dump($info); |
71 | 71 | curl_close($ch); |
72 | - if ($info['http_code'] == '503' && strstr($result,'DDoS protection by CloudFlare')) { |
|
72 | + if ($info['http_code'] == '503' && strstr($result, 'DDoS protection by CloudFlare')) { |
|
73 | 73 | echo "Cloudflare Detected\n"; |
74 | 74 | require_once(dirname(__FILE__).'/libs/cloudflare-bypass/libraries/cloudflareClass.php'); |
75 | 75 | $useragent = UAgent::random(); |
76 | 76 | cloudflare::useUserAgent($useragent); |
77 | 77 | if ($clearanceCookie = cloudflare::bypass($url)) { |
78 | - return $this->getData($url,'get',$data,$headers,$clearanceCookie,$referer,$timeout,$useragent); |
|
78 | + return $this->getData($url, 'get', $data, $headers, $clearanceCookie, $referer, $timeout, $useragent); |
|
79 | 79 | } |
80 | 80 | } else { |
81 | 81 | return $result; |
@@ -116,27 +116,27 @@ discard block |
||
116 | 116 | if ($data == '') return array(); |
117 | 117 | $html = str_get_html($data); |
118 | 118 | if ($html === false) return array(); |
119 | - $tabledata=array(); |
|
120 | - foreach($html->find('tr') as $element) |
|
119 | + $tabledata = array(); |
|
120 | + foreach ($html->find('tr') as $element) |
|
121 | 121 | { |
122 | 122 | $td = array(); |
123 | - foreach( $element->find('th') as $row) |
|
123 | + foreach ($element->find('th') as $row) |
|
124 | 124 | { |
125 | 125 | $td [] = trim($row->plaintext); |
126 | 126 | } |
127 | - $td=array_filter($td); |
|
127 | + $td = array_filter($td); |
|
128 | 128 | $tabledata[] = $td; |
129 | 129 | |
130 | 130 | $td = array(); |
131 | 131 | $tdi = array(); |
132 | - foreach( $element->find('td') as $row) |
|
132 | + foreach ($element->find('td') as $row) |
|
133 | 133 | { |
134 | 134 | $td [] = trim($row->plaintext); |
135 | 135 | $tdi [] = trim($row->innertext); |
136 | 136 | } |
137 | - $td=array_filter($td); |
|
138 | - $tdi=array_filter($tdi); |
|
139 | - $tabledata[]=array_merge($td,$tdi); |
|
137 | + $td = array_filter($td); |
|
138 | + $tdi = array_filter($tdi); |
|
139 | + $tabledata[] = array_merge($td, $tdi); |
|
140 | 140 | } |
141 | 141 | $html->clear(); |
142 | 142 | unset($html); |
@@ -151,8 +151,8 @@ discard block |
||
151 | 151 | public function text2array($data) { |
152 | 152 | $html = str_get_html($data); |
153 | 153 | if ($html === false) return array(); |
154 | - $tabledata=array(); |
|
155 | - foreach($html->find('p') as $element) |
|
154 | + $tabledata = array(); |
|
155 | + foreach ($html->find('p') as $element) |
|
156 | 156 | { |
157 | 157 | $tabledata [] = trim($element->plaintext); |
158 | 158 | } |
@@ -172,11 +172,11 @@ discard block |
||
172 | 172 | */ |
173 | 173 | public function distance($lat, $lon, $latc, $lonc, $unit = 'km') { |
174 | 174 | if ($lat == $latc && $lon == $lonc) return 0; |
175 | - $dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515; |
|
175 | + $dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc))) + cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon) - floatval($lonc)))))*60*1.1515; |
|
176 | 176 | if ($unit == "km") { |
177 | - return round($dist * 1.609344); |
|
177 | + return round($dist*1.609344); |
|
178 | 178 | } elseif ($unit == "m") { |
179 | - return round($dist * 1.609344 * 1000); |
|
179 | + return round($dist*1.609344*1000); |
|
180 | 180 | } elseif ($unit == "mile" || $unit == "mi") { |
181 | 181 | return round($dist); |
182 | 182 | } elseif ($unit == "nm") { |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | * @param float $distance distance covered |
193 | 193 | * @return whether distance is realistic |
194 | 194 | */ |
195 | - public function withinThreshold ($timeDifference, $distance) { |
|
195 | + public function withinThreshold($timeDifference, $distance) { |
|
196 | 196 | $x = abs($timeDifference); |
197 | 197 | $d = abs($distance); |
198 | 198 | if ($x == 0 || $d == 0) return true; |
@@ -208,12 +208,12 @@ discard block |
||
208 | 208 | return ($array !== array_values($array)); |
209 | 209 | } |
210 | 210 | |
211 | - public function isInteger($input){ |
|
211 | + public function isInteger($input) { |
|
212 | 212 | return(ctype_digit(strval($input))); |
213 | 213 | } |
214 | 214 | |
215 | 215 | |
216 | - public function convertDec($dms,$latlong) { |
|
216 | + public function convertDec($dms, $latlong) { |
|
217 | 217 | if ($latlong == 'latitude') { |
218 | 218 | $deg = substr($dms, 0, 2); |
219 | 219 | $min = substr($dms, 2, 4); |
@@ -221,10 +221,10 @@ discard block |
||
221 | 221 | $deg = substr($dms, 0, 3); |
222 | 222 | $min = substr($dms, 3, 5); |
223 | 223 | } |
224 | - return $deg+(($min*60)/3600); |
|
224 | + return $deg + (($min*60)/3600); |
|
225 | 225 | } |
226 | 226 | |
227 | - public function convertDM($coord,$latlong) { |
|
227 | + public function convertDM($coord, $latlong) { |
|
228 | 228 | if ($latlong == 'latitude') { |
229 | 229 | if ($coord < 0) $NSEW = 'S'; |
230 | 230 | else $NSEW = 'N'; |
@@ -234,9 +234,9 @@ discard block |
||
234 | 234 | } |
235 | 235 | $coord = abs($coord); |
236 | 236 | $deg = floor($coord); |
237 | - $coord = ($coord-$deg)*60; |
|
237 | + $coord = ($coord - $deg)*60; |
|
238 | 238 | $min = $coord; |
239 | - return array('deg' => $deg,'min' => $min,'NSEW' => $NSEW); |
|
239 | + return array('deg' => $deg, 'min' => $min, 'NSEW' => $NSEW); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | /** |
@@ -248,8 +248,8 @@ discard block |
||
248 | 248 | public function xcopy($source, $dest) |
249 | 249 | { |
250 | 250 | $files = glob($source.'*.*'); |
251 | - foreach($files as $file){ |
|
252 | - $file_to_go = str_replace($source,$dest,$file); |
|
251 | + foreach ($files as $file) { |
|
252 | + $file_to_go = str_replace($source, $dest, $file); |
|
253 | 253 | copy($file, $file_to_go); |
254 | 254 | } |
255 | 255 | return true; |
@@ -260,9 +260,9 @@ discard block |
||
260 | 260 | * @param String $url url to check |
261 | 261 | * @return bool Return true on succes false on failure |
262 | 262 | */ |
263 | - public function urlexist($url){ |
|
264 | - $headers=get_headers($url); |
|
265 | - return stripos($headers[0],"200 OK")?true:false; |
|
263 | + public function urlexist($url) { |
|
264 | + $headers = get_headers($url); |
|
265 | + return stripos($headers[0], "200 OK") ? true : false; |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | /** |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | public function hex2str($hex) { |
274 | 274 | $str = ''; |
275 | 275 | $hexln = strlen($hex); |
276 | - for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2))); |
|
276 | + for ($i = 0; $i < $hexln; $i += 2) $str .= chr(hexdec(substr($hex, $i, 2))); |
|
277 | 277 | return $str; |
278 | 278 | } |
279 | 279 | |
@@ -282,33 +282,33 @@ discard block |
||
282 | 282 | //difference in longitudinal coordinates |
283 | 283 | $dLon = deg2rad($lon2) - deg2rad($lon1); |
284 | 284 | //difference in the phi of latitudinal coordinates |
285 | - $dPhi = log(tan(deg2rad($lat2) / 2 + pi() / 4) / tan(deg2rad($lat1) / 2 + pi() / 4)); |
|
285 | + $dPhi = log(tan(deg2rad($lat2)/2 + pi()/4)/tan(deg2rad($lat1)/2 + pi()/4)); |
|
286 | 286 | //we need to recalculate $dLon if it is greater than pi |
287 | - if(abs($dLon) > pi()) { |
|
288 | - if($dLon > 0) { |
|
289 | - $dLon = (2 * pi() - $dLon) * -1; |
|
287 | + if (abs($dLon) > pi()) { |
|
288 | + if ($dLon > 0) { |
|
289 | + $dLon = (2*pi() - $dLon)*-1; |
|
290 | 290 | } else { |
291 | - $dLon = 2 * pi() + $dLon; |
|
291 | + $dLon = 2*pi() + $dLon; |
|
292 | 292 | } |
293 | 293 | } |
294 | 294 | //return the angle, normalized |
295 | - return (rad2deg(atan2($dLon, $dPhi)) + 360) % 360; |
|
295 | + return (rad2deg(atan2($dLon, $dPhi)) + 360)%360; |
|
296 | 296 | } |
297 | 297 | |
298 | - public function checkLine($lat1,$lon1,$lat2,$lon2,$lat3,$lon3,$approx = 0.2) { |
|
298 | + public function checkLine($lat1, $lon1, $lat2, $lon2, $lat3, $lon3, $approx = 0.2) { |
|
299 | 299 | //$a = ($lon2-$lon1)*$lat3+($lat2-$lat1)*$lon3+($lat1*$lon2+$lat2*$lon1); |
300 | - $a = -($lon2-$lon1); |
|
300 | + $a = -($lon2 - $lon1); |
|
301 | 301 | $b = $lat2 - $lat1; |
302 | - $c = -($a*$lat1+$b*$lon1); |
|
303 | - $d = $a*$lat3+$b*$lon3+$c; |
|
302 | + $c = -($a*$lat1 + $b*$lon1); |
|
303 | + $d = $a*$lat3 + $b*$lon3 + $c; |
|
304 | 304 | if ($d > -$approx && $d < $approx) return true; |
305 | 305 | else return false; |
306 | 306 | } |
307 | 307 | |
308 | 308 | public function array_merge_noappend() { |
309 | 309 | $output = array(); |
310 | - foreach(func_get_args() as $array) { |
|
311 | - foreach($array as $key => $value) { |
|
310 | + foreach (func_get_args() as $array) { |
|
311 | + foreach ($array as $key => $value) { |
|
312 | 312 | $output[$key] = isset($output[$key]) ? |
313 | 313 | array_merge($output[$key], $value) : $value; |
314 | 314 | } |
@@ -372,34 +372,34 @@ discard block |
||
372 | 372 | return $result; |
373 | 373 | } |
374 | 374 | |
375 | - public function nextcoord($latitude, $longitude, $speed, $heading, $archivespeed = 1){ |
|
375 | + public function nextcoord($latitude, $longitude, $speed, $heading, $archivespeed = 1) { |
|
376 | 376 | global $globalMapRefresh; |
377 | 377 | $distance = ($speed*0.514444*$globalMapRefresh*$archivespeed)/1000; |
378 | 378 | $r = 6378; |
379 | 379 | $latitude = deg2rad($latitude); |
380 | 380 | $longitude = deg2rad($longitude); |
381 | 381 | $bearing = deg2rad($heading); |
382 | - $latitude2 = asin( (sin($latitude) * cos($distance/$r)) + (cos($latitude) * sin($distance/$r) * cos($bearing)) ); |
|
383 | - $longitude2 = $longitude + atan2( sin($bearing)*sin($distance/$r)*cos($latitude), cos($distance/$r)-(sin($latitude)*sin($latitude2)) ); |
|
384 | - return array('latitude' => number_format(rad2deg($latitude2),5,'.',''),'longitude' => number_format(rad2deg($longitude2),5,'.','')); |
|
382 | + $latitude2 = asin((sin($latitude)*cos($distance/$r)) + (cos($latitude)*sin($distance/$r)*cos($bearing))); |
|
383 | + $longitude2 = $longitude + atan2(sin($bearing)*sin($distance/$r)*cos($latitude), cos($distance/$r) - (sin($latitude)*sin($latitude2))); |
|
384 | + return array('latitude' => number_format(rad2deg($latitude2), 5, '.', ''), 'longitude' => number_format(rad2deg($longitude2), 5, '.', '')); |
|
385 | 385 | } |
386 | 386 | |
387 | - public function getCoordfromDistanceBearing($latitude,$longitude,$bearing,$distance) { |
|
387 | + public function getCoordfromDistanceBearing($latitude, $longitude, $bearing, $distance) { |
|
388 | 388 | // distance in meter |
389 | 389 | $R = 6378.14; |
390 | - $latitude1 = $latitude * (M_PI/180); |
|
391 | - $longitude1 = $longitude * (M_PI/180); |
|
392 | - $brng = $bearing * (M_PI/180); |
|
390 | + $latitude1 = $latitude*(M_PI/180); |
|
391 | + $longitude1 = $longitude*(M_PI/180); |
|
392 | + $brng = $bearing*(M_PI/180); |
|
393 | 393 | $d = $distance; |
394 | 394 | |
395 | 395 | $latitude2 = asin(sin($latitude1)*cos($d/$R) + cos($latitude1)*sin($d/$R)*cos($brng)); |
396 | - $longitude2 = $longitude1 + atan2(sin($brng)*sin($d/$R)*cos($latitude1),cos($d/$R)-sin($latitude1)*sin($latitude2)); |
|
396 | + $longitude2 = $longitude1 + atan2(sin($brng)*sin($d/$R)*cos($latitude1), cos($d/$R) - sin($latitude1)*sin($latitude2)); |
|
397 | 397 | |
398 | - $latitude2 = $latitude2 * (180/M_PI); |
|
399 | - $longitude2 = $longitude2 * (180/M_PI); |
|
398 | + $latitude2 = $latitude2*(180/M_PI); |
|
399 | + $longitude2 = $longitude2*(180/M_PI); |
|
400 | 400 | |
401 | - $flat = round ($latitude2,6); |
|
402 | - $flong = round ($longitude2,6); |
|
401 | + $flat = round($latitude2, 6); |
|
402 | + $flong = round($longitude2, 6); |
|
403 | 403 | /* |
404 | 404 | $dx = $distance*cos($bearing); |
405 | 405 | $dy = $distance*sin($bearing); |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | $flong = $longitude + $dlong; |
409 | 409 | $flat = $latitude + $dlat; |
410 | 410 | */ |
411 | - return array('latitude' => $flat,'longitude' => $flong); |
|
411 | + return array('latitude' => $flat, 'longitude' => $flong); |
|
412 | 412 | } |
413 | 413 | |
414 | 414 | /** |
@@ -422,14 +422,14 @@ discard block |
||
422 | 422 | * @param integer $level GZIP compression level (default: 9) |
423 | 423 | * @return string New filename (with .gz appended) if success, or false if operation fails |
424 | 424 | */ |
425 | - public function gzCompressFile($source, $level = 9){ |
|
426 | - $dest = $source . '.gz'; |
|
427 | - $mode = 'wb' . $level; |
|
425 | + public function gzCompressFile($source, $level = 9) { |
|
426 | + $dest = $source.'.gz'; |
|
427 | + $mode = 'wb'.$level; |
|
428 | 428 | $error = false; |
429 | 429 | if ($fp_out = gzopen($dest, $mode)) { |
430 | - if ($fp_in = fopen($source,'rb')) { |
|
430 | + if ($fp_in = fopen($source, 'rb')) { |
|
431 | 431 | while (!feof($fp_in)) |
432 | - gzwrite($fp_out, fread($fp_in, 1024 * 512)); |
|
432 | + gzwrite($fp_out, fread($fp_in, 1024*512)); |
|
433 | 433 | fclose($fp_in); |
434 | 434 | } else { |
435 | 435 | $error = true; |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | } |
446 | 446 | |
447 | 447 | public function remove_accents($string) { |
448 | - if ( !preg_match('/[\x80-\xff]/', $string) ) return $string; |
|
448 | + if (!preg_match('/[\x80-\xff]/', $string)) return $string; |
|
449 | 449 | $chars = array( |
450 | 450 | // Decompositions for Latin-1 Supplement |
451 | 451 | chr(195).chr(128) => 'A', chr(195).chr(129) => 'A', |
@@ -502,7 +502,7 @@ discard block |
||
502 | 502 | chr(196).chr(172) => 'I', chr(196).chr(173) => 'i', |
503 | 503 | chr(196).chr(174) => 'I', chr(196).chr(175) => 'i', |
504 | 504 | chr(196).chr(176) => 'I', chr(196).chr(177) => 'i', |
505 | - chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij', |
|
505 | + chr(196).chr(178) => 'IJ', chr(196).chr(179) => 'ij', |
|
506 | 506 | chr(196).chr(180) => 'J', chr(196).chr(181) => 'j', |
507 | 507 | chr(196).chr(182) => 'K', chr(196).chr(183) => 'k', |
508 | 508 | chr(196).chr(184) => 'k', chr(196).chr(185) => 'L', |
@@ -518,13 +518,13 @@ discard block |
||
518 | 518 | chr(197).chr(140) => 'O', chr(197).chr(141) => 'o', |
519 | 519 | chr(197).chr(142) => 'O', chr(197).chr(143) => 'o', |
520 | 520 | chr(197).chr(144) => 'O', chr(197).chr(145) => 'o', |
521 | - chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe', |
|
522 | - chr(197).chr(148) => 'R',chr(197).chr(149) => 'r', |
|
523 | - chr(197).chr(150) => 'R',chr(197).chr(151) => 'r', |
|
524 | - chr(197).chr(152) => 'R',chr(197).chr(153) => 'r', |
|
525 | - chr(197).chr(154) => 'S',chr(197).chr(155) => 's', |
|
526 | - chr(197).chr(156) => 'S',chr(197).chr(157) => 's', |
|
527 | - chr(197).chr(158) => 'S',chr(197).chr(159) => 's', |
|
521 | + chr(197).chr(146) => 'OE', chr(197).chr(147) => 'oe', |
|
522 | + chr(197).chr(148) => 'R', chr(197).chr(149) => 'r', |
|
523 | + chr(197).chr(150) => 'R', chr(197).chr(151) => 'r', |
|
524 | + chr(197).chr(152) => 'R', chr(197).chr(153) => 'r', |
|
525 | + chr(197).chr(154) => 'S', chr(197).chr(155) => 's', |
|
526 | + chr(197).chr(156) => 'S', chr(197).chr(157) => 's', |
|
527 | + chr(197).chr(158) => 'S', chr(197).chr(159) => 's', |
|
528 | 528 | chr(197).chr(160) => 'S', chr(197).chr(161) => 's', |
529 | 529 | chr(197).chr(162) => 'T', chr(197).chr(163) => 't', |
530 | 530 | chr(197).chr(164) => 'T', chr(197).chr(165) => 't', |
@@ -558,7 +558,7 @@ discard block |
||
558 | 558 | for ($i = 0, $int = '', $concat_flag = true; $i < $length; $i++) { |
559 | 559 | if (is_numeric($string[$i]) && $concat_flag) { |
560 | 560 | $int .= $string[$i]; |
561 | - } elseif(!$concat && $concat_flag && strlen($int) > 0) { |
|
561 | + } elseif (!$concat && $concat_flag && strlen($int) > 0) { |
|
562 | 562 | $concat_flag = false; |
563 | 563 | } |
564 | 564 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | require_once(dirname(__FILE__).'/class.Image.php'); |
5 | 5 | $global_query = "SELECT marine_output.* FROM marine_output"; |
6 | 6 | |
7 | -class Marine{ |
|
7 | +class Marine { |
|
8 | 8 | public $db; |
9 | 9 | |
10 | 10 | public function __construct($dbc = null) { |
@@ -18,33 +18,33 @@ discard block |
||
18 | 18 | * @return Array the SQL part |
19 | 19 | */ |
20 | 20 | |
21 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
21 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
22 | 22 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
23 | 23 | $filters = array(); |
24 | 24 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
25 | 25 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
26 | 26 | $filters = $globalStatsFilters[$globalFilterName]; |
27 | 27 | } else { |
28 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
28 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
29 | 29 | } |
30 | 30 | } |
31 | 31 | if (isset($filter[0]['source'])) { |
32 | - $filters = array_merge($filters,$filter); |
|
32 | + $filters = array_merge($filters, $filter); |
|
33 | 33 | } |
34 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
34 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
35 | 35 | $filter_query_join = ''; |
36 | 36 | $filter_query_where = ''; |
37 | - foreach($filters as $flt) { |
|
37 | + foreach ($filters as $flt) { |
|
38 | 38 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
39 | 39 | if (isset($flt['source'])) { |
40 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
40 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
41 | 41 | } else { |
42 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
42 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
43 | 43 | } |
44 | 44 | } |
45 | 45 | } |
46 | 46 | if (isset($filter['source']) && !empty($filter['source'])) { |
47 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
47 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
48 | 48 | } |
49 | 49 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
50 | 50 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
74 | 74 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
75 | 75 | if ($filter_query_where != '') { |
76 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
76 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
77 | 77 | } |
78 | 78 | $filter_query = $filter_query_join.$filter_query_where; |
79 | 79 | return $filter_query; |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | * @return Array the spotter information |
89 | 89 | * |
90 | 90 | */ |
91 | - public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false) |
|
91 | + public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false) |
|
92 | 92 | { |
93 | 93 | date_default_timezone_set('UTC'); |
94 | 94 | if (!is_string($query)) |
@@ -108,13 +108,13 @@ discard block |
||
108 | 108 | $sth = $this->db->prepare($query.$limitQuery); |
109 | 109 | $sth->execute($params); |
110 | 110 | } catch (PDOException $e) { |
111 | - printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery); |
|
111 | + printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery); |
|
112 | 112 | exit(); |
113 | 113 | } |
114 | 114 | |
115 | 115 | $num_rows = 0; |
116 | 116 | $spotter_array = array(); |
117 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
117 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
118 | 118 | { |
119 | 119 | $num_rows++; |
120 | 120 | $temp_array = array(); |
@@ -169,17 +169,17 @@ discard block |
||
169 | 169 | { |
170 | 170 | $temp_array['date'] = "about ".$dateArray['hours']." hours ago"; |
171 | 171 | } else { |
172 | - $temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC")); |
|
172 | + $temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC")); |
|
173 | 173 | } |
174 | 174 | $temp_array['date_minutes_past'] = $dateArray['minutes']; |
175 | - $temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC")); |
|
176 | - $temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC")); |
|
175 | + $temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC")); |
|
176 | + $temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC")); |
|
177 | 177 | $temp_array['date_unix'] = strtotime($row['date']." UTC"); |
178 | 178 | if (isset($row['last_seen']) && $row['last_seen'] != '') { |
179 | 179 | if (strtotime($row['last_seen']) > strtotime($row['date'])) { |
180 | 180 | $temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']); |
181 | - $temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC")); |
|
182 | - $temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC")); |
|
181 | + $temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC")); |
|
182 | + $temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC")); |
|
183 | 183 | $temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC"); |
184 | 184 | } |
185 | 185 | } |
@@ -216,8 +216,8 @@ discard block |
||
216 | 216 | { |
217 | 217 | $limit_array = explode(",", $limit); |
218 | 218 | |
219 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
220 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
219 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
220 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
221 | 221 | |
222 | 222 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
223 | 223 | { |
@@ -234,9 +234,9 @@ discard block |
||
234 | 234 | $orderby_query = " ORDER BY marine_output.date DESC"; |
235 | 235 | } |
236 | 236 | |
237 | - $query = $global_query.$filter_query." ".$orderby_query; |
|
237 | + $query = $global_query.$filter_query." ".$orderby_query; |
|
238 | 238 | |
239 | - $spotter_array = $this->getDataFromDB($query, array(),$limit_query,true); |
|
239 | + $spotter_array = $this->getDataFromDB($query, array(), $limit_query, true); |
|
240 | 240 | |
241 | 241 | return $spotter_array; |
242 | 242 | } |
@@ -255,8 +255,8 @@ discard block |
||
255 | 255 | if ($id == '') return array(); |
256 | 256 | $additional_query = "marine_output.fammarine_id = :id"; |
257 | 257 | $query_values = array(':id' => $id); |
258 | - $query = $global_query." WHERE ".$additional_query." "; |
|
259 | - $spotter_array = $this->getDataFromDB($query,$query_values); |
|
258 | + $query = $global_query." WHERE ".$additional_query." "; |
|
259 | + $spotter_array = $this->getDataFromDB($query, $query_values); |
|
260 | 260 | return $spotter_array; |
261 | 261 | } |
262 | 262 | |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | $query_values = array(); |
276 | 276 | $limit_query = ''; |
277 | 277 | $additional_query = ''; |
278 | - $filter_query = $this->getFilter($filter,true,true); |
|
278 | + $filter_query = $this->getFilter($filter, true, true); |
|
279 | 279 | if ($ident != "") |
280 | 280 | { |
281 | 281 | if (!is_string($ident)) |
@@ -291,8 +291,8 @@ discard block |
||
291 | 291 | { |
292 | 292 | $limit_array = explode(",", $limit); |
293 | 293 | |
294 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
295 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
294 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
295 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
296 | 296 | |
297 | 297 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
298 | 298 | { |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | return $spotter_array; |
317 | 317 | } |
318 | 318 | |
319 | - public function getSpotterDataByDate($date = '', $limit = '', $sort = '',$filter = array()) |
|
319 | + public function getSpotterDataByDate($date = '', $limit = '', $sort = '', $filter = array()) |
|
320 | 320 | { |
321 | 321 | global $global_query, $globalTimezone, $globalDBdriver; |
322 | 322 | |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | $limit_query = ''; |
325 | 325 | $additional_query = ''; |
326 | 326 | |
327 | - $filter_query = $this->getFilter($filter,true,true); |
|
327 | + $filter_query = $this->getFilter($filter, true, true); |
|
328 | 328 | |
329 | 329 | if ($date != "") |
330 | 330 | { |
@@ -350,8 +350,8 @@ discard block |
||
350 | 350 | { |
351 | 351 | $limit_array = explode(",", $limit); |
352 | 352 | |
353 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
354 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
353 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
354 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
355 | 355 | |
356 | 356 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
357 | 357 | { |
@@ -382,11 +382,11 @@ discard block |
||
382 | 382 | * @return Array list of source name |
383 | 383 | * |
384 | 384 | */ |
385 | - public function getAllSourceName($type = '',$filters = array()) |
|
385 | + public function getAllSourceName($type = '', $filters = array()) |
|
386 | 386 | { |
387 | - $filter_query = $this->getFilter($filters,true,true); |
|
387 | + $filter_query = $this->getFilter($filters, true, true); |
|
388 | 388 | $query_values = array(); |
389 | - $query = "SELECT DISTINCT marine_output.source_name |
|
389 | + $query = "SELECT DISTINCT marine_output.source_name |
|
390 | 390 | FROM marine_output".$filter_query." marine_output.source_name <> ''"; |
391 | 391 | if ($type != '') { |
392 | 392 | $query_values = array(':type' => $type); |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | $source_array = array(); |
402 | 402 | $temp_array = array(); |
403 | 403 | |
404 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
404 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
405 | 405 | { |
406 | 406 | $temp_array['source_name'] = $row['source_name']; |
407 | 407 | $source_array[] = $temp_array; |
@@ -418,8 +418,8 @@ discard block |
||
418 | 418 | */ |
419 | 419 | public function getAllIdents($filters = array()) |
420 | 420 | { |
421 | - $filter_query = $this->getFilter($filters,true,true); |
|
422 | - $query = "SELECT DISTINCT marine_output.ident |
|
421 | + $filter_query = $this->getFilter($filters, true, true); |
|
422 | + $query = "SELECT DISTINCT marine_output.ident |
|
423 | 423 | FROM marine_output".$filter_query." marine_output.ident <> '' |
424 | 424 | ORDER BY marine_output.date ASC LIMIT 700 OFFSET 0"; |
425 | 425 | |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | $ident_array = array(); |
430 | 430 | $temp_array = array(); |
431 | 431 | |
432 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
432 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
433 | 433 | { |
434 | 434 | $temp_array['ident'] = $row['ident']; |
435 | 435 | $ident_array[] = $temp_array; |
@@ -446,7 +446,7 @@ discard block |
||
446 | 446 | */ |
447 | 447 | public function getIdentity($mmsi) |
448 | 448 | { |
449 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
449 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
450 | 450 | $query = "SELECT * FROM marine_identity WHERE mmsi = :mmsi LIMIT 1"; |
451 | 451 | $sth = $this->db->prepare($query); |
452 | 452 | $sth->execute(array(':mmsi' => $mmsi)); |
@@ -471,12 +471,12 @@ discard block |
||
471 | 471 | } else $offset = '+00:00'; |
472 | 472 | |
473 | 473 | if ($globalDBdriver == 'mysql') { |
474 | - $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
|
474 | + $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
|
475 | 475 | FROM marine_output |
476 | 476 | WHERE marine_output.date <> '' |
477 | 477 | ORDER BY marine_output.date ASC LIMIT 0,200"; |
478 | 478 | } else { |
479 | - $query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
479 | + $query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
480 | 480 | FROM marine_output |
481 | 481 | WHERE marine_output.date <> '' |
482 | 482 | ORDER BY marine_output.date ASC LIMIT 0,200"; |
@@ -488,7 +488,7 @@ discard block |
||
488 | 488 | $date_array = array(); |
489 | 489 | $temp_array = array(); |
490 | 490 | |
491 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
491 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
492 | 492 | { |
493 | 493 | $temp_array['date'] = $row['date']; |
494 | 494 | |
@@ -507,11 +507,11 @@ discard block |
||
507 | 507 | * @return String success or false |
508 | 508 | * |
509 | 509 | */ |
510 | - public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL) |
|
510 | + public function updateIdentMarineData($fammarine_id = '', $ident = '', $fromsource = NULL) |
|
511 | 511 | { |
512 | 512 | |
513 | 513 | $query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id'; |
514 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident); |
|
514 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident); |
|
515 | 515 | |
516 | 516 | try { |
517 | 517 | $sth = $this->db->prepare($query); |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '') |
535 | 535 | { |
536 | 536 | $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'; |
537 | - $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
537 | + $query_values = array(':fammarine_id' => $fammarine_id, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident); |
|
538 | 538 | |
539 | 539 | try { |
540 | 540 | $sth = $this->db->prepare($query); |
@@ -572,7 +572,7 @@ discard block |
||
572 | 572 | * @param String $verticalrate vertival rate of flight |
573 | 573 | * @return String success or false |
574 | 574 | */ |
575 | - public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$format_source = '', $source_name = '') |
|
575 | + public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $format_source = '', $source_name = '') |
|
576 | 576 | { |
577 | 577 | global $globalURL; |
578 | 578 | |
@@ -639,25 +639,25 @@ discard block |
||
639 | 639 | } |
640 | 640 | |
641 | 641 | |
642 | - if ($date == "" || strtotime($date) < time()-20*60) |
|
642 | + if ($date == "" || strtotime($date) < time() - 20*60) |
|
643 | 643 | { |
644 | 644 | $date = date("Y-m-d H:i:s", time()); |
645 | 645 | } |
646 | 646 | |
647 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
648 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
649 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
650 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
651 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
652 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
653 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
654 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
655 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
656 | - $status = filter_var($status,FILTER_SANITIZE_STRING); |
|
657 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
658 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
659 | - $arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING); |
|
660 | - $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
|
647 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
648 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
649 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
650 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
651 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
652 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
653 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
654 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
655 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
656 | + $status = filter_var($status, FILTER_SANITIZE_STRING); |
|
657 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
658 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
659 | + $arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING); |
|
660 | + $arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING); |
|
661 | 661 | |
662 | 662 | if ($latitude == '' && $longitude == '') { |
663 | 663 | $latitude = 0; |
@@ -666,10 +666,10 @@ discard block |
||
666 | 666 | if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
667 | 667 | if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
668 | 668 | if ($arrival_date == '') $arrival_date = NULL; |
669 | - $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) |
|
669 | + $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) |
|
670 | 670 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)"; |
671 | 671 | |
672 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':mmsi' => $mmsi,':type' => $type,':status' => $status,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date); |
|
672 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':speed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':mmsi' => $mmsi, ':type' => $type, ':status' => $status, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date); |
|
673 | 673 | try { |
674 | 674 | |
675 | 675 | $sth = $this->db->prepare($query); |
@@ -694,13 +694,13 @@ discard block |
||
694 | 694 | { |
695 | 695 | global $globalDBdriver, $globalTimezone; |
696 | 696 | if ($globalDBdriver == 'mysql') { |
697 | - $query = "SELECT marine_output.ident FROM marine_output |
|
697 | + $query = "SELECT marine_output.ident FROM marine_output |
|
698 | 698 | WHERE marine_output.ident = :ident |
699 | 699 | AND marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
700 | 700 | AND marine_output.date < UTC_TIMESTAMP()"; |
701 | 701 | $query_data = array(':ident' => $ident); |
702 | 702 | } else { |
703 | - $query = "SELECT marine_output.ident FROM marine_output |
|
703 | + $query = "SELECT marine_output.ident FROM marine_output |
|
704 | 704 | WHERE marine_output.ident = :ident |
705 | 705 | AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
706 | 706 | AND marine_output.date < now() AT TIME ZONE 'UTC'"; |
@@ -709,8 +709,8 @@ discard block |
||
709 | 709 | |
710 | 710 | $sth = $this->db->prepare($query); |
711 | 711 | $sth->execute($query_data); |
712 | - $ident_result=''; |
|
713 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
712 | + $ident_result = ''; |
|
713 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
714 | 714 | { |
715 | 715 | $ident_result = $row['ident']; |
716 | 716 | } |
@@ -736,8 +736,8 @@ discard block |
||
736 | 736 | return false; |
737 | 737 | } else { |
738 | 738 | $q_array = explode(" ", $q); |
739 | - foreach ($q_array as $q_item){ |
|
740 | - $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
739 | + foreach ($q_array as $q_item) { |
|
740 | + $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
741 | 741 | $additional_query .= " AND ("; |
742 | 742 | $additional_query .= "(marine_output.ident like '%".$q_item."%')"; |
743 | 743 | $additional_query .= ")"; |
@@ -745,11 +745,11 @@ discard block |
||
745 | 745 | } |
746 | 746 | } |
747 | 747 | if ($globalDBdriver == 'mysql') { |
748 | - $query = "SELECT marine_output.* FROM marine_output |
|
748 | + $query = "SELECT marine_output.* FROM marine_output |
|
749 | 749 | WHERE marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." |
750 | 750 | AND marine_output.date < UTC_TIMESTAMP()"; |
751 | 751 | } else { |
752 | - $query = "SELECT marine_output.* FROM marine_output |
|
752 | + $query = "SELECT marine_output.* FROM marine_output |
|
753 | 753 | WHERE marine_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." |
754 | 754 | AND marine_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
755 | 755 | } |
@@ -822,11 +822,11 @@ discard block |
||
822 | 822 | * @return Array the callsign list |
823 | 823 | * |
824 | 824 | */ |
825 | - public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
|
825 | + public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
826 | 826 | { |
827 | 827 | global $globalDBdriver; |
828 | - $filter_query = $this->getFilter($filters,true,true); |
|
829 | - $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
|
828 | + $filter_query = $this->getFilter($filters, true, true); |
|
829 | + $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
|
830 | 830 | FROM marine_output".$filter_query." marine_output.ident <> ''"; |
831 | 831 | if ($olderthanmonths > 0) { |
832 | 832 | if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
@@ -840,28 +840,28 @@ discard block |
||
840 | 840 | if ($year != '') { |
841 | 841 | if ($globalDBdriver == 'mysql') { |
842 | 842 | $query .= " AND YEAR(marine_output.date) = :year"; |
843 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
843 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
844 | 844 | } else { |
845 | 845 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
846 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
846 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
847 | 847 | } |
848 | 848 | } |
849 | 849 | if ($month != '') { |
850 | 850 | if ($globalDBdriver == 'mysql') { |
851 | 851 | $query .= " AND MONTH(marine_output.date) = :month"; |
852 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
852 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
853 | 853 | } else { |
854 | 854 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
855 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
855 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
856 | 856 | } |
857 | 857 | } |
858 | 858 | if ($day != '') { |
859 | 859 | if ($globalDBdriver == 'mysql') { |
860 | 860 | $query .= " AND DAY(marine_output.date) = :day"; |
861 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
861 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
862 | 862 | } else { |
863 | 863 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
864 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
864 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
865 | 865 | } |
866 | 866 | } |
867 | 867 | $query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC"; |
@@ -873,7 +873,7 @@ discard block |
||
873 | 873 | $callsign_array = array(); |
874 | 874 | $temp_array = array(); |
875 | 875 | |
876 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
876 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
877 | 877 | { |
878 | 878 | $temp_array['callsign_icao'] = $row['ident']; |
879 | 879 | $temp_array['airline_name'] = $row['airline_name']; |
@@ -925,7 +925,7 @@ discard block |
||
925 | 925 | $date_array = array(); |
926 | 926 | $temp_array = array(); |
927 | 927 | |
928 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
928 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
929 | 929 | { |
930 | 930 | $temp_array['date_name'] = $row['date_name']; |
931 | 931 | $temp_array['date_count'] = $row['date_count']; |
@@ -951,7 +951,7 @@ discard block |
||
951 | 951 | $datetime = new DateTime(); |
952 | 952 | $offset = $datetime->format('P'); |
953 | 953 | } else $offset = '+00:00'; |
954 | - $filter_query = $this->getFilter($filters,true,true); |
|
954 | + $filter_query = $this->getFilter($filters, true, true); |
|
955 | 955 | if ($globalDBdriver == 'mysql') { |
956 | 956 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
957 | 957 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)"; |
@@ -972,7 +972,7 @@ discard block |
||
972 | 972 | $date_array = array(); |
973 | 973 | $temp_array = array(); |
974 | 974 | |
975 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
975 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
976 | 976 | { |
977 | 977 | $temp_array['date_name'] = $row['date_name']; |
978 | 978 | $temp_array['date_count'] = $row['date_count']; |
@@ -997,7 +997,7 @@ discard block |
||
997 | 997 | $datetime = new DateTime(); |
998 | 998 | $offset = $datetime->format('P'); |
999 | 999 | } else $offset = '+00:00'; |
1000 | - $filter_query = $this->getFilter($filters,true,true); |
|
1000 | + $filter_query = $this->getFilter($filters, true, true); |
|
1001 | 1001 | if ($globalDBdriver == 'mysql') { |
1002 | 1002 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
1003 | 1003 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)"; |
@@ -1018,7 +1018,7 @@ discard block |
||
1018 | 1018 | $date_array = array(); |
1019 | 1019 | $temp_array = array(); |
1020 | 1020 | |
1021 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1021 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1022 | 1022 | { |
1023 | 1023 | $temp_array['date_name'] = $row['date_name']; |
1024 | 1024 | $temp_array['date_count'] = $row['date_count']; |
@@ -1065,7 +1065,7 @@ discard block |
||
1065 | 1065 | $date_array = array(); |
1066 | 1066 | $temp_array = array(); |
1067 | 1067 | |
1068 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1068 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1069 | 1069 | { |
1070 | 1070 | $temp_array['month_name'] = $row['month_name']; |
1071 | 1071 | $temp_array['year_name'] = $row['year_name']; |
@@ -1094,7 +1094,7 @@ discard block |
||
1094 | 1094 | $datetime = new DateTime(); |
1095 | 1095 | $offset = $datetime->format('P'); |
1096 | 1096 | } else $offset = '+00:00'; |
1097 | - $filter_query = $this->getFilter($filters,true,true); |
|
1097 | + $filter_query = $this->getFilter($filters, true, true); |
|
1098 | 1098 | if ($globalDBdriver == 'mysql') { |
1099 | 1099 | $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 |
1100 | 1100 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)"; |
@@ -1115,7 +1115,7 @@ discard block |
||
1115 | 1115 | $date_array = array(); |
1116 | 1116 | $temp_array = array(); |
1117 | 1117 | |
1118 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1118 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1119 | 1119 | { |
1120 | 1120 | $temp_array['year_name'] = $row['year_name']; |
1121 | 1121 | $temp_array['month_name'] = $row['month_name']; |
@@ -1135,7 +1135,7 @@ discard block |
||
1135 | 1135 | * @return Array the hour list |
1136 | 1136 | * |
1137 | 1137 | */ |
1138 | - public function countAllHours($orderby,$filters = array()) |
|
1138 | + public function countAllHours($orderby, $filters = array()) |
|
1139 | 1139 | { |
1140 | 1140 | global $globalTimezone, $globalDBdriver; |
1141 | 1141 | if ($globalTimezone != '') { |
@@ -1183,7 +1183,7 @@ discard block |
||
1183 | 1183 | $hour_array = array(); |
1184 | 1184 | $temp_array = array(); |
1185 | 1185 | |
1186 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1186 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1187 | 1187 | { |
1188 | 1188 | $temp_array['hour_name'] = $row['hour_name']; |
1189 | 1189 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1205,8 +1205,8 @@ discard block |
||
1205 | 1205 | public function countAllHoursByDate($date, $filters = array()) |
1206 | 1206 | { |
1207 | 1207 | global $globalTimezone, $globalDBdriver; |
1208 | - $filter_query = $this->getFilter($filters,true,true); |
|
1209 | - $date = filter_var($date,FILTER_SANITIZE_STRING); |
|
1208 | + $filter_query = $this->getFilter($filters, true, true); |
|
1209 | + $date = filter_var($date, FILTER_SANITIZE_STRING); |
|
1210 | 1210 | if ($globalTimezone != '') { |
1211 | 1211 | date_default_timezone_set($globalTimezone); |
1212 | 1212 | $datetime = new DateTime($date); |
@@ -1214,12 +1214,12 @@ discard block |
||
1214 | 1214 | } else $offset = '+00:00'; |
1215 | 1215 | |
1216 | 1216 | if ($globalDBdriver == 'mysql') { |
1217 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1217 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1218 | 1218 | FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = :date |
1219 | 1219 | GROUP BY hour_name |
1220 | 1220 | ORDER BY hour_name ASC"; |
1221 | 1221 | } else { |
1222 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1222 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1223 | 1223 | FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date |
1224 | 1224 | GROUP BY hour_name |
1225 | 1225 | ORDER BY hour_name ASC"; |
@@ -1231,7 +1231,7 @@ discard block |
||
1231 | 1231 | $hour_array = array(); |
1232 | 1232 | $temp_array = array(); |
1233 | 1233 | |
1234 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1234 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1235 | 1235 | { |
1236 | 1236 | $temp_array['hour_name'] = $row['hour_name']; |
1237 | 1237 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1253,8 +1253,8 @@ discard block |
||
1253 | 1253 | public function countAllHoursByIdent($ident, $filters = array()) |
1254 | 1254 | { |
1255 | 1255 | global $globalTimezone, $globalDBdriver; |
1256 | - $filter_query = $this->getFilter($filters,true,true); |
|
1257 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
1256 | + $filter_query = $this->getFilter($filters, true, true); |
|
1257 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
1258 | 1258 | if ($globalTimezone != '') { |
1259 | 1259 | date_default_timezone_set($globalTimezone); |
1260 | 1260 | $datetime = new DateTime(); |
@@ -1262,12 +1262,12 @@ discard block |
||
1262 | 1262 | } else $offset = '+00:00'; |
1263 | 1263 | |
1264 | 1264 | if ($globalDBdriver == 'mysql') { |
1265 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1265 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1266 | 1266 | FROM marine_output".$filter_query." marine_output.ident = :ident |
1267 | 1267 | GROUP BY hour_name |
1268 | 1268 | ORDER BY hour_name ASC"; |
1269 | 1269 | } else { |
1270 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1270 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1271 | 1271 | FROM marine_output".$filter_query." marine_output.ident = :ident |
1272 | 1272 | GROUP BY hour_name |
1273 | 1273 | ORDER BY hour_name ASC"; |
@@ -1275,12 +1275,12 @@ discard block |
||
1275 | 1275 | |
1276 | 1276 | |
1277 | 1277 | $sth = $this->db->prepare($query); |
1278 | - $sth->execute(array(':ident' => $ident,':offset' => $offset)); |
|
1278 | + $sth->execute(array(':ident' => $ident, ':offset' => $offset)); |
|
1279 | 1279 | |
1280 | 1280 | $hour_array = array(); |
1281 | 1281 | $temp_array = array(); |
1282 | 1282 | |
1283 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1283 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1284 | 1284 | { |
1285 | 1285 | $temp_array['hour_name'] = $row['hour_name']; |
1286 | 1286 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1299,32 +1299,32 @@ discard block |
||
1299 | 1299 | * @return Integer the number of flights |
1300 | 1300 | * |
1301 | 1301 | */ |
1302 | - public function countOverallTracked($filters = array(),$year = '',$month = '') |
|
1302 | + public function countOverallTracked($filters = array(), $year = '', $month = '') |
|
1303 | 1303 | { |
1304 | 1304 | global $globalDBdriver; |
1305 | - $queryi = "SELECT COUNT(marine_output.marine_id) AS flight_count FROM marine_output"; |
|
1305 | + $queryi = "SELECT COUNT(marine_output.marine_id) AS flight_count FROM marine_output"; |
|
1306 | 1306 | $query_values = array(); |
1307 | 1307 | $query = ''; |
1308 | 1308 | if ($year != '') { |
1309 | 1309 | if ($globalDBdriver == 'mysql') { |
1310 | 1310 | $query .= " AND YEAR(marine_output.date) = :year"; |
1311 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1311 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1312 | 1312 | } else { |
1313 | 1313 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
1314 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1314 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1315 | 1315 | } |
1316 | 1316 | } |
1317 | 1317 | if ($month != '') { |
1318 | 1318 | if ($globalDBdriver == 'mysql') { |
1319 | 1319 | $query .= " AND MONTH(marine_output.date) = :month"; |
1320 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1320 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1321 | 1321 | } else { |
1322 | 1322 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
1323 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1323 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1324 | 1324 | } |
1325 | 1325 | } |
1326 | 1326 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
1327 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1327 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
1328 | 1328 | |
1329 | 1329 | $sth = $this->db->prepare($queryi); |
1330 | 1330 | $sth->execute($query_values); |
@@ -1341,7 +1341,7 @@ discard block |
||
1341 | 1341 | public function countAllHoursFromToday($filters = array()) |
1342 | 1342 | { |
1343 | 1343 | global $globalTimezone, $globalDBdriver; |
1344 | - $filter_query = $this->getFilter($filters,true,true); |
|
1344 | + $filter_query = $this->getFilter($filters, true, true); |
|
1345 | 1345 | if ($globalTimezone != '') { |
1346 | 1346 | date_default_timezone_set($globalTimezone); |
1347 | 1347 | $datetime = new DateTime(); |
@@ -1349,12 +1349,12 @@ discard block |
||
1349 | 1349 | } else $offset = '+00:00'; |
1350 | 1350 | |
1351 | 1351 | if ($globalDBdriver == 'mysql') { |
1352 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1352 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1353 | 1353 | FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = CURDATE() |
1354 | 1354 | GROUP BY hour_name |
1355 | 1355 | ORDER BY hour_name ASC"; |
1356 | 1356 | } else { |
1357 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1357 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1358 | 1358 | FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date) |
1359 | 1359 | GROUP BY hour_name |
1360 | 1360 | ORDER BY hour_name ASC"; |
@@ -1366,7 +1366,7 @@ discard block |
||
1366 | 1366 | $hour_array = array(); |
1367 | 1367 | $temp_array = array(); |
1368 | 1368 | |
1369 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1369 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1370 | 1370 | { |
1371 | 1371 | $temp_array['hour_name'] = $row['hour_name']; |
1372 | 1372 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1385,9 +1385,9 @@ discard block |
||
1385 | 1385 | */ |
1386 | 1386 | public function getMarineIDBasedOnFamMarineID($fammarine_id) |
1387 | 1387 | { |
1388 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
1388 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
1389 | 1389 | |
1390 | - $query = "SELECT marine_output.marine_id |
|
1390 | + $query = "SELECT marine_output.marine_id |
|
1391 | 1391 | FROM marine_output |
1392 | 1392 | WHERE marine_output.fammarine_id = '".$fammarine_id."'"; |
1393 | 1393 | |
@@ -1395,7 +1395,7 @@ discard block |
||
1395 | 1395 | $sth = $this->db->prepare($query); |
1396 | 1396 | $sth->execute(); |
1397 | 1397 | |
1398 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1398 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1399 | 1399 | { |
1400 | 1400 | return $row['marine_id']; |
1401 | 1401 | } |
@@ -1420,23 +1420,23 @@ discard block |
||
1420 | 1420 | } |
1421 | 1421 | |
1422 | 1422 | $current_date = date("Y-m-d H:i:s"); |
1423 | - $date = date("Y-m-d H:i:s",strtotime($dateString." UTC")); |
|
1423 | + $date = date("Y-m-d H:i:s", strtotime($dateString." UTC")); |
|
1424 | 1424 | |
1425 | 1425 | $diff = abs(strtotime($current_date) - strtotime($date)); |
1426 | 1426 | |
1427 | - $time_array['years'] = floor($diff / (365*60*60*24)); |
|
1427 | + $time_array['years'] = floor($diff/(365*60*60*24)); |
|
1428 | 1428 | $years = $time_array['years']; |
1429 | 1429 | |
1430 | - $time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); |
|
1430 | + $time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24)); |
|
1431 | 1431 | $months = $time_array['months']; |
1432 | 1432 | |
1433 | - $time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); |
|
1433 | + $time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24)); |
|
1434 | 1434 | $days = $time_array['days']; |
1435 | - $time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60)); |
|
1435 | + $time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60)); |
|
1436 | 1436 | $hours = $time_array['hours']; |
1437 | - $time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60); |
|
1437 | + $time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60); |
|
1438 | 1438 | $minutes = $time_array['minutes']; |
1439 | - $time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
1439 | + $time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
1440 | 1440 | |
1441 | 1441 | return $time_array; |
1442 | 1442 | } |
@@ -1459,63 +1459,63 @@ discard block |
||
1459 | 1459 | $temp_array['direction_degree'] = $direction; |
1460 | 1460 | $temp_array['direction_shortname'] = "N"; |
1461 | 1461 | $temp_array['direction_fullname'] = "North"; |
1462 | - } elseif ($direction >= 22.5 && $direction < 45){ |
|
1462 | + } elseif ($direction >= 22.5 && $direction < 45) { |
|
1463 | 1463 | $temp_array['direction_degree'] = $direction; |
1464 | 1464 | $temp_array['direction_shortname'] = "NNE"; |
1465 | 1465 | $temp_array['direction_fullname'] = "North-Northeast"; |
1466 | - } elseif ($direction >= 45 && $direction < 67.5){ |
|
1466 | + } elseif ($direction >= 45 && $direction < 67.5) { |
|
1467 | 1467 | $temp_array['direction_degree'] = $direction; |
1468 | 1468 | $temp_array['direction_shortname'] = "NE"; |
1469 | 1469 | $temp_array['direction_fullname'] = "Northeast"; |
1470 | - } elseif ($direction >= 67.5 && $direction < 90){ |
|
1470 | + } elseif ($direction >= 67.5 && $direction < 90) { |
|
1471 | 1471 | $temp_array['direction_degree'] = $direction; |
1472 | 1472 | $temp_array['direction_shortname'] = "ENE"; |
1473 | 1473 | $temp_array['direction_fullname'] = "East-Northeast"; |
1474 | - } elseif ($direction >= 90 && $direction < 112.5){ |
|
1474 | + } elseif ($direction >= 90 && $direction < 112.5) { |
|
1475 | 1475 | $temp_array['direction_degree'] = $direction; |
1476 | 1476 | $temp_array['direction_shortname'] = "E"; |
1477 | 1477 | $temp_array['direction_fullname'] = "East"; |
1478 | - } elseif ($direction >= 112.5 && $direction < 135){ |
|
1478 | + } elseif ($direction >= 112.5 && $direction < 135) { |
|
1479 | 1479 | $temp_array['direction_degree'] = $direction; |
1480 | 1480 | $temp_array['direction_shortname'] = "ESE"; |
1481 | 1481 | $temp_array['direction_fullname'] = "East-Southeast"; |
1482 | - } elseif ($direction >= 135 && $direction < 157.5){ |
|
1482 | + } elseif ($direction >= 135 && $direction < 157.5) { |
|
1483 | 1483 | $temp_array['direction_degree'] = $direction; |
1484 | 1484 | $temp_array['direction_shortname'] = "SE"; |
1485 | 1485 | $temp_array['direction_fullname'] = "Southeast"; |
1486 | - } elseif ($direction >= 157.5 && $direction < 180){ |
|
1486 | + } elseif ($direction >= 157.5 && $direction < 180) { |
|
1487 | 1487 | $temp_array['direction_degree'] = $direction; |
1488 | 1488 | $temp_array['direction_shortname'] = "SSE"; |
1489 | 1489 | $temp_array['direction_fullname'] = "South-Southeast"; |
1490 | - } elseif ($direction >= 180 && $direction < 202.5){ |
|
1490 | + } elseif ($direction >= 180 && $direction < 202.5) { |
|
1491 | 1491 | $temp_array['direction_degree'] = $direction; |
1492 | 1492 | $temp_array['direction_shortname'] = "S"; |
1493 | 1493 | $temp_array['direction_fullname'] = "South"; |
1494 | - } elseif ($direction >= 202.5 && $direction < 225){ |
|
1494 | + } elseif ($direction >= 202.5 && $direction < 225) { |
|
1495 | 1495 | $temp_array['direction_degree'] = $direction; |
1496 | 1496 | $temp_array['direction_shortname'] = "SSW"; |
1497 | 1497 | $temp_array['direction_fullname'] = "South-Southwest"; |
1498 | - } elseif ($direction >= 225 && $direction < 247.5){ |
|
1498 | + } elseif ($direction >= 225 && $direction < 247.5) { |
|
1499 | 1499 | $temp_array['direction_degree'] = $direction; |
1500 | 1500 | $temp_array['direction_shortname'] = "SW"; |
1501 | 1501 | $temp_array['direction_fullname'] = "Southwest"; |
1502 | - } elseif ($direction >= 247.5 && $direction < 270){ |
|
1502 | + } elseif ($direction >= 247.5 && $direction < 270) { |
|
1503 | 1503 | $temp_array['direction_degree'] = $direction; |
1504 | 1504 | $temp_array['direction_shortname'] = "WSW"; |
1505 | 1505 | $temp_array['direction_fullname'] = "West-Southwest"; |
1506 | - } elseif ($direction >= 270 && $direction < 292.5){ |
|
1506 | + } elseif ($direction >= 270 && $direction < 292.5) { |
|
1507 | 1507 | $temp_array['direction_degree'] = $direction; |
1508 | 1508 | $temp_array['direction_shortname'] = "W"; |
1509 | 1509 | $temp_array['direction_fullname'] = "West"; |
1510 | - } elseif ($direction >= 292.5 && $direction < 315){ |
|
1510 | + } elseif ($direction >= 292.5 && $direction < 315) { |
|
1511 | 1511 | $temp_array['direction_degree'] = $direction; |
1512 | 1512 | $temp_array['direction_shortname'] = "WNW"; |
1513 | 1513 | $temp_array['direction_fullname'] = "West-Northwest"; |
1514 | - } elseif ($direction >= 315 && $direction < 337.5){ |
|
1514 | + } elseif ($direction >= 315 && $direction < 337.5) { |
|
1515 | 1515 | $temp_array['direction_degree'] = $direction; |
1516 | 1516 | $temp_array['direction_shortname'] = "NW"; |
1517 | 1517 | $temp_array['direction_fullname'] = "Northwest"; |
1518 | - } elseif ($direction >= 337.5 && $direction < 360){ |
|
1518 | + } elseif ($direction >= 337.5 && $direction < 360) { |
|
1519 | 1519 | $temp_array['direction_degree'] = $direction; |
1520 | 1520 | $temp_array['direction_shortname'] = "NNW"; |
1521 | 1521 | $temp_array['direction_fullname'] = "North-Northwest"; |
@@ -1532,11 +1532,11 @@ discard block |
||
1532 | 1532 | * @param Float $longitude longitute of the flight |
1533 | 1533 | * @return String the countrie |
1534 | 1534 | */ |
1535 | - public function getCountryFromLatitudeLongitude($latitude,$longitude) |
|
1535 | + public function getCountryFromLatitudeLongitude($latitude, $longitude) |
|
1536 | 1536 | { |
1537 | 1537 | global $globalDBdriver, $globalDebug; |
1538 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1539 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1538 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1539 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1540 | 1540 | |
1541 | 1541 | $Connection = new Connection($this->db); |
1542 | 1542 | if (!$Connection->tableExists('countries')) return ''; |
@@ -1576,7 +1576,7 @@ discard block |
||
1576 | 1576 | public function getCountryFromISO2($iso2) |
1577 | 1577 | { |
1578 | 1578 | global $globalDBdriver, $globalDebug; |
1579 | - $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
|
1579 | + $iso2 = filter_var($iso2, FILTER_SANITIZE_STRING); |
|
1580 | 1580 | |
1581 | 1581 | $Connection = new Connection($this->db); |
1582 | 1582 | if (!$Connection->tableExists('countries')) return ''; |
@@ -1624,7 +1624,7 @@ discard block |
||
1624 | 1624 | |
1625 | 1625 | $bitly_data = json_decode($bitly_data); |
1626 | 1626 | $bitly_url = ''; |
1627 | - if ($bitly_data->status_txt = "OK"){ |
|
1627 | + if ($bitly_data->status_txt = "OK") { |
|
1628 | 1628 | $bitly_url = $bitly_data->data->url; |
1629 | 1629 | } |
1630 | 1630 | |
@@ -1634,7 +1634,7 @@ discard block |
||
1634 | 1634 | |
1635 | 1635 | public function getOrderBy() |
1636 | 1636 | { |
1637 | - $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_output.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_output.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_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")); |
|
1637 | + $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_output.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_output.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_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")); |
|
1638 | 1638 | |
1639 | 1639 | return $orderby; |
1640 | 1640 |
@@ -16,62 +16,62 @@ discard block |
||
16 | 16 | * @param Array $filter the filter |
17 | 17 | * @return Array the SQL part |
18 | 18 | */ |
19 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
19 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
21 | 21 | $filters = array(); |
22 | 22 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
23 | 23 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
24 | 24 | $filters = $globalStatsFilters[$globalFilterName]; |
25 | 25 | } else { |
26 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
26 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
27 | 27 | } |
28 | 28 | } |
29 | 29 | if (isset($filter[0]['source'])) { |
30 | - $filters = array_merge($filters,$filter); |
|
30 | + $filters = array_merge($filters, $filter); |
|
31 | 31 | } |
32 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
32 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
33 | 33 | $filter_query_join = ''; |
34 | 34 | $filter_query_where = ''; |
35 | - foreach($filters as $flt) { |
|
35 | + foreach ($filters as $flt) { |
|
36 | 36 | if (isset($flt['airlines']) && !empty($flt['airlines'])) { |
37 | 37 | if ($flt['airlines'][0] != '') { |
38 | 38 | if (isset($flt['source'])) { |
39 | - $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'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id"; |
|
39 | + $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'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id"; |
|
40 | 40 | } else { |
41 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id"; |
|
41 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id"; |
|
42 | 42 | } |
43 | 43 | } |
44 | 44 | } |
45 | 45 | if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
46 | 46 | if (isset($flt['source'])) { |
47 | - $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'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id"; |
|
47 | + $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'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id"; |
|
48 | 48 | } else { |
49 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id"; |
|
49 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id"; |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
53 | 53 | if (isset($flt['source'])) { |
54 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id"; |
|
54 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id"; |
|
55 | 55 | } else { |
56 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id"; |
|
56 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id"; |
|
57 | 57 | } |
58 | 58 | } |
59 | 59 | if (isset($flt['registrations']) && !empty($flt['registrations'])) { |
60 | 60 | if (isset($flt['source'])) { |
61 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id"; |
|
61 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','", $flt['registrations'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id"; |
|
62 | 62 | } else { |
63 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id"; |
|
63 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','", $flt['registrations'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id"; |
|
64 | 64 | } |
65 | 65 | } |
66 | 66 | if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) { |
67 | 67 | if (isset($flt['source'])) { |
68 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) ssf ON ssf.flightaware_id = spotter_live.flightaware_id"; |
|
68 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','", $flt['source'])."')) ssf ON ssf.flightaware_id = spotter_live.flightaware_id"; |
|
69 | 69 | } |
70 | 70 | } |
71 | 71 | } |
72 | 72 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
73 | 73 | if ($filter['airlines'][0] != '') { |
74 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) sai ON sai.flightaware_id = spotter_live.flightaware_id"; |
|
74 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) sai ON sai.flightaware_id = spotter_live.flightaware_id"; |
|
75 | 75 | } |
76 | 76 | } |
77 | 77 | if (isset($filter['alliance']) && !empty($filter['alliance'])) { |
@@ -81,10 +81,10 @@ discard block |
||
81 | 81 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_live.flightaware_id "; |
82 | 82 | } |
83 | 83 | if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) { |
84 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) sp ON sp.flightaware_id = spotter_live.flightaware_id"; |
|
84 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) sp ON sp.flightaware_id = spotter_live.flightaware_id"; |
|
85 | 85 | } |
86 | 86 | if (isset($filter['source']) && !empty($filter['source'])) { |
87 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
87 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
88 | 88 | } |
89 | 89 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
90 | 90 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -113,15 +113,15 @@ discard block |
||
113 | 113 | $filter_query_date .= " AND EXTRACT(DAY FROM spotter_output.date) = '".$filter['day']."'"; |
114 | 114 | } |
115 | 115 | } |
116 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_live.flightaware_id"; |
|
116 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.flightaware_id = spotter_live.flightaware_id"; |
|
117 | 117 | } |
118 | 118 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
119 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
119 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
120 | 120 | } |
121 | 121 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
122 | 122 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
123 | 123 | if ($filter_query_where != '') { |
124 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
124 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
125 | 125 | } |
126 | 126 | $filter_query = $filter_query_join.$filter_query_where; |
127 | 127 | return $filter_query; |
@@ -144,8 +144,8 @@ discard block |
||
144 | 144 | if ($limit != '') |
145 | 145 | { |
146 | 146 | $limit_array = explode(',', $limit); |
147 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
148 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
147 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
148 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
149 | 149 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
150 | 150 | { |
151 | 151 | $limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0]; |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | } else { |
169 | 169 | $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate".$filter_query.$orderby_query; |
170 | 170 | } |
171 | - $spotter_array = $Spotter->getDataFromDB($query.$limit_query,array(),'',true); |
|
171 | + $spotter_array = $Spotter->getDataFromDB($query.$limit_query, array(), '', true); |
|
172 | 172 | |
173 | 173 | return $spotter_array; |
174 | 174 | } |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | global $globalDBdriver, $globalLiveInterval; |
185 | 185 | date_default_timezone_set('UTC'); |
186 | 186 | |
187 | - $filter_query = $this->getFilter($filter,true,true); |
|
187 | + $filter_query = $this->getFilter($filter, true, true); |
|
188 | 188 | |
189 | 189 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
190 | 190 | if ($globalDBdriver == 'mysql') { |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | $query = 'SELECT a.aircraft_shadow, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
196 | 196 | FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao'.$filter_query." spotter_live.latitude <> 0 AND spotter_live.longitude <> 0"; |
197 | 197 | */ |
198 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
198 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
199 | 199 | FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query." spotter_live.latitude <> 0 AND spotter_live.longitude <> 0"; |
200 | 200 | |
201 | 201 | // $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= spotter_live.date ORDER BY spotter_live.date GROUP BY spotter_live.flightaware_id'.$filter_query; |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao".$filter_query." spotter_live.latitude <> '0' AND spotter_live.longitude <> '0'"; |
211 | 211 | */ |
212 | 212 | |
213 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
213 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
214 | 214 | FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate".$filter_query." spotter_live.latitude <> '0' AND spotter_live.longitude <> '0'"; |
215 | 215 | |
216 | 216 | |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | try { |
222 | 222 | $sth = $this->db->prepare($query); |
223 | 223 | $sth->execute(); |
224 | - } catch(PDOException $e) { |
|
224 | + } catch (PDOException $e) { |
|
225 | 225 | echo $e->getMessage(); |
226 | 226 | die; |
227 | 227 | } |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | global $globalDBdriver, $globalLiveInterval; |
242 | 242 | date_default_timezone_set('UTC'); |
243 | 243 | |
244 | - $filter_query = $this->getFilter($filter,true,true); |
|
244 | + $filter_query = $this->getFilter($filter, true, true); |
|
245 | 245 | |
246 | 246 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
247 | 247 | if ($globalDBdriver == 'mysql') { |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | FROM spotter_live LEFT JOIN (SELECT aircraft_shadow,engine_type, engine_count, wake_category,icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
251 | 251 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
252 | 252 | */ |
253 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
253 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
254 | 254 | FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
255 | 255 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
256 | 256 | } else { |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | FROM spotter_live LEFT JOIN (SELECT aircraft_shadow,engine_type, engine_count, wake_category, icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
260 | 260 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
261 | 261 | */ |
262 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
262 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
263 | 263 | FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
264 | 264 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
265 | 265 | // echo $query; |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | try { |
269 | 269 | $sth = $this->db->prepare($query); |
270 | 270 | $sth->execute(); |
271 | - } catch(PDOException $e) { |
|
271 | + } catch (PDOException $e) { |
|
272 | 272 | echo $e->getMessage(); |
273 | 273 | die; |
274 | 274 | } |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | public function getLiveSpotterCount($filter = array()) |
286 | 286 | { |
287 | 287 | global $globalDBdriver, $globalLiveInterval; |
288 | - $filter_query = $this->getFilter($filter,true,true); |
|
288 | + $filter_query = $this->getFilter($filter, true, true); |
|
289 | 289 | |
290 | 290 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
291 | 291 | if ($globalDBdriver == 'mysql') { |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | try { |
299 | 299 | $sth = $this->db->prepare($query); |
300 | 300 | $sth->execute(); |
301 | - } catch(PDOException $e) { |
|
301 | + } catch (PDOException $e) { |
|
302 | 302 | echo $e->getMessage(); |
303 | 303 | die; |
304 | 304 | } |
@@ -321,10 +321,10 @@ discard block |
||
321 | 321 | $filter_query = $this->getFilter($filter); |
322 | 322 | |
323 | 323 | if (is_array($coord)) { |
324 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
325 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
326 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
327 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
324 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
325 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
326 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
327 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
328 | 328 | } else return array(); |
329 | 329 | if ($globalDBdriver == 'mysql') { |
330 | 330 | //$query = "SELECT spotter_output.* FROM spotter_output WHERE spotter_output.flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL ".$globalLiveInterval." SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")"; |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | if ($interval == '1m') |
378 | 378 | { |
379 | 379 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
380 | - } else if ($interval == '15m'){ |
|
380 | + } else if ($interval == '15m') { |
|
381 | 381 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
382 | 382 | } |
383 | 383 | } |
@@ -385,14 +385,14 @@ discard block |
||
385 | 385 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
386 | 386 | } |
387 | 387 | |
388 | - $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
388 | + $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
389 | 389 | WHERE spotter_live.latitude <> '' |
390 | 390 | AND spotter_live.longitude <> '' |
391 | 391 | ".$additional_query." |
392 | 392 | HAVING distance < :radius |
393 | 393 | ORDER BY distance"; |
394 | 394 | |
395 | - $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
395 | + $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius)); |
|
396 | 396 | |
397 | 397 | return $spotter_array; |
398 | 398 | } |
@@ -410,9 +410,9 @@ discard block |
||
410 | 410 | date_default_timezone_set('UTC'); |
411 | 411 | |
412 | 412 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
413 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
413 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
414 | 414 | |
415 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true); |
|
415 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident), '', true); |
|
416 | 416 | |
417 | 417 | return $spotter_array; |
418 | 418 | } |
@@ -423,16 +423,16 @@ discard block |
||
423 | 423 | * @return Array the spotter information |
424 | 424 | * |
425 | 425 | */ |
426 | - public function getDateLiveSpotterDataByIdent($ident,$date) |
|
426 | + public function getDateLiveSpotterDataByIdent($ident, $date) |
|
427 | 427 | { |
428 | 428 | $Spotter = new Spotter($this->db); |
429 | 429 | date_default_timezone_set('UTC'); |
430 | 430 | |
431 | 431 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
432 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
432 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
433 | 433 | |
434 | - $date = date('c',$date); |
|
435 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
434 | + $date = date('c', $date); |
|
435 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
436 | 436 | |
437 | 437 | return $spotter_array; |
438 | 438 | } |
@@ -449,9 +449,9 @@ discard block |
||
449 | 449 | date_default_timezone_set('UTC'); |
450 | 450 | |
451 | 451 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
452 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
452 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
453 | 453 | |
454 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true); |
|
454 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id), '', true); |
|
455 | 455 | |
456 | 456 | return $spotter_array; |
457 | 457 | } |
@@ -462,15 +462,15 @@ discard block |
||
462 | 462 | * @return Array the spotter information |
463 | 463 | * |
464 | 464 | */ |
465 | - public function getDateLiveSpotterDataById($id,$date) |
|
465 | + public function getDateLiveSpotterDataById($id, $date) |
|
466 | 466 | { |
467 | 467 | $Spotter = new Spotter($this->db); |
468 | 468 | date_default_timezone_set('UTC'); |
469 | 469 | |
470 | 470 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
471 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
472 | - $date = date('c',$date); |
|
473 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
|
471 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
472 | + $date = date('c', $date); |
|
473 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true); |
|
474 | 474 | |
475 | 475 | return $spotter_array; |
476 | 476 | } |
@@ -487,13 +487,13 @@ discard block |
||
487 | 487 | date_default_timezone_set('UTC'); |
488 | 488 | |
489 | 489 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
490 | - $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
490 | + $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
491 | 491 | |
492 | 492 | try { |
493 | 493 | |
494 | 494 | $sth = $this->db->prepare($query); |
495 | 495 | $sth->execute(array(':ident' => $ident)); |
496 | - } catch(PDOException $e) { |
|
496 | + } catch (PDOException $e) { |
|
497 | 497 | echo $e->getMessage(); |
498 | 498 | die; |
499 | 499 | } |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | * @return Array the spotter information |
509 | 509 | * |
510 | 510 | */ |
511 | - public function getAllLiveSpotterDataById($id,$liveinterval = false) |
|
511 | + public function getAllLiveSpotterDataById($id, $liveinterval = false) |
|
512 | 512 | { |
513 | 513 | global $globalDBdriver, $globalLiveInterval; |
514 | 514 | date_default_timezone_set('UTC'); |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | try { |
528 | 528 | $sth = $this->db->prepare($query); |
529 | 529 | $sth->execute(array(':id' => $id)); |
530 | - } catch(PDOException $e) { |
|
530 | + } catch (PDOException $e) { |
|
531 | 531 | echo $e->getMessage(); |
532 | 532 | die; |
533 | 533 | } |
@@ -545,12 +545,12 @@ discard block |
||
545 | 545 | { |
546 | 546 | date_default_timezone_set('UTC'); |
547 | 547 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
548 | - $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
|
548 | + $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
|
549 | 549 | try { |
550 | 550 | |
551 | 551 | $sth = $this->db->prepare($query); |
552 | 552 | $sth->execute(array(':ident' => $ident)); |
553 | - } catch(PDOException $e) { |
|
553 | + } catch (PDOException $e) { |
|
554 | 554 | echo $e->getMessage(); |
555 | 555 | die; |
556 | 556 | } |
@@ -580,7 +580,7 @@ discard block |
||
580 | 580 | |
581 | 581 | $sth = $this->db->prepare($query); |
582 | 582 | $sth->execute(); |
583 | - } catch(PDOException $e) { |
|
583 | + } catch (PDOException $e) { |
|
584 | 584 | return "error"; |
585 | 585 | } |
586 | 586 | |
@@ -603,14 +603,14 @@ discard block |
||
603 | 603 | |
604 | 604 | $sth = $this->db->prepare($query); |
605 | 605 | $sth->execute(); |
606 | - } catch(PDOException $e) { |
|
606 | + } catch (PDOException $e) { |
|
607 | 607 | return "error"; |
608 | 608 | } |
609 | 609 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
610 | 610 | $i = 0; |
611 | - $j =0; |
|
611 | + $j = 0; |
|
612 | 612 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
613 | - foreach($all as $row) |
|
613 | + foreach ($all as $row) |
|
614 | 614 | { |
615 | 615 | $i++; |
616 | 616 | $j++; |
@@ -618,9 +618,9 @@ discard block |
||
618 | 618 | if ($globalDebug) echo "."; |
619 | 619 | try { |
620 | 620 | |
621 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
621 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
622 | 622 | $sth->execute(); |
623 | - } catch(PDOException $e) { |
|
623 | + } catch (PDOException $e) { |
|
624 | 624 | return "error"; |
625 | 625 | } |
626 | 626 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
@@ -631,9 +631,9 @@ discard block |
||
631 | 631 | if ($i > 0) { |
632 | 632 | try { |
633 | 633 | |
634 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
634 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
635 | 635 | $sth->execute(); |
636 | - } catch(PDOException $e) { |
|
636 | + } catch (PDOException $e) { |
|
637 | 637 | return "error"; |
638 | 638 | } |
639 | 639 | } |
@@ -646,7 +646,7 @@ discard block |
||
646 | 646 | |
647 | 647 | $sth = $this->db->prepare($query); |
648 | 648 | $sth->execute(); |
649 | - } catch(PDOException $e) { |
|
649 | + } catch (PDOException $e) { |
|
650 | 650 | return "error"; |
651 | 651 | } |
652 | 652 | /* $query_delete = "DELETE FROM spotter_live WHERE flightaware_id IN ("; |
@@ -694,13 +694,13 @@ discard block |
||
694 | 694 | public function deleteLiveSpotterDataByIdent($ident) |
695 | 695 | { |
696 | 696 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
697 | - $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
|
697 | + $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
|
698 | 698 | |
699 | 699 | try { |
700 | 700 | |
701 | 701 | $sth = $this->db->prepare($query); |
702 | 702 | $sth->execute(array(':ident' => $ident)); |
703 | - } catch(PDOException $e) { |
|
703 | + } catch (PDOException $e) { |
|
704 | 704 | return "error"; |
705 | 705 | } |
706 | 706 | |
@@ -716,13 +716,13 @@ discard block |
||
716 | 716 | public function deleteLiveSpotterDataById($id) |
717 | 717 | { |
718 | 718 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
719 | - $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
|
719 | + $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
|
720 | 720 | |
721 | 721 | try { |
722 | 722 | |
723 | 723 | $sth = $this->db->prepare($query); |
724 | 724 | $sth->execute(array(':id' => $id)); |
725 | - } catch(PDOException $e) { |
|
725 | + } catch (PDOException $e) { |
|
726 | 726 | return "error"; |
727 | 727 | } |
728 | 728 | |
@@ -740,13 +740,13 @@ discard block |
||
740 | 740 | { |
741 | 741 | global $globalDBdriver, $globalTimezone; |
742 | 742 | if ($globalDBdriver == 'mysql') { |
743 | - $query = 'SELECT spotter_live.ident FROM spotter_live |
|
743 | + $query = 'SELECT spotter_live.ident FROM spotter_live |
|
744 | 744 | WHERE spotter_live.ident = :ident |
745 | 745 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
746 | 746 | AND spotter_live.date < UTC_TIMESTAMP()'; |
747 | 747 | $query_data = array(':ident' => $ident); |
748 | 748 | } else { |
749 | - $query = "SELECT spotter_live.ident FROM spotter_live |
|
749 | + $query = "SELECT spotter_live.ident FROM spotter_live |
|
750 | 750 | WHERE spotter_live.ident = :ident |
751 | 751 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
752 | 752 | AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -755,8 +755,8 @@ discard block |
||
755 | 755 | |
756 | 756 | $sth = $this->db->prepare($query); |
757 | 757 | $sth->execute($query_data); |
758 | - $ident_result=''; |
|
759 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
758 | + $ident_result = ''; |
|
759 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
760 | 760 | { |
761 | 761 | $ident_result = $row['ident']; |
762 | 762 | } |
@@ -773,13 +773,13 @@ discard block |
||
773 | 773 | { |
774 | 774 | global $globalDBdriver, $globalTimezone; |
775 | 775 | if ($globalDBdriver == 'mysql') { |
776 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
776 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
777 | 777 | WHERE spotter_live.ident = :ident |
778 | 778 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
779 | 779 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
780 | 780 | $query_data = array(':ident' => $ident); |
781 | 781 | } else { |
782 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
782 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
783 | 783 | WHERE spotter_live.ident = :ident |
784 | 784 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'"; |
785 | 785 | // AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -788,8 +788,8 @@ discard block |
||
788 | 788 | |
789 | 789 | $sth = $this->db->prepare($query); |
790 | 790 | $sth->execute($query_data); |
791 | - $ident_result=''; |
|
792 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
791 | + $ident_result = ''; |
|
792 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
793 | 793 | { |
794 | 794 | $ident_result = $row['flightaware_id']; |
795 | 795 | } |
@@ -806,13 +806,13 @@ discard block |
||
806 | 806 | { |
807 | 807 | global $globalDBdriver, $globalTimezone; |
808 | 808 | if ($globalDBdriver == 'mysql') { |
809 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
809 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
810 | 810 | WHERE spotter_live.flightaware_id = :id |
811 | 811 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
812 | 812 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
813 | 813 | $query_data = array(':id' => $id); |
814 | 814 | } else { |
815 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
815 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
816 | 816 | WHERE spotter_live.flightaware_id = :id |
817 | 817 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
818 | 818 | // AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -821,8 +821,8 @@ discard block |
||
821 | 821 | |
822 | 822 | $sth = $this->db->prepare($query); |
823 | 823 | $sth->execute($query_data); |
824 | - $ident_result=''; |
|
825 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
824 | + $ident_result = ''; |
|
825 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
826 | 826 | { |
827 | 827 | $ident_result = $row['flightaware_id']; |
828 | 828 | } |
@@ -839,13 +839,13 @@ discard block |
||
839 | 839 | { |
840 | 840 | global $globalDBdriver, $globalTimezone; |
841 | 841 | if ($globalDBdriver == 'mysql') { |
842 | - $query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
842 | + $query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
843 | 843 | WHERE spotter_live.ModeS = :modes |
844 | 844 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
845 | 845 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
846 | 846 | $query_data = array(':modes' => $modes); |
847 | 847 | } else { |
848 | - $query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
848 | + $query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
849 | 849 | WHERE spotter_live.ModeS = :modes |
850 | 850 | AND spotter_live.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '30 MINUTE'"; |
851 | 851 | // // AND spotter_live.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
@@ -854,8 +854,8 @@ discard block |
||
854 | 854 | |
855 | 855 | $sth = $this->db->prepare($query); |
856 | 856 | $sth->execute($query_data); |
857 | - $ident_result=''; |
|
858 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
857 | + $ident_result = ''; |
|
858 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
859 | 859 | { |
860 | 860 | //$ident_result = $row['spotter_live_id']; |
861 | 861 | $ident_result = $row['flightaware_id']; |
@@ -874,7 +874,7 @@ discard block |
||
874 | 874 | * @return String success or false |
875 | 875 | * |
876 | 876 | */ |
877 | - public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '',$heading = '', $groundspeed = '', $date = '',$departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false,$registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false,$format_source = '', $source_name = '', $over_country = '') |
|
877 | + public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '', $heading = '', $groundspeed = '', $date = '', $departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false, $registration = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false, $format_source = '', $source_name = '', $over_country = '') |
|
878 | 878 | { |
879 | 879 | global $globalURL, $globalArchive, $globalDebug; |
880 | 880 | $Common = new Common(); |
@@ -967,26 +967,26 @@ discard block |
||
967 | 967 | if ($date == '') $date = date("Y-m-d H:i:s", time()); |
968 | 968 | |
969 | 969 | |
970 | - $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
|
971 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
972 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
973 | - $departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); |
|
974 | - $arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); |
|
975 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
976 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
977 | - $waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING); |
|
978 | - $altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
979 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
980 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
981 | - $squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT); |
|
982 | - $route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING); |
|
983 | - $ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING); |
|
984 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING); |
|
985 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
986 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
987 | - $source_name = filter_var($source_name,FILTER_SANITIZE_STRING); |
|
988 | - $over_country = filter_var($over_country,FILTER_SANITIZE_STRING); |
|
989 | - $verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT); |
|
970 | + $flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING); |
|
971 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
972 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
973 | + $departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING); |
|
974 | + $arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING); |
|
975 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
976 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
977 | + $waypoints = filter_var($waypoints, FILTER_SANITIZE_STRING); |
|
978 | + $altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
979 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
980 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
981 | + $squawk = filter_var($squawk, FILTER_SANITIZE_NUMBER_INT); |
|
982 | + $route_stop = filter_var($route_stop, FILTER_SANITIZE_STRING); |
|
983 | + $ModeS = filter_var($ModeS, FILTER_SANITIZE_STRING); |
|
984 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING); |
|
985 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
986 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
987 | + $source_name = filter_var($source_name, FILTER_SANITIZE_STRING); |
|
988 | + $over_country = filter_var($over_country, FILTER_SANITIZE_STRING); |
|
989 | + $verticalrate = filter_var($verticalrate, FILTER_SANITIZE_NUMBER_INT); |
|
990 | 990 | |
991 | 991 | $airline_name = ''; |
992 | 992 | $airline_icao = ''; |
@@ -1008,26 +1008,26 @@ discard block |
||
1008 | 1008 | $arrival_airport_country = ''; |
1009 | 1009 | |
1010 | 1010 | |
1011 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
1012 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
1013 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1014 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1011 | + if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL; |
|
1012 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL; |
|
1013 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
1014 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
1015 | 1015 | |
1016 | - $query = 'INSERT INTO spotter_live (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, 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, ModeS, pilot_id, pilot_name, verticalrate, ground, format_source, source_name, over_country) |
|
1016 | + $query = 'INSERT INTO spotter_live (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, 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, ModeS, pilot_id, pilot_name, verticalrate, ground, format_source, source_name, over_country) |
|
1017 | 1017 | VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_shadow,: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,:ModeS, :pilot_id, :pilot_name, :verticalrate, :ground, :format_source, :source_name, :over_country)'; |
1018 | 1018 | |
1019 | - $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_shadow' => $aircraft_shadow,':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,':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source,':ground' => $ground, ':source_name' => $source_name, ':over_country' => $over_country); |
|
1019 | + $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_shadow' => $aircraft_shadow, ':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, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':ground' => $ground, ':source_name' => $source_name, ':over_country' => $over_country); |
|
1020 | 1020 | try { |
1021 | 1021 | |
1022 | 1022 | $sth = $this->db->prepare($query); |
1023 | 1023 | $sth->execute($query_values); |
1024 | - } catch(PDOException $e) { |
|
1024 | + } catch (PDOException $e) { |
|
1025 | 1025 | return "error : ".$e->getMessage(); |
1026 | 1026 | } |
1027 | 1027 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
1028 | 1028 | if ($globalDebug) echo '(Add to SBS archive : '; |
1029 | 1029 | $SpotterArchive = new SpotterArchive($this->db); |
1030 | - $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
1030 | + $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time, $arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name, $verticalrate, $format_source, $source_name, $over_country); |
|
1031 | 1031 | if ($globalDebug) echo $result.')'; |
1032 | 1032 | } |
1033 | 1033 | return "success"; |
@@ -1036,7 +1036,7 @@ discard block |
||
1036 | 1036 | |
1037 | 1037 | public function getOrderBy() |
1038 | 1038 | { |
1039 | - $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_live.date DESC")); |
|
1039 | + $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_live.date DESC")); |
|
1040 | 1040 | return $orderby; |
1041 | 1041 | } |
1042 | 1042 |
@@ -45,11 +45,11 @@ discard block |
||
45 | 45 | die; |
46 | 46 | } |
47 | 47 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
48 | - $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
|
48 | + $globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port); |
|
49 | 49 | } |
50 | 50 | } |
51 | 51 | |
52 | -$options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::')); |
|
52 | +$options = getopt('s::', array('source::', 'server', 'nodaemon', 'idsource::', 'aprsserverssid::', 'aprsserverpass::')); |
|
53 | 53 | //if (isset($options['s'])) $hosts = array($options['s']); |
54 | 54 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
55 | 55 | if (isset($options['s'])) { |
@@ -67,27 +67,27 @@ discard block |
||
67 | 67 | else $id_source = 1; |
68 | 68 | if (isset($globalServer) && $globalServer) { |
69 | 69 | if ($globalDebug) echo "Using Server Mode\n"; |
70 | - $SI=new SpotterServer(); |
|
70 | + $SI = new SpotterServer(); |
|
71 | 71 | /* |
72 | 72 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
73 | 73 | $SI = new adsb2aprs(); |
74 | 74 | $SI->connect(); |
75 | 75 | */ |
76 | -} else $SI=new SpotterImport($Connection->db); |
|
76 | +} else $SI = new SpotterImport($Connection->db); |
|
77 | 77 | if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
78 | 78 | if (isset($globalMarine) && $globalMarine) { |
79 | 79 | $AIS = new AIS(); |
80 | 80 | $MI = new MarineImport($Connection->db); |
81 | 81 | } |
82 | 82 | //$APRS=new APRS($Connection->db); |
83 | -$SBS=new SBS(); |
|
84 | -$ACARS=new ACARS($Connection->db); |
|
85 | -$Common=new Common(); |
|
83 | +$SBS = new SBS(); |
|
84 | +$ACARS = new ACARS($Connection->db); |
|
85 | +$Common = new Common(); |
|
86 | 86 | date_default_timezone_set('UTC'); |
87 | 87 | //$servertz = system('date +%Z'); |
88 | 88 | // signal handler - playing nice with sockets and dump1090 |
89 | 89 | if (function_exists('pcntl_fork')) { |
90 | - pcntl_signal(SIGINT, function() { |
|
90 | + pcntl_signal(SIGINT, function() { |
|
91 | 91 | global $sockets; |
92 | 92 | echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
93 | 93 | die("Bye!\n"); |
@@ -103,35 +103,35 @@ discard block |
||
103 | 103 | |
104 | 104 | function connect_all($hosts) { |
105 | 105 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
106 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
106 | + global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context; |
|
107 | 107 | $reset++; |
108 | 108 | if ($globalDebug) echo 'Connect to all...'."\n"; |
109 | 109 | foreach ($hosts as $id => $value) { |
110 | 110 | $host = $value['host']; |
111 | 111 | $globalSources[$id]['last_exec'] = 0; |
112 | 112 | // Here we check type of source(s) |
113 | - if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
114 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
113 | + if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
114 | + if (preg_match('/deltadb.txt$/i', $host)) { |
|
115 | 115 | //$formats[$id] = 'deltadbtxt'; |
116 | 116 | $globalSources[$id]['format'] = 'deltadbtxt'; |
117 | 117 | //$last_exec['deltadbtxt'] = 0; |
118 | 118 | if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
119 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
119 | + } else if (preg_match('/vatsim-data.txt$/i', $host)) { |
|
120 | 120 | //$formats[$id] = 'vatsimtxt'; |
121 | 121 | $globalSources[$id]['format'] = 'vatsimtxt'; |
122 | 122 | //$last_exec['vatsimtxt'] = 0; |
123 | 123 | if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
124 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
124 | + } else if (preg_match('/aircraftlist.json$/i', $host)) { |
|
125 | 125 | //$formats[$id] = 'aircraftlistjson'; |
126 | 126 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
127 | 127 | //$last_exec['aircraftlistjson'] = 0; |
128 | 128 | if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
129 | - } else if (preg_match('/opensky/i',$host)) { |
|
129 | + } else if (preg_match('/opensky/i', $host)) { |
|
130 | 130 | //$formats[$id] = 'aircraftlistjson'; |
131 | 131 | $globalSources[$id]['format'] = 'opensky'; |
132 | 132 | //$last_exec['aircraftlistjson'] = 0; |
133 | 133 | if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
134 | - } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
|
134 | + } else if (preg_match('/radarvirtuel.com\/file.json$/i', $host)) { |
|
135 | 135 | //$formats[$id] = 'radarvirtueljson'; |
136 | 136 | $globalSources[$id]['format'] = 'radarvirtueljson'; |
137 | 137 | //$last_exec['radarvirtueljson'] = 0; |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
141 | 141 | exit(0); |
142 | 142 | } |
143 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
143 | + } else if (preg_match('/planeUpdateFAA.php$/i', $host)) { |
|
144 | 144 | //$formats[$id] = 'planeupdatefaa'; |
145 | 145 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
146 | 146 | //$last_exec['planeupdatefaa'] = 0; |
@@ -149,26 +149,26 @@ discard block |
||
149 | 149 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
150 | 150 | exit(0); |
151 | 151 | } |
152 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
152 | + } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) { |
|
153 | 153 | //$formats[$id] = 'phpvmacars'; |
154 | 154 | $globalSources[$id]['format'] = 'phpvmacars'; |
155 | 155 | //$last_exec['phpvmacars'] = 0; |
156 | 156 | if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
157 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
157 | + } else if (preg_match('/VAM-json.php$/i', $host)) { |
|
158 | 158 | //$formats[$id] = 'phpvmacars'; |
159 | 159 | $globalSources[$id]['format'] = 'vam'; |
160 | 160 | if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
161 | - } else if (preg_match('/whazzup/i',$host)) { |
|
161 | + } else if (preg_match('/whazzup/i', $host)) { |
|
162 | 162 | //$formats[$id] = 'whazzup'; |
163 | 163 | $globalSources[$id]['format'] = 'whazzup'; |
164 | 164 | //$last_exec['whazzup'] = 0; |
165 | 165 | if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
166 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
166 | + } else if (preg_match('/recentpireps/i', $host)) { |
|
167 | 167 | //$formats[$id] = 'pirepsjson'; |
168 | 168 | $globalSources[$id]['format'] = 'pirepsjson'; |
169 | 169 | //$last_exec['pirepsjson'] = 0; |
170 | 170 | if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
171 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
171 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) { |
|
172 | 172 | //$formats[$id] = 'fr24json'; |
173 | 173 | $globalSources[$id]['format'] = 'fr24json'; |
174 | 174 | //$last_exec['fr24json'] = 0; |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
178 | 178 | exit(0); |
179 | 179 | } |
180 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
180 | + } else if (preg_match(':myshiptracking.com/:i', $host)) { |
|
181 | 181 | //$formats[$id] = 'fr24json'; |
182 | 182 | $globalSources[$id]['format'] = 'myshiptracking'; |
183 | 183 | //$last_exec['fr24json'] = 0; |
@@ -187,22 +187,22 @@ discard block |
||
187 | 187 | exit(0); |
188 | 188 | } |
189 | 189 | //} else if (preg_match('/10001/',$host)) { |
190 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
190 | + } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
191 | 191 | //$formats[$id] = 'tsv'; |
192 | 192 | $globalSources[$id]['format'] = 'tsv'; |
193 | 193 | if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
194 | 194 | } |
195 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
195 | + } elseif (filter_var($host, FILTER_VALIDATE_URL)) { |
|
196 | 196 | if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
197 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
197 | + $idf = fopen($globalSources[$id]['host'], 'r', false, $context); |
|
198 | 198 | if ($idf !== false) { |
199 | 199 | $httpfeeds[$id] = $idf; |
200 | 200 | if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
201 | 201 | } |
202 | 202 | elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
203 | 203 | } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
204 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
205 | - $hostport = explode(':',$host); |
|
204 | + } elseif (!filter_var($host, FILTER_VALIDATE_URL)) { |
|
205 | + $hostport = explode(':', $host); |
|
206 | 206 | if (isset($hostport[1])) { |
207 | 207 | $port = $hostport[1]; |
208 | 208 | $hostn = $hostport[0]; |
@@ -212,19 +212,19 @@ discard block |
||
212 | 212 | } |
213 | 213 | $Common = new Common(); |
214 | 214 | if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
215 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
215 | + $s = $Common->create_socket($hostn, $port, $errno, $errstr); |
|
216 | 216 | } else { |
217 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
217 | + $s = $Common->create_socket_udp($hostn, $port, $errno, $errstr); |
|
218 | 218 | } |
219 | 219 | if ($s) { |
220 | 220 | $sockets[$id] = $s; |
221 | 221 | if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
222 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
222 | + if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') { |
|
223 | 223 | //$formats[$id] = 'aprs'; |
224 | 224 | $globalSources[$id]['format'] = 'aprs'; |
225 | 225 | //$aprs_connect = 0; |
226 | 226 | //$use_aprs = true; |
227 | - } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
227 | + } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
228 | 228 | $globalSources[$id]['format'] = 'vrstcp'; |
229 | 229 | } elseif ($port == '10001') { |
230 | 230 | //$formats[$id] = 'tsv'; |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
264 | 264 | else $timeout = 20; |
265 | 265 | $errno = ''; |
266 | -$errstr=''; |
|
266 | +$errstr = ''; |
|
267 | 267 | |
268 | 268 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
269 | 269 | /* Initiate connections to all the hosts simultaneously */ |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | //connect_all($globalSources); |
272 | 272 | |
273 | 273 | if (isset($globalProxy) && $globalProxy) { |
274 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
274 | + $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true))); |
|
275 | 275 | } else { |
276 | 276 | $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
277 | 277 | } |
@@ -298,16 +298,16 @@ discard block |
||
298 | 298 | |
299 | 299 | if ($use_aprs) { |
300 | 300 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
301 | - $APRS=new APRS(); |
|
301 | + $APRS = new APRS(); |
|
302 | 302 | $aprs_connect = 0; |
303 | 303 | $aprs_keep = 120; |
304 | 304 | $aprs_last_tx = time(); |
305 | 305 | if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
306 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
306 | + else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName); |
|
307 | 307 | if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
308 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
308 | + else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8); |
|
309 | 309 | if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
310 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
310 | + else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
311 | 311 | if ($aprs_full) $aprs_filter = ''; |
312 | 312 | if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
313 | 313 | else $aprs_pass = '-1'; |
@@ -322,12 +322,12 @@ discard block |
||
322 | 322 | sleep(1); |
323 | 323 | if ($globalDebug) echo "SCAN MODE \n\n"; |
324 | 324 | if (!isset($globalCronEnd)) $globalCronEnd = 60; |
325 | -$endtime = time()+$globalCronEnd; |
|
325 | +$endtime = time() + $globalCronEnd; |
|
326 | 326 | $i = 1; |
327 | 327 | $tt = array(); |
328 | 328 | // Delete all ATC |
329 | 329 | if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) { |
330 | - $ATC=new ATC($Connection->db); |
|
330 | + $ATC = new ATC($Connection->db); |
|
331 | 331 | } |
332 | 332 | if (!$globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
333 | 333 | $ATC->deleteAll(); |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | |
336 | 336 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
337 | 337 | while ($i > 0) { |
338 | - if (!$globalDaemon) $i = $endtime-time(); |
|
338 | + if (!$globalDaemon) $i = $endtime - time(); |
|
339 | 339 | // Delete old ATC |
340 | 340 | if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
341 | 341 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | } |
351 | 351 | if ($max != $globalMinFetch) { |
352 | 352 | if ($globalDebug) echo 'Sleeping...'."\n"; |
353 | - sleep($globalMinFetch-$max+2); |
|
353 | + sleep($globalMinFetch - $max + 2); |
|
354 | 354 | } |
355 | 355 | } |
356 | 356 | |
@@ -363,8 +363,8 @@ discard block |
||
363 | 363 | //$buffer = $Common->getData($hosts[$id]); |
364 | 364 | $buffer = $Common->getData($value['host']); |
365 | 365 | if ($buffer != '') $reset = 0; |
366 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
367 | - $buffer = explode('\n',$buffer); |
|
366 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
367 | + $buffer = explode('\n', $buffer); |
|
368 | 368 | foreach ($buffer as $line) { |
369 | 369 | if ($line != '' && count($line) > 7) { |
370 | 370 | $line = explode(',', $line); |
@@ -391,11 +391,11 @@ discard block |
||
391 | 391 | $last_exec[$id]['last'] = time(); |
392 | 392 | } elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
393 | 393 | date_default_timezone_set('CET'); |
394 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
394 | + $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host'])); |
|
395 | 395 | date_default_timezone_set('UTC'); |
396 | 396 | if ($buffer != '') $reset = 0; |
397 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
398 | - $buffer = explode('\n',$buffer); |
|
397 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
398 | + $buffer = explode('\n', $buffer); |
|
399 | 399 | foreach ($buffer as $line) { |
400 | 400 | if ($line != '') { |
401 | 401 | echo "'".$line."'\n"; |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
414 | 414 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
415 | 415 | if (isset($ais_data['timestamp'])) { |
416 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
416 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
417 | 417 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
418 | 418 | $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
419 | 419 | $add = true; |
@@ -436,12 +436,12 @@ discard block |
||
436 | 436 | $w = $e = null; |
437 | 437 | |
438 | 438 | if (isset($arr[$id])) { |
439 | - $nn = stream_select($arr,$w,$e,$timeout); |
|
439 | + $nn = stream_select($arr, $w, $e, $timeout); |
|
440 | 440 | if ($nn > 0) { |
441 | 441 | foreach ($httpfeeds as $feed) { |
442 | - $buffer = stream_get_line($feed,2000,"\n"); |
|
443 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
444 | - $buffer = explode('\n',$buffer); |
|
442 | + $buffer = stream_get_line($feed, 2000, "\n"); |
|
443 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
444 | + $buffer = explode('\n', $buffer); |
|
445 | 445 | foreach ($buffer as $line) { |
446 | 446 | if ($line != '') { |
447 | 447 | $ais_data = $AIS->parse_line(trim($line)); |
@@ -457,9 +457,9 @@ discard block |
||
457 | 457 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
458 | 458 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
459 | 459 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
460 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
460 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); |
|
461 | 461 | if (isset($ais_data['timestamp'])) { |
462 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
462 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
463 | 463 | } else { |
464 | 464 | $data['datetime'] = date('Y-m-d H:i:s'); |
465 | 465 | } |
@@ -473,10 +473,10 @@ discard block |
||
473 | 473 | } |
474 | 474 | } |
475 | 475 | } elseif ($value['format'] == 'myshiptracking' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
476 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
476 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
477 | 477 | if ($buffer != '') { |
478 | 478 | //echo $buffer; |
479 | - $all_data = json_decode($buffer,true); |
|
479 | + $all_data = json_decode($buffer, true); |
|
480 | 480 | //print_r($all_data); |
481 | 481 | if (isset($all_data[0]['DATA'])) { |
482 | 482 | foreach ($all_data[0]['DATA'] as $line) { |
@@ -491,7 +491,7 @@ discard block |
||
491 | 491 | // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
492 | 492 | $data['imo'] = $line['IMO']; |
493 | 493 | //$data['arrival_code'] = $ais_data['destination']; |
494 | - $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
494 | + $data['datetime'] = date('Y-m-d H:i:s', $line['T']); |
|
495 | 495 | $data['format_source'] = 'myshiptracking'; |
496 | 496 | $data['id_source'] = $id_source; |
497 | 497 | $MI->add($data); |
@@ -503,9 +503,9 @@ discard block |
||
503 | 503 | } |
504 | 504 | $last_exec[$id]['last'] = time(); |
505 | 505 | } elseif ($value['format'] == 'boatbeaconapp' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
506 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
506 | + $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host'])); |
|
507 | 507 | if ($buffer != '') { |
508 | - $all_data = json_decode($buffer,true); |
|
508 | + $all_data = json_decode($buffer, true); |
|
509 | 509 | if (isset($all_data[0]['mmsi'])) { |
510 | 510 | foreach ($all_data as $line) { |
511 | 511 | if ($line != '') { |
@@ -532,27 +532,27 @@ discard block |
||
532 | 532 | $last_exec[$id]['last'] = time(); |
533 | 533 | } elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
534 | 534 | echo 'download...'; |
535 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
535 | + $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter'); |
|
536 | 536 | echo 'done !'."\n"; |
537 | 537 | if ($buffer != '') $reset = 0; |
538 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
539 | - $buffer = explode('\n',$buffer); |
|
538 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
539 | + $buffer = explode('\n', $buffer); |
|
540 | 540 | foreach ($buffer as $line) { |
541 | 541 | if ($line != '') { |
542 | 542 | $data = array(); |
543 | - $data['mmsi'] = (int)substr($line,0,9); |
|
544 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
543 | + $data['mmsi'] = (int) substr($line, 0, 9); |
|
544 | + $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10)); |
|
545 | 545 | //$data['status'] = substr($line,21,2); |
546 | 546 | //$data['type'] = substr($line,24,3); |
547 | - $data['latitude'] = substr($line,29,9); |
|
548 | - $data['longitude'] = substr($line,41,9); |
|
549 | - $data['speed'] = round(substr($line,51,5)); |
|
547 | + $data['latitude'] = substr($line, 29, 9); |
|
548 | + $data['longitude'] = substr($line, 41, 9); |
|
549 | + $data['speed'] = round(substr($line, 51, 5)); |
|
550 | 550 | //$data['course'] = substr($line,57,5); |
551 | - $data['heading'] = round(substr($line,63,3)); |
|
551 | + $data['heading'] = round(substr($line, 63, 3)); |
|
552 | 552 | //$data['draft'] = substr($line,67,4); |
553 | 553 | //$data['length'] = substr($line,72,3); |
554 | 554 | //$data['beam'] = substr($line,76,2); |
555 | - $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
555 | + $data['ident'] = trim(utf8_encode(substr($line, 79, 20))); |
|
556 | 556 | //$data['callsign'] = trim(substr($line,100,7); |
557 | 557 | //$data['dest'] = substr($line,108,20); |
558 | 558 | //$data['etaDate'] = substr($line,129,5); |
@@ -570,8 +570,8 @@ discard block |
||
570 | 570 | } elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) { |
571 | 571 | //$buffer = $Common->getData($hosts[$id]); |
572 | 572 | $buffer = $Common->getData($value['host']); |
573 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
574 | - $buffer = explode('\n',$buffer); |
|
573 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
574 | + $buffer = explode('\n', $buffer); |
|
575 | 575 | $reset = 0; |
576 | 576 | foreach ($buffer as $line) { |
577 | 577 | if ($line != '') { |
@@ -582,7 +582,7 @@ discard block |
||
582 | 582 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
583 | 583 | $data['pilot_id'] = $line[1]; |
584 | 584 | $data['pilot_name'] = $line[2]; |
585 | - $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
|
585 | + $data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT); |
|
586 | 586 | $data['ident'] = $line[0]; // ident |
587 | 587 | if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
588 | 588 | $data['speed'] = $line[8]; // speed |
@@ -598,7 +598,7 @@ discard block |
||
598 | 598 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
599 | 599 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
600 | 600 | $data['departure_airport_icao'] = $line[11]; |
601 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
601 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':'); |
|
602 | 602 | $data['arrival_airport_icao'] = $line[13]; |
603 | 603 | $data['frequency'] = $line[4]; |
604 | 604 | $data['type'] = $line[18]; |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | $data['id_source'] = $id_source; |
608 | 608 | //$data['arrival_airport_time'] = ; |
609 | 609 | if ($line[9] != '') { |
610 | - $aircraft_data = explode('/',$line[9]); |
|
610 | + $aircraft_data = explode('/', $line[9]); |
|
611 | 611 | if (isset($aircraft_data[1])) { |
612 | 612 | $data['aircraft_icao'] = $aircraft_data[1]; |
613 | 613 | } |
@@ -621,9 +621,9 @@ discard block |
||
621 | 621 | if ($line[3] == 'PILOT') $SI->add($data); |
622 | 622 | elseif ($line[3] == 'ATC') { |
623 | 623 | //print_r($data); |
624 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
625 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
626 | - $typec = substr($data['ident'],-3); |
|
624 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
625 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
626 | + $typec = substr($data['ident'], -3); |
|
627 | 627 | if ($typec == 'APP') $data['type'] = 'Approach'; |
628 | 628 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
629 | 629 | elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
@@ -634,7 +634,7 @@ discard block |
||
634 | 634 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
635 | 635 | elseif ($data['type'] == '') $data['type'] = 'Observer'; |
636 | 636 | if (!isset($data['source_name'])) $data['source_name'] = ''; |
637 | - if (isset($ATC)) echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
|
637 | + if (isset($ATC)) echo $ATC->add($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']); |
|
638 | 638 | } |
639 | 639 | unset($data); |
640 | 640 | } |
@@ -645,9 +645,9 @@ discard block |
||
645 | 645 | $last_exec[$id]['last'] = time(); |
646 | 646 | //} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) { |
647 | 647 | } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
648 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
648 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
649 | 649 | if ($buffer != '') { |
650 | - $all_data = json_decode($buffer,true); |
|
650 | + $all_data = json_decode($buffer, true); |
|
651 | 651 | if (isset($all_data['acList'])) { |
652 | 652 | $reset = 0; |
653 | 653 | foreach ($all_data['acList'] as $line) { |
@@ -703,7 +703,7 @@ discard block |
||
703 | 703 | //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
704 | 704 | } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
705 | 705 | $buffer = $Common->getData($value['host']); |
706 | - $all_data = json_decode($buffer,true); |
|
706 | + $all_data = json_decode($buffer, true); |
|
707 | 707 | if (isset($all_data['planes'])) { |
708 | 708 | $reset = 0; |
709 | 709 | foreach ($all_data['planes'] as $key => $line) { |
@@ -720,12 +720,12 @@ discard block |
||
720 | 720 | $data['emergency'] = ''; // emergency |
721 | 721 | $data['registration'] = $line[2]; |
722 | 722 | $data['aircraft_icao'] = $line[0]; |
723 | - $deparr = explode('-',$line[1]); |
|
723 | + $deparr = explode('-', $line[1]); |
|
724 | 724 | if (count($deparr) == 2) { |
725 | 725 | $data['departure_airport_icao'] = $deparr[0]; |
726 | 726 | $data['arrival_airport_icao'] = $deparr[1]; |
727 | 727 | } |
728 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
728 | + $data['datetime'] = date('Y-m-d H:i:s', $line[9]); |
|
729 | 729 | $data['format_source'] = 'planeupdatefaa'; |
730 | 730 | $data['id_source'] = $id_source; |
731 | 731 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
@@ -737,7 +737,7 @@ discard block |
||
737 | 737 | $last_exec[$id]['last'] = time(); |
738 | 738 | } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
739 | 739 | $buffer = $Common->getData($value['host']); |
740 | - $all_data = json_decode($buffer,true); |
|
740 | + $all_data = json_decode($buffer, true); |
|
741 | 741 | if (isset($all_data['states'])) { |
742 | 742 | $reset = 0; |
743 | 743 | foreach ($all_data['states'] as $key => $line) { |
@@ -754,7 +754,7 @@ discard block |
||
754 | 754 | //$data['emergency'] = ''; // emergency |
755 | 755 | //$data['registration'] = $line[2]; |
756 | 756 | //$data['aircraft_icao'] = $line[0]; |
757 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
757 | + $data['datetime'] = date('Y-m-d H:i:s', $line[3]); |
|
758 | 758 | $data['format_source'] = 'opensky'; |
759 | 759 | $data['id_source'] = $id_source; |
760 | 760 | $SI->add($data); |
@@ -767,7 +767,7 @@ discard block |
||
767 | 767 | } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
768 | 768 | //$buffer = $Common->getData($hosts[$id]); |
769 | 769 | $buffer = $Common->getData($value['host']); |
770 | - $all_data = json_decode($buffer,true); |
|
770 | + $all_data = json_decode($buffer, true); |
|
771 | 771 | if (!empty($all_data)) $reset = 0; |
772 | 772 | foreach ($all_data as $key => $line) { |
773 | 773 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
@@ -799,11 +799,11 @@ discard block |
||
799 | 799 | //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
800 | 800 | } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
801 | 801 | //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
802 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
802 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150'); |
|
803 | 803 | //echo $buffer; |
804 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
805 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
806 | - $all_data = json_decode($buffer,true); |
|
804 | + $buffer = str_replace(array("\n", "\r"), "", $buffer); |
|
805 | + $buffer = preg_replace('/,"num":(.+)/', '}', $buffer); |
|
806 | + $all_data = json_decode($buffer, true); |
|
807 | 807 | if (json_last_error() != JSON_ERROR_NONE) { |
808 | 808 | die(json_last_error_msg()); |
809 | 809 | } |
@@ -826,7 +826,7 @@ discard block |
||
826 | 826 | //$data['departure_airport_iata'] = $line[11]; |
827 | 827 | //$data['arrival_airport_iata'] = $line[12]; |
828 | 828 | //$data['emergency'] = ''; // emergency |
829 | - $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
|
829 | + $data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10] |
|
830 | 830 | $data['format_source'] = 'radarvirtueljson'; |
831 | 831 | $data['id_source'] = $id_source; |
832 | 832 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
@@ -841,14 +841,14 @@ discard block |
||
841 | 841 | } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
842 | 842 | //$buffer = $Common->getData($hosts[$id]); |
843 | 843 | $buffer = $Common->getData($value['host'].'?'.time()); |
844 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
844 | + $all_data = json_decode(utf8_encode($buffer), true); |
|
845 | 845 | |
846 | 846 | if (isset($all_data['pireps'])) { |
847 | 847 | $reset = 0; |
848 | 848 | foreach ($all_data['pireps'] as $line) { |
849 | 849 | $data = array(); |
850 | 850 | $data['id'] = $line['id']; |
851 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
851 | + $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
852 | 852 | $data['ident'] = $line['callsign']; // ident |
853 | 853 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
854 | 854 | if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
@@ -877,9 +877,9 @@ discard block |
||
877 | 877 | $SI->add($data); |
878 | 878 | // print_r($data); |
879 | 879 | } elseif ($line['icon'] == 'ct') { |
880 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
881 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
882 | - $typec = substr($data['ident'],-3); |
|
880 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
881 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
882 | + $typec = substr($data['ident'], -3); |
|
883 | 883 | $data['type'] = ''; |
884 | 884 | if ($typec == 'APP') $data['type'] = 'Approach'; |
885 | 885 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
@@ -890,7 +890,7 @@ discard block |
||
890 | 890 | elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
891 | 891 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
892 | 892 | else $data['type'] = 'Observer'; |
893 | - if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']); |
|
893 | + if (isset($ATC)) echo $ATC->add($data['ident'], '', $data['latitude'], $data['longitude'], '0', $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source']); |
|
894 | 894 | } |
895 | 895 | unset($data); |
896 | 896 | } |
@@ -902,14 +902,14 @@ discard block |
||
902 | 902 | //$buffer = $Common->getData($hosts[$id]); |
903 | 903 | if ($globalDebug) echo 'Get Data...'."\n"; |
904 | 904 | $buffer = $Common->getData($value['host']); |
905 | - $all_data = json_decode($buffer,true); |
|
905 | + $all_data = json_decode($buffer, true); |
|
906 | 906 | if ($buffer != '' && is_array($all_data)) { |
907 | 907 | $reset = 0; |
908 | 908 | foreach ($all_data as $line) { |
909 | 909 | $data = array(); |
910 | 910 | //$data['id'] = $line['id']; // id not usable |
911 | 911 | if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
912 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
912 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
913 | 913 | if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
914 | 914 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
915 | 915 | $data['ident'] = $line['flightnum']; // ident |
@@ -932,12 +932,12 @@ discard block |
||
932 | 932 | if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
933 | 933 | if (isset($line['aircraftname'])) { |
934 | 934 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
935 | - $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
|
936 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
935 | + $line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']); |
|
936 | + $aircraft_data = explode('-', $line['aircraftname']); |
|
937 | 937 | if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0]; |
938 | 938 | elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1]; |
939 | 939 | else { |
940 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
940 | + $aircraft_data = explode(' ', $line['aircraftname']); |
|
941 | 941 | if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1]; |
942 | 942 | else $data['aircraft_icao'] = $line['aircraftname']; |
943 | 943 | } |
@@ -959,14 +959,14 @@ discard block |
||
959 | 959 | //$buffer = $Common->getData($hosts[$id]); |
960 | 960 | if ($globalDebug) echo 'Get Data...'."\n"; |
961 | 961 | $buffer = $Common->getData($value['host']); |
962 | - $all_data = json_decode($buffer,true); |
|
962 | + $all_data = json_decode($buffer, true); |
|
963 | 963 | if ($buffer != '' && is_array($all_data)) { |
964 | 964 | $reset = 0; |
965 | 965 | foreach ($all_data as $line) { |
966 | 966 | $data = array(); |
967 | 967 | //$data['id'] = $line['id']; // id not usable |
968 | 968 | $data['id'] = trim($line['flight_id']); |
969 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
969 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
970 | 970 | $data['pilot_name'] = $line['pilot_name']; |
971 | 971 | $data['pilot_id'] = $line['pilot_id']; |
972 | 972 | $data['ident'] = trim($line['callsign']); // ident |
@@ -1017,9 +1017,9 @@ discard block |
||
1017 | 1017 | //$value = $formats[$nb]; |
1018 | 1018 | $format = $globalSources[$nb]['format']; |
1019 | 1019 | if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3' || $format == 'vrstcp') { |
1020 | - $buffer = socket_read($r, 6000,PHP_NORMAL_READ); |
|
1020 | + $buffer = socket_read($r, 6000, PHP_NORMAL_READ); |
|
1021 | 1021 | } else { |
1022 | - $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
|
1022 | + $az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port); |
|
1023 | 1023 | } |
1024 | 1024 | //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
1025 | 1025 | //echo $buffer."\n"; |
@@ -1028,8 +1028,8 @@ discard block |
||
1028 | 1028 | $error = false; |
1029 | 1029 | //$SI::del(); |
1030 | 1030 | if ($format == 'vrstcp') { |
1031 | - $buffer = explode('},{',$buffer); |
|
1032 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1031 | + $buffer = explode('},{', $buffer); |
|
1032 | + } else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer)); |
|
1033 | 1033 | // SBS format is CSV format |
1034 | 1034 | if ($buffer != '') { |
1035 | 1035 | $tt[$format] = 0; |
@@ -1061,10 +1061,10 @@ discard block |
||
1061 | 1061 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
1062 | 1062 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
1063 | 1063 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
1064 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1064 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); |
|
1065 | 1065 | |
1066 | 1066 | if (isset($ais_data['timestamp'])) { |
1067 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
1067 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
1068 | 1068 | } else { |
1069 | 1069 | $data['datetime'] = date('Y-m-d H:i:s'); |
1070 | 1070 | } |
@@ -1075,10 +1075,10 @@ discard block |
||
1075 | 1075 | } elseif ($format == 'flightgearsp') { |
1076 | 1076 | //echo $buffer."\n"; |
1077 | 1077 | if (strlen($buffer) > 5) { |
1078 | - $line = explode(',',$buffer); |
|
1078 | + $line = explode(',', $buffer); |
|
1079 | 1079 | $data = array(); |
1080 | 1080 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
1081 | - $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6); |
|
1081 | + $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
1082 | 1082 | $data['ident'] = $line[6]; |
1083 | 1083 | $data['aircraft_name'] = $line[7]; |
1084 | 1084 | $data['longitude'] = $line[1]; |
@@ -1089,21 +1089,21 @@ discard block |
||
1089 | 1089 | $data['datetime'] = date('Y-m-d H:i:s'); |
1090 | 1090 | $data['format_source'] = 'flightgearsp'; |
1091 | 1091 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1092 | - $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
|
1092 | + $send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0); |
|
1093 | 1093 | } |
1094 | 1094 | } elseif ($format == 'acars') { |
1095 | 1095 | if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
1096 | 1096 | $ACARS->add(trim($buffer)); |
1097 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1097 | + socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port); |
|
1098 | 1098 | $ACARS->deleteLiveAcarsData(); |
1099 | 1099 | } elseif ($format == 'flightgearmp') { |
1100 | - if (substr($buffer,0,1) != '#') { |
|
1100 | + if (substr($buffer, 0, 1) != '#') { |
|
1101 | 1101 | $data = array(); |
1102 | 1102 | //echo $buffer."\n"; |
1103 | - $line = explode(' ',$buffer); |
|
1103 | + $line = explode(' ', $buffer); |
|
1104 | 1104 | if (count($line) == 11) { |
1105 | - $userserver = explode('@',$line[0]); |
|
1106 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1105 | + $userserver = explode('@', $line[0]); |
|
1106 | + $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex |
|
1107 | 1107 | $data['ident'] = $userserver[0]; |
1108 | 1108 | $data['registration'] = $userserver[0]; |
1109 | 1109 | $data['latitude'] = $line[4]; |
@@ -1111,8 +1111,8 @@ discard block |
||
1111 | 1111 | $data['altitude'] = $line[6]; |
1112 | 1112 | $data['datetime'] = date('Y-m-d H:i:s'); |
1113 | 1113 | $aircraft_type = $line[10]; |
1114 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1115 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1114 | + $aircraft_type = preg_split(':/:', $aircraft_type); |
|
1115 | + $data['aircraft_name'] = substr(end($aircraft_type), 0, -4); |
|
1116 | 1116 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1117 | 1117 | } |
1118 | 1118 | } |
@@ -1120,8 +1120,8 @@ discard block |
||
1120 | 1120 | echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
1121 | 1121 | die; |
1122 | 1122 | } elseif ($format == 'vrstcp') { |
1123 | - foreach($buffer as $all_data) { |
|
1124 | - $line = json_decode('{'.$all_data.'}',true); |
|
1123 | + foreach ($buffer as $all_data) { |
|
1124 | + $line = json_decode('{'.$all_data.'}', true); |
|
1125 | 1125 | $data = array(); |
1126 | 1126 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
1127 | 1127 | if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
@@ -1146,16 +1146,16 @@ discard block |
||
1146 | 1146 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
1147 | 1147 | unset($data); |
1148 | 1148 | } |
1149 | - } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
|
1149 | + } elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') { |
|
1150 | 1150 | $line = explode("\t", $buffer); |
1151 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
1151 | + for ($k = 0; $k < count($line); $k = $k + 2) { |
|
1152 | 1152 | $key = $line[$k]; |
1153 | - $lined[$key] = $line[$k+1]; |
|
1153 | + $lined[$key] = $line[$k + 1]; |
|
1154 | 1154 | } |
1155 | 1155 | if (count($lined) > 3) { |
1156 | 1156 | $data['hex'] = $lined['hexid']; |
1157 | 1157 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
1158 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
1158 | + $data['datetime'] = date('Y-m-d H:i:s'); ; |
|
1159 | 1159 | if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
1160 | 1160 | if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
1161 | 1161 | if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
@@ -1173,22 +1173,22 @@ discard block |
||
1173 | 1173 | } else $error = true; |
1174 | 1174 | } elseif ($format == 'aprs' && $use_aprs) { |
1175 | 1175 | if ($aprs_connect == 0) { |
1176 | - $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
|
1176 | + $send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0); |
|
1177 | 1177 | $aprs_connect = 1; |
1178 | 1178 | } |
1179 | 1179 | |
1180 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1180 | + if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) { |
|
1181 | 1181 | $aprs_last_tx = time(); |
1182 | 1182 | $data_aprs = "# Keep alive"; |
1183 | - $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
|
1183 | + $send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0); |
|
1184 | 1184 | } |
1185 | 1185 | |
1186 | 1186 | //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
1187 | 1187 | //echo 'APRS data : '.$buffer."\n"; |
1188 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
1189 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
1188 | + $buffer = str_replace('APRS <- ', '', $buffer); |
|
1189 | + $buffer = str_replace('APRS -> ', '', $buffer); |
|
1190 | 1190 | //echo $buffer."\n"; |
1191 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1191 | + if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') { |
|
1192 | 1192 | $line = $APRS->parse($buffer); |
1193 | 1193 | //print_r($line); |
1194 | 1194 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
@@ -1197,7 +1197,7 @@ discard block |
||
1197 | 1197 | $data = array(); |
1198 | 1198 | //print_r($line); |
1199 | 1199 | if (isset($line['address'])) $data['hex'] = $line['address']; |
1200 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1200 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']); |
|
1201 | 1201 | else $data['datetime'] = date('Y-m-d H:i:s'); |
1202 | 1202 | //$data['datetime'] = date('Y-m-d H:i:s'); |
1203 | 1203 | if (isset($line['ident'])) $data['ident'] = $line['ident']; |
@@ -1223,7 +1223,7 @@ discard block |
||
1223 | 1223 | $currentdate = date('Y-m-d H:i:s'); |
1224 | 1224 | $aprsdate = strtotime($data['datetime']); |
1225 | 1225 | // Accept data if time <= system time + 20s |
1226 | - if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
1226 | + if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate) + 20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
1227 | 1227 | $send = $SI->add($data); |
1228 | 1228 | } elseif (isset($line['stealth'])) { |
1229 | 1229 | if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
@@ -1320,7 +1320,7 @@ discard block |
||
1320 | 1320 | connect_all($sourceee); |
1321 | 1321 | $sourceee = array(); |
1322 | 1322 | //connect_all($globalSources); |
1323 | - $tt[$format]=0; |
|
1323 | + $tt[$format] = 0; |
|
1324 | 1324 | break; |
1325 | 1325 | } |
1326 | 1326 | } |
@@ -1329,14 +1329,14 @@ discard block |
||
1329 | 1329 | } else { |
1330 | 1330 | $error = socket_strerror(socket_last_error()); |
1331 | 1331 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
1332 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
1332 | + if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n"; |
|
1333 | 1333 | if (isset($globalDebug)) echo "Restarting...\n"; |
1334 | 1334 | // Restart the script if possible |
1335 | 1335 | if (is_array($sockets)) { |
1336 | 1336 | if ($globalDebug) echo "Shutdown all sockets..."; |
1337 | 1337 | |
1338 | 1338 | foreach ($sockets as $sock) { |
1339 | - @socket_shutdown($sock,2); |
|
1339 | + @socket_shutdown($sock, 2); |
|
1340 | 1340 | @socket_close($sock); |
1341 | 1341 | } |
1342 | 1342 |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | require_once(dirname(__FILE__).'/require/settings.php'); |
3 | -$date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING); |
|
3 | +$date = filter_input(INPUT_POST, 'date', FILTER_SANITIZE_STRING); |
|
4 | 4 | if ($date == '') $date = date('Y-m-d'); |
5 | 5 | header('Location: '.$globalURL.'/date/'.$date); |
6 | 6 | ?> |
7 | 7 | \ No newline at end of file |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | require_once(dirname(__FILE__).'/require/settings.php'); |
3 | -$date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING); |
|
3 | +$date = filter_input(INPUT_POST, 'date', FILTER_SANITIZE_STRING); |
|
4 | 4 | if ($date == '') $date = date('Y-m-d'); |
5 | 5 | header('Location: '.$globalURL.'/accident/'.$date); |
6 | 6 | ?> |
7 | 7 | \ No newline at end of file |