@@ -4,12 +4,12 @@ discard block |
||
4 | 4 | require_once('require/class.Language.php'); |
5 | 5 | |
6 | 6 | $Spotter = new Spotter(); |
7 | -$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
8 | -$spotter_array = $Spotter->getSpotterDataByDate($_GET['date'],"0,1", $sort); |
|
7 | +$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
8 | +$spotter_array = $Spotter->getSpotterDataByDate($_GET['date'], "0,1", $sort); |
|
9 | 9 | |
10 | 10 | if (!empty($spotter_array)) |
11 | 11 | { |
12 | - $title = sprintf(_("Most Common Departure Airports on %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
12 | + $title = sprintf(_("Most Common Departure Airports 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">'; |
@@ -21,13 +21,13 @@ discard block |
||
21 | 21 | print '</div>'; |
22 | 22 | |
23 | 23 | print '<div class="info column">'; |
24 | - print '<h1>'.sprintf(_("Flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>'; |
|
24 | + print '<h1>'.sprintf(_("Flights from %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>'; |
|
25 | 25 | print '</div>'; |
26 | 26 | |
27 | 27 | include('date-sub-menu.php'); |
28 | 28 | print '<div class="column">'; |
29 | 29 | print '<h2>'._("Most Common Departure Airports").'</h2>'; |
30 | - print '<p>'.sprintf(_("The statistic below shows all departure airports of flights on <strong>%s</strong>."),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
30 | + print '<p>'.sprintf(_("The statistic below shows all departure airports of flights on <strong>%s</strong>."), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
31 | 31 | |
32 | 32 | $airport_airport_array = $Spotter->countAllDepartureAirportsByDate($_GET['date']); |
33 | 33 | print '<script type="text/javascript" src="https://www.google.com/jsapi"></script> |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | ["'._("Airport").'", "'._("# of times").'"],'; |
44 | 44 | |
45 | 45 | $airport_data = ''; |
46 | - foreach($airport_airport_array as $airport_item) |
|
46 | + foreach ($airport_airport_array as $airport_item) |
|
47 | 47 | { |
48 | 48 | $name = $airport_item['airport_departure_city'].', '.$airport_item['airport_departure_country'].' ('.$airport_item['airport_departure_icao'].')'; |
49 | 49 | $name = str_replace("'", "", $name); |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | print '</thead>'; |
83 | 83 | print '<tbody>'; |
84 | 84 | $i = 1; |
85 | - foreach($airport_airport_array as $airport_item) |
|
85 | + foreach ($airport_airport_array as $airport_item) |
|
86 | 86 | { |
87 | 87 | print '<tr>'; |
88 | 88 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -6,22 +6,22 @@ discard block |
||
6 | 6 | header('Location: '.$globalURL.'/airline'); |
7 | 7 | die(); |
8 | 8 | } |
9 | -$airline = filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
|
9 | +$airline = filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING); |
|
10 | 10 | $Spotter = new Spotter(); |
11 | -$spotter_array = $Spotter->getSpotterDataByAirline($airline,"0,1",""); |
|
11 | +$spotter_array = $Spotter->getSpotterDataByAirline($airline, "0,1", ""); |
|
12 | 12 | |
13 | 13 | if (!empty($spotter_array)) |
14 | 14 | { |
15 | - $title = sprintf(_("Most Common Arrival Airports by Country from %s (%s)"),$spotter_array[0]['airline_name'],$spotter_array[0]['airline_icao']); |
|
15 | + $title = sprintf(_("Most Common Arrival Airports by Country from %s (%s)"), $spotter_array[0]['airline_name'], $spotter_array[0]['airline_icao']); |
|
16 | 16 | require_once('header.php'); |
17 | 17 | print '<div class="select-item">'; |
18 | 18 | print '<form action="'.$globalURL.'/airline" method="post">'; |
19 | 19 | print '<select name="airline" class="selectpicker" data-live-search="true">'; |
20 | 20 | print '<option></option>'; |
21 | 21 | $airline_names = $Spotter->getAllAirlineNames(); |
22 | - foreach($airline_names as $airline_name) |
|
22 | + foreach ($airline_names as $airline_name) |
|
23 | 23 | { |
24 | - if($_GET['airline'] == $airline_name['airline_icao']) |
|
24 | + if ($_GET['airline'] == $airline_name['airline_icao']) |
|
25 | 25 | { |
26 | 26 | print '<option value="'.$airline_name['airline_icao'].'" selected="selected">'.$airline_name['airline_name'].' ('.$airline_name['airline_icao'].')</option>'; |
27 | 27 | } else { |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | include('airline-sub-menu.php'); |
60 | 60 | print '<div class="column">'; |
61 | 61 | print '<h2>'._("Most Common Arrival Airports by Country").'</h2>'; |
62 | - print '<p>'.sprintf(_("The statistic below shows all arrival airports by Country of origin of flights from <strong>%s</strong>."),$spotter_array[0]['airline_name']).'</p>'; |
|
62 | + print '<p>'.sprintf(_("The statistic below shows all arrival airports by Country of origin of flights from <strong>%s</strong>."), $spotter_array[0]['airline_name']).'</p>'; |
|
63 | 63 | $airport_country_array = $Spotter->countAllArrivalAirportCountriesByAirline($airline); |
64 | 64 | print '<script type="text/javascript" src="https://www.google.com/jsapi"></script>'; |
65 | 65 | print '<div id="chartCountry" class="chart" width="100%"></div> |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | var data = google.visualization.arrayToDataTable([ |
71 | 71 | ["'._("Country").'", "'._("# of times").'"], '; |
72 | 72 | $country_data = ''; |
73 | - foreach($airport_country_array as $airport_item) |
|
73 | + foreach ($airport_country_array as $airport_item) |
|
74 | 74 | { |
75 | 75 | $country_data .= '[ "'.$airport_item['arrival_airport_country'].'",'.$airport_item['airport_arrival_country_count'].'],'; |
76 | 76 | } |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | print '</thead>'; |
105 | 105 | print '<tbody>'; |
106 | 106 | $i = 1; |
107 | - foreach($airport_country_array as $airport_item) |
|
107 | + foreach ($airport_country_array as $airport_item) |
|
108 | 108 | { |
109 | 109 | print '<tr>'; |
110 | 110 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | var data = google.visualization.arrayToDataTable([ |
23 | 23 | ["'._("Country").'", "'._("# of times").'"], '; |
24 | 24 | $flightover_data = ''; |
25 | -foreach($flightover_array as $flightover_item) |
|
25 | +foreach ($flightover_array as $flightover_item) |
|
26 | 26 | { |
27 | 27 | $flightover_data .= '[ "'.$flightover_item['flight_country'].' ('.$flightover_item['flight_country_iso2'].')",'.$flightover_item['flight_count'].'],'; |
28 | 28 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | print '</thead>'; |
58 | 58 | print '<tbody>'; |
59 | 59 | $i = 1; |
60 | - foreach($flightover_array as $flightover_item) |
|
60 | + foreach ($flightover_array as $flightover_item) |
|
61 | 61 | { |
62 | 62 | print '<tr>'; |
63 | 63 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -3,10 +3,10 @@ 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; ?>/aircraft/<?php print $_GET['aircraft_type']; ?>" <?php if (strtolower($current_page) == "aircraft-detailed"){ print 'class="active"'; } ?>><?php echo _("Detailed"); ?></a></li> |
|
7 | - <li><a href="<?php print $globalURL; ?>/aircraft/statistics/registration/<?php print $_GET['aircraft_type']; ?>" <?php if (strtolower($current_page) == "aircraft-statistics-registration"){ print 'class="active"'; } ?>><?php echo _("Registration"); ?></a></li> |
|
6 | + <li><a href="<?php print $globalURL; ?>/aircraft/<?php print $_GET['aircraft_type']; ?>" <?php if (strtolower($current_page) == "aircraft-detailed") { print 'class="active"'; } ?>><?php echo _("Detailed"); ?></a></li> |
|
7 | + <li><a href="<?php print $globalURL; ?>/aircraft/statistics/registration/<?php print $_GET['aircraft_type']; ?>" <?php if (strtolower($current_page) == "aircraft-statistics-registration") { print 'class="active"'; } ?>><?php echo _("Registration"); ?></a></li> |
|
8 | 8 | <li class="dropdown"> |
9 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "aircraft-statistics-airline" || strtolower($current_page) == "aircraft-statistics-airline-country"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
9 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "aircraft-statistics-airline" || strtolower($current_page) == "aircraft-statistics-airline-country") { print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
10 | 10 | <?php echo _("Airline"); ?> <span class="caret"></span> |
11 | 11 | </a> |
12 | 12 | <ul class="dropdown-menu" role="menu"> |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | </ul> |
16 | 16 | </li> |
17 | 17 | <li class="dropdown"> |
18 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "aircraft-statistics-departure-airport" || strtolower($current_page) == "aircraft-statistics-departure-airport-country" || strtolower($current_page) == "aircraft-statistics-arrival-airport" || strtolower($current_page) == "aircraft-statistics-arrival-airport-country"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
18 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "aircraft-statistics-departure-airport" || strtolower($current_page) == "aircraft-statistics-departure-airport-country" || strtolower($current_page) == "aircraft-statistics-arrival-airport" || strtolower($current_page) == "aircraft-statistics-arrival-airport-country") { print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
19 | 19 | <?php echo _("Airport"); ?> <span class="caret"></span> |
20 | 20 | </a> |
21 | 21 | <ul class="dropdown-menu" role="menu"> |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | <li><a href="<?php print $globalURL; ?>/aircraft/statistics/arrival-airport-country/<?php print $_GET['aircraft_type']; ?>"><?php echo _("Arrival Airport by Country"); ?></a></li> |
26 | 26 | </ul> |
27 | 27 | </li> |
28 | - <li><a href="<?php print $globalURL; ?>/aircraft/statistics/route/<?php print $_GET['aircraft_type']; ?>" <?php if (strtolower($current_page) == "aircraft-statistics-route"){ print 'class="active"'; } ?>><?php echo _("Route"); ?></a></li> |
|
29 | - <li><a href="<?php print $globalURL; ?>/aircraft/statistics/time/<?php print $_GET['aircraft_type']; ?>" <?php if (strtolower($current_page) == "aircraft-statistics-time"){ print 'class="active"'; } ?>><?php echo ("Time"); ?></a></li> |
|
28 | + <li><a href="<?php print $globalURL; ?>/aircraft/statistics/route/<?php print $_GET['aircraft_type']; ?>" <?php if (strtolower($current_page) == "aircraft-statistics-route") { print 'class="active"'; } ?>><?php echo _("Route"); ?></a></li> |
|
29 | + <li><a href="<?php print $globalURL; ?>/aircraft/statistics/time/<?php print $_GET['aircraft_type']; ?>" <?php if (strtolower($current_page) == "aircraft-statistics-time") { print 'class="active"'; } ?>><?php echo ("Time"); ?></a></li> |
|
30 | 30 | </ul> |
31 | 31 | </div> |
32 | 32 | \ No newline at end of file |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | |
10 | 10 | $from_archive = false; |
11 | 11 | if (isset($_GET['ident'])) { |
12 | - $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING); |
|
12 | + $ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING); |
|
13 | 13 | $spotter_array = $SpotterLive->getLastLiveSpotterDataByIdent($ident); |
14 | 14 | if (empty($spotter_array)) { |
15 | 15 | $from_archive = true; |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | } |
18 | 18 | } |
19 | 19 | if (isset($_GET['flightaware_id'])) { |
20 | - $flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING); |
|
20 | + $flightaware_id = filter_input(INPUT_GET, 'flightaware_id', FILTER_SANITIZE_STRING); |
|
21 | 21 | $spotter_array = $SpotterLive->getLastLiveSpotterDataById($flightaware_id); |
22 | 22 | if (empty($spotter_array)) { |
23 | 23 | $from_archive = true; |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | if (isset($spotter_item['image_thumbnail']) && $spotter_item['image_thumbnail'] != "") |
34 | 34 | { |
35 | 35 | if ($spotter_item['image_source'] == 'flickr' || $spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart') { |
36 | - $image = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
|
36 | + $image = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']); |
|
37 | 37 | } else $image = $spotter_item['image_thumbnail']; |
38 | 38 | |
39 | 39 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | print '<div class="nomobile airports"><div class="airport"><span class="code"><a href="'.$globalURL.'/airport/'.$spotter_item['departure_airport'].'" target="_blank">'.$spotter_item['departure_airport'].'</a></span>'.$spotter_item['departure_airport_city'].' '.$spotter_item['departure_airport_country']; |
52 | 52 | if (isset($spotter_item['departure_airport_time'])) { |
53 | 53 | if ($spotter_item['departure_airport_time'] > 2460) { |
54 | - print '<br /><span class="time">'.date('H:m',$spotter_item['departure_airport_time']).'</span>'; |
|
54 | + print '<br /><span class="time">'.date('H:m', $spotter_item['departure_airport_time']).'</span>'; |
|
55 | 55 | } else { |
56 | 56 | print '<br /><span class="time">'.$spotter_item['departure_airport_time'].'</span>'; |
57 | 57 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | print '<span class="code"><a href="'.$globalURL.'/airport/'.$spotter_item['arrival_airport'].'" target="_blank">'.$spotter_item['arrival_airport'].'</a></span>'.$spotter_item['arrival_airport_city'].' '.$spotter_item['arrival_airport_country']; |
61 | 61 | if (isset($spotter_item['arrival_airport_time'])) { |
62 | 62 | if ($spotter_item['arrival_airport_time'] > 2460) { |
63 | - print '<br /><span class="time">'.date('H:m',$spotter_item['arrival_airport_time']).'</span>'; |
|
63 | + print '<br /><span class="time">'.date('H:m', $spotter_item['arrival_airport_time']).'</span>'; |
|
64 | 64 | } else { |
65 | 65 | print '<br /><span class="time">'.$spotter_item['arrival_airport_time'].'</span>'; |
66 | 66 | } |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | |
124 | 124 | if (isset($globalphpVMS) && $globalphpVMS && isset($globalVATSIM) && $globalVATSIM && isset($globalIVAO) && $globalIVAO && isset($spotter_item['format_source']) && $spotter_item['format_source'] != '' && $spotter_item['format_source'] != 'pireps') print '<div class="waypoints"><span>'._("Source").'</span>'.$spotter_item['format_source'].'</div>'; |
125 | 125 | if (isset($spotter_item['waypoints']) && $spotter_item['waypoints'] != '') print '<div class="waypoints"><span>'._("Route").'</span>'.$spotter_item['waypoints'].'</div>'; |
126 | -if (isset($spotter_item['acars']['message'])) print '<div class="acars"><span>'._("Latest ACARS message").'</span>'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'<br/>',$spotter_item['acars']['message'])).'</div>'; |
|
126 | +if (isset($spotter_item['acars']['message'])) print '<div class="acars"><span>'._("Latest ACARS message").'</span>'.trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '<br/>', $spotter_item['acars']['message'])).'</div>'; |
|
127 | 127 | if (isset($spotter_item['squawk']) && $spotter_item['squawk'] != '' && $spotter_item['squawk'] != 0) print '<div class="bottom">'._("Squawk:").' '.$spotter_item['squawk'].' - '.$spotter_item['squawk_usage'].'</div>'; |
128 | 128 | print '</div>'; |
129 | 129 | ?> |
@@ -8,12 +8,12 @@ discard block |
||
8 | 8 | require_once('require/class.Spotter.php'); |
9 | 9 | require_once('require/class.Language.php'); |
10 | 10 | $Spotter = new Spotter(); |
11 | -$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
11 | +$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
12 | 12 | $spotter_array = $Spotter->getSpotterDataByRoute($_GET['departure_airport'], $_GET['arrival_airport'], "0,1", $sort); |
13 | 13 | |
14 | 14 | if (!empty($spotter_array)) |
15 | 15 | { |
16 | - $title = sprintf(_("Most Common Airlines by Country between %s (%s), %s - %s (%s), %s"),$spotter_array[0]['departure_airport_name'],$spotter_array[0]['departure_airport_icao'],$spotter_array[0]['departure_airport_country'],$spotter_array[0]['arrival_airport_name'],$spotter_array[0]['arrival_airport_icao'],$spotter_array[0]['arrival_airport_country']); |
|
16 | + $title = sprintf(_("Most Common Airlines by Country between %s (%s), %s - %s (%s), %s"), $spotter_array[0]['departure_airport_name'], $spotter_array[0]['departure_airport_icao'], $spotter_array[0]['departure_airport_country'], $spotter_array[0]['arrival_airport_name'], $spotter_array[0]['arrival_airport_icao'], $spotter_array[0]['arrival_airport_country']); |
|
17 | 17 | require_once('header.php'); |
18 | 18 | print '<div class="info column">'; |
19 | 19 | print '<h1>'._("Flights between").' '.$spotter_array[0]['departure_airport_name'].' ('.$spotter_array[0]['departure_airport_icao'].'), '.$spotter_array[0]['departure_airport_country'].' - '.$spotter_array[0]['arrival_airport_name'].' ('.$spotter_array[0]['arrival_airport_icao'].'), '.$spotter_array[0]['arrival_airport_country'].'</h1>'; |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | include('route-sub-menu.php'); |
25 | 25 | print '<div class="column">'; |
26 | 26 | print '<h2>'._("Most Common Airlines by Country").'</h2>'; |
27 | - print '<p>'.sprintf(_("The statistic below shows the most common airlines by Country of origin of flights between <strong>%s (%s), %s</strong> and <strong>%s (%s), %s</strong>."),$spotter_array[0]['departure_airport_name'],$spotter_array[0]['departure_airport_icao'],$spotter_array[0]['departure_airport_country'],$spotter_array[0]['arrival_airport_name'],$spotter_array[0]['arrival_airport_icao'],$spotter_array[0]['arrival_airport_country']).'</p>'; |
|
27 | + print '<p>'.sprintf(_("The statistic below shows the most common airlines by Country of origin of flights between <strong>%s (%s), %s</strong> and <strong>%s (%s), %s</strong>."), $spotter_array[0]['departure_airport_name'], $spotter_array[0]['departure_airport_icao'], $spotter_array[0]['departure_airport_country'], $spotter_array[0]['arrival_airport_name'], $spotter_array[0]['arrival_airport_icao'], $spotter_array[0]['arrival_airport_country']).'</p>'; |
|
28 | 28 | |
29 | 29 | $airline_array = $Spotter->countAllAirlineCountriesByRoute($_GET['departure_airport'], $_GET['arrival_airport']); |
30 | 30 | print '<script type="text/javascript" src="https://www.google.com/jsapi"></script>'; |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | var data = google.visualization.arrayToDataTable([ |
37 | 37 | ["'._("Country").'", "'._("# of times").'"], '; |
38 | 38 | $country_data = ''; |
39 | - foreach($airline_array as $airline_item) |
|
39 | + foreach ($airline_array as $airline_item) |
|
40 | 40 | { |
41 | 41 | $country_data .= '[ "'.$airline_item['airline_country'].'",'.$airline_item['airline_country_count'].'],'; |
42 | 42 | } |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | print '</thead>'; |
71 | 71 | print '<tbody>'; |
72 | 72 | $i = 1; |
73 | - foreach($airline_array as $airline_item) |
|
73 | + foreach ($airline_array as $airline_item) |
|
74 | 74 | { |
75 | 75 | print '<tr>'; |
76 | 76 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -14,11 +14,11 @@ discard block |
||
14 | 14 | try { |
15 | 15 | $sth = $Connection->db->prepare($query); |
16 | 16 | $sth->execute(); |
17 | - } catch(PDOException $e) { |
|
17 | + } catch (PDOException $e) { |
|
18 | 18 | return "error : ".$e->getMessage()."\n"; |
19 | 19 | } |
20 | 20 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
21 | - $Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']); |
|
21 | + $Schedule->addSchedule($row['ident'], $row['departure_airport_icao'], $row['departure_airport_time'], $row['arrival_airport_icao'], $row['arrival_airport_time']); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | } |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | try { |
51 | 51 | $sth = $Connection->db->prepare($query); |
52 | 52 | $sth->execute(); |
53 | - } catch(PDOException $e) { |
|
53 | + } catch (PDOException $e) { |
|
54 | 54 | return "error (add new columns to routes table) : ".$e->getMessage()."\n"; |
55 | 55 | } |
56 | 56 | // Copy schedules data to routes table |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | try { |
61 | 61 | $sth = $Connection->db->prepare($query); |
62 | 62 | $sth->execute(); |
63 | - } catch(PDOException $e) { |
|
63 | + } catch (PDOException $e) { |
|
64 | 64 | return "error (delete schedule table) : ".$e->getMessage()."\n"; |
65 | 65 | } |
66 | 66 | // Add source column |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | try { |
69 | 69 | $sth = $Connection->db->prepare($query); |
70 | 70 | $sth->execute(); |
71 | - } catch(PDOException $e) { |
|
71 | + } catch (PDOException $e) { |
|
72 | 72 | return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n"; |
73 | 73 | } |
74 | 74 | // Delete unused column |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | try { |
77 | 77 | $sth = $Connection->db->prepare($query); |
78 | 78 | $sth->execute(); |
79 | - } catch(PDOException $e) { |
|
79 | + } catch (PDOException $e) { |
|
80 | 80 | return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n"; |
81 | 81 | } |
82 | 82 | // Add ModeS column |
@@ -84,14 +84,14 @@ discard block |
||
84 | 84 | try { |
85 | 85 | $sth = $Connection->db->prepare($query); |
86 | 86 | $sth->execute(); |
87 | - } catch(PDOException $e) { |
|
87 | + } catch (PDOException $e) { |
|
88 | 88 | return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n"; |
89 | 89 | } |
90 | 90 | $query = "ALTER TABLE `spotter_live` ADD `ModeS` VARCHAR(255)"; |
91 | 91 | try { |
92 | 92 | $sth = $Connection->db->prepare($query); |
93 | 93 | $sth->execute(); |
94 | - } catch(PDOException $e) { |
|
94 | + } catch (PDOException $e) { |
|
95 | 95 | return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n"; |
96 | 96 | } |
97 | 97 | // Add auto_increment for aircraft_modes |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | try { |
100 | 100 | $sth = $Connection->db->prepare($query); |
101 | 101 | $sth->execute(); |
102 | - } catch(PDOException $e) { |
|
102 | + } catch (PDOException $e) { |
|
103 | 103 | return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n"; |
104 | 104 | } |
105 | 105 | $error = ''; |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | try { |
111 | 111 | $sth = $Connection->db->prepare($query); |
112 | 112 | $sth->execute(); |
113 | - } catch(PDOException $e) { |
|
113 | + } catch (PDOException $e) { |
|
114 | 114 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
115 | 115 | } |
116 | 116 | return $error; |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | try { |
124 | 124 | $sth = $Connection->db->prepare($query); |
125 | 125 | $sth->execute(); |
126 | - } catch(PDOException $e) { |
|
126 | + } catch (PDOException $e) { |
|
127 | 127 | return "error (add new columns to routes table) : ".$e->getMessage()."\n"; |
128 | 128 | } |
129 | 129 | $error = ''; |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | try { |
135 | 135 | $sth = $Connection->db->prepare($query); |
136 | 136 | $sth->execute(); |
137 | - } catch(PDOException $e) { |
|
137 | + } catch (PDOException $e) { |
|
138 | 138 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
139 | 139 | } |
140 | 140 | return $error; |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | try { |
148 | 148 | $sth = $Connection->db->prepare($query); |
149 | 149 | $sth->execute(); |
150 | - } catch(PDOException $e) { |
|
150 | + } catch (PDOException $e) { |
|
151 | 151 | return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n"; |
152 | 152 | } |
153 | 153 | // Add image_source_website column to spotter_image |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | try { |
156 | 156 | $sth = $Connection->db->prepare($query); |
157 | 157 | $sth->execute(); |
158 | - } catch(PDOException $e) { |
|
158 | + } catch (PDOException $e) { |
|
159 | 159 | return "error (add new columns to spotter_image) : ".$e->getMessage()."\n"; |
160 | 160 | } |
161 | 161 | $error = ''; |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | try { |
165 | 165 | $sth = $Connection->db->prepare($query); |
166 | 166 | $sth->execute(); |
167 | - } catch(PDOException $e) { |
|
167 | + } catch (PDOException $e) { |
|
168 | 168 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
169 | 169 | } |
170 | 170 | return $error; |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | try { |
183 | 183 | $sth = $Connection->db->prepare($query); |
184 | 184 | $sth->execute(); |
185 | - } catch(PDOException $e) { |
|
185 | + } catch (PDOException $e) { |
|
186 | 186 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
187 | 187 | } |
188 | 188 | } |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | try { |
197 | 197 | $sth = $Connection->db->prepare($query); |
198 | 198 | $sth->execute(); |
199 | - } catch(PDOException $e) { |
|
199 | + } catch (PDOException $e) { |
|
200 | 200 | return "error (add new columns to translation) : ".$e->getMessage()."\n"; |
201 | 201 | } |
202 | 202 | // Add aircraft_shadow column to aircraft |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | try { |
205 | 205 | $sth = $Connection->db->prepare($query); |
206 | 206 | $sth->execute(); |
207 | - } catch(PDOException $e) { |
|
207 | + } catch (PDOException $e) { |
|
208 | 208 | return "error (add new column to aircraft) : ".$e->getMessage()."\n"; |
209 | 209 | } |
210 | 210 | // Add aircraft_shadow column to spotter_live |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | try { |
213 | 213 | $sth = $Connection->db->prepare($query); |
214 | 214 | $sth->execute(); |
215 | - } catch(PDOException $e) { |
|
215 | + } catch (PDOException $e) { |
|
216 | 216 | return "error (add new column to spotter_live) : ".$e->getMessage()."\n"; |
217 | 217 | } |
218 | 218 | $error = ''; |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | try { |
226 | 226 | $sth = $Connection->db->prepare($query); |
227 | 227 | $sth->execute(); |
228 | - } catch(PDOException $e) { |
|
228 | + } catch (PDOException $e) { |
|
229 | 229 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
230 | 230 | } |
231 | 231 | return $error; |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | |
234 | 234 | private static function update_from_6() { |
235 | 235 | $Connection = new Connection(); |
236 | - if (!$Connection−>indexExists('spotter_output','flightaware_id')) { |
|
236 | + if (!$Connection− > indexExists('spotter_output', 'flightaware_id')) { |
|
237 | 237 | $query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id); |
238 | 238 | ALTER TABLE spotter_output ADD INDEX(date); |
239 | 239 | ALTER TABLE spotter_output ADD INDEX(ident); |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | try { |
251 | 251 | $sth = $Connection->db->prepare($query); |
252 | 252 | $sth->execute(); |
253 | - } catch(PDOException $e) { |
|
253 | + } catch (PDOException $e) { |
|
254 | 254 | return "error (add some indexes) : ".$e->getMessage()."\n"; |
255 | 255 | } |
256 | 256 | } |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | try { |
266 | 266 | $sth = $Connection->db->prepare($query); |
267 | 267 | $sth->execute(); |
268 | - } catch(PDOException $e) { |
|
268 | + } catch (PDOException $e) { |
|
269 | 269 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
270 | 270 | } |
271 | 271 | return $error; |
@@ -274,12 +274,12 @@ discard block |
||
274 | 274 | private static function update_from_7() { |
275 | 275 | global $globalDBname, $globalDBdriver; |
276 | 276 | $Connection = new Connection(); |
277 | - $query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL; |
|
277 | + $query = "ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL; |
|
278 | 278 | ALTER TABLE spotter_output ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;"; |
279 | 279 | try { |
280 | 280 | $sth = $Connection->db->prepare($query); |
281 | 281 | $sth->execute(); |
282 | - } catch(PDOException $e) { |
|
282 | + } catch (PDOException $e) { |
|
283 | 283 | return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; |
284 | 284 | } |
285 | 285 | if ($globalDBdriver == 'mysql') { |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | try { |
288 | 288 | $sth = $Connection->db->prepare($query); |
289 | 289 | $sth->execute(); |
290 | - } catch(PDOException $e) { |
|
290 | + } catch (PDOException $e) { |
|
291 | 291 | return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n"; |
292 | 292 | } |
293 | 293 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -299,15 +299,15 @@ discard block |
||
299 | 299 | DROP TABLE spotter_archive; |
300 | 300 | RENAME TABLE copy TO spotter_archive;"; |
301 | 301 | } else { |
302 | - $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
302 | + $query = "ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
303 | 303 | } |
304 | 304 | } else { |
305 | - $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
305 | + $query = "ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
306 | 306 | } |
307 | 307 | try { |
308 | 308 | $sth = $Connection->db->prepare($query); |
309 | 309 | $sth->execute(); |
310 | - } catch(PDOException $e) { |
|
310 | + } catch (PDOException $e) { |
|
311 | 311 | return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n"; |
312 | 312 | } |
313 | 313 | |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | try { |
321 | 321 | $sth = $Connection->db->prepare($query); |
322 | 322 | $sth->execute(); |
323 | - } catch(PDOException $e) { |
|
323 | + } catch (PDOException $e) { |
|
324 | 324 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
325 | 325 | } |
326 | 326 | return $error; |
@@ -339,14 +339,14 @@ discard block |
||
339 | 339 | try { |
340 | 340 | $sth = $Connection->db->prepare($query); |
341 | 341 | $sth->execute(); |
342 | - } catch(PDOException $e) { |
|
342 | + } catch (PDOException $e) { |
|
343 | 343 | return "error (insert last_update values) : ".$e->getMessage()."\n"; |
344 | 344 | } |
345 | 345 | $query = "UPDATE `config` SET `value` = '9' WHERE `name` = 'schema_version'"; |
346 | 346 | try { |
347 | 347 | $sth = $Connection->db->prepare($query); |
348 | 348 | $sth->execute(); |
349 | - } catch(PDOException $e) { |
|
349 | + } catch (PDOException $e) { |
|
350 | 350 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
351 | 351 | } |
352 | 352 | return $error; |
@@ -354,12 +354,12 @@ discard block |
||
354 | 354 | |
355 | 355 | private static function update_from_9() { |
356 | 356 | $Connection = new Connection(); |
357 | - $query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL; |
|
357 | + $query = "ALTER TABLE spotter_live ADD verticalrate INT(11) NULL; |
|
358 | 358 | ALTER TABLE spotter_output ADD verticalrate INT(11) NULL;"; |
359 | 359 | try { |
360 | 360 | $sth = $Connection->db->prepare($query); |
361 | 361 | $sth->execute(); |
362 | - } catch(PDOException $e) { |
|
362 | + } catch (PDOException $e) { |
|
363 | 363 | return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; |
364 | 364 | } |
365 | 365 | $error = ''; |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | try { |
372 | 372 | $sth = $Connection->db->prepare($query); |
373 | 373 | $sth->execute(); |
374 | - } catch(PDOException $e) { |
|
374 | + } catch (PDOException $e) { |
|
375 | 375 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
376 | 376 | } |
377 | 377 | return $error; |
@@ -379,11 +379,11 @@ discard block |
||
379 | 379 | |
380 | 380 | private static function update_from_10() { |
381 | 381 | $Connection = new Connection(); |
382 | - $query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL"; |
|
382 | + $query = "ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL"; |
|
383 | 383 | try { |
384 | 384 | $sth = $Connection->db->prepare($query); |
385 | 385 | $sth->execute(); |
386 | - } catch(PDOException $e) { |
|
386 | + } catch (PDOException $e) { |
|
387 | 387 | return "error (add new enum to ATC table) : ".$e->getMessage()."\n"; |
388 | 388 | } |
389 | 389 | $error = ''; |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | try { |
402 | 402 | $sth = $Connection->db->prepare($query); |
403 | 403 | $sth->execute(); |
404 | - } catch(PDOException $e) { |
|
404 | + } catch (PDOException $e) { |
|
405 | 405 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
406 | 406 | } |
407 | 407 | return $error; |
@@ -409,18 +409,18 @@ discard block |
||
409 | 409 | |
410 | 410 | private static function update_from_11() { |
411 | 411 | $Connection = new Connection(); |
412 | - $query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)"; |
|
412 | + $query = "ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)"; |
|
413 | 413 | try { |
414 | 414 | $sth = $Connection->db->prepare($query); |
415 | 415 | $sth->execute(); |
416 | - } catch(PDOException $e) { |
|
416 | + } catch (PDOException $e) { |
|
417 | 417 | return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n"; |
418 | 418 | } |
419 | - $query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
419 | + $query = "ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
420 | 420 | try { |
421 | 421 | $sth = $Connection->db->prepare($query); |
422 | 422 | $sth->execute(); |
423 | - } catch(PDOException $e) { |
|
423 | + } catch (PDOException $e) { |
|
424 | 424 | return "error (format_source column to spotter_live) : ".$e->getMessage()."\n"; |
425 | 425 | } |
426 | 426 | if ($globalDBdriver == 'mysql') { |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | try { |
429 | 429 | $sth = $Connection->db->prepare($query); |
430 | 430 | $sth->execute(); |
431 | - } catch(PDOException $e) { |
|
431 | + } catch (PDOException $e) { |
|
432 | 432 | return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n"; |
433 | 433 | } |
434 | 434 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -440,15 +440,15 @@ discard block |
||
440 | 440 | DROP TABLE spotter_archive; |
441 | 441 | RENAME TABLE copy TO spotter_archive;"; |
442 | 442 | } else { |
443 | - $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
443 | + $query = "ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
444 | 444 | } |
445 | 445 | } else { |
446 | - $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
446 | + $query = "ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
447 | 447 | } |
448 | 448 | try { |
449 | 449 | $sth = $Connection->db->prepare($query); |
450 | 450 | $sth->execute(); |
451 | - } catch(PDOException $e) { |
|
451 | + } catch (PDOException $e) { |
|
452 | 452 | return "error (add columns to spotter_archive) : ".$e->getMessage()."\n"; |
453 | 453 | } |
454 | 454 | |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | try { |
459 | 459 | $sth = $Connection->db->prepare($query); |
460 | 460 | $sth->execute(); |
461 | - } catch(PDOException $e) { |
|
461 | + } catch (PDOException $e) { |
|
462 | 462 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
463 | 463 | } |
464 | 464 | return $error; |
@@ -486,7 +486,7 @@ discard block |
||
486 | 486 | try { |
487 | 487 | $sth = $Connection->db->prepare($query); |
488 | 488 | $sth->execute(); |
489 | - } catch(PDOException $e) { |
|
489 | + } catch (PDOException $e) { |
|
490 | 490 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
491 | 491 | } |
492 | 492 | return $error; |
@@ -494,11 +494,11 @@ discard block |
||
494 | 494 | |
495 | 495 | private static function update_from_13() { |
496 | 496 | $Connection = new Connection(); |
497 | - $query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)"; |
|
497 | + $query = "ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)"; |
|
498 | 498 | try { |
499 | 499 | $sth = $Connection->db->prepare($query); |
500 | 500 | $sth->execute(); |
501 | - } catch(PDOException $e) { |
|
501 | + } catch (PDOException $e) { |
|
502 | 502 | return "error (update spotter_archive_output) : ".$e->getMessage()."\n"; |
503 | 503 | } |
504 | 504 | |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | try { |
508 | 508 | $sth = $Connection->db->prepare($query); |
509 | 509 | $sth->execute(); |
510 | - } catch(PDOException $e) { |
|
510 | + } catch (PDOException $e) { |
|
511 | 511 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
512 | 512 | } |
513 | 513 | return $error; |
@@ -523,7 +523,7 @@ discard block |
||
523 | 523 | try { |
524 | 524 | $sth = $Connection->db->prepare($query); |
525 | 525 | $sth->execute(); |
526 | - } catch(PDOException $e) { |
|
526 | + } catch (PDOException $e) { |
|
527 | 527 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
528 | 528 | } |
529 | 529 | return $error; |
@@ -534,11 +534,11 @@ discard block |
||
534 | 534 | $Connection = new Connection(); |
535 | 535 | $error = ''; |
536 | 536 | // Add tables |
537 | - $query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP"; |
|
537 | + $query = "ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP"; |
|
538 | 538 | try { |
539 | 539 | $sth = $Connection->db->prepare($query); |
540 | 540 | $sth->execute(); |
541 | - } catch(PDOException $e) { |
|
541 | + } catch (PDOException $e) { |
|
542 | 542 | return "error (update stats) : ".$e->getMessage()."\n"; |
543 | 543 | } |
544 | 544 | if ($error != '') return $error; |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | try { |
547 | 547 | $sth = $Connection->db->prepare($query); |
548 | 548 | $sth->execute(); |
549 | - } catch(PDOException $e) { |
|
549 | + } catch (PDOException $e) { |
|
550 | 550 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
551 | 551 | } |
552 | 552 | return $error; |
@@ -563,7 +563,7 @@ discard block |
||
563 | 563 | try { |
564 | 564 | $sth = $Connection->db->prepare($query); |
565 | 565 | $sth->execute(); |
566 | - } catch(PDOException $e) { |
|
566 | + } catch (PDOException $e) { |
|
567 | 567 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
568 | 568 | } |
569 | 569 | return $error; |
@@ -579,7 +579,7 @@ discard block |
||
579 | 579 | try { |
580 | 580 | $sth = $Connection->db->prepare($query); |
581 | 581 | $sth->execute(); |
582 | - } catch(PDOException $e) { |
|
582 | + } catch (PDOException $e) { |
|
583 | 583 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
584 | 584 | } |
585 | 585 | return $error; |
@@ -592,7 +592,7 @@ discard block |
||
592 | 592 | try { |
593 | 593 | $sth = $Connection->db->prepare($query); |
594 | 594 | $sth->execute(); |
595 | - } catch(PDOException $e) { |
|
595 | + } catch (PDOException $e) { |
|
596 | 596 | return "error (update stats) : ".$e->getMessage()."\n"; |
597 | 597 | } |
598 | 598 | if ($error != '') return $error; |
@@ -600,7 +600,7 @@ discard block |
||
600 | 600 | try { |
601 | 601 | $sth = $Connection->db->prepare($query); |
602 | 602 | $sth->execute(); |
603 | - } catch(PDOException $e) { |
|
603 | + } catch (PDOException $e) { |
|
604 | 604 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
605 | 605 | } |
606 | 606 | return $error; |
@@ -617,7 +617,7 @@ discard block |
||
617 | 617 | try { |
618 | 618 | $sth = $Connection->db->prepare($query); |
619 | 619 | $sth->execute(); |
620 | - } catch(PDOException $e) { |
|
620 | + } catch (PDOException $e) { |
|
621 | 621 | return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n"; |
622 | 622 | } |
623 | 623 | |
@@ -626,7 +626,7 @@ discard block |
||
626 | 626 | try { |
627 | 627 | $sth = $Connection->db->prepare($query); |
628 | 628 | $sth->execute(); |
629 | - } catch(PDOException $e) { |
|
629 | + } catch (PDOException $e) { |
|
630 | 630 | return "error (add over_country) : ".$e->getMessage()."\n"; |
631 | 631 | } |
632 | 632 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
@@ -634,7 +634,7 @@ discard block |
||
634 | 634 | try { |
635 | 635 | $sth = $Connection->db->prepare($query); |
636 | 636 | $sth->execute(); |
637 | - } catch(PDOException $e) { |
|
637 | + } catch (PDOException $e) { |
|
638 | 638 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
639 | 639 | } |
640 | 640 | if ($error != '') return $error; |
@@ -642,7 +642,7 @@ discard block |
||
642 | 642 | try { |
643 | 643 | $sth = $Connection->db->prepare($query); |
644 | 644 | $sth->execute(); |
645 | - } catch(PDOException $e) { |
|
645 | + } catch (PDOException $e) { |
|
646 | 646 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
647 | 647 | } |
648 | 648 | return $error; |
@@ -662,7 +662,7 @@ discard block |
||
662 | 662 | try { |
663 | 663 | $sth = $Connection->db->prepare($query); |
664 | 664 | $sth->execute(); |
665 | - } catch(PDOException $e) { |
|
665 | + } catch (PDOException $e) { |
|
666 | 666 | return "error (add over_country) : ".$e->getMessage()."\n"; |
667 | 667 | } |
668 | 668 | if ($error != '') return $error; |
@@ -677,7 +677,7 @@ discard block |
||
677 | 677 | try { |
678 | 678 | $sth = $Connection->db->prepare($query); |
679 | 679 | $sth->execute(); |
680 | - } catch(PDOException $e) { |
|
680 | + } catch (PDOException $e) { |
|
681 | 681 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
682 | 682 | } |
683 | 683 | return $error; |
@@ -691,7 +691,7 @@ discard block |
||
691 | 691 | try { |
692 | 692 | $sth = $Connection->db->prepare($query); |
693 | 693 | $sth->execute(); |
694 | - } catch(PDOException $e) { |
|
694 | + } catch (PDOException $e) { |
|
695 | 695 | return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n"; |
696 | 696 | } |
697 | 697 | if ($error != '') return $error; |
@@ -699,7 +699,7 @@ discard block |
||
699 | 699 | try { |
700 | 700 | $sth = $Connection->db->prepare($query); |
701 | 701 | $sth->execute(); |
702 | - } catch(PDOException $e) { |
|
702 | + } catch (PDOException $e) { |
|
703 | 703 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
704 | 704 | } |
705 | 705 | return $error; |
@@ -720,7 +720,7 @@ discard block |
||
720 | 720 | try { |
721 | 721 | $sth = $Connection->db->prepare($query); |
722 | 722 | $sth->execute(); |
723 | - } catch(PDOException $e) { |
|
723 | + } catch (PDOException $e) { |
|
724 | 724 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
725 | 725 | } |
726 | 726 | return $error; |
@@ -743,7 +743,7 @@ discard block |
||
743 | 743 | try { |
744 | 744 | $sth = $Connection->db->prepare($query); |
745 | 745 | $sth->execute(); |
746 | - } catch(PDOException $e) { |
|
746 | + } catch (PDOException $e) { |
|
747 | 747 | return "error : ".$e->getMessage()."\n"; |
748 | 748 | } |
749 | 749 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -4,21 +4,21 @@ discard block |
||
4 | 4 | |
5 | 5 | class create_db { |
6 | 6 | public static function import_file($filename) { |
7 | - $filename = filter_var($filename,FILTER_SANITIZE_STRING); |
|
7 | + $filename = filter_var($filename, FILTER_SANITIZE_STRING); |
|
8 | 8 | $Connection = new Connection(); |
9 | 9 | //Connection::$db->beginTransaction(); |
10 | 10 | $templine = ''; |
11 | 11 | $lines = file($filename); |
12 | 12 | foreach ($lines as $line) |
13 | 13 | { |
14 | - if (substr($line,0,2) == '--' || $line == '') continue; |
|
14 | + if (substr($line, 0, 2) == '--' || $line == '') continue; |
|
15 | 15 | $templine .= $line; |
16 | - if (substr(trim($line), -1,1) == ';') |
|
16 | + if (substr(trim($line), -1, 1) == ';') |
|
17 | 17 | { |
18 | 18 | try { |
19 | 19 | $sth = $Connection->db->prepare($templine); |
20 | 20 | $sth->execute(); |
21 | - } catch(PDOException $e) { |
|
21 | + } catch (PDOException $e) { |
|
22 | 22 | return "error (import ".$filename.") : ".$e->getMessage()."\n"; |
23 | 23 | } |
24 | 24 | $templine = ''; |
@@ -33,27 +33,27 @@ discard block |
||
33 | 33 | $error = ''; |
34 | 34 | $dh = opendir($directory); |
35 | 35 | //foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)) as $filename) |
36 | - while(false !== ($filename = readdir($dh))) |
|
36 | + while (false !== ($filename = readdir($dh))) |
|
37 | 37 | { |
38 | - if (preg_match('/\.sql$/',$filename)) $error .= create_db::import_file($directory.$filename); |
|
38 | + if (preg_match('/\.sql$/', $filename)) $error .= create_db::import_file($directory.$filename); |
|
39 | 39 | } |
40 | 40 | return $error; |
41 | 41 | } |
42 | 42 | |
43 | - public static function create_database($root,$root_pass,$user,$pass,$db,$db_type,$host) { |
|
44 | - $root = filter_var($root,FILTER_SANITIZE_STRING); |
|
45 | - $root_pass = filter_var($root_pass,FILTER_SANITIZE_STRING); |
|
46 | - $user = filter_var($user,FILTER_SANITIZE_STRING); |
|
47 | - $password = filter_var($pass,FILTER_SANITIZE_STRING); |
|
48 | - $db = filter_var($db,FILTER_SANITIZE_STRING); |
|
49 | - $db_type = filter_var($db_type,FILTER_SANITIZE_STRING); |
|
50 | - $host = filter_var($host,FILTER_SANITIZE_STRING); |
|
43 | + public static function create_database($root, $root_pass, $user, $pass, $db, $db_type, $host) { |
|
44 | + $root = filter_var($root, FILTER_SANITIZE_STRING); |
|
45 | + $root_pass = filter_var($root_pass, FILTER_SANITIZE_STRING); |
|
46 | + $user = filter_var($user, FILTER_SANITIZE_STRING); |
|
47 | + $password = filter_var($pass, FILTER_SANITIZE_STRING); |
|
48 | + $db = filter_var($db, FILTER_SANITIZE_STRING); |
|
49 | + $db_type = filter_var($db_type, FILTER_SANITIZE_STRING); |
|
50 | + $host = filter_var($host, FILTER_SANITIZE_STRING); |
|
51 | 51 | // Dirty hack |
52 | 52 | if ($host != 'localhost' && $host != '127.0.0.1') { |
53 | 53 | $grantright = $_SERVER['SERVER_ADDR']; |
54 | 54 | } else $grantright = 'localhost'; |
55 | 55 | try { |
56 | - $dbh = new PDO($db_type.':host='.$host,$root,$root_pass); |
|
56 | + $dbh = new PDO($db_type.':host='.$host, $root, $root_pass); |
|
57 | 57 | $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
58 | 58 | if ($db_type == 'mysql') { |
59 | 59 | $dbh->exec('CREATE DATABASE IF NOT EXISTS `'.$db.'`;GRANT ALL ON `'.$db."`.* TO '".$user."'@'".$grantright."' IDENTIFIED BY '".$password."';FLUSH PRIVILEGES;"); |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | $dbh->exec("CREATE USER ".$user." WITH PASSWORD '".$password."'; |
64 | 64 | GRANT ALL PRIVILEGES ON DATABASE ".$db." TO ".$user.";"); |
65 | 65 | } |
66 | - } catch(PDOException $e) { |
|
66 | + } catch (PDOException $e) { |
|
67 | 67 | $dbh = null; |
68 | 68 | return "error : ".$e->getMessage(); |
69 | 69 | } |
@@ -10,37 +10,37 @@ discard block |
||
10 | 10 | |
11 | 11 | # to document: CGIParams |
12 | 12 | |
13 | -function sparql_connect( $endpoint ) { return new sparql_connection( $endpoint ); } |
|
13 | +function sparql_connect($endpoint) { return new sparql_connection($endpoint); } |
|
14 | 14 | |
15 | -function sparql_ns( $short, $long, $db = null ) { return _sparql_a_connection( $db )->ns( $short, $long ); } |
|
16 | -function sparql_query( $sparql, $db = null ) { return _sparql_a_connection( $db )->query( $sparql ); } |
|
17 | -function sparql_errno( $db = null ) { return _sparql_a_connection( $db )->errno(); } |
|
18 | -function sparql_error( $db = null ) { return _sparql_a_connection( $db )->error(); } |
|
15 | +function sparql_ns($short, $long, $db = null) { return _sparql_a_connection($db)->ns($short, $long); } |
|
16 | +function sparql_query($sparql, $db = null) { return _sparql_a_connection($db)->query($sparql); } |
|
17 | +function sparql_errno($db = null) { return _sparql_a_connection($db)->errno(); } |
|
18 | +function sparql_error($db = null) { return _sparql_a_connection($db)->error(); } |
|
19 | 19 | |
20 | -function sparql_fetch_array( $result ) { return $result->fetch_array(); } |
|
21 | -function sparql_num_rows( $result ) { return $result->num_rows(); } |
|
22 | -function sparql_field_array( $result ) { return $result->field_array(); } |
|
23 | -function sparql_field_name( $result, $i ) { return $result->field_name( $i ); } |
|
20 | +function sparql_fetch_array($result) { return $result->fetch_array(); } |
|
21 | +function sparql_num_rows($result) { return $result->num_rows(); } |
|
22 | +function sparql_field_array($result) { return $result->field_array(); } |
|
23 | +function sparql_field_name($result, $i) { return $result->field_name($i); } |
|
24 | 24 | |
25 | -function sparql_fetch_all( $result ) { return $result->fetch_all(); } |
|
25 | +function sparql_fetch_all($result) { return $result->fetch_all(); } |
|
26 | 26 | |
27 | -function sparql_get( $endpoint, $sparql ) |
|
27 | +function sparql_get($endpoint, $sparql) |
|
28 | 28 | { |
29 | - $db = sparql_connect( $endpoint ); |
|
30 | - if( !$db ) { return; } |
|
31 | - $result = $db->query( $sparql ); |
|
32 | - if( !$result ) { return; } |
|
29 | + $db = sparql_connect($endpoint); |
|
30 | + if (!$db) { return; } |
|
31 | + $result = $db->query($sparql); |
|
32 | + if (!$result) { return; } |
|
33 | 33 | return $result->fetch_all(); |
34 | 34 | } |
35 | 35 | |
36 | -function _sparql_a_connection( $db ) |
|
36 | +function _sparql_a_connection($db) |
|
37 | 37 | { |
38 | 38 | global $sparql_last_connection; |
39 | - if( !isset( $db ) ) |
|
39 | + if (!isset($db)) |
|
40 | 40 | { |
41 | - if( !isset( $sparql_last_connection ) ) |
|
41 | + if (!isset($sparql_last_connection)) |
|
42 | 42 | { |
43 | - print( "No currect SPARQL connection (connection) in play!" ); |
|
43 | + print("No currect SPARQL connection (connection) in play!"); |
|
44 | 44 | return; |
45 | 45 | } |
46 | 46 | $db = $sparql_last_connection; |
@@ -62,14 +62,14 @@ discard block |
||
62 | 62 | var $params = null; |
63 | 63 | # capabilities are either true, false or null if not yet tested. |
64 | 64 | |
65 | - function __construct( $endpoint ) |
|
65 | + function __construct($endpoint) |
|
66 | 66 | { |
67 | 67 | $this->endpoint = $endpoint; |
68 | 68 | global $sparql_last_connection; |
69 | 69 | $sparql_last_connection = $this; |
70 | 70 | } |
71 | 71 | |
72 | - function ns( $short, $long ) |
|
72 | + function ns($short, $long) |
|
73 | 73 | { |
74 | 74 | $this->ns[$short] = $long; |
75 | 75 | } |
@@ -77,77 +77,77 @@ discard block |
||
77 | 77 | function errno() { return $this->errno; } |
78 | 78 | function error() { return $this->error; } |
79 | 79 | |
80 | - function cgiParams( $params = null ) |
|
80 | + function cgiParams($params = null) |
|
81 | 81 | { |
82 | - if( $params === null ) { return $this->params; } |
|
83 | - if( $params === "" ) { $this->params = null; return; } |
|
82 | + if ($params === null) { return $this->params; } |
|
83 | + if ($params === "") { $this->params = null; return; } |
|
84 | 84 | $this->params = $params; |
85 | 85 | } |
86 | 86 | |
87 | - function query( $query, $timeout=null ) |
|
87 | + function query($query, $timeout = null) |
|
88 | 88 | { |
89 | 89 | $prefixes = ""; |
90 | - foreach( $this->ns as $k=>$v ) |
|
90 | + foreach ($this->ns as $k=>$v) |
|
91 | 91 | { |
92 | 92 | $prefixes .= "PREFIX $k: <$v>\n"; |
93 | 93 | } |
94 | - $output = $this->dispatchQuery( $prefixes.$query, $timeout ); |
|
95 | - if( $this->errno ) { return; } |
|
94 | + $output = $this->dispatchQuery($prefixes.$query, $timeout); |
|
95 | + if ($this->errno) { return; } |
|
96 | 96 | $parser = new xx_xml($output, 'contents'); |
97 | - if( $parser->error() ) |
|
97 | + if ($parser->error()) |
|
98 | 98 | { |
99 | 99 | $this->errno = -1; # to not clash with CURLOPT return; } |
100 | 100 | $this->error = $parser->error(); |
101 | 101 | return; |
102 | 102 | } |
103 | - return new sparql_result( $this, $parser->rows, $parser->fields ); |
|
103 | + return new sparql_result($this, $parser->rows, $parser->fields); |
|
104 | 104 | } |
105 | 105 | |
106 | - function alive( $timeout=3 ) |
|
106 | + function alive($timeout = 3) |
|
107 | 107 | { |
108 | - $result = $this->query( "SELECT * WHERE { ?s ?p ?o } LIMIT 1", $timeout ); |
|
108 | + $result = $this->query("SELECT * WHERE { ?s ?p ?o } LIMIT 1", $timeout); |
|
109 | 109 | |
110 | - if( $this->errno ) { return false; } |
|
110 | + if ($this->errno) { return false; } |
|
111 | 111 | |
112 | 112 | return true; |
113 | 113 | } |
114 | 114 | |
115 | - function dispatchQuery( $sparql, $timeout=null ) |
|
115 | + function dispatchQuery($sparql, $timeout = null) |
|
116 | 116 | { |
117 | - $url = $this->endpoint."?query=".urlencode( $sparql ); |
|
118 | - if( $this->params !== null ) |
|
117 | + $url = $this->endpoint."?query=".urlencode($sparql); |
|
118 | + if ($this->params !== null) |
|
119 | 119 | { |
120 | 120 | $url .= "&".$this->params; |
121 | 121 | } |
122 | - if( $this->debug ) { print "<div class='debug'><a href='".htmlspecialchars($url)."'>".htmlspecialchars($prefixes.$query)."</a></div>\n"; } |
|
122 | + if ($this->debug) { print "<div class='debug'><a href='".htmlspecialchars($url)."'>".htmlspecialchars($prefixes.$query)."</a></div>\n"; } |
|
123 | 123 | $this->errno = null; |
124 | 124 | $this->error = null; |
125 | 125 | $ch = curl_init($url); |
126 | 126 | #curl_setopt($ch, CURLOPT_HEADER, 1); |
127 | - if( $timeout !== null ) |
|
127 | + if ($timeout !== null) |
|
128 | 128 | { |
129 | - curl_setopt($ch, CURLOPT_TIMEOUT, $timeout ); |
|
129 | + curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); |
|
130 | 130 | } |
131 | 131 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
132 | - curl_setopt($ch, CURLOPT_HTTPHEADER,array ( |
|
132 | + curl_setopt($ch, CURLOPT_HTTPHEADER, array( |
|
133 | 133 | "Accept: application/sparql-results+xml" |
134 | 134 | )); |
135 | 135 | |
136 | 136 | $output = curl_exec($ch); |
137 | 137 | $info = curl_getinfo($ch); |
138 | - if(curl_errno($ch)) |
|
138 | + if (curl_errno($ch)) |
|
139 | 139 | { |
140 | - $this->errno = curl_errno( $ch ); |
|
141 | - $this->error = 'Curl error: ' . curl_error($ch); |
|
140 | + $this->errno = curl_errno($ch); |
|
141 | + $this->error = 'Curl error: '.curl_error($ch); |
|
142 | 142 | return; |
143 | 143 | } |
144 | - if( $output === '' ) |
|
144 | + if ($output === '') |
|
145 | 145 | { |
146 | 146 | $this->errno = "-1"; |
147 | 147 | $this->error = 'URL returned no data'; |
148 | 148 | return; |
149 | 149 | } |
150 | - if( $info['http_code'] != 200) |
|
150 | + if ($info['http_code'] != 200) |
|
151 | 151 | { |
152 | 152 | $this->errno = $info['http_code']; |
153 | 153 | $this->error = 'Bad response, '.$info['http_code'].': '.$output; |
@@ -179,13 +179,13 @@ discard block |
||
179 | 179 | |
180 | 180 | var $caps_cache; |
181 | 181 | var $caps_anysubject; |
182 | - function capabilityCache( $filename, $dba_type='db4' ) |
|
182 | + function capabilityCache($filename, $dba_type = 'db4') |
|
183 | 183 | { |
184 | - $this->caps_cache = dba_open($filename, "c", $dba_type ); |
|
184 | + $this->caps_cache = dba_open($filename, "c", $dba_type); |
|
185 | 185 | } |
186 | 186 | function capabilityCodes() |
187 | 187 | { |
188 | - return array_keys( $this->caps_desc ); |
|
188 | + return array_keys($this->caps_desc); |
|
189 | 189 | } |
190 | 190 | function capabilityDescription($code) |
191 | 191 | { |
@@ -194,19 +194,19 @@ discard block |
||
194 | 194 | |
195 | 195 | # return true if the endpoint supports a capability |
196 | 196 | # nb. returns false if connecion isn't authoriased to use the feature, eg LOAD |
197 | - function supports( $code ) |
|
197 | + function supports($code) |
|
198 | 198 | { |
199 | - if( isset( $this->caps[$code] ) ) { return $this->caps[$code]; } |
|
199 | + if (isset($this->caps[$code])) { return $this->caps[$code]; } |
|
200 | 200 | $was_cached = false; |
201 | - if( isset( $this->caps_cache ) ) |
|
201 | + if (isset($this->caps_cache)) |
|
202 | 202 | { |
203 | 203 | $CACHE_TIMEOUT_SECONDS = 7*24*60*60; |
204 | 204 | $db_key = $this->endpoint.";".$code; |
205 | - $db_val = dba_fetch( $db_key, $this->caps_cache ); |
|
206 | - if( $db_val !== false ) |
|
205 | + $db_val = dba_fetch($db_key, $this->caps_cache); |
|
206 | + if ($db_val !== false) |
|
207 | 207 | { |
208 | - list( $result, $when ) = preg_split( '/;/', $db_val ); |
|
209 | - if( $when + $CACHE_TIMEOUT_SECONDS > time() ) |
|
208 | + list($result, $when) = preg_split('/;/', $db_val); |
|
209 | + if ($when + $CACHE_TIMEOUT_SECONDS > time()) |
|
210 | 210 | { |
211 | 211 | return $result; |
212 | 212 | } |
@@ -215,26 +215,26 @@ discard block |
||
215 | 215 | } |
216 | 216 | $r = null; |
217 | 217 | |
218 | - if( $code == "select" ) { $r = $this->test_select(); } |
|
219 | - elseif( $code == "constant_as" ) { $r = $this->test_constant_as(); } |
|
220 | - elseif( $code == "math_as" ) { $r = $this->test_math_as(); } |
|
221 | - elseif( $code == "count" ) { $r = $this->test_count(); } |
|
222 | - elseif( $code == "max" ) { $r = $this->test_max(); } |
|
223 | - elseif( $code == "load" ) { $r = $this->test_load(); } |
|
224 | - elseif( $code == "sample" ) { $r = $this->test_sample(); } |
|
218 | + if ($code == "select") { $r = $this->test_select(); } |
|
219 | + elseif ($code == "constant_as") { $r = $this->test_constant_as(); } |
|
220 | + elseif ($code == "math_as") { $r = $this->test_math_as(); } |
|
221 | + elseif ($code == "count") { $r = $this->test_count(); } |
|
222 | + elseif ($code == "max") { $r = $this->test_max(); } |
|
223 | + elseif ($code == "load") { $r = $this->test_load(); } |
|
224 | + elseif ($code == "sample") { $r = $this->test_sample(); } |
|
225 | 225 | else { print "<p>Unknown capability code: '$code'</p>"; return false; } |
226 | 226 | $this->caps[$code] = $r; |
227 | - if( isset( $this->caps_cache ) ) |
|
227 | + if (isset($this->caps_cache)) |
|
228 | 228 | { |
229 | 229 | $db_key = $this->endpoint.";".$code; |
230 | 230 | $db_val = $r.";".time(); |
231 | - if( $was_cached ) |
|
231 | + if ($was_cached) |
|
232 | 232 | { |
233 | - dba_replace( $db_key, $db_val, $this->caps_cache ); |
|
233 | + dba_replace($db_key, $db_val, $this->caps_cache); |
|
234 | 234 | } |
235 | 235 | else |
236 | 236 | { |
237 | - dba_insert( $db_key, $db_val, $this->caps_cache ); |
|
237 | + dba_insert($db_key, $db_val, $this->caps_cache); |
|
238 | 238 | } |
239 | 239 | } |
240 | 240 | return $r; |
@@ -242,11 +242,11 @@ discard block |
||
242 | 242 | |
243 | 243 | function anySubject() |
244 | 244 | { |
245 | - if( !isset( $this->caps_anysubject ) ) |
|
245 | + if (!isset($this->caps_anysubject)) |
|
246 | 246 | { |
247 | 247 | $results = $this->query( |
248 | 248 | "SELECT * WHERE { ?s ?p ?o } LIMIT 1" ); |
249 | - if( sizeof($results)) |
|
249 | + if (sizeof($results)) |
|
250 | 250 | { |
251 | 251 | $row = $results->fetch_array(); |
252 | 252 | $this->caps_anysubject = $row["s"]; |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | { |
261 | 261 | $output = $this->dispatchQuery( |
262 | 262 | "SELECT ?s ?p ?o WHERE { ?s ?p ?o } LIMIT 1" ); |
263 | - return !isset( $this->errno ); |
|
263 | + return !isset($this->errno); |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | # return true if the endpoint supports AS |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | { |
269 | 269 | $output = $this->dispatchQuery( |
270 | 270 | "SELECT (1+2 AS ?bar) WHERE { ?s ?p ?o } LIMIT 1" ); |
271 | - return !isset( $this->errno ); |
|
271 | + return !isset($this->errno); |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | # return true if the endpoint supports AS |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | { |
277 | 277 | $output = $this->dispatchQuery( |
278 | 278 | "SELECT (\"foo\" AS ?bar) WHERE { ?s ?p ?o } LIMIT 1" ); |
279 | - return !isset( $this->errno ); |
|
279 | + return !isset($this->errno); |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | # return true if the endpoint supports SELECT (COUNT(?x) as ?n) ... GROUP BY |
@@ -284,35 +284,35 @@ discard block |
||
284 | 284 | { |
285 | 285 | # assumes at least one rdf:type predicate |
286 | 286 | $s = $this->anySubject(); |
287 | - if( !isset($s) ) { return false; } |
|
287 | + if (!isset($s)) { return false; } |
|
288 | 288 | $output = $this->dispatchQuery( |
289 | 289 | "SELECT (COUNT(?p) AS ?n) ?o WHERE { <$s> ?p ?o } GROUP BY ?o" ); |
290 | - return !isset( $this->errno ); |
|
290 | + return !isset($this->errno); |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | function test_max() |
294 | 294 | { |
295 | 295 | $s = $this->anySubject(); |
296 | - if( !isset($s) ) { return false; } |
|
296 | + if (!isset($s)) { return false; } |
|
297 | 297 | $output = $this->dispatchQuery( |
298 | 298 | "SELECT (MAX(?p) AS ?max) ?o WHERE { <$s> ?p ?o } GROUP BY ?o" ); |
299 | - return !isset( $this->errno ); |
|
299 | + return !isset($this->errno); |
|
300 | 300 | } |
301 | 301 | |
302 | 302 | function test_sample() |
303 | 303 | { |
304 | 304 | $s = $this->anySubject(); |
305 | - if( !isset($s) ) { return false; } |
|
305 | + if (!isset($s)) { return false; } |
|
306 | 306 | $output = $this->dispatchQuery( |
307 | 307 | "SELECT (SAMPLE(?p) AS ?sam) ?o WHERE { <$s> ?p ?o } GROUP BY ?o" ); |
308 | - return !isset( $this->errno ); |
|
308 | + return !isset($this->errno); |
|
309 | 309 | } |
310 | 310 | |
311 | 311 | function test_load() |
312 | 312 | { |
313 | 313 | $output = $this->dispatchQuery( |
314 | 314 | "LOAD <http://graphite.ecs.soton.ac.uk/sparqllib/examples/loadtest.rdf>" ); |
315 | - return !isset( $this->errno ); |
|
315 | + return !isset($this->errno); |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | var $fields; |
325 | 325 | var $db; |
326 | 326 | var $i = 0; |
327 | - function __construct( $db, $rows, $fields ) |
|
327 | + function __construct($db, $rows, $fields) |
|
328 | 328 | { |
329 | 329 | $this->rows = $rows; |
330 | 330 | $this->fields = $fields; |
@@ -333,17 +333,17 @@ discard block |
||
333 | 333 | |
334 | 334 | function fetch_array() |
335 | 335 | { |
336 | - if( !@$this->rows[$this->i] ) { return; } |
|
336 | + if (!@$this->rows[$this->i]) { return; } |
|
337 | 337 | $r = array(); |
338 | - foreach( $this->rows[$this->i++] as $k=>$v ) |
|
338 | + foreach ($this->rows[$this->i++] as $k=>$v) |
|
339 | 339 | { |
340 | 340 | $r[$k] = $v["value"]; |
341 | 341 | $r["$k.type"] = $v["type"]; |
342 | - if( isset( $v["language"] ) ) |
|
342 | + if (isset($v["language"])) |
|
343 | 343 | { |
344 | 344 | $r["$k.language"] = $v["language"]; |
345 | 345 | } |
346 | - if( isset( $v["datatype"] ) ) |
|
346 | + if (isset($v["datatype"])) |
|
347 | 347 | { |
348 | 348 | $r["$k.datatype"] = $v["datatype"]; |
349 | 349 | } |
@@ -355,16 +355,16 @@ discard block |
||
355 | 355 | { |
356 | 356 | $r = new sparql_results(); |
357 | 357 | $r->fields = $this->fields; |
358 | - foreach( $this->rows as $i=>$row ) |
|
358 | + foreach ($this->rows as $i=>$row) |
|
359 | 359 | { |
360 | - $r []= $this->fetch_array(); |
|
360 | + $r [] = $this->fetch_array(); |
|
361 | 361 | } |
362 | 362 | return $r; |
363 | 363 | } |
364 | 364 | |
365 | 365 | function num_rows() |
366 | 366 | { |
367 | - return sizeof( $this->rows ); |
|
367 | + return sizeof($this->rows); |
|
368 | 368 | } |
369 | 369 | |
370 | 370 | function field_array() |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | var $type; |
401 | 401 | |
402 | 402 | // function with the default parameter value |
403 | - function xx_xml($url='http://www.opocot.com', $type='url') { |
|
403 | + function xx_xml($url = 'http://www.opocot.com', $type = 'url') { |
|
404 | 404 | $this->type = $type; |
405 | 405 | $this->url = $url; |
406 | 406 | $this->parse(); |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | $this->rows = array(); |
415 | 415 | $this->fields = array(); |
416 | 416 | $data = ''; |
417 | - $this->parser = xml_parser_create ("UTF-8"); |
|
417 | + $this->parser = xml_parser_create("UTF-8"); |
|
418 | 418 | xml_set_object($this->parser, $this); |
419 | 419 | xml_set_element_handler($this->parser, 'startXML', 'endXML'); |
420 | 420 | xml_set_character_data_handler($this->parser, 'charXML'); |
@@ -439,9 +439,9 @@ discard block |
||
439 | 439 | } else if ($this->type == 'contents') { |
440 | 440 | // Now we can pass the contents, maybe if you want |
441 | 441 | // to use CURL, SOCK or other method. |
442 | - $lines = explode("\n",$this->url); |
|
442 | + $lines = explode("\n", $this->url); |
|
443 | 443 | foreach ($lines as $val) { |
444 | - $data = $val . "\n"; |
|
444 | + $data = $val."\n"; |
|
445 | 445 | if (!xml_parse($this->parser, $data)) { |
446 | 446 | $this->error = $data."\n".sprintf('XML error at line %d column %d', |
447 | 447 | xml_get_current_line_number($this->parser), |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | } |
451 | 451 | } |
452 | 452 | } |
453 | - if( !$this->looks_legit ) |
|
453 | + if (!$this->looks_legit) |
|
454 | 454 | { |
455 | 455 | $this->error = "Didn't even see a sparql element, is this really an endpoint?"; |
456 | 456 | } |
@@ -458,53 +458,53 @@ discard block |
||
458 | 458 | |
459 | 459 | function startXML($parser, $name, $attr) |
460 | 460 | { |
461 | - if( $name == "sparql" ) { $this->looks_legit = true; } |
|
462 | - if( $name == "result" ) |
|
461 | + if ($name == "sparql") { $this->looks_legit = true; } |
|
462 | + if ($name == "result") |
|
463 | 463 | { |
464 | 464 | $this->result = array(); |
465 | 465 | } |
466 | - if( $name == "binding" ) |
|
466 | + if ($name == "binding") |
|
467 | 467 | { |
468 | 468 | $this->part = $attr["name"]; |
469 | 469 | } |
470 | - if( $name == "uri" || $name == "bnode" ) |
|
470 | + if ($name == "uri" || $name == "bnode") |
|
471 | 471 | { |
472 | 472 | $this->part_type = $name; |
473 | 473 | $this->chars = ""; |
474 | 474 | } |
475 | - if( $name == "literal" ) |
|
475 | + if ($name == "literal") |
|
476 | 476 | { |
477 | 477 | $this->part_type = "literal"; |
478 | - if( isset( $attr["datatype"] ) ) |
|
478 | + if (isset($attr["datatype"])) |
|
479 | 479 | { |
480 | 480 | $this->part_datatype = $attr["datatype"]; |
481 | 481 | } |
482 | - if( isset( $attr["xml:lang"] ) ) |
|
482 | + if (isset($attr["xml:lang"])) |
|
483 | 483 | { |
484 | 484 | $this->part_lang = $attr["xml:lang"]; |
485 | 485 | } |
486 | 486 | $this->chars = ""; |
487 | 487 | } |
488 | - if( $name == "variable" ) |
|
488 | + if ($name == "variable") |
|
489 | 489 | { |
490 | 490 | $this->fields[] = $attr["name"]; |
491 | 491 | } |
492 | 492 | } |
493 | 493 | |
494 | - function endXML($parser, $name) { |
|
495 | - if( $name == "result" ) |
|
494 | + function endXML($parser, $name) { |
|
495 | + if ($name == "result") |
|
496 | 496 | { |
497 | 497 | $this->rows[] = $this->result; |
498 | 498 | $this->result = array(); |
499 | 499 | } |
500 | - if( $name == "uri" || $name == "bnode" || $name == "literal" ) |
|
500 | + if ($name == "uri" || $name == "bnode" || $name == "literal") |
|
501 | 501 | { |
502 | - $this->result[$this->part] = array( "type"=>$name, "value"=>$this->chars ); |
|
503 | - if( isset( $this->part_lang ) ) |
|
502 | + $this->result[$this->part] = array("type"=>$name, "value"=>$this->chars); |
|
503 | + if (isset($this->part_lang)) |
|
504 | 504 | { |
505 | 505 | $this->result[$this->part]["lang"] = $this->part_lang; |
506 | 506 | } |
507 | - if( isset( $this->part_datatype ) ) |
|
507 | + if (isset($this->part_datatype)) |
|
508 | 508 | { |
509 | 509 | $this->result[$this->part]["datatype"] = $this->part_datatype; |
510 | 510 | } |
@@ -513,7 +513,7 @@ discard block |
||
513 | 513 | } |
514 | 514 | } |
515 | 515 | |
516 | - function charXML($parser, $data) { |
|
516 | + function charXML($parser, $data) { |
|
517 | 517 | @$this->chars .= $data; |
518 | 518 | } |
519 | 519 | |
@@ -527,28 +527,28 @@ discard block |
||
527 | 527 | function render_table() |
528 | 528 | { |
529 | 529 | $html = "<table class='sparql-results'><tr>"; |
530 | - foreach( $this->fields as $i=>$field ) |
|
530 | + foreach ($this->fields as $i=>$field) |
|
531 | 531 | { |
532 | 532 | $html .= "<th>?$field</th>"; |
533 | 533 | } |
534 | 534 | $html .= "</tr>"; |
535 | - foreach( $this as $row ) |
|
535 | + foreach ($this as $row) |
|
536 | 536 | { |
537 | - $html.="<tr>"; |
|
538 | - foreach( $row as $cell ) |
|
537 | + $html .= "<tr>"; |
|
538 | + foreach ($row as $cell) |
|
539 | 539 | { |
540 | - $html .= "<td>".htmlspecialchars( $cell )."</td>"; |
|
540 | + $html .= "<td>".htmlspecialchars($cell)."</td>"; |
|
541 | 541 | } |
542 | - $html.="</tr>"; |
|
542 | + $html .= "</tr>"; |
|
543 | 543 | } |
544 | - $html.="</table> |
|
544 | + $html .= "</table> |
|
545 | 545 | <style> |
546 | 546 | table.sparql-results { border-collapse: collapse; } |
547 | 547 | table.sparql-results tr td { border: solid 1px #000 ; padding:4px;vertical-align:top} |
548 | 548 | table.sparql-results tr th { border: solid 1px #000 ; padding:4px;vertical-align:top ; background-color:#eee;} |
549 | 549 | </style> |
550 | 550 | "; |
551 | - return $html;exit; |
|
551 | + return $html; exit; |
|
552 | 552 | } |
553 | 553 | |
554 | 554 | } |