Ysurac /
FlightAirMap
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | require_once('require/class.Connection.php'); |
||
| 3 | require_once('require/class.Spotter.php'); |
||
| 4 | require_once('require/class.Language.php'); |
||
| 5 | |||
| 6 | $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
||
| 7 | $country = filter_input(INPUT_GET,'country',FILTER_SANITIZE_STRING); |
||
| 8 | $date = filter_input(INPUT_GET,'date',FILTER_SANITIZE_STRING); |
||
| 9 | |||
| 10 | $Spotter = new Spotter(); |
||
| 11 | View Code Duplication | if (isset($_GET['date'])) $spotter_array = $Spotter->getSpotterDataByDate($date,"0,1", $sort); |
|
|
1 ignored issue
–
show
|
|||
| 12 | else $spotter_array = array(); |
||
| 13 | |||
| 14 | View Code Duplication | if (!empty($spotter_array)) |
|
|
1 ignored issue
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 15 | { |
||
| 16 | $title = sprintf(_("Most Common Airlines by Country on %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
||
| 17 | require_once('header.php'); |
||
| 18 | print '<div class="select-item">'; |
||
| 19 | print '<form action="'.$globalURL.'/date" method="post">'; |
||
| 20 | print '<label for="date">'._("Select a Date").'</label>'; |
||
| 21 | print '<input type="text" id="date" name="date" value="'.$date.'" size="8" readonly="readonly" class="custom" />'; |
||
| 22 | print '<button type="submit"><i class="fa fa-angle-double-right"></i></button>'; |
||
| 23 | print '</form>'; |
||
| 24 | print '</div>'; |
||
| 25 | |||
| 26 | print '<div class="info column">'; |
||
| 27 | print '<h1>'.sprintf(_("Flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>'; |
||
| 28 | print '</div>'; |
||
| 29 | |||
| 30 | include('date-sub-menu.php'); |
||
| 31 | print '<div class="column">'; |
||
| 32 | print '<h2>'._("Most Common Airlines by Country").'</h2>'; |
||
| 33 | print '<p>'.sprintf(_("The statistic below shows the most common airlines by Country of origin of flights on <strong>%s</strong>."),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
||
| 34 | |||
| 35 | $airline_array = $Spotter->countAllAirlineCountriesByDate($date); |
||
| 36 | print '<script type="text/javascript" src="https://www.google.com/jsapi"></script>'; |
||
| 37 | print '<div id="chartCountry" class="chart" width="100%"></div> |
||
| 38 | <script> |
||
| 39 | google.load("visualization", "1", {packages:["geochart"]}); |
||
| 40 | google.setOnLoadCallback(drawChart); |
||
| 41 | function drawChart() { |
||
| 42 | var data = google.visualization.arrayToDataTable([ |
||
| 43 | ["'._("Country").'", "'._("# of times").'"], '; |
||
| 44 | $country_data = ''; |
||
| 45 | foreach($airline_array as $airline_item) |
||
| 46 | { |
||
| 47 | $country_data .= '[ "'.$airline_item['airline_country'].'",'.$airline_item['airline_country_count'].'],'; |
||
| 48 | } |
||
| 49 | $country_data = substr($country_data, 0, -1); |
||
| 50 | print $country_data; |
||
| 51 | print ']); |
||
| 52 | |||
| 53 | var options = { |
||
| 54 | legend: {position: "none"}, |
||
| 55 | chartArea: {"width": "80%", "height": "60%"}, |
||
| 56 | height:500, |
||
| 57 | colors: ["#8BA9D0","#1a3151"] |
||
| 58 | }; |
||
| 59 | |||
| 60 | var chart = new google.visualization.GeoChart(document.getElementById("chartCountry")); |
||
| 61 | chart.draw(data, options); |
||
| 62 | } |
||
| 63 | $(window).resize(function(){ |
||
| 64 | drawChart(); |
||
| 65 | }); |
||
| 66 | </script>'; |
||
| 67 | |||
| 68 | if (!empty($airline_array)) |
||
| 69 | { |
||
| 70 | print '<div class="table-responsive">'; |
||
| 71 | print '<table class="common-country table-striped">'; |
||
| 72 | print '<thead>'; |
||
| 73 | print '<th></th>'; |
||
| 74 | print '<th>'._("Country").'</th>'; |
||
| 75 | print '<th>'._("# of times").'</th>'; |
||
| 76 | print '</thead>'; |
||
| 77 | print '<tbody>'; |
||
| 78 | $i = 1; |
||
| 79 | foreach($airline_array as $airline_item) |
||
| 80 | { |
||
| 81 | print '<tr>'; |
||
| 82 | print '<td><strong>'.$i.'</strong></td>'; |
||
| 83 | print '<td>'; |
||
| 84 | print '<a href="'.$globalURL.'/country/'.strtolower(str_replace(" ", "-", $airline_item['airline_country'])).'">'.$airline_item['airline_country'].'</a>'; |
||
| 85 | print '</td>'; |
||
| 86 | print '<td>'; |
||
| 87 | print $airline_item['airline_country_count']; |
||
| 88 | print '</td>'; |
||
| 89 | print '</tr>'; |
||
| 90 | $i++; |
||
| 91 | } |
||
| 92 | print '<tbody>'; |
||
| 93 | print '</table>'; |
||
| 94 | print '</div>'; |
||
| 95 | } |
||
| 96 | print '</div>'; |
||
| 97 | } else { |
||
| 98 | $title = _("Unknown Date"); |
||
| 99 | require_once('header.php'); |
||
| 100 | print '<h1>'._("Error").'</h1>'; |
||
| 101 | print '<p>'._("Sorry, this date does not exist in this database. :(").'</p>'; |
||
| 102 | } |
||
| 103 | require_once('footer.php'); |
||
| 104 | ?> |
||
|
1 ignored issue
–
show
It is not recommended to use PHP's closing tag
?> in files other than templates.
Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore. A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever. Loading history...
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.