@@ -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.'/incident/'.$date); |
| 6 | 6 | ?> |
| 7 | 7 | \ No newline at end of file |
@@ -1,6 +1,8 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | require_once(dirname(__FILE__).'/require/settings.php'); |
| 3 | 3 | $date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING); |
| 4 | -if ($date == '') $date = date('Y-m-d'); |
|
| 4 | +if ($date == '') { |
|
| 5 | + $date = date('Y-m-d'); |
|
| 6 | +} |
|
| 5 | 7 | header('Location: '.$globalURL.'/incident/'.$date); |
| 6 | 8 | ?> |
| 7 | 9 | \ No newline at end of file |
@@ -3,8 +3,8 @@ |
||
| 3 | 3 | require_once('require/class.Spotter.php'); |
| 4 | 4 | require_once('require/class.Language.php'); |
| 5 | 5 | if (!isset($_GET['country'])) { |
| 6 | - header('Location: '.$globalURL.'/country'); |
|
| 7 | - die(); |
|
| 6 | + header('Location: '.$globalURL.'/country'); |
|
| 7 | + die(); |
|
| 8 | 8 | } |
| 9 | 9 | $Spotter = new Spotter(); |
| 10 | 10 | $country = ucwords(str_replace("-", " ", filter_input(INPUT_GET,'country',FILTER_SANITIZE_STRING))); |
@@ -7,8 +7,8 @@ discard block |
||
| 7 | 7 | die(); |
| 8 | 8 | } |
| 9 | 9 | $Spotter = new Spotter(); |
| 10 | -$country = ucwords(str_replace("-", " ", filter_input(INPUT_GET,'country',FILTER_SANITIZE_STRING))); |
|
| 11 | -$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
| 10 | +$country = ucwords(str_replace("-", " ", filter_input(INPUT_GET, 'country', FILTER_SANITIZE_STRING))); |
|
| 11 | +$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
| 12 | 12 | |
| 13 | 13 | if (isset($_GET['sort'])) { |
| 14 | 14 | $spotter_array = $Spotter->getSpotterDataByCountry($country, "0,1", $sort); |
@@ -18,16 +18,16 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | if (!empty($spotter_array)) |
| 20 | 20 | { |
| 21 | - $title = sprintf(_("Most Common Airlines by Country of %s"),$country); |
|
| 21 | + $title = sprintf(_("Most Common Airlines by Country of %s"), $country); |
|
| 22 | 22 | require_once('header.php'); |
| 23 | 23 | print '<div class="select-item">'; |
| 24 | 24 | print '<form action="'.$globalURL.'/country" method="post">'; |
| 25 | 25 | print '<select name="country" class="selectpicker" data-live-search="true">'; |
| 26 | 26 | print '<option></option>'; |
| 27 | 27 | $all_countries = $Spotter->getAllCountries(); |
| 28 | - foreach($all_countries as $all_country) |
|
| 28 | + foreach ($all_countries as $all_country) |
|
| 29 | 29 | { |
| 30 | - if($country == $all_country['country']) |
|
| 30 | + if ($country == $all_country['country']) |
|
| 31 | 31 | { |
| 32 | 32 | print '<option value="'.strtolower(str_replace(" ", "-", $all_country['country'])).'" selected="selected">'.$all_country['country'].'</option>'; |
| 33 | 33 | } else { |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | if ($_GET['country'] != "NA") |
| 43 | 43 | { |
| 44 | 44 | print '<div class="info column">'; |
| 45 | - print '<h1>'.sprintf(_("Airports & Airlines from %s"),$country).'</h1>'; |
|
| 45 | + print '<h1>'.sprintf(_("Airports & Airlines from %s"), $country).'</h1>'; |
|
| 46 | 46 | print '</div>'; |
| 47 | 47 | } else { |
| 48 | 48 | print '<div class="alert alert-warning">'._("This special country profile shows all flights that do <u>not</u> have a country of a airline or departure/arrival airport associated with them.").'</div>'; |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | include('country-sub-menu.php'); |
| 52 | 52 | print '<div class="column">'; |
| 53 | 53 | print '<h2>'._("Most Common Airlines by Country").'</h2>'; |
| 54 | - print '<p>'.sprintf(_("The statistic below shows the most common airlines by Country of origin of flights from airports & airlines of <strong>%s</strong>."),$country).'</p>'; |
|
| 54 | + print '<p>'.sprintf(_("The statistic below shows the most common airlines by Country of origin of flights from airports & airlines of <strong>%s</strong>."), $country).'</p>'; |
|
| 55 | 55 | $airline_array = $Spotter->countAllAirlineCountriesByCountry($country); |
| 56 | 56 | print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>'; |
| 57 | 57 | print '<script type="text/javascript" src="'.$globalURL.'/js/topojson.v2.min.js"></script>'; |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | print '<div id="chartCountry" class="chart" width="100%"></div><script>'; |
| 60 | 60 | print 'var series = ['; |
| 61 | 61 | $country_data = ''; |
| 62 | - foreach($airline_array as $airline_item) |
|
| 62 | + foreach ($airline_array as $airline_item) |
|
| 63 | 63 | { |
| 64 | 64 | $country_data .= '[ "'.$airline_item['airline_country_iso3'].'",'.$airline_item['airline_country_count'].'],'; |
| 65 | 65 | } |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | print '</thead>'; |
| 108 | 108 | print '<tbody>'; |
| 109 | 109 | $i = 1; |
| 110 | - foreach($airline_array as $airline_item) |
|
| 110 | + foreach ($airline_array as $airline_item) |
|
| 111 | 111 | { |
| 112 | 112 | print '<tr>'; |
| 113 | 113 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -3,8 +3,8 @@ discard block |
||
| 3 | 3 | require_once('require/class.Spotter.php'); |
| 4 | 4 | require_once('require/class.Language.php'); |
| 5 | 5 | if (!isset($_GET['country'])) { |
| 6 | - header('Location: '.$globalURL.'/country'); |
|
| 7 | - die(); |
|
| 6 | + header('Location: '.$globalURL.'/country'); |
|
| 7 | + die(); |
|
| 8 | 8 | } |
| 9 | 9 | $Spotter = new Spotter(); |
| 10 | 10 | $country = ucwords(str_replace("-", " ", filter_input(INPUT_GET,'country',FILTER_SANITIZE_STRING))); |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | include('country-sub-menu.php'); |
| 52 | 52 | print '<div class="column">'; |
| 53 | 53 | print '<h2>'._("Most Common Arrival Airports by Country").'</h2>'; |
| 54 | - print '<p>'.sprintf(_("The statistic below shows all arrival airports by Country of origin of flights of airports & airlines from <strong>%s</strong>."),$country).'</p>'; |
|
| 54 | + print '<p>'.sprintf(_("The statistic below shows all arrival airports by Country of origin of flights of airports & airlines from <strong>%s</strong>."),$country).'</p>'; |
|
| 55 | 55 | |
| 56 | 56 | $airport_country_array = $Spotter->countAllArrivalAirportCountriesByCountry($country); |
| 57 | 57 | print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>'; |
@@ -7,8 +7,8 @@ discard block |
||
| 7 | 7 | die(); |
| 8 | 8 | } |
| 9 | 9 | $Spotter = new Spotter(); |
| 10 | -$country = ucwords(str_replace("-", " ", filter_input(INPUT_GET,'country',FILTER_SANITIZE_STRING))); |
|
| 11 | -$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
| 10 | +$country = ucwords(str_replace("-", " ", filter_input(INPUT_GET, 'country', FILTER_SANITIZE_STRING))); |
|
| 11 | +$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
| 12 | 12 | |
| 13 | 13 | if (isset($_GET['sort'])) { |
| 14 | 14 | $spotter_array = $Spotter->getSpotterDataByCountry($country, "0,1", $sort); |
@@ -18,16 +18,16 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | if (!empty($spotter_array)) |
| 20 | 20 | { |
| 21 | - $title = sprintf(_("Most Common Arrival Airports by Country from %s"),$country); |
|
| 21 | + $title = sprintf(_("Most Common Arrival Airports by Country from %s"), $country); |
|
| 22 | 22 | require_once('header.php'); |
| 23 | 23 | print '<div class="select-item">'; |
| 24 | 24 | print '<form action="'.$globalURL.'/country" method="post">'; |
| 25 | 25 | print '<select name="country" class="selectpicker" data-live-search="true">'; |
| 26 | 26 | print '<option></option>'; |
| 27 | 27 | $all_countries = $Spotter->getAllCountries(); |
| 28 | - foreach($all_countries as $all_country) |
|
| 28 | + foreach ($all_countries as $all_country) |
|
| 29 | 29 | { |
| 30 | - if($country == $all_country['country']) |
|
| 30 | + if ($country == $all_country['country']) |
|
| 31 | 31 | { |
| 32 | 32 | print '<option value="'.strtolower(str_replace(" ", "-", $all_country['country'])).'" selected="selected">'.$all_country['country'].'</option>'; |
| 33 | 33 | } else { |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | if ($_GET['country'] != "NA") |
| 43 | 43 | { |
| 44 | 44 | print '<div class="info column">'; |
| 45 | - print '<h1>'.sprintf(_("Airports & Airlines from %s"),$country).'</h1>'; |
|
| 45 | + print '<h1>'.sprintf(_("Airports & Airlines from %s"), $country).'</h1>'; |
|
| 46 | 46 | print '</div>'; |
| 47 | 47 | } else { |
| 48 | 48 | print '<div class="alert alert-warning">'._("This special country profile shows all flights that do <u>not</u> have a country of a airline or departure/arrival airport associated with them.").'</div>'; |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | include('country-sub-menu.php'); |
| 52 | 52 | print '<div class="column">'; |
| 53 | 53 | print '<h2>'._("Most Common Arrival Airports by Country").'</h2>'; |
| 54 | - print '<p>'.sprintf(_("The statistic below shows all arrival airports by Country of origin of flights of airports & airlines from <strong>%s</strong>."),$country).'</p>'; |
|
| 54 | + print '<p>'.sprintf(_("The statistic below shows all arrival airports by Country of origin of flights of airports & airlines from <strong>%s</strong>."), $country).'</p>'; |
|
| 55 | 55 | |
| 56 | 56 | $airport_country_array = $Spotter->countAllArrivalAirportCountriesByCountry($country); |
| 57 | 57 | print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>'; |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | print '<div id="chartCountry" class="chart" width="100%"></div><script>'; |
| 62 | 62 | print 'var series = ['; |
| 63 | 63 | $country_data = ''; |
| 64 | - foreach($airport_country_array as $airport_item) |
|
| 64 | + foreach ($airport_country_array as $airport_item) |
|
| 65 | 65 | { |
| 66 | 66 | $country_data .= '[ "'.$airport_item['arrival_airport_country_iso3'].'",'.$airport_item['airport_arrival_country_count'].'],'; |
| 67 | 67 | } |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | print '</thead>'; |
| 110 | 110 | print '<tbody>'; |
| 111 | 111 | $i = 1; |
| 112 | - foreach($airport_country_array as $airport_item) |
|
| 112 | + foreach ($airport_country_array as $airport_item) |
|
| 113 | 113 | { |
| 114 | 114 | print '<tr>'; |
| 115 | 115 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -3,13 +3,13 @@ discard block |
||
| 3 | 3 | require_once('require/class.Spotter.php'); |
| 4 | 4 | require_once('require/class.Language.php'); |
| 5 | 5 | $Spotter = new Spotter(); |
| 6 | -$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
| 7 | -$date = filter_input(INPUT_GET,'date',FILTER_SANITIZE_STRING); |
|
| 8 | -$spotter_array = $Spotter->getSpotterDataByDate($date,"0,1", $sort); |
|
| 6 | +$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
| 7 | +$date = filter_input(INPUT_GET, 'date', FILTER_SANITIZE_STRING); |
|
| 8 | +$spotter_array = $Spotter->getSpotterDataByDate($date, "0,1", $sort); |
|
| 9 | 9 | |
| 10 | 10 | if (!empty($spotter_array)) |
| 11 | 11 | { |
| 12 | - $title = sprintf(_("Most Common Departure Airports by Country on %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
| 12 | + $title = sprintf(_("Most Common Departure Airports by Country on %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
| 13 | 13 | |
| 14 | 14 | require_once('header.php'); |
| 15 | 15 | print '<div class="select-item">'; |
@@ -27,13 +27,13 @@ discard block |
||
| 27 | 27 | print '<script type="text/javascript">$(function () { $("#datepicker").datetimepicker({ format: "YYYY-MM-DD", defaultDate: "'.$date.'" }); }); </script>'; |
| 28 | 28 | print '<br />'; |
| 29 | 29 | print '<div class="info column">'; |
| 30 | - print '<h1>'.sprintf(_("Flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>'; |
|
| 30 | + print '<h1>'.sprintf(_("Flights from %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>'; |
|
| 31 | 31 | print '</div>'; |
| 32 | 32 | |
| 33 | 33 | include('date-sub-menu.php'); |
| 34 | 34 | print '<div class="column">'; |
| 35 | 35 | print '<h2>'._("Most Common Departure Airports by Country").'</h2>'; |
| 36 | - print '<p>'.sprintf(_("The statistic below shows all departure airports by Country of origin of flights on <strong>%s</strong>."),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
| 36 | + print '<p>'.sprintf(_("The statistic below shows all departure airports by Country of origin of flights on <strong>%s</strong>."), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
| 37 | 37 | $airport_country_array = $Spotter->countAllDepartureAirportCountriesByDate($date); |
| 38 | 38 | print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>'; |
| 39 | 39 | print '<script type="text/javascript" src="'.$globalURL.'/js/topojson.v2.min.js"></script>'; |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | print '<div id="chartCountry" class="chart" width="100%"></div><script>'; |
| 42 | 42 | print 'var series = ['; |
| 43 | 43 | $country_data = ''; |
| 44 | - foreach($airport_country_array as $airport_item) |
|
| 44 | + foreach ($airport_country_array as $airport_item) |
|
| 45 | 45 | { |
| 46 | 46 | $country_data .= '[ "'.$airport_item['departure_airport_country_iso3'].'",'.$airport_item['airport_departure_country_count'].'],'; |
| 47 | 47 | } |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | print '</thead>'; |
| 90 | 90 | print '<tbody>'; |
| 91 | 91 | $i = 1; |
| 92 | - foreach($airport_country_array as $airport_item) |
|
| 92 | + foreach ($airport_country_array as $airport_item) |
|
| 93 | 93 | { |
| 94 | 94 | print '<tr>'; |
| 95 | 95 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -3,13 +3,13 @@ discard block |
||
| 3 | 3 | require_once('require/class.Spotter.php'); |
| 4 | 4 | require_once('require/class.Language.php'); |
| 5 | 5 | $Spotter = new Spotter(); |
| 6 | -$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
| 7 | -$date = filter_input(INPUT_GET,'date',FILTER_SANITIZE_STRING); |
|
| 8 | -$spotter_array = $Spotter->getSpotterDataByDate($date,"0,1", $sort); |
|
| 6 | +$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
| 7 | +$date = filter_input(INPUT_GET, 'date', FILTER_SANITIZE_STRING); |
|
| 8 | +$spotter_array = $Spotter->getSpotterDataByDate($date, "0,1", $sort); |
|
| 9 | 9 | |
| 10 | 10 | if (!empty($spotter_array)) |
| 11 | 11 | { |
| 12 | - $title = sprintf(_("Most Common Arrival Airports by Country on %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
| 12 | + $title = sprintf(_("Most Common Arrival Airports by Country on %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
| 13 | 13 | require_once('header.php'); |
| 14 | 14 | print '<div class="select-item">'; |
| 15 | 15 | print '<form action="'.$globalURL.'/date" method="post" class="form-inline">'; |
@@ -26,13 +26,13 @@ discard block |
||
| 26 | 26 | print '<script type="text/javascript">$(function () { $("#datepicker").datetimepicker({ format: "YYYY-MM-DD", defaultDate: "'.$date.'" }); }); </script>'; |
| 27 | 27 | print '<br />'; |
| 28 | 28 | print '<div class="info column">'; |
| 29 | - print '<h1>'.sprintf(_("Flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>'; |
|
| 29 | + print '<h1>'.sprintf(_("Flights from %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>'; |
|
| 30 | 30 | print '</div>'; |
| 31 | 31 | |
| 32 | 32 | include('date-sub-menu.php'); |
| 33 | 33 | print '<div class="column">'; |
| 34 | 34 | print '<h2>'._("Most Common Arrival Airports by Country").'</h2>'; |
| 35 | - print '<p>'.sprintf(_("The statistic below shows all arrival airports by Country of origin of flights on <strong>%s</strong>."),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
| 35 | + print '<p>'.sprintf(_("The statistic below shows all arrival airports by Country of origin of flights on <strong>%s</strong>."), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
| 36 | 36 | |
| 37 | 37 | $airport_country_array = $Spotter->countAllArrivalAirportCountriesByDate($date); |
| 38 | 38 | //print '<script type="text/javascript" src="https://www.google.com/jsapi"></script>'; |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | */ |
| 74 | 74 | print 'var series = ['; |
| 75 | 75 | $country_data = ''; |
| 76 | - foreach($airport_country_array as $airport_item) |
|
| 76 | + foreach ($airport_country_array as $airport_item) |
|
| 77 | 77 | { |
| 78 | 78 | $country_data .= '[ "'.$airport_item['arrival_airport_country_iso3'].'",'.$airport_item['airport_arrival_country_count'].'],'; |
| 79 | 79 | } |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | print '</thead>'; |
| 122 | 122 | print '<tbody>'; |
| 123 | 123 | $i = 1; |
| 124 | - foreach($airport_country_array as $airport_item) |
|
| 124 | + foreach ($airport_country_array as $airport_item) |
|
| 125 | 125 | { |
| 126 | 126 | print '<tr>'; |
| 127 | 127 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -7,13 +7,13 @@ discard block |
||
| 7 | 7 | //protected $cookies = array(); |
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | - * Get data from form result |
|
| 11 | - * @param String $url form URL |
|
| 12 | - * @param String $type type of submit form method (get or post) |
|
| 13 | - * @param String|Array $data values form post method |
|
| 14 | - * @param Array $headers header to submit with the form |
|
| 15 | - * @return String the result |
|
| 16 | - */ |
|
| 10 | + * Get data from form result |
|
| 11 | + * @param String $url form URL |
|
| 12 | + * @param String $type type of submit form method (get or post) |
|
| 13 | + * @param String|Array $data values form post method |
|
| 14 | + * @param Array $headers header to submit with the form |
|
| 15 | + * @return String the result |
|
| 16 | + */ |
|
| 17 | 17 | public function getData($url, $type = 'get', $data = '', $headers = '',$cookie = '',$referer = '',$timeout = '',$useragent = '') { |
| 18 | 18 | global $globalProxy, $globalForceIPv4; |
| 19 | 19 | $ch = curl_init(); |
@@ -107,10 +107,10 @@ discard block |
||
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | /** |
| 110 | - * Convert a HTML table to an array |
|
| 111 | - * @param String $data HTML page |
|
| 112 | - * @return Array array of the tables in HTML page |
|
| 113 | - */ |
|
| 110 | + * Convert a HTML table to an array |
|
| 111 | + * @param String $data HTML page |
|
| 112 | + * @return Array array of the tables in HTML page |
|
| 113 | + */ |
|
| 114 | 114 | public function table2array($data) { |
| 115 | 115 | if (!is_string($data)) return array(); |
| 116 | 116 | if ($data == '') return array(); |
@@ -144,10 +144,10 @@ discard block |
||
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | /** |
| 147 | - * Convert <p> part of a HTML page to an array |
|
| 148 | - * @param String $data HTML page |
|
| 149 | - * @return Array array of the <p> in HTML page |
|
| 150 | - */ |
|
| 147 | + * Convert <p> part of a HTML page to an array |
|
| 148 | + * @param String $data HTML page |
|
| 149 | + * @return Array array of the <p> in HTML page |
|
| 150 | + */ |
|
| 151 | 151 | public function text2array($data) { |
| 152 | 152 | $html = str_get_html($data); |
| 153 | 153 | if ($html === false) return array(); |
@@ -162,14 +162,14 @@ discard block |
||
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | /** |
| 165 | - * Give distance between 2 coordonnates |
|
| 166 | - * @param Float $lat latitude of first point |
|
| 167 | - * @param Float $lon longitude of first point |
|
| 168 | - * @param Float $latc latitude of second point |
|
| 169 | - * @param Float $lonc longitude of second point |
|
| 170 | - * @param String $unit km else no unit used |
|
| 171 | - * @return Float Distance in $unit |
|
| 172 | - */ |
|
| 165 | + * Give distance between 2 coordonnates |
|
| 166 | + * @param Float $lat latitude of first point |
|
| 167 | + * @param Float $lon longitude of first point |
|
| 168 | + * @param Float $latc latitude of second point |
|
| 169 | + * @param Float $lonc longitude of second point |
|
| 170 | + * @param String $unit km else no unit used |
|
| 171 | + * @return Float Distance in $unit |
|
| 172 | + */ |
|
| 173 | 173 | public function distance($lat, $lon, $latc, $lonc, $unit = 'km') { |
| 174 | 174 | if ($lat == $latc && $lon == $lonc) return 0; |
| 175 | 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; |
@@ -187,11 +187,11 @@ discard block |
||
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | /** |
| 190 | - * Check is distance realistic |
|
| 191 | - * @param int $timeDifference the time between the reception of both messages |
|
| 192 | - * @param float $distance distance covered |
|
| 193 | - * @return whether distance is realistic |
|
| 194 | - */ |
|
| 190 | + * Check is distance realistic |
|
| 191 | + * @param int $timeDifference the time between the reception of both messages |
|
| 192 | + * @param float $distance distance covered |
|
| 193 | + * @return whether distance is realistic |
|
| 194 | + */ |
|
| 195 | 195 | public function withinThreshold ($timeDifference, $distance) { |
| 196 | 196 | $x = abs($timeDifference); |
| 197 | 197 | $d = abs($distance); |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | public function isInteger($input){ |
| 212 | - return(ctype_digit(strval($input))); |
|
| 212 | + return(ctype_digit(strval($input))); |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | |
@@ -240,11 +240,11 @@ discard block |
||
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | /** |
| 243 | - * Copy folder contents |
|
| 244 | - * @param string $source Source path |
|
| 245 | - * @param string $dest Destination path |
|
| 246 | - * @return bool Returns true on success, false on failure |
|
| 247 | - */ |
|
| 243 | + * Copy folder contents |
|
| 244 | + * @param string $source Source path |
|
| 245 | + * @param string $dest Destination path |
|
| 246 | + * @return bool Returns true on success, false on failure |
|
| 247 | + */ |
|
| 248 | 248 | public function xcopy($source, $dest) |
| 249 | 249 | { |
| 250 | 250 | $files = glob($source.'*.*'); |
@@ -256,20 +256,20 @@ discard block |
||
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | /** |
| 259 | - * Check if an url exist |
|
| 260 | - * @param String $url url to check |
|
| 261 | - * @return bool Return true on succes false on failure |
|
| 262 | - */ |
|
| 259 | + * Check if an url exist |
|
| 260 | + * @param String $url url to check |
|
| 261 | + * @return bool Return true on succes false on failure |
|
| 262 | + */ |
|
| 263 | 263 | public function urlexist($url){ |
| 264 | 264 | $headers=get_headers($url); |
| 265 | 265 | return stripos($headers[0],"200 OK")?true:false; |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | /** |
| 269 | - * Convert hexa to string |
|
| 270 | - * @param String $hex data in hexa |
|
| 271 | - * @return String Return result |
|
| 272 | - */ |
|
| 269 | + * Convert hexa to string |
|
| 270 | + * @param String $hex data in hexa |
|
| 271 | + * @return String Return result |
|
| 272 | + */ |
|
| 273 | 273 | public function hex2str($hex) { |
| 274 | 274 | $str = ''; |
| 275 | 275 | $hexln = strlen($hex); |
@@ -278,10 +278,10 @@ discard block |
||
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | /** |
| 281 | - * Convert hexa color to rgb |
|
| 282 | - * @param String $hex data in hexa |
|
| 283 | - * @return String Return result |
|
| 284 | - */ |
|
| 281 | + * Convert hexa color to rgb |
|
| 282 | + * @param String $hex data in hexa |
|
| 283 | + * @return String Return result |
|
| 284 | + */ |
|
| 285 | 285 | public function hex2rgb($hex) { |
| 286 | 286 | $hex = str_replace('#','',$hex); |
| 287 | 287 | return sscanf($hex, "%02x%02x%02x"); |
@@ -359,9 +359,9 @@ discard block |
||
| 359 | 359 | } |
| 360 | 360 | |
| 361 | 361 | /** |
| 362 | - * Returns list of available locales |
|
| 363 | - * |
|
| 364 | - * @return array |
|
| 362 | + * Returns list of available locales |
|
| 363 | + * |
|
| 364 | + * @return array |
|
| 365 | 365 | */ |
| 366 | 366 | public function listLocaleDir() |
| 367 | 367 | { |
@@ -456,100 +456,100 @@ discard block |
||
| 456 | 456 | public function remove_accents($string) { |
| 457 | 457 | if ( !preg_match('/[\x80-\xff]/', $string) ) return $string; |
| 458 | 458 | $chars = array( |
| 459 | - // Decompositions for Latin-1 Supplement |
|
| 460 | - chr(195).chr(128) => 'A', chr(195).chr(129) => 'A', |
|
| 461 | - chr(195).chr(130) => 'A', chr(195).chr(131) => 'A', |
|
| 462 | - chr(195).chr(132) => 'A', chr(195).chr(133) => 'A', |
|
| 463 | - chr(195).chr(135) => 'C', chr(195).chr(136) => 'E', |
|
| 464 | - chr(195).chr(137) => 'E', chr(195).chr(138) => 'E', |
|
| 465 | - chr(195).chr(139) => 'E', chr(195).chr(140) => 'I', |
|
| 466 | - chr(195).chr(141) => 'I', chr(195).chr(142) => 'I', |
|
| 467 | - chr(195).chr(143) => 'I', chr(195).chr(145) => 'N', |
|
| 468 | - chr(195).chr(146) => 'O', chr(195).chr(147) => 'O', |
|
| 469 | - chr(195).chr(148) => 'O', chr(195).chr(149) => 'O', |
|
| 470 | - chr(195).chr(150) => 'O', chr(195).chr(153) => 'U', |
|
| 471 | - chr(195).chr(154) => 'U', chr(195).chr(155) => 'U', |
|
| 472 | - chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y', |
|
| 473 | - chr(195).chr(159) => 's', chr(195).chr(160) => 'a', |
|
| 474 | - chr(195).chr(161) => 'a', chr(195).chr(162) => 'a', |
|
| 475 | - chr(195).chr(163) => 'a', chr(195).chr(164) => 'a', |
|
| 476 | - chr(195).chr(165) => 'a', chr(195).chr(167) => 'c', |
|
| 477 | - chr(195).chr(168) => 'e', chr(195).chr(169) => 'e', |
|
| 478 | - chr(195).chr(170) => 'e', chr(195).chr(171) => 'e', |
|
| 479 | - chr(195).chr(172) => 'i', chr(195).chr(173) => 'i', |
|
| 480 | - chr(195).chr(174) => 'i', chr(195).chr(175) => 'i', |
|
| 481 | - chr(195).chr(177) => 'n', chr(195).chr(178) => 'o', |
|
| 482 | - chr(195).chr(179) => 'o', chr(195).chr(180) => 'o', |
|
| 483 | - chr(195).chr(181) => 'o', chr(195).chr(182) => 'o', |
|
| 484 | - chr(195).chr(182) => 'o', chr(195).chr(185) => 'u', |
|
| 485 | - chr(195).chr(186) => 'u', chr(195).chr(187) => 'u', |
|
| 486 | - chr(195).chr(188) => 'u', chr(195).chr(189) => 'y', |
|
| 487 | - chr(195).chr(191) => 'y', |
|
| 488 | - // Decompositions for Latin Extended-A |
|
| 489 | - chr(196).chr(128) => 'A', chr(196).chr(129) => 'a', |
|
| 490 | - chr(196).chr(130) => 'A', chr(196).chr(131) => 'a', |
|
| 491 | - chr(196).chr(132) => 'A', chr(196).chr(133) => 'a', |
|
| 492 | - chr(196).chr(134) => 'C', chr(196).chr(135) => 'c', |
|
| 493 | - chr(196).chr(136) => 'C', chr(196).chr(137) => 'c', |
|
| 494 | - chr(196).chr(138) => 'C', chr(196).chr(139) => 'c', |
|
| 495 | - chr(196).chr(140) => 'C', chr(196).chr(141) => 'c', |
|
| 496 | - chr(196).chr(142) => 'D', chr(196).chr(143) => 'd', |
|
| 497 | - chr(196).chr(144) => 'D', chr(196).chr(145) => 'd', |
|
| 498 | - chr(196).chr(146) => 'E', chr(196).chr(147) => 'e', |
|
| 499 | - chr(196).chr(148) => 'E', chr(196).chr(149) => 'e', |
|
| 500 | - chr(196).chr(150) => 'E', chr(196).chr(151) => 'e', |
|
| 501 | - chr(196).chr(152) => 'E', chr(196).chr(153) => 'e', |
|
| 502 | - chr(196).chr(154) => 'E', chr(196).chr(155) => 'e', |
|
| 503 | - chr(196).chr(156) => 'G', chr(196).chr(157) => 'g', |
|
| 504 | - chr(196).chr(158) => 'G', chr(196).chr(159) => 'g', |
|
| 505 | - chr(196).chr(160) => 'G', chr(196).chr(161) => 'g', |
|
| 506 | - chr(196).chr(162) => 'G', chr(196).chr(163) => 'g', |
|
| 507 | - chr(196).chr(164) => 'H', chr(196).chr(165) => 'h', |
|
| 508 | - chr(196).chr(166) => 'H', chr(196).chr(167) => 'h', |
|
| 509 | - chr(196).chr(168) => 'I', chr(196).chr(169) => 'i', |
|
| 510 | - chr(196).chr(170) => 'I', chr(196).chr(171) => 'i', |
|
| 511 | - chr(196).chr(172) => 'I', chr(196).chr(173) => 'i', |
|
| 512 | - chr(196).chr(174) => 'I', chr(196).chr(175) => 'i', |
|
| 513 | - chr(196).chr(176) => 'I', chr(196).chr(177) => 'i', |
|
| 514 | - chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij', |
|
| 515 | - chr(196).chr(180) => 'J', chr(196).chr(181) => 'j', |
|
| 516 | - chr(196).chr(182) => 'K', chr(196).chr(183) => 'k', |
|
| 517 | - chr(196).chr(184) => 'k', chr(196).chr(185) => 'L', |
|
| 518 | - chr(196).chr(186) => 'l', chr(196).chr(187) => 'L', |
|
| 519 | - chr(196).chr(188) => 'l', chr(196).chr(189) => 'L', |
|
| 520 | - chr(196).chr(190) => 'l', chr(196).chr(191) => 'L', |
|
| 521 | - chr(197).chr(128) => 'l', chr(197).chr(129) => 'L', |
|
| 522 | - chr(197).chr(130) => 'l', chr(197).chr(131) => 'N', |
|
| 523 | - chr(197).chr(132) => 'n', chr(197).chr(133) => 'N', |
|
| 524 | - chr(197).chr(134) => 'n', chr(197).chr(135) => 'N', |
|
| 525 | - chr(197).chr(136) => 'n', chr(197).chr(137) => 'N', |
|
| 526 | - chr(197).chr(138) => 'n', chr(197).chr(139) => 'N', |
|
| 527 | - chr(197).chr(140) => 'O', chr(197).chr(141) => 'o', |
|
| 528 | - chr(197).chr(142) => 'O', chr(197).chr(143) => 'o', |
|
| 529 | - chr(197).chr(144) => 'O', chr(197).chr(145) => 'o', |
|
| 530 | - chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe', |
|
| 531 | - chr(197).chr(148) => 'R',chr(197).chr(149) => 'r', |
|
| 532 | - chr(197).chr(150) => 'R',chr(197).chr(151) => 'r', |
|
| 533 | - chr(197).chr(152) => 'R',chr(197).chr(153) => 'r', |
|
| 534 | - chr(197).chr(154) => 'S',chr(197).chr(155) => 's', |
|
| 535 | - chr(197).chr(156) => 'S',chr(197).chr(157) => 's', |
|
| 536 | - chr(197).chr(158) => 'S',chr(197).chr(159) => 's', |
|
| 537 | - chr(197).chr(160) => 'S', chr(197).chr(161) => 's', |
|
| 538 | - chr(197).chr(162) => 'T', chr(197).chr(163) => 't', |
|
| 539 | - chr(197).chr(164) => 'T', chr(197).chr(165) => 't', |
|
| 540 | - chr(197).chr(166) => 'T', chr(197).chr(167) => 't', |
|
| 541 | - chr(197).chr(168) => 'U', chr(197).chr(169) => 'u', |
|
| 542 | - chr(197).chr(170) => 'U', chr(197).chr(171) => 'u', |
|
| 543 | - chr(197).chr(172) => 'U', chr(197).chr(173) => 'u', |
|
| 544 | - chr(197).chr(174) => 'U', chr(197).chr(175) => 'u', |
|
| 545 | - chr(197).chr(176) => 'U', chr(197).chr(177) => 'u', |
|
| 546 | - chr(197).chr(178) => 'U', chr(197).chr(179) => 'u', |
|
| 547 | - chr(197).chr(180) => 'W', chr(197).chr(181) => 'w', |
|
| 548 | - chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y', |
|
| 549 | - chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z', |
|
| 550 | - chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z', |
|
| 551 | - chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z', |
|
| 552 | - chr(197).chr(190) => 'z', chr(197).chr(191) => 's' |
|
| 459 | + // Decompositions for Latin-1 Supplement |
|
| 460 | + chr(195).chr(128) => 'A', chr(195).chr(129) => 'A', |
|
| 461 | + chr(195).chr(130) => 'A', chr(195).chr(131) => 'A', |
|
| 462 | + chr(195).chr(132) => 'A', chr(195).chr(133) => 'A', |
|
| 463 | + chr(195).chr(135) => 'C', chr(195).chr(136) => 'E', |
|
| 464 | + chr(195).chr(137) => 'E', chr(195).chr(138) => 'E', |
|
| 465 | + chr(195).chr(139) => 'E', chr(195).chr(140) => 'I', |
|
| 466 | + chr(195).chr(141) => 'I', chr(195).chr(142) => 'I', |
|
| 467 | + chr(195).chr(143) => 'I', chr(195).chr(145) => 'N', |
|
| 468 | + chr(195).chr(146) => 'O', chr(195).chr(147) => 'O', |
|
| 469 | + chr(195).chr(148) => 'O', chr(195).chr(149) => 'O', |
|
| 470 | + chr(195).chr(150) => 'O', chr(195).chr(153) => 'U', |
|
| 471 | + chr(195).chr(154) => 'U', chr(195).chr(155) => 'U', |
|
| 472 | + chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y', |
|
| 473 | + chr(195).chr(159) => 's', chr(195).chr(160) => 'a', |
|
| 474 | + chr(195).chr(161) => 'a', chr(195).chr(162) => 'a', |
|
| 475 | + chr(195).chr(163) => 'a', chr(195).chr(164) => 'a', |
|
| 476 | + chr(195).chr(165) => 'a', chr(195).chr(167) => 'c', |
|
| 477 | + chr(195).chr(168) => 'e', chr(195).chr(169) => 'e', |
|
| 478 | + chr(195).chr(170) => 'e', chr(195).chr(171) => 'e', |
|
| 479 | + chr(195).chr(172) => 'i', chr(195).chr(173) => 'i', |
|
| 480 | + chr(195).chr(174) => 'i', chr(195).chr(175) => 'i', |
|
| 481 | + chr(195).chr(177) => 'n', chr(195).chr(178) => 'o', |
|
| 482 | + chr(195).chr(179) => 'o', chr(195).chr(180) => 'o', |
|
| 483 | + chr(195).chr(181) => 'o', chr(195).chr(182) => 'o', |
|
| 484 | + chr(195).chr(182) => 'o', chr(195).chr(185) => 'u', |
|
| 485 | + chr(195).chr(186) => 'u', chr(195).chr(187) => 'u', |
|
| 486 | + chr(195).chr(188) => 'u', chr(195).chr(189) => 'y', |
|
| 487 | + chr(195).chr(191) => 'y', |
|
| 488 | + // Decompositions for Latin Extended-A |
|
| 489 | + chr(196).chr(128) => 'A', chr(196).chr(129) => 'a', |
|
| 490 | + chr(196).chr(130) => 'A', chr(196).chr(131) => 'a', |
|
| 491 | + chr(196).chr(132) => 'A', chr(196).chr(133) => 'a', |
|
| 492 | + chr(196).chr(134) => 'C', chr(196).chr(135) => 'c', |
|
| 493 | + chr(196).chr(136) => 'C', chr(196).chr(137) => 'c', |
|
| 494 | + chr(196).chr(138) => 'C', chr(196).chr(139) => 'c', |
|
| 495 | + chr(196).chr(140) => 'C', chr(196).chr(141) => 'c', |
|
| 496 | + chr(196).chr(142) => 'D', chr(196).chr(143) => 'd', |
|
| 497 | + chr(196).chr(144) => 'D', chr(196).chr(145) => 'd', |
|
| 498 | + chr(196).chr(146) => 'E', chr(196).chr(147) => 'e', |
|
| 499 | + chr(196).chr(148) => 'E', chr(196).chr(149) => 'e', |
|
| 500 | + chr(196).chr(150) => 'E', chr(196).chr(151) => 'e', |
|
| 501 | + chr(196).chr(152) => 'E', chr(196).chr(153) => 'e', |
|
| 502 | + chr(196).chr(154) => 'E', chr(196).chr(155) => 'e', |
|
| 503 | + chr(196).chr(156) => 'G', chr(196).chr(157) => 'g', |
|
| 504 | + chr(196).chr(158) => 'G', chr(196).chr(159) => 'g', |
|
| 505 | + chr(196).chr(160) => 'G', chr(196).chr(161) => 'g', |
|
| 506 | + chr(196).chr(162) => 'G', chr(196).chr(163) => 'g', |
|
| 507 | + chr(196).chr(164) => 'H', chr(196).chr(165) => 'h', |
|
| 508 | + chr(196).chr(166) => 'H', chr(196).chr(167) => 'h', |
|
| 509 | + chr(196).chr(168) => 'I', chr(196).chr(169) => 'i', |
|
| 510 | + chr(196).chr(170) => 'I', chr(196).chr(171) => 'i', |
|
| 511 | + chr(196).chr(172) => 'I', chr(196).chr(173) => 'i', |
|
| 512 | + chr(196).chr(174) => 'I', chr(196).chr(175) => 'i', |
|
| 513 | + chr(196).chr(176) => 'I', chr(196).chr(177) => 'i', |
|
| 514 | + chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij', |
|
| 515 | + chr(196).chr(180) => 'J', chr(196).chr(181) => 'j', |
|
| 516 | + chr(196).chr(182) => 'K', chr(196).chr(183) => 'k', |
|
| 517 | + chr(196).chr(184) => 'k', chr(196).chr(185) => 'L', |
|
| 518 | + chr(196).chr(186) => 'l', chr(196).chr(187) => 'L', |
|
| 519 | + chr(196).chr(188) => 'l', chr(196).chr(189) => 'L', |
|
| 520 | + chr(196).chr(190) => 'l', chr(196).chr(191) => 'L', |
|
| 521 | + chr(197).chr(128) => 'l', chr(197).chr(129) => 'L', |
|
| 522 | + chr(197).chr(130) => 'l', chr(197).chr(131) => 'N', |
|
| 523 | + chr(197).chr(132) => 'n', chr(197).chr(133) => 'N', |
|
| 524 | + chr(197).chr(134) => 'n', chr(197).chr(135) => 'N', |
|
| 525 | + chr(197).chr(136) => 'n', chr(197).chr(137) => 'N', |
|
| 526 | + chr(197).chr(138) => 'n', chr(197).chr(139) => 'N', |
|
| 527 | + chr(197).chr(140) => 'O', chr(197).chr(141) => 'o', |
|
| 528 | + chr(197).chr(142) => 'O', chr(197).chr(143) => 'o', |
|
| 529 | + chr(197).chr(144) => 'O', chr(197).chr(145) => 'o', |
|
| 530 | + chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe', |
|
| 531 | + chr(197).chr(148) => 'R',chr(197).chr(149) => 'r', |
|
| 532 | + chr(197).chr(150) => 'R',chr(197).chr(151) => 'r', |
|
| 533 | + chr(197).chr(152) => 'R',chr(197).chr(153) => 'r', |
|
| 534 | + chr(197).chr(154) => 'S',chr(197).chr(155) => 's', |
|
| 535 | + chr(197).chr(156) => 'S',chr(197).chr(157) => 's', |
|
| 536 | + chr(197).chr(158) => 'S',chr(197).chr(159) => 's', |
|
| 537 | + chr(197).chr(160) => 'S', chr(197).chr(161) => 's', |
|
| 538 | + chr(197).chr(162) => 'T', chr(197).chr(163) => 't', |
|
| 539 | + chr(197).chr(164) => 'T', chr(197).chr(165) => 't', |
|
| 540 | + chr(197).chr(166) => 'T', chr(197).chr(167) => 't', |
|
| 541 | + chr(197).chr(168) => 'U', chr(197).chr(169) => 'u', |
|
| 542 | + chr(197).chr(170) => 'U', chr(197).chr(171) => 'u', |
|
| 543 | + chr(197).chr(172) => 'U', chr(197).chr(173) => 'u', |
|
| 544 | + chr(197).chr(174) => 'U', chr(197).chr(175) => 'u', |
|
| 545 | + chr(197).chr(176) => 'U', chr(197).chr(177) => 'u', |
|
| 546 | + chr(197).chr(178) => 'U', chr(197).chr(179) => 'u', |
|
| 547 | + chr(197).chr(180) => 'W', chr(197).chr(181) => 'w', |
|
| 548 | + chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y', |
|
| 549 | + chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z', |
|
| 550 | + chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z', |
|
| 551 | + chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z', |
|
| 552 | + chr(197).chr(190) => 'z', chr(197).chr(191) => 's' |
|
| 553 | 553 | ); |
| 554 | 554 | $string = strtr($string, $chars); |
| 555 | 555 | return $string; |
@@ -90,6 +90,10 @@ discard block |
||
| 90 | 90 | return strlen($headerLine); // Needed by curl |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | + /** |
|
| 94 | + * @param string $url |
|
| 95 | + * @param string $file |
|
| 96 | + */ |
|
| 93 | 97 | public static function download($url, $file, $referer = '') { |
| 94 | 98 | global $globalDebug; |
| 95 | 99 | $fp = fopen($file, 'w'); |
@@ -106,6 +110,9 @@ discard block |
||
| 106 | 110 | fclose($fp); |
| 107 | 111 | } |
| 108 | 112 | |
| 113 | + /** |
|
| 114 | + * @param string $in_file |
|
| 115 | + */ |
|
| 109 | 116 | public static function gunzip($in_file,$out_file_name = '') { |
| 110 | 117 | //echo $in_file.' -> '.$out_file_name."\n"; |
| 111 | 118 | $buffer_size = 4096; // read 4kb at a time |
@@ -211,7 +218,7 @@ discard block |
||
| 211 | 218 | * Check is distance realistic |
| 212 | 219 | * @param int $timeDifference the time between the reception of both messages |
| 213 | 220 | * @param float $distance distance covered |
| 214 | - * @return whether distance is realistic |
|
| 221 | + * @return boolean distance is realistic |
|
| 215 | 222 | */ |
| 216 | 223 | public function withinThreshold ($timeDifference, $distance) { |
| 217 | 224 | $x = abs($timeDifference); |
@@ -234,6 +241,9 @@ discard block |
||
| 234 | 241 | } |
| 235 | 242 | |
| 236 | 243 | |
| 244 | + /** |
|
| 245 | + * @param string $latlong |
|
| 246 | + */ |
|
| 237 | 247 | public function convertDec($dms,$latlong) { |
| 238 | 248 | if ($latlong == 'latitude') { |
| 239 | 249 | $deg = substr($dms, 0, 2); |
@@ -245,6 +255,9 @@ discard block |
||
| 245 | 255 | return $deg+(($min*60)/3600); |
| 246 | 256 | } |
| 247 | 257 | |
| 258 | + /** |
|
| 259 | + * @param string $latlong |
|
| 260 | + */ |
|
| 248 | 261 | public function convertDM($coord,$latlong) { |
| 249 | 262 | if ($latlong == 'latitude') { |
| 250 | 263 | if ($coord < 0) $NSEW = 'S'; |
@@ -382,7 +395,7 @@ discard block |
||
| 382 | 395 | /** |
| 383 | 396 | * Returns list of available locales |
| 384 | 397 | * |
| 385 | - * @return array |
|
| 398 | + * @return string[] |
|
| 386 | 399 | */ |
| 387 | 400 | public function listLocaleDir() |
| 388 | 401 | { |
@@ -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; |
@@ -106,20 +106,20 @@ discard block |
||
| 106 | 106 | fclose($fp); |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - public static function gunzip($in_file,$out_file_name = '') { |
|
| 109 | + public static function gunzip($in_file, $out_file_name = '') { |
|
| 110 | 110 | //echo $in_file.' -> '.$out_file_name."\n"; |
| 111 | 111 | $buffer_size = 4096; // read 4kb at a time |
| 112 | 112 | if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); |
| 113 | 113 | if ($in_file != '' && file_exists($in_file)) { |
| 114 | 114 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
| 115 | - if (function_exists('gzopen')) $file = gzopen($in_file,'rb'); |
|
| 116 | - elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb'); |
|
| 115 | + if (function_exists('gzopen')) $file = gzopen($in_file, 'rb'); |
|
| 116 | + elseif (function_exists('gzopen64')) $file = gzopen64($in_file, 'rb'); |
|
| 117 | 117 | else { |
| 118 | 118 | echo 'gzopen not available'; |
| 119 | 119 | die; |
| 120 | 120 | } |
| 121 | 121 | $out_file = fopen($out_file_name, 'wb'); |
| 122 | - while(!gzeof($file)) { |
|
| 122 | + while (!gzeof($file)) { |
|
| 123 | 123 | fwrite($out_file, gzread($file, $buffer_size)); |
| 124 | 124 | } |
| 125 | 125 | fclose($out_file); |
@@ -127,19 +127,19 @@ discard block |
||
| 127 | 127 | } |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - public static function bunzip2($in_file,$out_file_name = '') { |
|
| 130 | + public static function bunzip2($in_file, $out_file_name = '') { |
|
| 131 | 131 | //echo $in_file.' -> '.$out_file_name."\n"; |
| 132 | 132 | $buffer_size = 4096; // read 4kb at a time |
| 133 | 133 | if ($out_file_name == '') $out_file_name = str_replace('.bz2', '', $in_file); |
| 134 | 134 | if ($in_file != '' && file_exists($in_file)) { |
| 135 | 135 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
| 136 | - if (function_exists('bzopen')) $file = bzopen($in_file,'rb'); |
|
| 136 | + if (function_exists('bzopen')) $file = bzopen($in_file, 'rb'); |
|
| 137 | 137 | else { |
| 138 | 138 | echo 'bzopen not available'; |
| 139 | 139 | die; |
| 140 | 140 | } |
| 141 | 141 | $out_file = fopen($out_file_name, 'wb'); |
| 142 | - while(!feof($file)) { |
|
| 142 | + while (!feof($file)) { |
|
| 143 | 143 | fwrite($out_file, bzread($file, $buffer_size)); |
| 144 | 144 | } |
| 145 | 145 | fclose($out_file); |
@@ -157,27 +157,27 @@ discard block |
||
| 157 | 157 | if ($data == '') return array(); |
| 158 | 158 | $html = str_get_html($data); |
| 159 | 159 | if ($html === false) return array(); |
| 160 | - $tabledata=array(); |
|
| 161 | - foreach($html->find('tr') as $element) |
|
| 160 | + $tabledata = array(); |
|
| 161 | + foreach ($html->find('tr') as $element) |
|
| 162 | 162 | { |
| 163 | 163 | $td = array(); |
| 164 | - foreach( $element->find('th') as $row) |
|
| 164 | + foreach ($element->find('th') as $row) |
|
| 165 | 165 | { |
| 166 | 166 | $td [] = trim($row->plaintext); |
| 167 | 167 | } |
| 168 | - $td=array_filter($td); |
|
| 168 | + $td = array_filter($td); |
|
| 169 | 169 | $tabledata[] = $td; |
| 170 | 170 | |
| 171 | 171 | $td = array(); |
| 172 | 172 | $tdi = array(); |
| 173 | - foreach( $element->find('td') as $row) |
|
| 173 | + foreach ($element->find('td') as $row) |
|
| 174 | 174 | { |
| 175 | 175 | $td [] = trim($row->plaintext); |
| 176 | 176 | $tdi [] = trim($row->innertext); |
| 177 | 177 | } |
| 178 | - $td=array_filter($td); |
|
| 179 | - $tdi=array_filter($tdi); |
|
| 180 | - $tabledata[]=array_merge($td,$tdi); |
|
| 178 | + $td = array_filter($td); |
|
| 179 | + $tdi = array_filter($tdi); |
|
| 180 | + $tabledata[] = array_merge($td, $tdi); |
|
| 181 | 181 | } |
| 182 | 182 | $html->clear(); |
| 183 | 183 | unset($html); |
@@ -192,8 +192,8 @@ discard block |
||
| 192 | 192 | public function text2array($data) { |
| 193 | 193 | $html = str_get_html($data); |
| 194 | 194 | if ($html === false) return array(); |
| 195 | - $tabledata=array(); |
|
| 196 | - foreach($html->find('p') as $element) |
|
| 195 | + $tabledata = array(); |
|
| 196 | + foreach ($html->find('p') as $element) |
|
| 197 | 197 | { |
| 198 | 198 | $tabledata [] = trim($element->plaintext); |
| 199 | 199 | } |
@@ -213,11 +213,11 @@ discard block |
||
| 213 | 213 | */ |
| 214 | 214 | public function distance($lat, $lon, $latc, $lonc, $unit = 'km') { |
| 215 | 215 | if ($lat == $latc && $lon == $lonc) return 0; |
| 216 | - $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; |
|
| 216 | + $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; |
|
| 217 | 217 | if ($unit == "km") { |
| 218 | - return round($dist * 1.609344); |
|
| 218 | + return round($dist*1.609344); |
|
| 219 | 219 | } elseif ($unit == "m") { |
| 220 | - return round($dist * 1.609344 * 1000); |
|
| 220 | + return round($dist*1.609344*1000); |
|
| 221 | 221 | } elseif ($unit == "mile" || $unit == "mi") { |
| 222 | 222 | return round($dist); |
| 223 | 223 | } elseif ($unit == "nm") { |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | * @param float $distance distance covered |
| 234 | 234 | * @return whether distance is realistic |
| 235 | 235 | */ |
| 236 | - public function withinThreshold ($timeDifference, $distance) { |
|
| 236 | + public function withinThreshold($timeDifference, $distance) { |
|
| 237 | 237 | $x = abs($timeDifference); |
| 238 | 238 | $d = abs($distance); |
| 239 | 239 | if ($x == 0 || $d == 0) return true; |
@@ -249,12 +249,12 @@ discard block |
||
| 249 | 249 | return ($array !== array_values($array)); |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | - public function isInteger($input){ |
|
| 252 | + public function isInteger($input) { |
|
| 253 | 253 | return(ctype_digit(strval($input))); |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | |
| 257 | - public function convertDec($dms,$latlong) { |
|
| 257 | + public function convertDec($dms, $latlong) { |
|
| 258 | 258 | if ($latlong == 'latitude') { |
| 259 | 259 | $deg = substr($dms, 0, 2); |
| 260 | 260 | $min = substr($dms, 2, 4); |
@@ -262,10 +262,10 @@ discard block |
||
| 262 | 262 | $deg = substr($dms, 0, 3); |
| 263 | 263 | $min = substr($dms, 3, 5); |
| 264 | 264 | } |
| 265 | - return $deg+(($min*60)/3600); |
|
| 265 | + return $deg + (($min*60)/3600); |
|
| 266 | 266 | } |
| 267 | 267 | |
| 268 | - public function convertDM($coord,$latlong) { |
|
| 268 | + public function convertDM($coord, $latlong) { |
|
| 269 | 269 | if ($latlong == 'latitude') { |
| 270 | 270 | if ($coord < 0) $NSEW = 'S'; |
| 271 | 271 | else $NSEW = 'N'; |
@@ -275,9 +275,9 @@ discard block |
||
| 275 | 275 | } |
| 276 | 276 | $coord = abs($coord); |
| 277 | 277 | $deg = floor($coord); |
| 278 | - $coord = ($coord-$deg)*60; |
|
| 278 | + $coord = ($coord - $deg)*60; |
|
| 279 | 279 | $min = $coord; |
| 280 | - return array('deg' => $deg,'min' => $min,'NSEW' => $NSEW); |
|
| 280 | + return array('deg' => $deg, 'min' => $min, 'NSEW' => $NSEW); |
|
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | /** |
@@ -289,8 +289,8 @@ discard block |
||
| 289 | 289 | public function xcopy($source, $dest) |
| 290 | 290 | { |
| 291 | 291 | $files = glob($source.'*.*'); |
| 292 | - foreach($files as $file){ |
|
| 293 | - $file_to_go = str_replace($source,$dest,$file); |
|
| 292 | + foreach ($files as $file) { |
|
| 293 | + $file_to_go = str_replace($source, $dest, $file); |
|
| 294 | 294 | copy($file, $file_to_go); |
| 295 | 295 | } |
| 296 | 296 | return true; |
@@ -301,9 +301,9 @@ discard block |
||
| 301 | 301 | * @param String $url url to check |
| 302 | 302 | * @return bool Return true on succes false on failure |
| 303 | 303 | */ |
| 304 | - public function urlexist($url){ |
|
| 305 | - $headers=get_headers($url); |
|
| 306 | - return stripos($headers[0],"200 OK")?true:false; |
|
| 304 | + public function urlexist($url) { |
|
| 305 | + $headers = get_headers($url); |
|
| 306 | + return stripos($headers[0], "200 OK") ? true : false; |
|
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | /** |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | public function hex2str($hex) { |
| 315 | 315 | $str = ''; |
| 316 | 316 | $hexln = strlen($hex); |
| 317 | - for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2))); |
|
| 317 | + for ($i = 0; $i < $hexln; $i += 2) $str .= chr(hexdec(substr($hex, $i, 2))); |
|
| 318 | 318 | return $str; |
| 319 | 319 | } |
| 320 | 320 | |
@@ -324,7 +324,7 @@ discard block |
||
| 324 | 324 | * @return String Return result |
| 325 | 325 | */ |
| 326 | 326 | public function hex2rgb($hex) { |
| 327 | - $hex = str_replace('#','',$hex); |
|
| 327 | + $hex = str_replace('#', '', $hex); |
|
| 328 | 328 | return sscanf($hex, "%02x%02x%02x"); |
| 329 | 329 | } |
| 330 | 330 | |
@@ -332,33 +332,33 @@ discard block |
||
| 332 | 332 | //difference in longitudinal coordinates |
| 333 | 333 | $dLon = deg2rad($lon2) - deg2rad($lon1); |
| 334 | 334 | //difference in the phi of latitudinal coordinates |
| 335 | - $dPhi = log(tan(deg2rad($lat2) / 2 + pi() / 4) / tan(deg2rad($lat1) / 2 + pi() / 4)); |
|
| 335 | + $dPhi = log(tan(deg2rad($lat2)/2 + pi()/4)/tan(deg2rad($lat1)/2 + pi()/4)); |
|
| 336 | 336 | //we need to recalculate $dLon if it is greater than pi |
| 337 | - if(abs($dLon) > pi()) { |
|
| 338 | - if($dLon > 0) { |
|
| 339 | - $dLon = (2 * pi() - $dLon) * -1; |
|
| 337 | + if (abs($dLon) > pi()) { |
|
| 338 | + if ($dLon > 0) { |
|
| 339 | + $dLon = (2*pi() - $dLon)*-1; |
|
| 340 | 340 | } else { |
| 341 | - $dLon = 2 * pi() + $dLon; |
|
| 341 | + $dLon = 2*pi() + $dLon; |
|
| 342 | 342 | } |
| 343 | 343 | } |
| 344 | 344 | //return the angle, normalized |
| 345 | - return (rad2deg(atan2($dLon, $dPhi)) + 360) % 360; |
|
| 345 | + return (rad2deg(atan2($dLon, $dPhi)) + 360)%360; |
|
| 346 | 346 | } |
| 347 | 347 | |
| 348 | - public function checkLine($lat1,$lon1,$lat2,$lon2,$lat3,$lon3,$approx = 0.2) { |
|
| 348 | + public function checkLine($lat1, $lon1, $lat2, $lon2, $lat3, $lon3, $approx = 0.2) { |
|
| 349 | 349 | //$a = ($lon2-$lon1)*$lat3+($lat2-$lat1)*$lon3+($lat1*$lon2+$lat2*$lon1); |
| 350 | - $a = -($lon2-$lon1); |
|
| 350 | + $a = -($lon2 - $lon1); |
|
| 351 | 351 | $b = $lat2 - $lat1; |
| 352 | - $c = -($a*$lat1+$b*$lon1); |
|
| 353 | - $d = $a*$lat3+$b*$lon3+$c; |
|
| 352 | + $c = -($a*$lat1 + $b*$lon1); |
|
| 353 | + $d = $a*$lat3 + $b*$lon3 + $c; |
|
| 354 | 354 | if ($d > -$approx && $d < $approx) return true; |
| 355 | 355 | else return false; |
| 356 | 356 | } |
| 357 | 357 | |
| 358 | 358 | public function array_merge_noappend() { |
| 359 | 359 | $output = array(); |
| 360 | - foreach(func_get_args() as $array) { |
|
| 361 | - foreach($array as $key => $value) { |
|
| 360 | + foreach (func_get_args() as $array) { |
|
| 361 | + foreach ($array as $key => $value) { |
|
| 362 | 362 | $output[$key] = isset($output[$key]) ? |
| 363 | 363 | array_merge($output[$key], $value) : $value; |
| 364 | 364 | } |
@@ -422,34 +422,34 @@ discard block |
||
| 422 | 422 | return $result; |
| 423 | 423 | } |
| 424 | 424 | |
| 425 | - public function nextcoord($latitude, $longitude, $speed, $heading, $archivespeed = 1){ |
|
| 425 | + public function nextcoord($latitude, $longitude, $speed, $heading, $archivespeed = 1) { |
|
| 426 | 426 | global $globalMapRefresh; |
| 427 | 427 | $distance = ($speed*0.514444*$globalMapRefresh*$archivespeed)/1000; |
| 428 | 428 | $r = 6378; |
| 429 | 429 | $latitude = deg2rad($latitude); |
| 430 | 430 | $longitude = deg2rad($longitude); |
| 431 | 431 | $bearing = deg2rad($heading); |
| 432 | - $latitude2 = asin( (sin($latitude) * cos($distance/$r)) + (cos($latitude) * sin($distance/$r) * cos($bearing)) ); |
|
| 433 | - $longitude2 = $longitude + atan2( sin($bearing)*sin($distance/$r)*cos($latitude), cos($distance/$r)-(sin($latitude)*sin($latitude2)) ); |
|
| 434 | - return array('latitude' => number_format(rad2deg($latitude2),5,'.',''),'longitude' => number_format(rad2deg($longitude2),5,'.','')); |
|
| 432 | + $latitude2 = asin((sin($latitude)*cos($distance/$r)) + (cos($latitude)*sin($distance/$r)*cos($bearing))); |
|
| 433 | + $longitude2 = $longitude + atan2(sin($bearing)*sin($distance/$r)*cos($latitude), cos($distance/$r) - (sin($latitude)*sin($latitude2))); |
|
| 434 | + return array('latitude' => number_format(rad2deg($latitude2), 5, '.', ''), 'longitude' => number_format(rad2deg($longitude2), 5, '.', '')); |
|
| 435 | 435 | } |
| 436 | 436 | |
| 437 | - public function getCoordfromDistanceBearing($latitude,$longitude,$bearing,$distance) { |
|
| 437 | + public function getCoordfromDistanceBearing($latitude, $longitude, $bearing, $distance) { |
|
| 438 | 438 | // distance in meter |
| 439 | 439 | $R = 6378.14; |
| 440 | - $latitude1 = $latitude * (M_PI/180); |
|
| 441 | - $longitude1 = $longitude * (M_PI/180); |
|
| 442 | - $brng = $bearing * (M_PI/180); |
|
| 440 | + $latitude1 = $latitude*(M_PI/180); |
|
| 441 | + $longitude1 = $longitude*(M_PI/180); |
|
| 442 | + $brng = $bearing*(M_PI/180); |
|
| 443 | 443 | $d = $distance; |
| 444 | 444 | |
| 445 | 445 | $latitude2 = asin(sin($latitude1)*cos($d/$R) + cos($latitude1)*sin($d/$R)*cos($brng)); |
| 446 | - $longitude2 = $longitude1 + atan2(sin($brng)*sin($d/$R)*cos($latitude1),cos($d/$R)-sin($latitude1)*sin($latitude2)); |
|
| 446 | + $longitude2 = $longitude1 + atan2(sin($brng)*sin($d/$R)*cos($latitude1), cos($d/$R) - sin($latitude1)*sin($latitude2)); |
|
| 447 | 447 | |
| 448 | - $latitude2 = $latitude2 * (180/M_PI); |
|
| 449 | - $longitude2 = $longitude2 * (180/M_PI); |
|
| 448 | + $latitude2 = $latitude2*(180/M_PI); |
|
| 449 | + $longitude2 = $longitude2*(180/M_PI); |
|
| 450 | 450 | |
| 451 | - $flat = round ($latitude2,6); |
|
| 452 | - $flong = round ($longitude2,6); |
|
| 451 | + $flat = round($latitude2, 6); |
|
| 452 | + $flong = round($longitude2, 6); |
|
| 453 | 453 | /* |
| 454 | 454 | $dx = $distance*cos($bearing); |
| 455 | 455 | $dy = $distance*sin($bearing); |
@@ -458,7 +458,7 @@ discard block |
||
| 458 | 458 | $flong = $longitude + $dlong; |
| 459 | 459 | $flat = $latitude + $dlat; |
| 460 | 460 | */ |
| 461 | - return array('latitude' => $flat,'longitude' => $flong); |
|
| 461 | + return array('latitude' => $flat, 'longitude' => $flong); |
|
| 462 | 462 | } |
| 463 | 463 | |
| 464 | 464 | /** |
@@ -472,14 +472,14 @@ discard block |
||
| 472 | 472 | * @param integer $level GZIP compression level (default: 9) |
| 473 | 473 | * @return string New filename (with .gz appended) if success, or false if operation fails |
| 474 | 474 | */ |
| 475 | - public function gzCompressFile($source, $level = 9){ |
|
| 476 | - $dest = $source . '.gz'; |
|
| 477 | - $mode = 'wb' . $level; |
|
| 475 | + public function gzCompressFile($source, $level = 9) { |
|
| 476 | + $dest = $source.'.gz'; |
|
| 477 | + $mode = 'wb'.$level; |
|
| 478 | 478 | $error = false; |
| 479 | 479 | if ($fp_out = gzopen($dest, $mode)) { |
| 480 | - if ($fp_in = fopen($source,'rb')) { |
|
| 480 | + if ($fp_in = fopen($source, 'rb')) { |
|
| 481 | 481 | while (!feof($fp_in)) |
| 482 | - gzwrite($fp_out, fread($fp_in, 1024 * 512)); |
|
| 482 | + gzwrite($fp_out, fread($fp_in, 1024*512)); |
|
| 483 | 483 | fclose($fp_in); |
| 484 | 484 | } else { |
| 485 | 485 | $error = true; |
@@ -495,7 +495,7 @@ discard block |
||
| 495 | 495 | } |
| 496 | 496 | |
| 497 | 497 | public function remove_accents($string) { |
| 498 | - if ( !preg_match('/[\x80-\xff]/', $string) ) return $string; |
|
| 498 | + if (!preg_match('/[\x80-\xff]/', $string)) return $string; |
|
| 499 | 499 | $chars = array( |
| 500 | 500 | // Decompositions for Latin-1 Supplement |
| 501 | 501 | chr(195).chr(128) => 'A', chr(195).chr(129) => 'A', |
@@ -552,7 +552,7 @@ discard block |
||
| 552 | 552 | chr(196).chr(172) => 'I', chr(196).chr(173) => 'i', |
| 553 | 553 | chr(196).chr(174) => 'I', chr(196).chr(175) => 'i', |
| 554 | 554 | chr(196).chr(176) => 'I', chr(196).chr(177) => 'i', |
| 555 | - chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij', |
|
| 555 | + chr(196).chr(178) => 'IJ', chr(196).chr(179) => 'ij', |
|
| 556 | 556 | chr(196).chr(180) => 'J', chr(196).chr(181) => 'j', |
| 557 | 557 | chr(196).chr(182) => 'K', chr(196).chr(183) => 'k', |
| 558 | 558 | chr(196).chr(184) => 'k', chr(196).chr(185) => 'L', |
@@ -568,13 +568,13 @@ discard block |
||
| 568 | 568 | chr(197).chr(140) => 'O', chr(197).chr(141) => 'o', |
| 569 | 569 | chr(197).chr(142) => 'O', chr(197).chr(143) => 'o', |
| 570 | 570 | chr(197).chr(144) => 'O', chr(197).chr(145) => 'o', |
| 571 | - chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe', |
|
| 572 | - chr(197).chr(148) => 'R',chr(197).chr(149) => 'r', |
|
| 573 | - chr(197).chr(150) => 'R',chr(197).chr(151) => 'r', |
|
| 574 | - chr(197).chr(152) => 'R',chr(197).chr(153) => 'r', |
|
| 575 | - chr(197).chr(154) => 'S',chr(197).chr(155) => 's', |
|
| 576 | - chr(197).chr(156) => 'S',chr(197).chr(157) => 's', |
|
| 577 | - chr(197).chr(158) => 'S',chr(197).chr(159) => 's', |
|
| 571 | + chr(197).chr(146) => 'OE', chr(197).chr(147) => 'oe', |
|
| 572 | + chr(197).chr(148) => 'R', chr(197).chr(149) => 'r', |
|
| 573 | + chr(197).chr(150) => 'R', chr(197).chr(151) => 'r', |
|
| 574 | + chr(197).chr(152) => 'R', chr(197).chr(153) => 'r', |
|
| 575 | + chr(197).chr(154) => 'S', chr(197).chr(155) => 's', |
|
| 576 | + chr(197).chr(156) => 'S', chr(197).chr(157) => 's', |
|
| 577 | + chr(197).chr(158) => 'S', chr(197).chr(159) => 's', |
|
| 578 | 578 | chr(197).chr(160) => 'S', chr(197).chr(161) => 's', |
| 579 | 579 | chr(197).chr(162) => 'T', chr(197).chr(163) => 't', |
| 580 | 580 | chr(197).chr(164) => 'T', chr(197).chr(165) => 't', |
@@ -608,7 +608,7 @@ discard block |
||
| 608 | 608 | for ($i = 0, $int = '', $concat_flag = true; $i < $length; $i++) { |
| 609 | 609 | if (is_numeric($string[$i]) && $concat_flag) { |
| 610 | 610 | $int .= $string[$i]; |
| 611 | - } elseif(!$concat && $concat_flag && strlen($int) > 0) { |
|
| 611 | + } elseif (!$concat && $concat_flag && strlen($int) > 0) { |
|
| 612 | 612 | $concat_flag = false; |
| 613 | 613 | } |
| 614 | 614 | } |
@@ -37,8 +37,11 @@ discard block |
||
| 37 | 37 | } else { |
| 38 | 38 | curl_setopt($ch, CURLOPT_USERAGENT, $useragent); |
| 39 | 39 | } |
| 40 | - if ($timeout == '') curl_setopt($ch, CURLOPT_TIMEOUT, 10); |
|
| 41 | - else curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); |
|
| 40 | + if ($timeout == '') { |
|
| 41 | + curl_setopt($ch, CURLOPT_TIMEOUT, 10); |
|
| 42 | + } else { |
|
| 43 | + curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); |
|
| 44 | + } |
|
| 42 | 45 | curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common',"curlResponseHeaderCallback")); |
| 43 | 46 | if ($type == 'post') { |
| 44 | 47 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); |
@@ -85,8 +88,9 @@ discard block |
||
| 85 | 88 | private function curlResponseHeaderCallback($ch, $headerLine) { |
| 86 | 89 | //global $cookies; |
| 87 | 90 | $cookies = array(); |
| 88 | - if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1) |
|
| 89 | - $cookies[] = $cookie; |
|
| 91 | + if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1) { |
|
| 92 | + $cookies[] = $cookie; |
|
| 93 | + } |
|
| 90 | 94 | return strlen($headerLine); // Needed by curl |
| 91 | 95 | } |
| 92 | 96 | |
@@ -97,11 +101,15 @@ discard block |
||
| 97 | 101 | curl_setopt($ch, CURLOPT_URL, $url); |
| 98 | 102 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
| 99 | 103 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
| 100 | - if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
| 104 | + if ($referer != '') { |
|
| 105 | + curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
| 106 | + } |
|
| 101 | 107 | 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'); |
| 102 | 108 | curl_setopt($ch, CURLOPT_FILE, $fp); |
| 103 | 109 | curl_exec($ch); |
| 104 | - if (curl_errno($ch) && $globalDebug) echo 'Download error: '.curl_error($ch); |
|
| 110 | + if (curl_errno($ch) && $globalDebug) { |
|
| 111 | + echo 'Download error: '.curl_error($ch); |
|
| 112 | + } |
|
| 105 | 113 | curl_close($ch); |
| 106 | 114 | fclose($fp); |
| 107 | 115 | } |
@@ -109,12 +117,16 @@ discard block |
||
| 109 | 117 | public static function gunzip($in_file,$out_file_name = '') { |
| 110 | 118 | //echo $in_file.' -> '.$out_file_name."\n"; |
| 111 | 119 | $buffer_size = 4096; // read 4kb at a time |
| 112 | - if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); |
|
| 120 | + if ($out_file_name == '') { |
|
| 121 | + $out_file_name = str_replace('.gz', '', $in_file); |
|
| 122 | + } |
|
| 113 | 123 | if ($in_file != '' && file_exists($in_file)) { |
| 114 | 124 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
| 115 | - if (function_exists('gzopen')) $file = gzopen($in_file,'rb'); |
|
| 116 | - elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb'); |
|
| 117 | - else { |
|
| 125 | + if (function_exists('gzopen')) { |
|
| 126 | + $file = gzopen($in_file,'rb'); |
|
| 127 | + } elseif (function_exists('gzopen64')) { |
|
| 128 | + $file = gzopen64($in_file,'rb'); |
|
| 129 | + } else { |
|
| 118 | 130 | echo 'gzopen not available'; |
| 119 | 131 | die; |
| 120 | 132 | } |
@@ -130,11 +142,14 @@ discard block |
||
| 130 | 142 | public static function bunzip2($in_file,$out_file_name = '') { |
| 131 | 143 | //echo $in_file.' -> '.$out_file_name."\n"; |
| 132 | 144 | $buffer_size = 4096; // read 4kb at a time |
| 133 | - if ($out_file_name == '') $out_file_name = str_replace('.bz2', '', $in_file); |
|
| 145 | + if ($out_file_name == '') { |
|
| 146 | + $out_file_name = str_replace('.bz2', '', $in_file); |
|
| 147 | + } |
|
| 134 | 148 | if ($in_file != '' && file_exists($in_file)) { |
| 135 | 149 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
| 136 | - if (function_exists('bzopen')) $file = bzopen($in_file,'rb'); |
|
| 137 | - else { |
|
| 150 | + if (function_exists('bzopen')) { |
|
| 151 | + $file = bzopen($in_file,'rb'); |
|
| 152 | + } else { |
|
| 138 | 153 | echo 'bzopen not available'; |
| 139 | 154 | die; |
| 140 | 155 | } |
@@ -153,10 +168,16 @@ discard block |
||
| 153 | 168 | * @return Array array of the tables in HTML page |
| 154 | 169 | */ |
| 155 | 170 | public function table2array($data) { |
| 156 | - if (!is_string($data)) return array(); |
|
| 157 | - if ($data == '') return array(); |
|
| 171 | + if (!is_string($data)) { |
|
| 172 | + return array(); |
|
| 173 | + } |
|
| 174 | + if ($data == '') { |
|
| 175 | + return array(); |
|
| 176 | + } |
|
| 158 | 177 | $html = str_get_html($data); |
| 159 | - if ($html === false) return array(); |
|
| 178 | + if ($html === false) { |
|
| 179 | + return array(); |
|
| 180 | + } |
|
| 160 | 181 | $tabledata=array(); |
| 161 | 182 | foreach($html->find('tr') as $element) |
| 162 | 183 | { |
@@ -191,7 +212,9 @@ discard block |
||
| 191 | 212 | */ |
| 192 | 213 | public function text2array($data) { |
| 193 | 214 | $html = str_get_html($data); |
| 194 | - if ($html === false) return array(); |
|
| 215 | + if ($html === false) { |
|
| 216 | + return array(); |
|
| 217 | + } |
|
| 195 | 218 | $tabledata=array(); |
| 196 | 219 | foreach($html->find('p') as $element) |
| 197 | 220 | { |
@@ -212,7 +235,9 @@ discard block |
||
| 212 | 235 | * @return Float Distance in $unit |
| 213 | 236 | */ |
| 214 | 237 | public function distance($lat, $lon, $latc, $lonc, $unit = 'km') { |
| 215 | - if ($lat == $latc && $lon == $lonc) return 0; |
|
| 238 | + if ($lat == $latc && $lon == $lonc) { |
|
| 239 | + return 0; |
|
| 240 | + } |
|
| 216 | 241 | $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; |
| 217 | 242 | if ($unit == "km") { |
| 218 | 243 | return round($dist * 1.609344); |
@@ -236,10 +261,16 @@ discard block |
||
| 236 | 261 | public function withinThreshold ($timeDifference, $distance) { |
| 237 | 262 | $x = abs($timeDifference); |
| 238 | 263 | $d = abs($distance); |
| 239 | - if ($x == 0 || $d == 0) return true; |
|
| 264 | + if ($x == 0 || $d == 0) { |
|
| 265 | + return true; |
|
| 266 | + } |
|
| 240 | 267 | // may be due to Internet jitter; distance is realistic |
| 241 | - if ($x < 0.7 && $d < 2000) return true; |
|
| 242 | - else return $d/$x < 1500*0.27778; // 1500 km/h max |
|
| 268 | + if ($x < 0.7 && $d < 2000) { |
|
| 269 | + return true; |
|
| 270 | + } else { |
|
| 271 | + return $d/$x < 1500*0.27778; |
|
| 272 | + } |
|
| 273 | + // 1500 km/h max |
|
| 243 | 274 | } |
| 244 | 275 | |
| 245 | 276 | |
@@ -267,11 +298,17 @@ discard block |
||
| 267 | 298 | |
| 268 | 299 | public function convertDM($coord,$latlong) { |
| 269 | 300 | if ($latlong == 'latitude') { |
| 270 | - if ($coord < 0) $NSEW = 'S'; |
|
| 271 | - else $NSEW = 'N'; |
|
| 301 | + if ($coord < 0) { |
|
| 302 | + $NSEW = 'S'; |
|
| 303 | + } else { |
|
| 304 | + $NSEW = 'N'; |
|
| 305 | + } |
|
| 272 | 306 | } elseif ($latlong == 'longitude') { |
| 273 | - if ($coord < 0) $NSEW = 'W'; |
|
| 274 | - else $NSEW = 'E'; |
|
| 307 | + if ($coord < 0) { |
|
| 308 | + $NSEW = 'W'; |
|
| 309 | + } else { |
|
| 310 | + $NSEW = 'E'; |
|
| 311 | + } |
|
| 275 | 312 | } |
| 276 | 313 | $coord = abs($coord); |
| 277 | 314 | $deg = floor($coord); |
@@ -314,7 +351,9 @@ discard block |
||
| 314 | 351 | public function hex2str($hex) { |
| 315 | 352 | $str = ''; |
| 316 | 353 | $hexln = strlen($hex); |
| 317 | - for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2))); |
|
| 354 | + for($i=0;$i<$hexln;$i+=2) { |
|
| 355 | + $str .= chr(hexdec(substr($hex,$i,2))); |
|
| 356 | + } |
|
| 318 | 357 | return $str; |
| 319 | 358 | } |
| 320 | 359 | |
@@ -351,8 +390,11 @@ discard block |
||
| 351 | 390 | $b = $lat2 - $lat1; |
| 352 | 391 | $c = -($a*$lat1+$b*$lon1); |
| 353 | 392 | $d = $a*$lat3+$b*$lon3+$c; |
| 354 | - if ($d > -$approx && $d < $approx) return true; |
|
| 355 | - else return false; |
|
| 393 | + if ($d > -$approx && $d < $approx) { |
|
| 394 | + return true; |
|
| 395 | + } else { |
|
| 396 | + return false; |
|
| 397 | + } |
|
| 356 | 398 | } |
| 357 | 399 | |
| 358 | 400 | public function array_merge_noappend() { |
@@ -411,7 +453,9 @@ discard block |
||
| 411 | 453 | return $result; |
| 412 | 454 | } |
| 413 | 455 | $handle = @opendir('./locale'); |
| 414 | - if ($handle === false) return $result; |
|
| 456 | + if ($handle === false) { |
|
| 457 | + return $result; |
|
| 458 | + } |
|
| 415 | 459 | while (false !== ($file = readdir($handle))) { |
| 416 | 460 | $path = './locale'.'/'.$file.'/LC_MESSAGES/fam.mo'; |
| 417 | 461 | if ($file != "." && $file != ".." && @file_exists($path)) { |
@@ -478,8 +522,9 @@ discard block |
||
| 478 | 522 | $error = false; |
| 479 | 523 | if ($fp_out = gzopen($dest, $mode)) { |
| 480 | 524 | if ($fp_in = fopen($source,'rb')) { |
| 481 | - while (!feof($fp_in)) |
|
| 482 | - gzwrite($fp_out, fread($fp_in, 1024 * 512)); |
|
| 525 | + while (!feof($fp_in)) { |
|
| 526 | + gzwrite($fp_out, fread($fp_in, 1024 * 512)); |
|
| 527 | + } |
|
| 483 | 528 | fclose($fp_in); |
| 484 | 529 | } else { |
| 485 | 530 | $error = true; |
@@ -488,14 +533,17 @@ discard block |
||
| 488 | 533 | } else { |
| 489 | 534 | $error = true; |
| 490 | 535 | } |
| 491 | - if ($error) |
|
| 492 | - return false; |
|
| 493 | - else |
|
| 494 | - return $dest; |
|
| 536 | + if ($error) { |
|
| 537 | + return false; |
|
| 538 | + } else { |
|
| 539 | + return $dest; |
|
| 540 | + } |
|
| 495 | 541 | } |
| 496 | 542 | |
| 497 | 543 | public function remove_accents($string) { |
| 498 | - if ( !preg_match('/[\x80-\xff]/', $string) ) return $string; |
|
| 544 | + if ( !preg_match('/[\x80-\xff]/', $string) ) { |
|
| 545 | + return $string; |
|
| 546 | + } |
|
| 499 | 547 | $chars = array( |
| 500 | 548 | // Decompositions for Latin-1 Supplement |
| 501 | 549 | chr(195).chr(128) => 'A', chr(195).chr(129) => 'A', |
@@ -619,7 +667,9 @@ discard block |
||
| 619 | 667 | $ip = gethostbyname($host); |
| 620 | 668 | $s = socket_create(AF_INET, SOCK_STREAM, 0); |
| 621 | 669 | $r = @socket_connect($s, $ip, $port); |
| 622 | - if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n"; |
|
| 670 | + if (!socket_set_nonblock($s)) { |
|
| 671 | + echo "Unable to set nonblock on socket\n"; |
|
| 672 | + } |
|
| 623 | 673 | if ($r || socket_last_error() == 114 || socket_last_error() == 115) { |
| 624 | 674 | return $s; |
| 625 | 675 | } |
@@ -3,9 +3,9 @@ discard block |
||
| 3 | 3 | </span> |
| 4 | 4 | <div class="sub-menu sub-menu-container"> |
| 5 | 5 | <ul class="nav nav-pills"> |
| 6 | - <li><a href="<?php print $globalURL; ?>/manufacturer/<?php print $manufacturer; ?>" <?php if (strtolower($current_page) == "manufacturer-detailed"){ print 'class="active"'; } ?>><?php echo _("Detailed"); ?></a></li> |
|
| 6 | + <li><a href="<?php print $globalURL; ?>/manufacturer/<?php print $manufacturer; ?>" <?php if (strtolower($current_page) == "manufacturer-detailed") { print 'class="active"'; } ?>><?php echo _("Detailed"); ?></a></li> |
|
| 7 | 7 | <li class="dropdown"> |
| 8 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "manufacturer-statistics-aircraft" || strtolower($current_page) == "manufacturer-statistics-registration"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
| 8 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "manufacturer-statistics-aircraft" || strtolower($current_page) == "manufacturer-statistics-registration") { print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
| 9 | 9 | <?php echo _("Aircraft"); ?> <span class="caret"></span> |
| 10 | 10 | </a> |
| 11 | 11 | <ul class="dropdown-menu" role="menu"> |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | </ul> |
| 15 | 15 | </li> |
| 16 | 16 | <li class="dropdown"> |
| 17 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "manufacturer-statistics-airline" || strtolower($current_page) == "manufacturer-statistics-airline-country"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
| 17 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "manufacturer-statistics-airline" || strtolower($current_page) == "manufacturer-statistics-airline-country") { print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
| 18 | 18 | <?php echo _("Airline"); ?> <span class="caret"></span> |
| 19 | 19 | </a> |
| 20 | 20 | <ul class="dropdown-menu" role="menu"> |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | </ul> |
| 24 | 24 | </li> |
| 25 | 25 | <li class="dropdown"> |
| 26 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "manufacturer-statistics-departure-airport" || strtolower($current_page) == "manufacturer-statistics-departure-airport-country" || strtolower($current_page) == "manufacturer-statistics-arrival-airport" || strtolower($current_page) == "manufacturer-statistics-arrival-airport-country"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
| 26 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "manufacturer-statistics-departure-airport" || strtolower($current_page) == "manufacturer-statistics-departure-airport-country" || strtolower($current_page) == "manufacturer-statistics-arrival-airport" || strtolower($current_page) == "manufacturer-statistics-arrival-airport-country") { print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
| 27 | 27 | <?php echo _("Airport"); ?> <span class="caret"></span> |
| 28 | 28 | </a> |
| 29 | 29 | <ul class="dropdown-menu" role="menu"> |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | <li><a href="<?php print $globalURL; ?>/manufacturer/statistics/arrival-airport-country/<?php print $manufacturer; ?>"><?php echo _("Arrival Airport by Country"); ?></a></li> |
| 34 | 34 | </ul> |
| 35 | 35 | </li> |
| 36 | - <li><a href="<?php print $globalURL; ?>/manufacturer/statistics/route/<?php print $manufacturer; ?>" <?php if (strtolower($current_page) == "manufacturer-statistics-route"){ print 'class="active"'; } ?>><?php echo _("Route"); ?></a></li> |
|
| 37 | - <li><a href="<?php print $globalURL; ?>/manufacturer/statistics/time/<?php print $manufacturer; ?>" <?php if (strtolower($current_page) == "manufacturer-statistics-time"){ print 'class="active"'; } ?>><?php echo _("Time"); ?></a></li> |
|
| 36 | + <li><a href="<?php print $globalURL; ?>/manufacturer/statistics/route/<?php print $manufacturer; ?>" <?php if (strtolower($current_page) == "manufacturer-statistics-route") { print 'class="active"'; } ?>><?php echo _("Route"); ?></a></li> |
|
| 37 | + <li><a href="<?php print $globalURL; ?>/manufacturer/statistics/time/<?php print $manufacturer; ?>" <?php if (strtolower($current_page) == "manufacturer-statistics-time") { print 'class="active"'; } ?>><?php echo _("Time"); ?></a></li> |
|
| 38 | 38 | </ul> |
| 39 | 39 | </div> |
| 40 | 40 | \ No newline at end of file |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | date_default_timezone_set('UTC'); |
| 28 | 28 | //waypoint plotting |
| 29 | 29 | $output .= '{"type": "Feature",'; |
| 30 | - $output .= '"properties": {'; |
|
| 30 | + $output .= '"properties": {'; |
|
| 31 | 31 | $output .= '"name": "'.str_replace('"',"'",$spotter_item['name']).'",'; |
| 32 | 32 | $output .= '"city": "'.str_replace('"',"'",$spotter_item['city']).'",'; |
| 33 | 33 | $output .= '"country": "'.$spotter_item['country'].'",'; |
@@ -50,13 +50,13 @@ discard block |
||
| 50 | 50 | $output .= '"homepage": "'.$spotter_item['home_link'].'",'; |
| 51 | 51 | $output .= '"image_thumb": "'.$spotter_item['image_thumb'].'"'; |
| 52 | 52 | // $output .= '"photo": "'.$spotter_item['image_thumbnail'].'",'; |
| 53 | - $output .= '},'; |
|
| 54 | - $output .= '"geometry": {'; |
|
| 53 | + $output .= '},'; |
|
| 54 | + $output .= '"geometry": {'; |
|
| 55 | 55 | $output .= '"type": "Point",'; |
| 56 | 56 | $output .= '"coordinates": ['; |
| 57 | - $output .= $spotter_item['longitude'].', '.$spotter_item['latitude']; |
|
| 57 | + $output .= $spotter_item['longitude'].', '.$spotter_item['latitude']; |
|
| 58 | 58 | $output .= ']'; |
| 59 | - $output .= '}'; |
|
| 59 | + $output .= '}'; |
|
| 60 | 60 | $output .= '},'; |
| 61 | 61 | } |
| 62 | 62 | $output = substr($output, 0, -1); |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | if (isset($_GET['coord'])) |
| 13 | 13 | { |
| 14 | - $coords = explode(',',$_GET['coord']); |
|
| 14 | + $coords = explode(',', $_GET['coord']); |
|
| 15 | 15 | $spotter_array = $Spotter->getAllAirportInfobyCoord($coords); |
| 16 | 16 | } else { |
| 17 | 17 | $spotter_array = $Spotter->getAllAirportInfo(); |
@@ -22,17 +22,17 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | if (!empty($spotter_array)) |
| 24 | 24 | { |
| 25 | - foreach($spotter_array as $spotter_item) |
|
| 25 | + foreach ($spotter_array as $spotter_item) |
|
| 26 | 26 | { |
| 27 | 27 | date_default_timezone_set('UTC'); |
| 28 | 28 | //waypoint plotting |
| 29 | 29 | $output .= '{"type": "Feature",'; |
| 30 | 30 | $output .= '"properties": {'; |
| 31 | - $output .= '"name": "'.str_replace('"',"'",$spotter_item['name']).'",'; |
|
| 32 | - $output .= '"city": "'.str_replace('"',"'",$spotter_item['city']).'",'; |
|
| 31 | + $output .= '"name": "'.str_replace('"', "'", $spotter_item['name']).'",'; |
|
| 32 | + $output .= '"city": "'.str_replace('"', "'", $spotter_item['city']).'",'; |
|
| 33 | 33 | $output .= '"country": "'.$spotter_item['country'].'",'; |
| 34 | 34 | $output .= '"altitude": "'.$spotter_item['altitude'].'",'; |
| 35 | - $output .= '"popupContent": "'.str_replace('"',"'",$spotter_item['name']).' : '.str_replace('"',"'",$spotter_item['city']).', '.$spotter_item['country'].'",'; |
|
| 35 | + $output .= '"popupContent": "'.str_replace('"', "'", $spotter_item['name']).' : '.str_replace('"', "'", $spotter_item['city']).', '.$spotter_item['country'].'",'; |
|
| 36 | 36 | if ($spotter_item['type'] == 'large_airport') { |
| 37 | 37 | $output .= '"icon": "'.$globalURL.'/images/airport.png",'; |
| 38 | 38 | } elseif ($spotter_item['type'] == 'heliport') { |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | $output .= '}'; |
| 60 | 60 | $output .= '},'; |
| 61 | 61 | } |
| 62 | - $output = substr($output, 0, -1); |
|
| 62 | + $output = substr($output, 0, -1); |
|
| 63 | 63 | } |
| 64 | 64 | $output .= ']}'; |
| 65 | 65 | print $output; |
@@ -254,6 +254,7 @@ discard block |
||
| 254 | 254 | * |
| 255 | 255 | * @param String $aircraft_registration the registration of the aircraft |
| 256 | 256 | * @param String $aircraft_name type of the aircraft |
| 257 | + * @param string $type |
|
| 257 | 258 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 258 | 259 | * |
| 259 | 260 | */ |
@@ -287,6 +288,7 @@ discard block |
||
| 287 | 288 | * |
| 288 | 289 | * @param String $registration the registration of the aircraft |
| 289 | 290 | * @param String $name type of the aircraft |
| 291 | + * @param string $type |
|
| 290 | 292 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 291 | 293 | * |
| 292 | 294 | */ |
@@ -325,6 +327,7 @@ discard block |
||
| 325 | 327 | * |
| 326 | 328 | * @param String $aircraft_registration the registration of the aircraft |
| 327 | 329 | * @param String $aircraft_name type of the aircraft |
| 330 | + * @param string $type |
|
| 328 | 331 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 329 | 332 | * |
| 330 | 333 | */ |
@@ -367,6 +370,7 @@ discard block |
||
| 367 | 370 | * |
| 368 | 371 | * @param String $aircraft_registration the registration of the aircraft |
| 369 | 372 | * @param String $aircraft_name type of the aircraft |
| 373 | + * @param string $type |
|
| 370 | 374 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 371 | 375 | * |
| 372 | 376 | */ |
@@ -401,6 +405,7 @@ discard block |
||
| 401 | 405 | * |
| 402 | 406 | * @param String $registration the registration of the aircraft |
| 403 | 407 | * @param String $name type of the aircraft |
| 408 | + * @param string $type |
|
| 404 | 409 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 405 | 410 | * |
| 406 | 411 | */ |
@@ -429,6 +434,10 @@ discard block |
||
| 429 | 434 | return false; |
| 430 | 435 | } |
| 431 | 436 | |
| 437 | + /** |
|
| 438 | + * @param string $type |
|
| 439 | + * @param string $aircraft_icao |
|
| 440 | + */ |
|
| 432 | 441 | public function fromIvaoMtl($type,$aircraft_icao,$airline_icao) { |
| 433 | 442 | $Common = new Common(); |
| 434 | 443 | //echo "\n".'SEARCH IMAGE : http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg'; |
@@ -450,6 +459,7 @@ discard block |
||
| 450 | 459 | * |
| 451 | 460 | * @param String $aircraft_registration the registration of the aircraft |
| 452 | 461 | * @param String $aircraft_name type of the aircraft |
| 462 | + * @param string $type |
|
| 453 | 463 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 454 | 464 | * |
| 455 | 465 | */ |
@@ -482,6 +492,7 @@ discard block |
||
| 482 | 492 | * |
| 483 | 493 | * @param String $aircraft_registration the registration of the aircraft |
| 484 | 494 | * @param String $aircraft_name type of the aircraft |
| 495 | + * @param string $type |
|
| 485 | 496 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 486 | 497 | * |
| 487 | 498 | */ |
@@ -507,6 +518,7 @@ discard block |
||
| 507 | 518 | * |
| 508 | 519 | * @param String $registration the registration of the aircraft/mmsi |
| 509 | 520 | * @param String $name name |
| 521 | + * @param string $type |
|
| 510 | 522 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 511 | 523 | * |
| 512 | 524 | */ |
@@ -568,6 +580,7 @@ discard block |
||
| 568 | 580 | * |
| 569 | 581 | * @param String $registration the registration of the aircraft |
| 570 | 582 | * @param String $name type of the aircraft |
| 583 | + * @param string $type |
|
| 571 | 584 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 572 | 585 | * |
| 573 | 586 | */ |
@@ -12,11 +12,11 @@ discard block |
||
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | /** |
| 15 | - * Gets the images based on the aircraft registration |
|
| 16 | - * |
|
| 17 | - * @return Array the images list |
|
| 18 | - * |
|
| 19 | - */ |
|
| 15 | + * Gets the images based on the aircraft registration |
|
| 16 | + * |
|
| 17 | + * @return Array the images list |
|
| 18 | + * |
|
| 19 | + */ |
|
| 20 | 20 | public function getSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
| 21 | 21 | { |
| 22 | 22 | $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
@@ -37,11 +37,11 @@ discard block |
||
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | /** |
| 40 | - * Gets the images based on the ship name |
|
| 41 | - * |
|
| 42 | - * @return Array the images list |
|
| 43 | - * |
|
| 44 | - */ |
|
| 40 | + * Gets the images based on the ship name |
|
| 41 | + * |
|
| 42 | + * @return Array the images list |
|
| 43 | + * |
|
| 44 | + */ |
|
| 45 | 45 | public function getMarineImage($mmsi,$imo = '',$name = '') |
| 46 | 46 | { |
| 47 | 47 | $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
@@ -68,11 +68,11 @@ discard block |
||
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
| 71 | - * Gets the image copyright based on the Exif data |
|
| 72 | - * |
|
| 73 | - * @return String image copyright |
|
| 74 | - * |
|
| 75 | - */ |
|
| 71 | + * Gets the image copyright based on the Exif data |
|
| 72 | + * |
|
| 73 | + * @return String image copyright |
|
| 74 | + * |
|
| 75 | + */ |
|
| 76 | 76 | public function getExifCopyright($url) { |
| 77 | 77 | $exif = exif_read_data($url); |
| 78 | 78 | $copyright = ''; |
@@ -87,11 +87,11 @@ discard block |
||
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | /** |
| 90 | - * Adds the images based on the aircraft registration |
|
| 91 | - * |
|
| 92 | - * @return String either success or error |
|
| 93 | - * |
|
| 94 | - */ |
|
| 90 | + * Adds the images based on the aircraft registration |
|
| 91 | + * |
|
| 92 | + * @return String either success or error |
|
| 93 | + * |
|
| 94 | + */ |
|
| 95 | 95 | public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
| 96 | 96 | { |
| 97 | 97 | global $globalDebug,$globalAircraftImageFetch; |
@@ -119,11 +119,11 @@ discard block |
||
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | /** |
| 122 | - * Adds the images based on the marine name |
|
| 123 | - * |
|
| 124 | - * @return String either success or error |
|
| 125 | - * |
|
| 126 | - */ |
|
| 122 | + * Adds the images based on the marine name |
|
| 123 | + * |
|
| 124 | + * @return String either success or error |
|
| 125 | + * |
|
| 126 | + */ |
|
| 127 | 127 | public function addMarineImage($mmsi,$imo = '',$name = '') |
| 128 | 128 | { |
| 129 | 129 | global $globalDebug,$globalMarineImageFetch; |
@@ -160,12 +160,12 @@ discard block |
||
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | /** |
| 163 | - * Gets the aircraft image |
|
| 164 | - * |
|
| 165 | - * @param String $aircraft_registration the registration of the aircraft |
|
| 166 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 167 | - * |
|
| 168 | - */ |
|
| 163 | + * Gets the aircraft image |
|
| 164 | + * |
|
| 165 | + * @param String $aircraft_registration the registration of the aircraft |
|
| 166 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 167 | + * |
|
| 168 | + */ |
|
| 169 | 169 | public function findAircraftImage($aircraft_registration, $aircraft_icao = '', $airline_icao = '') |
| 170 | 170 | { |
| 171 | 171 | global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO, $globalVA; |
@@ -209,14 +209,14 @@ discard block |
||
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | /** |
| 212 | - * Gets the vessel image |
|
| 213 | - * |
|
| 214 | - * @param String $mmsi the vessel mmsi |
|
| 215 | - * @param String $imo the vessel imo |
|
| 216 | - * @param String $name the vessel name |
|
| 217 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 218 | - * |
|
| 219 | - */ |
|
| 212 | + * Gets the vessel image |
|
| 213 | + * |
|
| 214 | + * @param String $mmsi the vessel mmsi |
|
| 215 | + * @param String $imo the vessel imo |
|
| 216 | + * @param String $name the vessel name |
|
| 217 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 218 | + * |
|
| 219 | + */ |
|
| 220 | 220 | public function findMarineImage($mmsi,$imo = '',$name = '') |
| 221 | 221 | { |
| 222 | 222 | global $globalMarineImageSources; |
@@ -250,13 +250,13 @@ discard block |
||
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | /** |
| 253 | - * Gets the aircraft image from Planespotters |
|
| 254 | - * |
|
| 255 | - * @param String $aircraft_registration the registration of the aircraft |
|
| 256 | - * @param String $aircraft_name type of the aircraft |
|
| 257 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 258 | - * |
|
| 259 | - */ |
|
| 253 | + * Gets the aircraft image from Planespotters |
|
| 254 | + * |
|
| 255 | + * @param String $aircraft_registration the registration of the aircraft |
|
| 256 | + * @param String $aircraft_name type of the aircraft |
|
| 257 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 258 | + * |
|
| 259 | + */ |
|
| 260 | 260 | public function fromPlanespotters($type,$aircraft_registration, $aircraft_name='') { |
| 261 | 261 | $Common = new Common(); |
| 262 | 262 | // If aircraft registration is only number, also check with aircraft model |
@@ -283,13 +283,13 @@ discard block |
||
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | /** |
| 286 | - * Gets the aircraft image from Deviantart |
|
| 287 | - * |
|
| 288 | - * @param String $registration the registration of the aircraft |
|
| 289 | - * @param String $name type of the aircraft |
|
| 290 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 291 | - * |
|
| 292 | - */ |
|
| 286 | + * Gets the aircraft image from Deviantart |
|
| 287 | + * |
|
| 288 | + * @param String $registration the registration of the aircraft |
|
| 289 | + * @param String $name type of the aircraft |
|
| 290 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 291 | + * |
|
| 292 | + */ |
|
| 293 | 293 | public function fromDeviantart($type,$registration, $name='') { |
| 294 | 294 | $Common = new Common(); |
| 295 | 295 | if ($type == 'aircraft') { |
@@ -321,13 +321,13 @@ discard block |
||
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | /** |
| 324 | - * Gets the aircraft image from JetPhotos |
|
| 325 | - * |
|
| 326 | - * @param String $aircraft_registration the registration of the aircraft |
|
| 327 | - * @param String $aircraft_name type of the aircraft |
|
| 328 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 329 | - * |
|
| 330 | - */ |
|
| 324 | + * Gets the aircraft image from JetPhotos |
|
| 325 | + * |
|
| 326 | + * @param String $aircraft_registration the registration of the aircraft |
|
| 327 | + * @param String $aircraft_name type of the aircraft |
|
| 328 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 329 | + * |
|
| 330 | + */ |
|
| 331 | 331 | public function fromJetPhotos($type,$aircraft_registration, $aircraft_name='') { |
| 332 | 332 | $Common = new Common(); |
| 333 | 333 | $url= 'http://jetphotos.net/showphotos.php?displaymode=2®search='.$aircraft_registration; |
@@ -363,13 +363,13 @@ discard block |
||
| 363 | 363 | } |
| 364 | 364 | |
| 365 | 365 | /** |
| 366 | - * Gets the aircraft image from PlanePictures |
|
| 367 | - * |
|
| 368 | - * @param String $aircraft_registration the registration of the aircraft |
|
| 369 | - * @param String $aircraft_name type of the aircraft |
|
| 370 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 371 | - * |
|
| 372 | - */ |
|
| 366 | + * Gets the aircraft image from PlanePictures |
|
| 367 | + * |
|
| 368 | + * @param String $aircraft_registration the registration of the aircraft |
|
| 369 | + * @param String $aircraft_name type of the aircraft |
|
| 370 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 371 | + * |
|
| 372 | + */ |
|
| 373 | 373 | public function fromPlanePictures($type,$aircraft_registration, $aircraft_name='') { |
| 374 | 374 | $Common = new Common(); |
| 375 | 375 | $url= 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2'; |
@@ -397,13 +397,13 @@ discard block |
||
| 397 | 397 | } |
| 398 | 398 | |
| 399 | 399 | /** |
| 400 | - * Gets the aircraft image from Flickr |
|
| 401 | - * |
|
| 402 | - * @param String $registration the registration of the aircraft |
|
| 403 | - * @param String $name type of the aircraft |
|
| 404 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 405 | - * |
|
| 406 | - */ |
|
| 400 | + * Gets the aircraft image from Flickr |
|
| 401 | + * |
|
| 402 | + * @param String $registration the registration of the aircraft |
|
| 403 | + * @param String $name type of the aircraft |
|
| 404 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 405 | + * |
|
| 406 | + */ |
|
| 407 | 407 | public function fromFlickr($type,$registration,$name='') { |
| 408 | 408 | $Common = new Common(); |
| 409 | 409 | if ($type == 'aircraft') { |
@@ -446,13 +446,13 @@ discard block |
||
| 446 | 446 | } |
| 447 | 447 | |
| 448 | 448 | /** |
| 449 | - * Gets the aircraft image from Bing |
|
| 450 | - * |
|
| 451 | - * @param String $aircraft_registration the registration of the aircraft |
|
| 452 | - * @param String $aircraft_name type of the aircraft |
|
| 453 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 454 | - * |
|
| 455 | - */ |
|
| 449 | + * Gets the aircraft image from Bing |
|
| 450 | + * |
|
| 451 | + * @param String $aircraft_registration the registration of the aircraft |
|
| 452 | + * @param String $aircraft_name type of the aircraft |
|
| 453 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 454 | + * |
|
| 455 | + */ |
|
| 456 | 456 | public function fromBing($type,$aircraft_registration,$aircraft_name='') { |
| 457 | 457 | global $globalImageBingKey; |
| 458 | 458 | $Common = new Common(); |
@@ -478,13 +478,13 @@ discard block |
||
| 478 | 478 | } |
| 479 | 479 | |
| 480 | 480 | /** |
| 481 | - * Gets the aircraft image from airport-data |
|
| 482 | - * |
|
| 483 | - * @param String $aircraft_registration the registration of the aircraft |
|
| 484 | - * @param String $aircraft_name type of the aircraft |
|
| 485 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 486 | - * |
|
| 487 | - */ |
|
| 481 | + * Gets the aircraft image from airport-data |
|
| 482 | + * |
|
| 483 | + * @param String $aircraft_registration the registration of the aircraft |
|
| 484 | + * @param String $aircraft_name type of the aircraft |
|
| 485 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 486 | + * |
|
| 487 | + */ |
|
| 488 | 488 | public function fromAirportData($type,$aircraft_registration,$aircraft_name='') { |
| 489 | 489 | $Common = new Common(); |
| 490 | 490 | $url = 'http://www.airport-data.com/api/ac_thumb.json?&n=1&r='.$aircraft_registration; |
@@ -503,13 +503,13 @@ discard block |
||
| 503 | 503 | } |
| 504 | 504 | |
| 505 | 505 | /** |
| 506 | - * Gets image from WikiMedia |
|
| 507 | - * |
|
| 508 | - * @param String $registration the registration of the aircraft/mmsi |
|
| 509 | - * @param String $name name |
|
| 510 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 511 | - * |
|
| 512 | - */ |
|
| 506 | + * Gets image from WikiMedia |
|
| 507 | + * |
|
| 508 | + * @param String $registration the registration of the aircraft/mmsi |
|
| 509 | + * @param String $name name |
|
| 510 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 511 | + * |
|
| 512 | + */ |
|
| 513 | 513 | public function fromWikimedia($type,$registration,$name='') { |
| 514 | 514 | $Common = new Common(); |
| 515 | 515 | if ($type == 'aircraft') { |
@@ -564,13 +564,13 @@ discard block |
||
| 564 | 564 | } |
| 565 | 565 | |
| 566 | 566 | /** |
| 567 | - * Gets the aircraft image from custom url |
|
| 568 | - * |
|
| 569 | - * @param String $registration the registration of the aircraft |
|
| 570 | - * @param String $name type of the aircraft |
|
| 571 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 572 | - * |
|
| 573 | - */ |
|
| 567 | + * Gets the aircraft image from custom url |
|
| 568 | + * |
|
| 569 | + * @param String $registration the registration of the aircraft |
|
| 570 | + * @param String $name type of the aircraft |
|
| 571 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 572 | + * |
|
| 573 | + */ |
|
| 574 | 574 | public function fromCustomSource($type,$registration,$name='') { |
| 575 | 575 | global $globalAircraftImageCustomSources, $globalMarineImageCustomSources, $globalDebug; |
| 576 | 576 | //$globalAircraftImageCustomSource[] = array('thumbnail' => '','original' => '', 'copyright' => '', 'source_website' => '', 'source' => '','exif' => true); |
@@ -17,22 +17,22 @@ discard block |
||
| 17 | 17 | * @return Array the images list |
| 18 | 18 | * |
| 19 | 19 | */ |
| 20 | - public function getSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
|
| 20 | + public function getSpotterImage($registration, $aircraft_icao = '', $airline_icao = '') |
|
| 21 | 21 | { |
| 22 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 23 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 24 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 22 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
| 23 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
| 24 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
| 25 | 25 | $reg = $registration; |
| 26 | 26 | if ($reg == '' && $aircraft_icao != '') $reg = $aircraft_icao.$airline_icao; |
| 27 | 27 | $reg = trim($reg); |
| 28 | - $query = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration |
|
| 28 | + $query = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration |
|
| 29 | 29 | FROM spotter_image |
| 30 | 30 | WHERE spotter_image.registration = :registration LIMIT 1"; |
| 31 | 31 | $sth = $this->db->prepare($query); |
| 32 | 32 | $sth->execute(array(':registration' => $reg)); |
| 33 | 33 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 34 | 34 | if (!empty($result)) return $result; |
| 35 | - elseif ($registration != '') return $this->getSpotterImage('',$aircraft_icao,$airline_icao); |
|
| 35 | + elseif ($registration != '') return $this->getSpotterImage('', $aircraft_icao, $airline_icao); |
|
| 36 | 36 | else return array(); |
| 37 | 37 | } |
| 38 | 38 | |
@@ -42,23 +42,23 @@ discard block |
||
| 42 | 42 | * @return Array the images list |
| 43 | 43 | * |
| 44 | 44 | */ |
| 45 | - public function getMarineImage($mmsi,$imo = '',$name = '') |
|
| 45 | + public function getMarineImage($mmsi, $imo = '', $name = '') |
|
| 46 | 46 | { |
| 47 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
| 48 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
| 49 | - $name = filter_var($name,FILTER_SANITIZE_STRING); |
|
| 47 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
| 48 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
| 49 | + $name = filter_var($name, FILTER_SANITIZE_STRING); |
|
| 50 | 50 | $name = trim($name); |
| 51 | - $query = "SELECT marine_image.image, marine_image.image_thumbnail, marine_image.image_source, marine_image.image_source_website,marine_image.image_copyright, marine_image.mmsi, marine_image.imo, marine_image.name |
|
| 51 | + $query = "SELECT marine_image.image, marine_image.image_thumbnail, marine_image.image_source, marine_image.image_source_website,marine_image.image_copyright, marine_image.mmsi, marine_image.imo, marine_image.name |
|
| 52 | 52 | FROM marine_image |
| 53 | 53 | WHERE marine_image.mmsi = :mmsi"; |
| 54 | 54 | $query_data = array(':mmsi' => $mmsi); |
| 55 | 55 | if ($imo != '') { |
| 56 | 56 | $query .= " AND marine_image.imo = :imo"; |
| 57 | - $query_data = array_merge($query_data,array(':imo' => $imo)); |
|
| 57 | + $query_data = array_merge($query_data, array(':imo' => $imo)); |
|
| 58 | 58 | } |
| 59 | 59 | if ($name != '') { |
| 60 | 60 | $query .= " AND marine_image.name = :name"; |
| 61 | - $query_data = array_merge($query_data,array(':name' => $name)); |
|
| 61 | + $query_data = array_merge($query_data, array(':name' => $name)); |
|
| 62 | 62 | } |
| 63 | 63 | $query .= " LIMIT 1"; |
| 64 | 64 | $sth = $this->db->prepare($query); |
@@ -79,9 +79,9 @@ discard block |
||
| 79 | 79 | if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright']; |
| 80 | 80 | elseif (isset($exif['copyright'])) $copyright = $exif['copyright']; |
| 81 | 81 | if ($copyright != '') { |
| 82 | - $copyright = str_replace('Copyright ','',$copyright); |
|
| 83 | - $copyright = str_replace('© ','',$copyright); |
|
| 84 | - $copyright = str_replace('(c) ','',$copyright); |
|
| 82 | + $copyright = str_replace('Copyright ', '', $copyright); |
|
| 83 | + $copyright = str_replace('© ', '', $copyright); |
|
| 84 | + $copyright = str_replace('(c) ', '', $copyright); |
|
| 85 | 85 | } |
| 86 | 86 | return $copyright; |
| 87 | 87 | } |
@@ -92,25 +92,25 @@ discard block |
||
| 92 | 92 | * @return String either success or error |
| 93 | 93 | * |
| 94 | 94 | */ |
| 95 | - public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
|
| 95 | + public function addSpotterImage($registration, $aircraft_icao = '', $airline_icao = '') |
|
| 96 | 96 | { |
| 97 | - global $globalDebug,$globalAircraftImageFetch; |
|
| 97 | + global $globalDebug, $globalAircraftImageFetch; |
|
| 98 | 98 | if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) return ''; |
| 99 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 99 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
| 100 | 100 | $registration = trim($registration); |
| 101 | 101 | //getting the aircraft image |
| 102 | 102 | if ($globalDebug && $registration != '') echo 'Try to find an aircraft image for '.$registration.'...'; |
| 103 | 103 | elseif ($globalDebug && $aircraft_icao != '') echo 'Try to find an aircraft image for '.$aircraft_icao.'...'; |
| 104 | 104 | elseif ($globalDebug && $airline_icao != '') echo 'Try to find an aircraft image for '.$airline_icao.'...'; |
| 105 | - $image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao); |
|
| 105 | + $image_url = $this->findAircraftImage($registration, $aircraft_icao, $airline_icao); |
|
| 106 | 106 | if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao; |
| 107 | 107 | if ($image_url['original'] != '') { |
| 108 | 108 | if ($globalDebug) echo 'Found !'."\n"; |
| 109 | - $query = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
|
| 109 | + $query = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
|
| 110 | 110 | try { |
| 111 | 111 | $sth = $this->db->prepare($query); |
| 112 | - $sth->execute(array(':registration' => $registration,':image' => $image_url['original'],':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'],':source' => $image_url['source'],':source_website' => $image_url['source_website'])); |
|
| 113 | - } catch(PDOException $e) { |
|
| 112 | + $sth->execute(array(':registration' => $registration, ':image' => $image_url['original'], ':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'], ':source' => $image_url['source'], ':source_website' => $image_url['source_website'])); |
|
| 113 | + } catch (PDOException $e) { |
|
| 114 | 114 | echo $e->getMessage()."\n"; |
| 115 | 115 | return "error"; |
| 116 | 116 | } |
@@ -124,13 +124,13 @@ discard block |
||
| 124 | 124 | * @return String either success or error |
| 125 | 125 | * |
| 126 | 126 | */ |
| 127 | - public function addMarineImage($mmsi,$imo = '',$name = '') |
|
| 127 | + public function addMarineImage($mmsi, $imo = '', $name = '') |
|
| 128 | 128 | { |
| 129 | - global $globalDebug,$globalMarineImageFetch; |
|
| 129 | + global $globalDebug, $globalMarineImageFetch; |
|
| 130 | 130 | if (isset($globalMarineImageFetch) && !$globalMarineImageFetch) return ''; |
| 131 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
| 132 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
| 133 | - $name = filter_var($name,FILTER_SANITIZE_STRING); |
|
| 131 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
| 132 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
| 133 | + $name = filter_var($name, FILTER_SANITIZE_STRING); |
|
| 134 | 134 | $name = trim($name); |
| 135 | 135 | $Marine = new Marine($this->db); |
| 136 | 136 | if ($imo == '' || $name == '') { |
@@ -144,14 +144,14 @@ discard block |
||
| 144 | 144 | |
| 145 | 145 | //getting the aircraft image |
| 146 | 146 | if ($globalDebug && $name != '') echo 'Try to find an vessel image for '.$name.'...'; |
| 147 | - $image_url = $this->findMarineImage($mmsi,$imo,$name); |
|
| 147 | + $image_url = $this->findMarineImage($mmsi, $imo, $name); |
|
| 148 | 148 | if ($image_url['original'] != '') { |
| 149 | 149 | if ($globalDebug) echo 'Found !'."\n"; |
| 150 | - $query = "INSERT INTO marine_image (mmsi,imo,name, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:mmsi,:imo,:name,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
|
| 150 | + $query = "INSERT INTO marine_image (mmsi,imo,name, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:mmsi,:imo,:name,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
|
| 151 | 151 | try { |
| 152 | 152 | $sth = $this->db->prepare($query); |
| 153 | - $sth->execute(array(':mmsi' => $mmsi,':imo' => $imo,':name' => $name,':image' => $image_url['original'],':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'],':source' => $image_url['source'],':source_website' => $image_url['source_website'])); |
|
| 154 | - } catch(PDOException $e) { |
|
| 153 | + $sth->execute(array(':mmsi' => $mmsi, ':imo' => $imo, ':name' => $name, ':image' => $image_url['original'], ':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'], ':source' => $image_url['source'], ':source_website' => $image_url['source_website'])); |
|
| 154 | + } catch (PDOException $e) { |
|
| 155 | 155 | echo $e->getMessage()."\n"; |
| 156 | 156 | return "error"; |
| 157 | 157 | } |
@@ -171,9 +171,9 @@ discard block |
||
| 171 | 171 | global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO, $globalVA; |
| 172 | 172 | $Spotter = new Spotter($this->db); |
| 173 | 173 | if (!isset($globalIVAO)) $globalIVAO = FALSE; |
| 174 | - $aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING); |
|
| 174 | + $aircraft_registration = filter_var($aircraft_registration, FILTER_SANITIZE_STRING); |
|
| 175 | 175 | if ($aircraft_registration != '' && (!isset($globalVA) || $globalVA !== TRUE)) { |
| 176 | - if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 176 | + if (strpos($aircraft_registration, '/') !== false) return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
| 177 | 177 | $aircraft_registration = urlencode(trim($aircraft_registration)); |
| 178 | 178 | $aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration); |
| 179 | 179 | if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name']; |
@@ -187,25 +187,25 @@ discard block |
||
| 187 | 187 | if (isset($aircraft_info[0]['type'])) $aircraft_name = $aircraft_info[0]['type']; |
| 188 | 188 | else $aircraft_name = ''; |
| 189 | 189 | $aircraft_registration = $aircraft_icao; |
| 190 | - } else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
| 190 | + } else return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
| 191 | 191 | unset($Spotter); |
| 192 | - if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
| 192 | + if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl', 'wikimedia', 'airportdata', 'deviantart', 'flickr', 'bing', 'jetphotos', 'planepictures', 'planespotters'); |
|
| 193 | 193 | foreach ($globalAircraftImageSources as $source) { |
| 194 | 194 | $source = strtolower($source); |
| 195 | - if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao); |
|
| 196 | - if ($source == 'planespotters' && !$globalIVAO) $images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name); |
|
| 197 | - if ($source == 'flickr') $images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name); |
|
| 198 | - if ($source == 'bing') $images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name); |
|
| 199 | - if ($source == 'deviantart') $images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name); |
|
| 200 | - if ($source == 'wikimedia') $images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name); |
|
| 201 | - if ($source == 'jetphotos' && !$globalIVAO) $images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name); |
|
| 202 | - if ($source == 'planepictures' && !$globalIVAO) $images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name); |
|
| 203 | - if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_name); |
|
| 204 | - if ($source == 'customsources') $images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name); |
|
| 195 | + if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl('aircraft', $aircraft_icao, $airline_icao); |
|
| 196 | + if ($source == 'planespotters' && !$globalIVAO) $images_array = $this->fromPlanespotters('aircraft', $aircraft_registration, $aircraft_name); |
|
| 197 | + if ($source == 'flickr') $images_array = $this->fromFlickr('aircraft', $aircraft_registration, $aircraft_name); |
|
| 198 | + if ($source == 'bing') $images_array = $this->fromBing('aircraft', $aircraft_registration, $aircraft_name); |
|
| 199 | + if ($source == 'deviantart') $images_array = $this->fromDeviantart('aircraft', $aircraft_registration, $aircraft_name); |
|
| 200 | + if ($source == 'wikimedia') $images_array = $this->fromWikimedia('aircraft', $aircraft_registration, $aircraft_name); |
|
| 201 | + if ($source == 'jetphotos' && !$globalIVAO) $images_array = $this->fromJetPhotos('aircraft', $aircraft_registration, $aircraft_name); |
|
| 202 | + if ($source == 'planepictures' && !$globalIVAO) $images_array = $this->fromPlanePictures('aircraft', $aircraft_registration, $aircraft_name); |
|
| 203 | + if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData('aircraft', $aircraft_registration, $aircraft_name); |
|
| 204 | + if ($source == 'customsources') $images_array = $this->fromCustomSource('aircraft', $aircraft_registration, $aircraft_name); |
|
| 205 | 205 | if (isset($images_array) && $images_array['original'] != '') return $images_array; |
| 206 | 206 | } |
| 207 | 207 | if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) return $this->findAircraftImage($aircraft_icao); |
| 208 | - return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 208 | + return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | /** |
@@ -217,14 +217,14 @@ discard block |
||
| 217 | 217 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 218 | 218 | * |
| 219 | 219 | */ |
| 220 | - public function findMarineImage($mmsi,$imo = '',$name = '') |
|
| 220 | + public function findMarineImage($mmsi, $imo = '', $name = '') |
|
| 221 | 221 | { |
| 222 | 222 | global $globalMarineImageSources; |
| 223 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
| 223 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
| 224 | 224 | //$imo = filter_var($imo,FILTER_SANITIZE_STRING); |
| 225 | - $name = filter_var($name,FILTER_SANITIZE_STRING); |
|
| 225 | + $name = filter_var($name, FILTER_SANITIZE_STRING); |
|
| 226 | 226 | $name = trim($name); |
| 227 | - if (strlen($name) < 4) return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
| 227 | + if (strlen($name) < 4) return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
| 228 | 228 | /* |
| 229 | 229 | $Marine = new Marine($this->db); |
| 230 | 230 | if ($imo == '' || $name == '') { |
@@ -236,17 +236,17 @@ discard block |
||
| 236 | 236 | } |
| 237 | 237 | unset($Marine); |
| 238 | 238 | */ |
| 239 | - if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia','deviantart','flickr','bing'); |
|
| 239 | + if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia', 'deviantart', 'flickr', 'bing'); |
|
| 240 | 240 | foreach ($globalMarineImageSources as $source) { |
| 241 | 241 | $source = strtolower($source); |
| 242 | - if ($source == 'flickr') $images_array = $this->fromFlickr('marine',$mmsi,$name); |
|
| 243 | - if ($source == 'bing') $images_array = $this->fromBing('marine',$mmsi,$name); |
|
| 244 | - if ($source == 'deviantart') $images_array = $this->fromDeviantart('marine',$mmsi,$name); |
|
| 245 | - if ($source == 'wikimedia') $images_array = $this->fromWikimedia('marine',$mmsi,$name); |
|
| 246 | - if ($source == 'customsources') $images_array = $this->fromCustomSource('marine',$mmsi,$name); |
|
| 242 | + if ($source == 'flickr') $images_array = $this->fromFlickr('marine', $mmsi, $name); |
|
| 243 | + if ($source == 'bing') $images_array = $this->fromBing('marine', $mmsi, $name); |
|
| 244 | + if ($source == 'deviantart') $images_array = $this->fromDeviantart('marine', $mmsi, $name); |
|
| 245 | + if ($source == 'wikimedia') $images_array = $this->fromWikimedia('marine', $mmsi, $name); |
|
| 246 | + if ($source == 'customsources') $images_array = $this->fromCustomSource('marine', $mmsi, $name); |
|
| 247 | 247 | if (isset($images_array) && $images_array['original'] != '') return $images_array; |
| 248 | 248 | } |
| 249 | - return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 249 | + return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | /** |
@@ -257,24 +257,24 @@ discard block |
||
| 257 | 257 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 258 | 258 | * |
| 259 | 259 | */ |
| 260 | - public function fromPlanespotters($type,$aircraft_registration, $aircraft_name='') { |
|
| 260 | + public function fromPlanespotters($type, $aircraft_registration, $aircraft_name = '') { |
|
| 261 | 261 | $Common = new Common(); |
| 262 | 262 | // If aircraft registration is only number, also check with aircraft model |
| 263 | - if (preg_match('/^[[:digit]]+$/',$aircraft_registration) && $aircraft_name != '') { |
|
| 264 | - $url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss'; |
|
| 263 | + if (preg_match('/^[[:digit]]+$/', $aircraft_registration) && $aircraft_name != '') { |
|
| 264 | + $url = 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss'; |
|
| 265 | 265 | } else { |
| 266 | 266 | //$url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$airline_aircraft_type.'&output=rss'; |
| 267 | - $url= 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss'; |
|
| 267 | + $url = 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss'; |
|
| 268 | 268 | } |
| 269 | 269 | $data = $Common->getData($url); |
| 270 | 270 | if ($xml = simplexml_load_string($data)) { |
| 271 | 271 | if (isset($xml->channel->item)) { |
| 272 | 272 | $image_url = array(); |
| 273 | - $thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
| 273 | + $thumbnail_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
| 274 | 274 | $image_url['thumbnail'] = $thumbnail_url; |
| 275 | - $image_url['original'] = str_replace('thumbnail','original',$thumbnail_url); |
|
| 276 | - $image_url['copyright'] = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright); |
|
| 277 | - $image_url['source_website'] = trim((string)$xml->channel->item->link); |
|
| 275 | + $image_url['original'] = str_replace('thumbnail', 'original', $thumbnail_url); |
|
| 276 | + $image_url['copyright'] = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright); |
|
| 277 | + $image_url['source_website'] = trim((string) $xml->channel->item->link); |
|
| 278 | 278 | $image_url['source'] = 'planespotters'; |
| 279 | 279 | return $image_url; |
| 280 | 280 | } |
@@ -290,29 +290,29 @@ discard block |
||
| 290 | 290 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 291 | 291 | * |
| 292 | 292 | */ |
| 293 | - public function fromDeviantart($type,$registration, $name='') { |
|
| 293 | + public function fromDeviantart($type, $registration, $name = '') { |
|
| 294 | 294 | $Common = new Common(); |
| 295 | 295 | if ($type == 'aircraft') { |
| 296 | 296 | // If aircraft registration is only number, also check with aircraft model |
| 297 | - if (preg_match('/^[[:digit]]+$/',$registration) && $name != '') { |
|
| 298 | - $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$registration.'%20'.urlencode($name); |
|
| 297 | + if (preg_match('/^[[:digit]]+$/', $registration) && $name != '') { |
|
| 298 | + $url = 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$registration.'%20'.urlencode($name); |
|
| 299 | 299 | } else { |
| 300 | - $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$registration; |
|
| 300 | + $url = 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$registration; |
|
| 301 | 301 | } |
| 302 | 302 | } elseif ($type == 'marine') { |
| 303 | - $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q=ship%20"'.urlencode($name).'"'; |
|
| 303 | + $url = 'http://backend.deviantart.com/rss.xml?type=deviation&q=ship%20"'.urlencode($name).'"'; |
|
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | $data = $Common->getData($url); |
| 307 | 307 | if ($xml = simplexml_load_string($data)) { |
| 308 | 308 | if (isset($xml->channel->item->link)) { |
| 309 | 309 | $image_url = array(); |
| 310 | - $thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
| 310 | + $thumbnail_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
| 311 | 311 | $image_url['thumbnail'] = $thumbnail_url; |
| 312 | - $original_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url); |
|
| 312 | + $original_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url); |
|
| 313 | 313 | $image_url['original'] = $original_url; |
| 314 | - $image_url['copyright'] = str_replace('Copyright ','',trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright)); |
|
| 315 | - $image_url['source_website'] = trim((string)$xml->channel->item->link); |
|
| 314 | + $image_url['copyright'] = str_replace('Copyright ', '', trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright)); |
|
| 315 | + $image_url['source_website'] = trim((string) $xml->channel->item->link); |
|
| 316 | 316 | $image_url['source'] = 'deviantart'; |
| 317 | 317 | return $image_url; |
| 318 | 318 | } |
@@ -328,32 +328,32 @@ discard block |
||
| 328 | 328 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 329 | 329 | * |
| 330 | 330 | */ |
| 331 | - public function fromJetPhotos($type,$aircraft_registration, $aircraft_name='') { |
|
| 331 | + public function fromJetPhotos($type, $aircraft_registration, $aircraft_name = '') { |
|
| 332 | 332 | $Common = new Common(); |
| 333 | - $url= 'http://jetphotos.net/showphotos.php?displaymode=2®search='.$aircraft_registration; |
|
| 333 | + $url = 'http://jetphotos.net/showphotos.php?displaymode=2®search='.$aircraft_registration; |
|
| 334 | 334 | $data = $Common->getData($url); |
| 335 | 335 | $dom = new DOMDocument(); |
| 336 | 336 | @$dom->loadHTML($data); |
| 337 | 337 | $all_pics = array(); |
| 338 | - foreach($dom->getElementsByTagName('img') as $image) { |
|
| 338 | + foreach ($dom->getElementsByTagName('img') as $image) { |
|
| 339 | 339 | if ($image->getAttribute('itemprop') == "http://schema.org/image") { |
| 340 | 340 | $all_pics[] = $image->getAttribute('src'); |
| 341 | 341 | } |
| 342 | 342 | } |
| 343 | 343 | $all_authors = array(); |
| 344 | - foreach($dom->getElementsByTagName('meta') as $author) { |
|
| 344 | + foreach ($dom->getElementsByTagName('meta') as $author) { |
|
| 345 | 345 | if ($author->getAttribute('itemprop') == "http://schema.org/author") { |
| 346 | 346 | $all_authors[] = $author->getAttribute('content'); |
| 347 | 347 | } |
| 348 | 348 | } |
| 349 | 349 | $all_ref = array(); |
| 350 | - foreach($dom->getElementsByTagName('a') as $link) { |
|
| 350 | + foreach ($dom->getElementsByTagName('a') as $link) { |
|
| 351 | 351 | $all_ref[] = $link->getAttribute('href'); |
| 352 | 352 | } |
| 353 | 353 | if (isset($all_pics[0])) { |
| 354 | 354 | $image_url = array(); |
| 355 | 355 | $image_url['thumbnail'] = $all_pics[0]; |
| 356 | - $image_url['original'] = str_replace('_tb','',$all_pics[0]); |
|
| 356 | + $image_url['original'] = str_replace('_tb', '', $all_pics[0]); |
|
| 357 | 357 | $image_url['copyright'] = $all_authors[0]; |
| 358 | 358 | $image_url['source_website'] = 'http://jetphotos.net'.$all_ref[8]; |
| 359 | 359 | $image_url['source'] = 'JetPhotos'; |
@@ -370,24 +370,24 @@ discard block |
||
| 370 | 370 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 371 | 371 | * |
| 372 | 372 | */ |
| 373 | - public function fromPlanePictures($type,$aircraft_registration, $aircraft_name='') { |
|
| 373 | + public function fromPlanePictures($type, $aircraft_registration, $aircraft_name = '') { |
|
| 374 | 374 | $Common = new Common(); |
| 375 | - $url= 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2'; |
|
| 375 | + $url = 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2'; |
|
| 376 | 376 | $data = $Common->getData($url); |
| 377 | 377 | $dom = new DOMDocument(); |
| 378 | 378 | @$dom->loadHTML($data); |
| 379 | 379 | $all_pics = array(); |
| 380 | - foreach($dom->getElementsByTagName('img') as $image) { |
|
| 380 | + foreach ($dom->getElementsByTagName('img') as $image) { |
|
| 381 | 381 | $all_pics[] = $image->getAttribute('src'); |
| 382 | 382 | } |
| 383 | 383 | $all_links = array(); |
| 384 | - foreach($dom->getElementsByTagName('a') as $link) { |
|
| 385 | - $all_links[] = array('text' => $link->textContent,'href' => $link->getAttribute('href')); |
|
| 384 | + foreach ($dom->getElementsByTagName('a') as $link) { |
|
| 385 | + $all_links[] = array('text' => $link->textContent, 'href' => $link->getAttribute('href')); |
|
| 386 | 386 | } |
| 387 | - if (isset($all_pics[1]) && !preg_match('/bit.ly/',$all_pics[1]) && !preg_match('/flagge/',$all_pics[1])) { |
|
| 387 | + if (isset($all_pics[1]) && !preg_match('/bit.ly/', $all_pics[1]) && !preg_match('/flagge/', $all_pics[1])) { |
|
| 388 | 388 | $image_url = array(); |
| 389 | 389 | $image_url['thumbnail'] = 'http://www.planepictures.net/'.$all_pics[1]; |
| 390 | - $image_url['original'] = 'http://www.planepictures.net/'.str_replace('_TN','',$all_pics[1]); |
|
| 390 | + $image_url['original'] = 'http://www.planepictures.net/'.str_replace('_TN', '', $all_pics[1]); |
|
| 391 | 391 | $image_url['copyright'] = $all_links[6]['text']; |
| 392 | 392 | $image_url['source_website'] = 'http://www.planepictures.net/'.$all_links[2]['href']; |
| 393 | 393 | $image_url['source'] = 'PlanePictures'; |
@@ -404,7 +404,7 @@ discard block |
||
| 404 | 404 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 405 | 405 | * |
| 406 | 406 | */ |
| 407 | - public function fromFlickr($type,$registration,$name='') { |
|
| 407 | + public function fromFlickr($type, $registration, $name = '') { |
|
| 408 | 408 | $Common = new Common(); |
| 409 | 409 | if ($type == 'aircraft') { |
| 410 | 410 | if ($name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.','.urlencode($name); |
@@ -416,12 +416,12 @@ discard block |
||
| 416 | 416 | $data = $Common->getData($url); |
| 417 | 417 | if ($xml = simplexml_load_string($data)) { |
| 418 | 418 | if (isset($xml->channel->item)) { |
| 419 | - $original_url = trim((string)$xml->channel->item->enclosure->attributes()->url); |
|
| 419 | + $original_url = trim((string) $xml->channel->item->enclosure->attributes()->url); |
|
| 420 | 420 | $image_url = array(); |
| 421 | 421 | $image_url['thumbnail'] = $original_url; |
| 422 | 422 | $image_url['original'] = $original_url; |
| 423 | - $image_url['copyright'] = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->credit); |
|
| 424 | - $image_url['source_website'] = trim((string)$xml->channel->item->link); |
|
| 423 | + $image_url['copyright'] = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->credit); |
|
| 424 | + $image_url['source_website'] = trim((string) $xml->channel->item->link); |
|
| 425 | 425 | $image_url['source'] = 'flickr'; |
| 426 | 426 | return $image_url; |
| 427 | 427 | } |
@@ -429,7 +429,7 @@ discard block |
||
| 429 | 429 | return false; |
| 430 | 430 | } |
| 431 | 431 | |
| 432 | - public function fromIvaoMtl($type,$aircraft_icao,$airline_icao) { |
|
| 432 | + public function fromIvaoMtl($type, $aircraft_icao, $airline_icao) { |
|
| 433 | 433 | $Common = new Common(); |
| 434 | 434 | //echo "\n".'SEARCH IMAGE : http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg'; |
| 435 | 435 | if ($Common->urlexist('http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg')) { |
@@ -453,7 +453,7 @@ discard block |
||
| 453 | 453 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 454 | 454 | * |
| 455 | 455 | */ |
| 456 | - public function fromBing($type,$aircraft_registration,$aircraft_name='') { |
|
| 456 | + public function fromBing($type, $aircraft_registration, $aircraft_name = '') { |
|
| 457 | 457 | global $globalImageBingKey; |
| 458 | 458 | $Common = new Common(); |
| 459 | 459 | if (!isset($globalImageBingKey) || $globalImageBingKey == '') return false; |
@@ -464,8 +464,8 @@ discard block |
||
| 464 | 464 | if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.urlencode($aircraft_name).'%20%2Bship%20-site:flickr.com%27'; |
| 465 | 465 | else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Bship%20-site:flickr.com%27'; |
| 466 | 466 | } |
| 467 | - $headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey)); |
|
| 468 | - $data = $Common->getData($url,'get','',$headers); |
|
| 467 | + $headers = array("Authorization: Basic ".base64_encode("ignored:".$globalImageBingKey)); |
|
| 468 | + $data = $Common->getData($url, 'get', '', $headers); |
|
| 469 | 469 | $result = json_decode($data); |
| 470 | 470 | if (isset($result->d->results[0]->MediaUrl)) { |
| 471 | 471 | $image_url = array(); |
@@ -490,14 +490,14 @@ discard block |
||
| 490 | 490 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 491 | 491 | * |
| 492 | 492 | */ |
| 493 | - public function fromAirportData($type,$aircraft_registration,$aircraft_name='') { |
|
| 493 | + public function fromAirportData($type, $aircraft_registration, $aircraft_name = '') { |
|
| 494 | 494 | $Common = new Common(); |
| 495 | 495 | $url = 'http://www.airport-data.com/api/ac_thumb.json?&n=1&r='.$aircraft_registration; |
| 496 | 496 | $data = $Common->getData($url); |
| 497 | 497 | $result = json_decode($data); |
| 498 | 498 | if (isset($result->count) && $result->count > 0) { |
| 499 | 499 | $image_url = array(); |
| 500 | - $image_url['original'] = str_replace('thumbnails','large',$result->data[0]->image); |
|
| 500 | + $image_url['original'] = str_replace('thumbnails', 'large', $result->data[0]->image); |
|
| 501 | 501 | $image_url['source_website'] = $result->data[0]->link; |
| 502 | 502 | $image_url['thumbnail'] = $result->data[0]->image; |
| 503 | 503 | $image_url['copyright'] = $result->data[0]->photographer; |
@@ -515,7 +515,7 @@ discard block |
||
| 515 | 515 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 516 | 516 | * |
| 517 | 517 | */ |
| 518 | - public function fromWikimedia($type,$registration,$name='') { |
|
| 518 | + public function fromWikimedia($type, $registration, $name = '') { |
|
| 519 | 519 | $Common = new Common(); |
| 520 | 520 | if ($type == 'aircraft') { |
| 521 | 521 | if ($name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20'.urlencode($name); |
@@ -528,7 +528,7 @@ discard block |
||
| 528 | 528 | $result = json_decode($data); |
| 529 | 529 | if (isset($result->query->search[0]->title)) { |
| 530 | 530 | $fileo = $result->query->search[0]->title; |
| 531 | - if (substr($fileo,-3) == 'pdf') return false; |
|
| 531 | + if (substr($fileo, -3) == 'pdf') return false; |
|
| 532 | 532 | $file = urlencode($fileo); |
| 533 | 533 | $url2 = 'https://commons.wikimedia.org/w/api.php?action=query&format=json&continue&iilimit=500&prop=imageinfo&iiprop=user|url|size|mime|sha1|timestamp&iiurlwidth=200%27&titles='.$file; |
| 534 | 534 | $data2 = $Common->getData($url2); |
@@ -553,11 +553,11 @@ discard block |
||
| 553 | 553 | if (isset($result2->query->pages)) { |
| 554 | 554 | foreach ($result2->query->pages as $page) { |
| 555 | 555 | if (isset($page->imageinfo[0]->extmetadata->Artist)) { |
| 556 | - $image_url['copyright'] = preg_replace('/ from(.*)/','',strip_tags($page->imageinfo[0]->extmetadata->Artist->value)); |
|
| 556 | + $image_url['copyright'] = preg_replace('/ from(.*)/', '', strip_tags($page->imageinfo[0]->extmetadata->Artist->value)); |
|
| 557 | 557 | if (isset($page->imageinfo[0]->extmetadata->License->value)) { |
| 558 | 558 | $image_url['copyright'] = $image_url['copyright'].' (under '.$page->imageinfo[0]->extmetadata->License->value.')'; |
| 559 | 559 | } |
| 560 | - $image_url['copyright'] = trim(str_replace('\n','',$image_url['copyright'])); |
|
| 560 | + $image_url['copyright'] = trim(str_replace('\n', '', $image_url['copyright'])); |
|
| 561 | 561 | return $image_url; |
| 562 | 562 | } |
| 563 | 563 | } |
@@ -576,7 +576,7 @@ discard block |
||
| 576 | 576 | * @return Array the aircraft thumbnail, orignal url and copyright |
| 577 | 577 | * |
| 578 | 578 | */ |
| 579 | - public function fromCustomSource($type,$registration,$name='') { |
|
| 579 | + public function fromCustomSource($type, $registration, $name = '') { |
|
| 580 | 580 | global $globalAircraftImageCustomSources, $globalMarineImageCustomSources, $globalDebug; |
| 581 | 581 | //$globalAircraftImageCustomSource[] = array('thumbnail' => '','original' => '', 'copyright' => '', 'source_website' => '', 'source' => '','exif' => true); |
| 582 | 582 | if (!empty($globalAircraftImageCustomSources) && $type == 'aircraft') { |
@@ -593,15 +593,15 @@ discard block |
||
| 593 | 593 | print_r($source); |
| 594 | 594 | print_r($customsources); |
| 595 | 595 | } |
| 596 | - $url = str_replace('{registration}',$registration,$source['original']); |
|
| 597 | - $url_thumbnail = str_replace('{registration}',$registration,$source['thumbnail']); |
|
| 596 | + $url = str_replace('{registration}', $registration, $source['original']); |
|
| 597 | + $url_thumbnail = str_replace('{registration}', $registration, $source['thumbnail']); |
|
| 598 | 598 | if ($Common->urlexist($url)) { |
| 599 | 599 | $image_url = array(); |
| 600 | 600 | $image_url['thumbnail'] = $url_thumbnail; |
| 601 | 601 | $image_url['original'] = $url; |
| 602 | 602 | if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url); |
| 603 | 603 | else $exifCopyright = ''; |
| 604 | - if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
| 604 | + if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
| 605 | 605 | elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright']; |
| 606 | 606 | else $image_url['copyright'] = $source['source_website']; |
| 607 | 607 | $image_url['source_website'] = $source['source_website']; |
@@ -625,19 +625,19 @@ discard block |
||
| 625 | 625 | print_r($source); |
| 626 | 626 | print_r($customsources); |
| 627 | 627 | } |
| 628 | - $url = str_replace('{registration}',$registration,$source['original']); |
|
| 629 | - $url = str_replace('{mmsi}',$registration,$url); |
|
| 630 | - $url = str_replace('{name}',$name,$url); |
|
| 631 | - $url_thumbnail = str_replace('{registration}',$registration,$source['thumbnail']); |
|
| 632 | - $url_thumbnail = str_replace('{mmsi}',$registration,$url_thumbnail); |
|
| 633 | - $url_thumbnail = str_replace('{name}',$name,$url_thumbnail); |
|
| 628 | + $url = str_replace('{registration}', $registration, $source['original']); |
|
| 629 | + $url = str_replace('{mmsi}', $registration, $url); |
|
| 630 | + $url = str_replace('{name}', $name, $url); |
|
| 631 | + $url_thumbnail = str_replace('{registration}', $registration, $source['thumbnail']); |
|
| 632 | + $url_thumbnail = str_replace('{mmsi}', $registration, $url_thumbnail); |
|
| 633 | + $url_thumbnail = str_replace('{name}', $name, $url_thumbnail); |
|
| 634 | 634 | if ($Common->urlexist($url)) { |
| 635 | 635 | $image_url = array(); |
| 636 | 636 | $image_url['thumbnail'] = $url_thumbnail; |
| 637 | 637 | $image_url['original'] = $url; |
| 638 | 638 | if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url); |
| 639 | 639 | else $exifCopyright = ''; |
| 640 | - if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
| 640 | + if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
| 641 | 641 | elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright']; |
| 642 | 642 | else $image_url['copyright'] = $source['source_website']; |
| 643 | 643 | $image_url['source_website'] = $source['source_website']; |
@@ -23,7 +23,9 @@ discard block |
||
| 23 | 23 | $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
| 24 | 24 | $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
| 25 | 25 | $reg = $registration; |
| 26 | - if ($reg == '' && $aircraft_icao != '') $reg = $aircraft_icao.$airline_icao; |
|
| 26 | + if ($reg == '' && $aircraft_icao != '') { |
|
| 27 | + $reg = $aircraft_icao.$airline_icao; |
|
| 28 | + } |
|
| 27 | 29 | $reg = trim($reg); |
| 28 | 30 | $query = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration |
| 29 | 31 | FROM spotter_image |
@@ -31,9 +33,13 @@ discard block |
||
| 31 | 33 | $sth = $this->db->prepare($query); |
| 32 | 34 | $sth->execute(array(':registration' => $reg)); |
| 33 | 35 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 34 | - if (!empty($result)) return $result; |
|
| 35 | - elseif ($registration != '') return $this->getSpotterImage('',$aircraft_icao,$airline_icao); |
|
| 36 | - else return array(); |
|
| 36 | + if (!empty($result)) { |
|
| 37 | + return $result; |
|
| 38 | + } elseif ($registration != '') { |
|
| 39 | + return $this->getSpotterImage('',$aircraft_icao,$airline_icao); |
|
| 40 | + } else { |
|
| 41 | + return array(); |
|
| 42 | + } |
|
| 37 | 43 | } |
| 38 | 44 | |
| 39 | 45 | /** |
@@ -76,8 +82,11 @@ discard block |
||
| 76 | 82 | public function getExifCopyright($url) { |
| 77 | 83 | $exif = exif_read_data($url); |
| 78 | 84 | $copyright = ''; |
| 79 | - if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright']; |
|
| 80 | - elseif (isset($exif['copyright'])) $copyright = $exif['copyright']; |
|
| 85 | + if (isset($exif['COMPUTED']['copyright'])) { |
|
| 86 | + $copyright = $exif['COMPUTED']['copyright']; |
|
| 87 | + } elseif (isset($exif['copyright'])) { |
|
| 88 | + $copyright = $exif['copyright']; |
|
| 89 | + } |
|
| 81 | 90 | if ($copyright != '') { |
| 82 | 91 | $copyright = str_replace('Copyright ','',$copyright); |
| 83 | 92 | $copyright = str_replace('© ','',$copyright); |
@@ -95,17 +104,27 @@ discard block |
||
| 95 | 104 | public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
| 96 | 105 | { |
| 97 | 106 | global $globalDebug,$globalAircraftImageFetch; |
| 98 | - if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) return ''; |
|
| 107 | + if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) { |
|
| 108 | + return ''; |
|
| 109 | + } |
|
| 99 | 110 | $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
| 100 | 111 | $registration = trim($registration); |
| 101 | 112 | //getting the aircraft image |
| 102 | - if ($globalDebug && $registration != '') echo 'Try to find an aircraft image for '.$registration.'...'; |
|
| 103 | - elseif ($globalDebug && $aircraft_icao != '') echo 'Try to find an aircraft image for '.$aircraft_icao.'...'; |
|
| 104 | - elseif ($globalDebug && $airline_icao != '') echo 'Try to find an aircraft image for '.$airline_icao.'...'; |
|
| 113 | + if ($globalDebug && $registration != '') { |
|
| 114 | + echo 'Try to find an aircraft image for '.$registration.'...'; |
|
| 115 | + } elseif ($globalDebug && $aircraft_icao != '') { |
|
| 116 | + echo 'Try to find an aircraft image for '.$aircraft_icao.'...'; |
|
| 117 | + } elseif ($globalDebug && $airline_icao != '') { |
|
| 118 | + echo 'Try to find an aircraft image for '.$airline_icao.'...'; |
|
| 119 | + } |
|
| 105 | 120 | $image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao); |
| 106 | - if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao; |
|
| 121 | + if ($registration == '' && $aircraft_icao != '') { |
|
| 122 | + $registration = $aircraft_icao.$airline_icao; |
|
| 123 | + } |
|
| 107 | 124 | if ($image_url['original'] != '') { |
| 108 | - if ($globalDebug) echo 'Found !'."\n"; |
|
| 125 | + if ($globalDebug) { |
|
| 126 | + echo 'Found !'."\n"; |
|
| 127 | + } |
|
| 109 | 128 | $query = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
| 110 | 129 | try { |
| 111 | 130 | $sth = $this->db->prepare($query); |
@@ -114,7 +133,9 @@ discard block |
||
| 114 | 133 | echo $e->getMessage()."\n"; |
| 115 | 134 | return "error"; |
| 116 | 135 | } |
| 117 | - } elseif ($globalDebug) echo "Not found :'(\n"; |
|
| 136 | + } elseif ($globalDebug) { |
|
| 137 | + echo "Not found :'(\n"; |
|
| 138 | + } |
|
| 118 | 139 | return "success"; |
| 119 | 140 | } |
| 120 | 141 | |
@@ -127,7 +148,9 @@ discard block |
||
| 127 | 148 | public function addMarineImage($mmsi,$imo = '',$name = '') |
| 128 | 149 | { |
| 129 | 150 | global $globalDebug,$globalMarineImageFetch; |
| 130 | - if (isset($globalMarineImageFetch) && !$globalMarineImageFetch) return ''; |
|
| 151 | + if (isset($globalMarineImageFetch) && !$globalMarineImageFetch) { |
|
| 152 | + return ''; |
|
| 153 | + } |
|
| 131 | 154 | $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
| 132 | 155 | $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
| 133 | 156 | $name = filter_var($name,FILTER_SANITIZE_STRING); |
@@ -137,16 +160,22 @@ discard block |
||
| 137 | 160 | $identity = $Marine->getIdentity($mmsi); |
| 138 | 161 | if (isset($identity[0]['mmsi'])) { |
| 139 | 162 | $imo = $identity[0]['imo']; |
| 140 | - if ($identity[0]['ship_name'] != '') $name = $identity[0]['ship_name']; |
|
| 163 | + if ($identity[0]['ship_name'] != '') { |
|
| 164 | + $name = $identity[0]['ship_name']; |
|
| 165 | + } |
|
| 141 | 166 | } |
| 142 | 167 | } |
| 143 | 168 | unset($Marine); |
| 144 | 169 | |
| 145 | 170 | //getting the aircraft image |
| 146 | - if ($globalDebug && $name != '') echo 'Try to find an vessel image for '.$name.'...'; |
|
| 171 | + if ($globalDebug && $name != '') { |
|
| 172 | + echo 'Try to find an vessel image for '.$name.'...'; |
|
| 173 | + } |
|
| 147 | 174 | $image_url = $this->findMarineImage($mmsi,$imo,$name); |
| 148 | 175 | if ($image_url['original'] != '') { |
| 149 | - if ($globalDebug) echo 'Found !'."\n"; |
|
| 176 | + if ($globalDebug) { |
|
| 177 | + echo 'Found !'."\n"; |
|
| 178 | + } |
|
| 150 | 179 | $query = "INSERT INTO marine_image (mmsi,imo,name, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:mmsi,:imo,:name,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
| 151 | 180 | try { |
| 152 | 181 | $sth = $this->db->prepare($query); |
@@ -155,7 +184,9 @@ discard block |
||
| 155 | 184 | echo $e->getMessage()."\n"; |
| 156 | 185 | return "error"; |
| 157 | 186 | } |
| 158 | - } elseif ($globalDebug) echo "Not found :'(\n"; |
|
| 187 | + } elseif ($globalDebug) { |
|
| 188 | + echo "Not found :'(\n"; |
|
| 189 | + } |
|
| 159 | 190 | return "success"; |
| 160 | 191 | } |
| 161 | 192 | |
@@ -170,41 +201,85 @@ discard block |
||
| 170 | 201 | { |
| 171 | 202 | global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO, $globalVA; |
| 172 | 203 | $Spotter = new Spotter($this->db); |
| 173 | - if (!isset($globalIVAO)) $globalIVAO = FALSE; |
|
| 204 | + if (!isset($globalIVAO)) { |
|
| 205 | + $globalIVAO = FALSE; |
|
| 206 | + } |
|
| 174 | 207 | $aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING); |
| 175 | 208 | if ($aircraft_registration != '' && (!isset($globalVA) || $globalVA !== TRUE)) { |
| 176 | - if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 209 | + if (strpos($aircraft_registration,'/') !== false) { |
|
| 210 | + return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 211 | + } |
|
| 177 | 212 | $aircraft_registration = urlencode(trim($aircraft_registration)); |
| 178 | 213 | $aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration); |
| 179 | - if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name']; |
|
| 180 | - else $aircraft_name = ''; |
|
| 181 | - if (isset($aircraft_info[0]['aircraft_icao'])) $aircraft_name = $aircraft_info[0]['aircraft_icao']; |
|
| 182 | - else $aircraft_icao = ''; |
|
| 183 | - if (isset($aircraft_info[0]['airline_icao'])) $airline_icao = $aircraft_info[0]['airline_icao']; |
|
| 184 | - else $airline_icao = ''; |
|
| 214 | + if (isset($aircraft_info[0]['aircraft_name'])) { |
|
| 215 | + $aircraft_name = $aircraft_info[0]['aircraft_name']; |
|
| 216 | + } else { |
|
| 217 | + $aircraft_name = ''; |
|
| 218 | + } |
|
| 219 | + if (isset($aircraft_info[0]['aircraft_icao'])) { |
|
| 220 | + $aircraft_name = $aircraft_info[0]['aircraft_icao']; |
|
| 221 | + } else { |
|
| 222 | + $aircraft_icao = ''; |
|
| 223 | + } |
|
| 224 | + if (isset($aircraft_info[0]['airline_icao'])) { |
|
| 225 | + $airline_icao = $aircraft_info[0]['airline_icao']; |
|
| 226 | + } else { |
|
| 227 | + $airline_icao = ''; |
|
| 228 | + } |
|
| 185 | 229 | } elseif ($aircraft_icao != '') { |
| 186 | 230 | $aircraft_info = $Spotter->getAllAircraftInfo($aircraft_icao); |
| 187 | - if (isset($aircraft_info[0]['type'])) $aircraft_name = $aircraft_info[0]['type']; |
|
| 188 | - else $aircraft_name = ''; |
|
| 231 | + if (isset($aircraft_info[0]['type'])) { |
|
| 232 | + $aircraft_name = $aircraft_info[0]['type']; |
|
| 233 | + } else { |
|
| 234 | + $aircraft_name = ''; |
|
| 235 | + } |
|
| 189 | 236 | $aircraft_registration = $aircraft_icao; |
| 190 | - } else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
| 237 | + } else { |
|
| 238 | + return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
| 239 | + } |
|
| 191 | 240 | unset($Spotter); |
| 192 | - if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
| 241 | + if (!isset($globalAircraftImageSources)) { |
|
| 242 | + $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
| 243 | + } |
|
| 193 | 244 | foreach ($globalAircraftImageSources as $source) { |
| 194 | 245 | $source = strtolower($source); |
| 195 | - if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao); |
|
| 196 | - if ($source == 'planespotters' && !$globalIVAO) $images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name); |
|
| 197 | - if ($source == 'flickr') $images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name); |
|
| 198 | - if ($source == 'bing') $images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name); |
|
| 199 | - if ($source == 'deviantart') $images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name); |
|
| 200 | - if ($source == 'wikimedia') $images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name); |
|
| 201 | - if ($source == 'jetphotos' && !$globalIVAO) $images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name); |
|
| 202 | - if ($source == 'planepictures' && !$globalIVAO) $images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name); |
|
| 203 | - if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_name); |
|
| 204 | - if ($source == 'customsources') $images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name); |
|
| 205 | - if (isset($images_array) && $images_array['original'] != '') return $images_array; |
|
| 206 | - } |
|
| 207 | - if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) return $this->findAircraftImage($aircraft_icao); |
|
| 246 | + if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') { |
|
| 247 | + $images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao); |
|
| 248 | + } |
|
| 249 | + if ($source == 'planespotters' && !$globalIVAO) { |
|
| 250 | + $images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name); |
|
| 251 | + } |
|
| 252 | + if ($source == 'flickr') { |
|
| 253 | + $images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name); |
|
| 254 | + } |
|
| 255 | + if ($source == 'bing') { |
|
| 256 | + $images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name); |
|
| 257 | + } |
|
| 258 | + if ($source == 'deviantart') { |
|
| 259 | + $images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name); |
|
| 260 | + } |
|
| 261 | + if ($source == 'wikimedia') { |
|
| 262 | + $images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name); |
|
| 263 | + } |
|
| 264 | + if ($source == 'jetphotos' && !$globalIVAO) { |
|
| 265 | + $images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name); |
|
| 266 | + } |
|
| 267 | + if ($source == 'planepictures' && !$globalIVAO) { |
|
| 268 | + $images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name); |
|
| 269 | + } |
|
| 270 | + if ($source == 'airportdata' && !$globalIVAO) { |
|
| 271 | + $images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_name); |
|
| 272 | + } |
|
| 273 | + if ($source == 'customsources') { |
|
| 274 | + $images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name); |
|
| 275 | + } |
|
| 276 | + if (isset($images_array) && $images_array['original'] != '') { |
|
| 277 | + return $images_array; |
|
| 278 | + } |
|
| 279 | + } |
|
| 280 | + if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) { |
|
| 281 | + return $this->findAircraftImage($aircraft_icao); |
|
| 282 | + } |
|
| 208 | 283 | return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
| 209 | 284 | } |
| 210 | 285 | |
@@ -224,7 +299,9 @@ discard block |
||
| 224 | 299 | //$imo = filter_var($imo,FILTER_SANITIZE_STRING); |
| 225 | 300 | $name = filter_var($name,FILTER_SANITIZE_STRING); |
| 226 | 301 | $name = trim($name); |
| 227 | - if (strlen($name) < 4) return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
| 302 | + if (strlen($name) < 4) { |
|
| 303 | + return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
| 304 | + } |
|
| 228 | 305 | /* |
| 229 | 306 | $Marine = new Marine($this->db); |
| 230 | 307 | if ($imo == '' || $name == '') { |
@@ -236,15 +313,29 @@ discard block |
||
| 236 | 313 | } |
| 237 | 314 | unset($Marine); |
| 238 | 315 | */ |
| 239 | - if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia','deviantart','flickr','bing'); |
|
| 316 | + if (!isset($globalMarineImageSources)) { |
|
| 317 | + $globalMarineImageSources = array('wikimedia','deviantart','flickr','bing'); |
|
| 318 | + } |
|
| 240 | 319 | foreach ($globalMarineImageSources as $source) { |
| 241 | 320 | $source = strtolower($source); |
| 242 | - if ($source == 'flickr') $images_array = $this->fromFlickr('marine',$mmsi,$name); |
|
| 243 | - if ($source == 'bing') $images_array = $this->fromBing('marine',$mmsi,$name); |
|
| 244 | - if ($source == 'deviantart') $images_array = $this->fromDeviantart('marine',$mmsi,$name); |
|
| 245 | - if ($source == 'wikimedia') $images_array = $this->fromWikimedia('marine',$mmsi,$name); |
|
| 246 | - if ($source == 'customsources') $images_array = $this->fromCustomSource('marine',$mmsi,$name); |
|
| 247 | - if (isset($images_array) && $images_array['original'] != '') return $images_array; |
|
| 321 | + if ($source == 'flickr') { |
|
| 322 | + $images_array = $this->fromFlickr('marine',$mmsi,$name); |
|
| 323 | + } |
|
| 324 | + if ($source == 'bing') { |
|
| 325 | + $images_array = $this->fromBing('marine',$mmsi,$name); |
|
| 326 | + } |
|
| 327 | + if ($source == 'deviantart') { |
|
| 328 | + $images_array = $this->fromDeviantart('marine',$mmsi,$name); |
|
| 329 | + } |
|
| 330 | + if ($source == 'wikimedia') { |
|
| 331 | + $images_array = $this->fromWikimedia('marine',$mmsi,$name); |
|
| 332 | + } |
|
| 333 | + if ($source == 'customsources') { |
|
| 334 | + $images_array = $this->fromCustomSource('marine',$mmsi,$name); |
|
| 335 | + } |
|
| 336 | + if (isset($images_array) && $images_array['original'] != '') { |
|
| 337 | + return $images_array; |
|
| 338 | + } |
|
| 248 | 339 | } |
| 249 | 340 | return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
| 250 | 341 | } |
@@ -407,11 +498,17 @@ discard block |
||
| 407 | 498 | public function fromFlickr($type,$registration,$name='') { |
| 408 | 499 | $Common = new Common(); |
| 409 | 500 | if ($type == 'aircraft') { |
| 410 | - if ($name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.','.urlencode($name); |
|
| 411 | - else $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',aircraft'; |
|
| 501 | + if ($name != '') { |
|
| 502 | + $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.','.urlencode($name); |
|
| 503 | + } else { |
|
| 504 | + $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',aircraft'; |
|
| 505 | + } |
|
| 412 | 506 | } elseif ($type == 'marine') { |
| 413 | - if ($name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags=ship,'.urlencode($name); |
|
| 414 | - else $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',ship'; |
|
| 507 | + if ($name != '') { |
|
| 508 | + $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags=ship,'.urlencode($name); |
|
| 509 | + } else { |
|
| 510 | + $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',ship'; |
|
| 511 | + } |
|
| 415 | 512 | } |
| 416 | 513 | $data = $Common->getData($url); |
| 417 | 514 | if ($xml = simplexml_load_string($data)) { |
@@ -456,13 +553,21 @@ discard block |
||
| 456 | 553 | public function fromBing($type,$aircraft_registration,$aircraft_name='') { |
| 457 | 554 | global $globalImageBingKey; |
| 458 | 555 | $Common = new Common(); |
| 459 | - if (!isset($globalImageBingKey) || $globalImageBingKey == '') return false; |
|
| 556 | + if (!isset($globalImageBingKey) || $globalImageBingKey == '') { |
|
| 557 | + return false; |
|
| 558 | + } |
|
| 460 | 559 | if ($type == 'aircraft') { |
| 461 | - if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27'; |
|
| 462 | - else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27'; |
|
| 560 | + if ($aircraft_name != '') { |
|
| 561 | + $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27'; |
|
| 562 | + } else { |
|
| 563 | + $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27'; |
|
| 564 | + } |
|
| 463 | 565 | } elseif ($type == 'marine') { |
| 464 | - if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.urlencode($aircraft_name).'%20%2Bship%20-site:flickr.com%27'; |
|
| 465 | - else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Bship%20-site:flickr.com%27'; |
|
| 566 | + if ($aircraft_name != '') { |
|
| 567 | + $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.urlencode($aircraft_name).'%20%2Bship%20-site:flickr.com%27'; |
|
| 568 | + } else { |
|
| 569 | + $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Bship%20-site:flickr.com%27'; |
|
| 570 | + } |
|
| 466 | 571 | } |
| 467 | 572 | $headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey)); |
| 468 | 573 | $data = $Common->getData($url,'get','',$headers); |
@@ -518,17 +623,25 @@ discard block |
||
| 518 | 623 | public function fromWikimedia($type,$registration,$name='') { |
| 519 | 624 | $Common = new Common(); |
| 520 | 625 | if ($type == 'aircraft') { |
| 521 | - if ($name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20'.urlencode($name); |
|
| 522 | - else $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20aircraft'; |
|
| 626 | + if ($name != '') { |
|
| 627 | + $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20'.urlencode($name); |
|
| 628 | + } else { |
|
| 629 | + $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20aircraft'; |
|
| 630 | + } |
|
| 523 | 631 | } elseif ($type == 'marine') { |
| 524 | - if ($name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.urlencode($name).'%20ship"'; |
|
| 525 | - else return false; |
|
| 632 | + if ($name != '') { |
|
| 633 | + $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.urlencode($name).'%20ship"'; |
|
| 634 | + } else { |
|
| 635 | + return false; |
|
| 636 | + } |
|
| 526 | 637 | } |
| 527 | 638 | $data = $Common->getData($url); |
| 528 | 639 | $result = json_decode($data); |
| 529 | 640 | if (isset($result->query->search[0]->title)) { |
| 530 | 641 | $fileo = $result->query->search[0]->title; |
| 531 | - if (substr($fileo,-3) == 'pdf') return false; |
|
| 642 | + if (substr($fileo,-3) == 'pdf') { |
|
| 643 | + return false; |
|
| 644 | + } |
|
| 532 | 645 | $file = urlencode($fileo); |
| 533 | 646 | $url2 = 'https://commons.wikimedia.org/w/api.php?action=query&format=json&continue&iilimit=500&prop=imageinfo&iiprop=user|url|size|mime|sha1|timestamp&iiurlwidth=200%27&titles='.$file; |
| 534 | 647 | $data2 = $Common->getData($url2); |
@@ -599,18 +712,27 @@ discard block |
||
| 599 | 712 | $image_url = array(); |
| 600 | 713 | $image_url['thumbnail'] = $url_thumbnail; |
| 601 | 714 | $image_url['original'] = $url; |
| 602 | - if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url); |
|
| 603 | - else $exifCopyright = ''; |
|
| 604 | - if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
| 605 | - elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright']; |
|
| 606 | - else $image_url['copyright'] = $source['source_website']; |
|
| 715 | + if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) { |
|
| 716 | + $exifCopyright = $this->getExifCopyright($url); |
|
| 717 | + } else { |
|
| 718 | + $exifCopyright = ''; |
|
| 719 | + } |
|
| 720 | + if ($exifCopyright != '') { |
|
| 721 | + $image_url['copyright'] = $exifCopyright; |
|
| 722 | + } elseif (isset($source['copyright'])) { |
|
| 723 | + $image_url['copyright'] = $source['copyright']; |
|
| 724 | + } else { |
|
| 725 | + $image_url['copyright'] = $source['source_website']; |
|
| 726 | + } |
|
| 607 | 727 | $image_url['source_website'] = $source['source_website']; |
| 608 | 728 | $image_url['source'] = $source['source']; |
| 609 | 729 | return $image_url; |
| 610 | 730 | } |
| 611 | 731 | } |
| 612 | 732 | return false; |
| 613 | - } else return false; |
|
| 733 | + } else { |
|
| 734 | + return false; |
|
| 735 | + } |
|
| 614 | 736 | if (!empty($globalMarineImageCustomSources) && $type == 'marine') { |
| 615 | 737 | $customsources = array(); |
| 616 | 738 | if (!isset($globalMarineImageCustomSources[0])) { |
@@ -635,18 +757,27 @@ discard block |
||
| 635 | 757 | $image_url = array(); |
| 636 | 758 | $image_url['thumbnail'] = $url_thumbnail; |
| 637 | 759 | $image_url['original'] = $url; |
| 638 | - if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url); |
|
| 639 | - else $exifCopyright = ''; |
|
| 640 | - if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
| 641 | - elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright']; |
|
| 642 | - else $image_url['copyright'] = $source['source_website']; |
|
| 760 | + if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) { |
|
| 761 | + $exifCopyright = $this->getExifCopyright($url); |
|
| 762 | + } else { |
|
| 763 | + $exifCopyright = ''; |
|
| 764 | + } |
|
| 765 | + if ($exifCopyright != '') { |
|
| 766 | + $image_url['copyright'] = $exifCopyright; |
|
| 767 | + } elseif (isset($source['copyright'])) { |
|
| 768 | + $image_url['copyright'] = $source['copyright']; |
|
| 769 | + } else { |
|
| 770 | + $image_url['copyright'] = $source['source_website']; |
|
| 771 | + } |
|
| 643 | 772 | $image_url['source_website'] = $source['source_website']; |
| 644 | 773 | $image_url['source'] = $source['source']; |
| 645 | 774 | return $image_url; |
| 646 | 775 | } |
| 647 | 776 | } |
| 648 | 777 | return false; |
| 649 | - } else return false; |
|
| 778 | + } else { |
|
| 779 | + return false; |
|
| 780 | + } |
|
| 650 | 781 | } |
| 651 | 782 | } |
| 652 | 783 | |