Completed
Push — master ( 6eadb9...5e27ff )
by Yannick
09:33
created

statistics.php (2 issues)

Severity

Upgrade to new PHP Analysis Engine

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.Stats.php');
4
require_once('require/class.Language.php');
5
$beginpage = microtime(true);
6
$Stats = new Stats();
7
$title = _("Statistics");
8
9
if (!isset($filter_name)) $filter_name = '';
10
$airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
11
if ($airline_icao == 'all') {
12
	unset($_COOKIE['stats_airline_icao']);
13
	setcookie('stats_airline_icao', '', time()-3600);
14
	$airline_icao = '';
15
} elseif ($airline_icao == '' && isset($_COOKIE['stats_airline_icao'])) {
16
	$airline_icao = $_COOKIE['stats_airline_icao'];
17
} elseif ($airline_icao == '' && isset($globalFilter)) {
18
	if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
19
}
20
setcookie('stats_airline_icao',$airline_icao);
21
require_once('header.php');
22
23
?>
24
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
25
<!--<script type="text/javascript" src="https://d3js.org/d3.v4.min.js"></script>-->
26
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js"></script>
27
<script type="text/javascript" src="js/radarChart.js"></script>
28
<script type="text/javascript" src="js/raphael-2.1.4.min.js"></script>
29
<script type="text/javascript" src="js/justgage.js"></script>
30
<div class="column">
31
    <div class="info">
32
            <h1><?php echo _("Statistics"); ?></h1>
33
    <?php 
34
	$last_update = $Stats->getLastStatsUpdate();
35
	//if (isset($last_update[0]['value'])) print '<!-- Last update : '.$last_update[0]['value'].' -->';
36
	if (isset($last_update[0]['value'])) {
37
		date_default_timezone_set('UTC');
38
		$lastupdate = strtotime($last_update[0]['value']);
39
		if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone);
40
		print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>';
41
	}
42
    ?>
43
    </div>
44
    <?php    
45
	// print_r($Stats->getAllAirlineNames()); 
46
    ?>
47
    <?php include('statistics-sub-menu.php'); ?>
48
    <p class="global-stats">
49
        <span><span class="badge"><?php print number_format($Stats->countOverallFlights($airline_icao,$filter_name)); ?></span> <?php echo _("Flights"); ?></span>
50
	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
51
        <span><span class="badge"><?php print number_format($Stats->countOverallArrival($airline_icao,$filter_name)); ?></span> <?php echo _("Arrivals seen"); ?></span>
52
        <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
53
	<?php
54
	    if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
55
	?>
56
    	    <span><span class="badge"><?php print number_format($Stats->countOverallPilots($airline_icao,$filter_name)); ?></span> <?php echo _("Pilots"); ?></span>
57
	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
58
        <?php
59
    	    } else {
60
    	?>
61
    	    <span><span class="badge"><?php print number_format($Stats->countOverallOwners($airline_icao,$filter_name)); ?></span> <?php echo _("Owners"); ?></span>
62
	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
63
    	<?php
64
    	    }
65
    	?>
66
        <span><span class="badge"><?php print number_format($Stats->countOverallAircrafts($airline_icao,$filter_name)); ?></span> <?php echo _("Aircrafts types"); ?></span>
67
        <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
68
        <?php
69
    		if ($airline_icao == '') {
70
    	?>
71
        <span><span class="badge"><?php print number_format($Stats->countOverallAirlines($filter_name)); ?></span> <?php echo _("Airlines"); ?></span>
72
	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
73
	<?php
74
		}
75
	?>
76
	<?php
77
		if (!(isset($globalIVAO) && $globalIVAO) && !(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalphpVMS) && $globalphpVMS)) {
78
	?>
79
        <span><span class="badge"><?php print number_format($Stats->countOverallMilitaryFlights($filter_name)); ?></span> <?php echo _("Military"); ?></span>
80
	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
81
	<?php
82
		}
83
	?>
84
    </p>
85
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
86
    <div class="specific-stats">
87
        <div class="row column">
88
            <div class="col-md-6">
89
                <h2><?php echo _("Top 10 Most Common Aircraft Type"); ?></h2>
90
                 <?php
91
                  $aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name);
92
		    if (count($aircraft_array) == 0) print _("No data available");
93
		    else {
94
95
                    print '<div id="chart1" class="chart" width="100%"></div>
96
                    <script> 
97
                        google.load("visualization", "1", {packages:["corechart"]});
98
                      google.setOnLoadCallback(drawChart1);
99
                      function drawChart1() {
100
                        var data = google.visualization.arrayToDataTable([
101
                            ["'._("Aircraft").'", "'._("# of times").'"], ';
102
                            $aircraft_data = '';
103
                          foreach($aircraft_array as $aircraft_item)
104
                                    {
105
                                            $aircraft_data .= '[ "'.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
106
                                    }
107
                                    $aircraft_data = substr($aircraft_data, 0, -1);
108
                                    print $aircraft_data;
109
                        print ']);
110
111
                        var options = {
112
                            chartArea: {"width": "80%", "height": "60%"},
113
                            height:300,
114
                             is3D: true
115
                        };
116
117
                        var chart = new google.visualization.PieChart(document.getElementById("chart1"));
118
                        chart.draw(data, options);
119
                      }
120
                      $(window).resize(function(){
121
                              drawChart1();
122
                            });
123
                  </script>';
124
                  }
125
                  ?>
126
                <div class="more">
127
                    <a href="<?php print $globalURL; ?>/statistics/aircraft" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
128
                </div>
129
            </div>
130
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
131
<?php
132
//    echo $airline_icao;
133
    if ($airline_icao == '' || $airline_icao == 'all') {
134
	$airline_array = $Stats->countAllAirlines(true,$filter_name);
135
	if (count($airline_array) > 0) {
136
            print '<div class="col-md-6">';
137
	    print '<h2>'._("Top 10 Most Common Airline").'</h2>';
138
	    print '<div id="chart2" class="chart" width="100%"></div>
139
                    <script> 
140
                        google.load("visualization", "1", {packages:["corechart"]});
141
                      google.setOnLoadCallback(drawChart2);
142
                      function drawChart2() {
143
                        var data = google.visualization.arrayToDataTable([
144
                            ["'._("Airline").'", "'._("# of times").'"], ';
145
	    $airline_data = '';
146
	    foreach($airline_array as $airline_item)
147
	    {
148
		$airline_data .= '[ "'.$airline_item['airline_name'].' ('.$airline_item['airline_icao'].')",'.$airline_item['airline_count'].'],';
149
	    }
150
	    $airline_data = substr($airline_data, 0, -1);
151
	    print $airline_data;
152
	    print ']);
153
154
                        var options = {
155
                            chartArea: {"width": "80%", "height": "60%"},
156
                            height:300,
157
                             is3D: true
158
                        };
159
160
                        var chart = new google.visualization.PieChart(document.getElementById("chart2"));
161
                        chart.draw(data, options);
162
                      }
163
                      $(window).resize(function(){
164
                              drawChart2();
165
                            });
166
                  </script>';
167
	    print '<div class="more"><a href="'.$globalURL.'/statistics/airline" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
168
    	    print '</div>';
169
	}
170
?>
171
        </div>
172
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
173
<?php
174
    }
175
?>
176
        <div class="row column">
177
<?php
178
    $flightover_array = $Stats->countAllFlightOverCountries($airline_icao,$filter_name);
179
    if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
180
	if (empty($flightover_array)) {
181
	    print '<div class="col-md-12">';
182
	} else {
183
            print '<div class="col-md-6">';
184
	}
185
?>
186
                <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2>
187
<?php
188
	$pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name);
189
	if (count($pilot_array) == 0) print _("No data available");
190
	else {
191
	    print '<div id="chart7" class="chart" width="100%"></div>
192
                    <script> 
193
                        google.load("visualization", "1", {packages:["corechart"]});
194
                      google.setOnLoadCallback(drawChart7);
195
                      function drawChart7() {
196
                        var data = google.visualization.arrayToDataTable([
197
                            ["'._("Pilots").'", "'._("# of times").'"], ';
198
	    $pilot_data = '';
199
	    foreach($pilot_array as $pilot_item)
200
	    {
201
		$pilot_data .= '[ "'.$pilot_item['pilot_name'].' ('.$pilot_item['pilot_id'].')",'.$pilot_item['pilot_count'].'],';
202
	    }
203
	    $pilot_data = substr($pilot_data, 0, -1);
204
	    print $pilot_data;
205
	    print ']);
206
207
                        var options = {
208
                            chartArea: {"width": "80%", "height": "60%"},
209
                            height:300,
210
                             is3D: true
211
                        };
212
213
                        var chart = new google.visualization.PieChart(document.getElementById("chart7"));
214
                        chart.draw(data, options);
215
                      }
216
                      $(window).resize(function(){
217
                              drawChart7();
218
                            });
219
                  </script>';
220
        }
221
?>
222
                <div class="more">
223
                    <a href="<?php print $globalURL; ?>/statistics/pilot" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
224
                </div>
225
            </div>
226
        
227
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
228
<?php
229
    } else {
230
?>
231
            <div class="col-md-6">
232
                <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
233
<?php
234
	$owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name);
235
	if (count($owner_array) == 0) print _("No data available");
236
	else {
237
	    print '<div id="chart7" class="chart" width="100%"></div>
238
                    <script> 
239
                        google.load("visualization", "1", {packages:["corechart"]});
240
                      google.setOnLoadCallback(drawChart7);
241
                      function drawChart7() {
242
                        var data = google.visualization.arrayToDataTable([
243
                            ["'._("Owner").'", "'._("# of times").'"], ';
244
                            $owner_data = '';
245
	    foreach($owner_array as $owner_item)
246
	    {
247
		$owner_data .= '[ "'.$owner_item['owner_name'].'",'.$owner_item['owner_count'].'],';
248
	    }
249
	    $owner_data = substr($owner_data, 0, -1);
250
	    print $owner_data;
251
	    print ']);
252
253
                        var options = {
254
                            chartArea: {"width": "80%", "height": "60%"},
255
                            height:300,
256
                             is3D: true
257
                        };
258
259
                        var chart = new google.visualization.PieChart(document.getElementById("chart7"));
260
                        chart.draw(data, options);
261
                      }
262
                      $(window).resize(function(){
263
                              drawChart7();
264
                            });
265
                  </script>';
266
	}
267
?>
268
                <div class="more">
269
                    <a href="<?php print $globalURL; ?>/statistics/owner" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
270
                </div>
271
            </div>
272
        
273
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
274
<?php
275
    }
276
    if (!empty($flightover_array)) {
277
?>
278
            <div class="col-md-6">
279
                <h2><?php echo _("Top 20 Most Common Country a Flight was Over"); ?></h2>
280
<?php
281
	 //$flightover_array = $Stats->countAllFlightOverCountries();
282
	if (count($flightover_array) == 0) print _("No data available");
283
	else {
284
	    print '<div id="chart10" class="chart" width="100%"></div>
285
                    <script> 
286
                        google.load("visualization", "1", {packages:["corechart"]});
287
                      google.setOnLoadCallback(drawChart10);
288
                      function drawChart10() {
289
                        var data = google.visualization.arrayToDataTable([
290
                            ["'._("Country").'", "'._("# of times").'"], ';
291
                            $flightover_data = '';
292
	    foreach($flightover_array as $flightover_item)
293
	    {
294
		$flightover_data .= '[ "'.$flightover_item['flight_country'].' ('.$flightover_item['flight_country_iso2'].')",'.$flightover_item['flight_count'].'],';
295
	    }
296
	    $flightover_data = substr($flightover_data, 0, -1);
297
	    print $flightover_data;
298
	    print ']);
299
300
                        var options = {
301
                            chartArea: {"width": "80%", "height": "60%"},
302
                            height:300,
303
                             is3D: true,
304
	                    colors: ["#8BA9D0","#1a3151"]
305
                        };
306
307
                        //var chart = new google.visualization.PieChart(document.getElementById("chart10"));
308
            		var chart = new google.visualization.GeoChart(document.getElementById("chart10"));
309
                        chart.draw(data, options);
310
                      }
311
                      $(window).resize(function(){
312
                              drawChart10();
313
                            });
314
                  </script>';
315
	}
316
?>
317
                <div class="more">
318
                    <a href="<?php print $globalURL; ?>/statistics/country" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
319
                </div>
320
            </div>
321
<?php
322
    }
323
?>
324
        </div>
325
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
326
327
    	
328
        </div>
329
        <div class="row column">
330
            <div class="col-md-6">
331
<?php
332
    $airport_airport_array = $Stats->countAllDepartureAirports(true,$airline_icao,$filter_name);
333
    if (count($airport_airport_array) > 0) {
334
	print '<h2>'._("Top 10 Most Common Departure Airports").'</h2>';
335
	print '<div id="chart3" class="chart" width="100%"></div>
336
                <script>
337
                google.load("visualization", "1", {packages:["geochart"]});
338
                google.setOnLoadCallback(drawCharts3);
339
                $(window).resize(function(){
340
                    drawCharts3();
341
                });
342
                function drawCharts3() {
343
344
                var data = google.visualization.arrayToDataTable([ 
345
                    ["'._("Airport").'", "'._("# of times").'"],';
346
                    $airport_data = '';
347
	foreach($airport_airport_array as $airport_item)
348
	{
349
	    $name = $airport_item['airport_departure_city'].', '.$airport_item['airport_departure_country'].' ('.$airport_item['airport_departure_icao'].')';
350
	    $name = str_replace("'", "", $name);
351
	    $name = str_replace('"', "", $name);
352
	    $airport_data .= '[ "'.$name.'",'.$airport_item['airport_departure_icao_count'].'],';
353
	}
354
	$airport_data = substr($airport_data, 0, -1);
355
	print $airport_data;
356
	print ']);
357
358
                var options = {
359
                    legend: {position: "none"},
360
                    chartArea: {"width": "80%", "height": "60%"},
361
                    height:300,
362
                    displayMode: "markers",
363
                    colors: ["#8BA9D0","#1a3151"]
364
                };
365
366
                var chart = new google.visualization.GeoChart(document.getElementById("chart3"));
367
                chart.draw(data, options);
368
              }
369
                </script>';
370
	print '<div class="more"><a href="'.$globalURL.'/statistics/airport-departure" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
371
    }
372
?>
373
            </div>
374
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
375
376
            <div class="col-md-6">
377
<?php
378
    $airport_airport_array2 = $Stats->countAllArrivalAirports(true,$airline_icao,$filter_name);
379
    if (count($airport_airport_array2) > 0) {
380
	print '<h2>'._("Top 10 Most Common Arrival Airports").'</h2>';
381
	print '<div id="chart4" class="chart" width="100%"></div>
382
                <script>
383
                google.load("visualization", "1", {packages:["geochart"]});
384
                google.setOnLoadCallback(drawCharts4);
385
                $(window).resize(function(){
386
                    drawCharts4();
387
                });
388
                function drawCharts4() {
389
390
                var data = google.visualization.arrayToDataTable([ 
391
                    ["'._("Airport").'", "'._("# of times").'"],';
392
	$airport_data2 = '';
393
	foreach($airport_airport_array2 as $airport_item2)
394
	{
395
	    $name2 = $airport_item2['airport_arrival_city'].', '.$airport_item2['airport_arrival_country'].' ('.$airport_item2['airport_arrival_icao'].')';
396
	    $name2 = str_replace(array("'",'"'), '', $name2);
397
	    $airport_data2 .= '[ "'.$name2.'",'.$airport_item2['airport_arrival_icao_count'].'],';
398
	}
399
	$airport_data2 = substr($airport_data2, 0, -1);
400
	print $airport_data2;
401
	print ']);
402
403
                var options = {
404
                    legend: {position: "none"},
405
                    chartArea: {"width": "80%", "height": "60%"},
406
                    height:300,
407
                    displayMode: "markers",
408
                    colors: ["#8BA9D0","#1a3151"]
409
                };
410
411
                var chart = new google.visualization.GeoChart(document.getElementById("chart4"));
412
                chart.draw(data, options);
413
              }
414
                </script>';
415
	print '<div class="more"><a href="'.$globalURL.'/statistics/airport-arrival" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
416
    }
417
?>
418
            </div>
419
        </div>
420
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
421
422
        <div class="row column">
423
            <div class="col-md-6">
424
                <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
425
                <?php
426
                  $year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
427
		    if (count($year_array) == 0) print _("No data available");
428
		    else {
429
                  print '<div id="chart8" class="chart" width="100%"></div>
430
                    <script> 
431
                        google.load("visualization", "1", {packages:["corechart"]});
432
                      google.setOnLoadCallback(drawChart8);
433
                      function drawChart8() {
434
                        var data = google.visualization.arrayToDataTable([
435
                            ["'._("Month").'", "'._("# of Flights").'"], ';
436
                            $year_data = '';
437
                          foreach($year_array as $year_item)
438
                                    {
439
                                        $year_data .= '[ "'.date('F, Y',strtotime($year_item['year_name'].'-'.$year_item['month_name'].'-01')).'",'.$year_item['date_count'].'],';
440
                                    }
441
                                    $year_data = substr($year_data, 0, -1);
442
                                    print $year_data;
443
                        print ']);
444
445
                        var options = {
446
                            legend: {position: "none"},
447
                            chartArea: {"width": "80%", "height": "60%"},
448
                            vAxis: {title: "'._("# of Flights").'"},
449
                            hAxis: {showTextEvery: 2},
450
                            height:300,
451
                            colors: ["#1a3151"]
452
                        };
453
454
                        var chart = new google.visualization.AreaChart(document.getElementById("chart8"));
455
                        chart.draw(data, options);
456
                      }
457
                      $(window).resize(function(){
458
                              drawChart8();
459
                            });
460
                  </script>';
461
                  }
462
                  ?>
463
                <div class="more">
464
                    <a href="<?php print $globalURL; ?>/statistics/year" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
465
                </div>
466
            </div>
467
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
468
469
            <div class="col-md-6">
470
                <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
471
                <?php
472
                  $month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
473
		    if (count($month_array) == 0) print _("No data available");
474
		    else {
475
                  print '<div id="chart9" class="chart" width="100%"></div>
476
                    <script> 
477
                        google.load("visualization", "1", {packages:["corechart"]});
478
                      google.setOnLoadCallback(drawChart9);
479
                      function drawChart9() {
480
                        var data = google.visualization.arrayToDataTable([
481
                            ["'._("Day").'", "'._("# of Flights").'"], ';
482
                            $month_data = '';
483
                          foreach($month_array as $month_item)
484
                                    {
485
                                        $month_data .= '[ "'.date('F j, Y',strtotime($month_item['date_name'])).'",'.$month_item['date_count'].'],';
486
                                    }
487
                                    $month_data = substr($month_data, 0, -1);
488
                                    print $month_data;
489
                        print ']);
490
491
                        var options = {
492
                            legend: {position: "none"},
493
                            chartArea: {"width": "80%", "height": "60%"},
494
                            vAxis: {title: "'._("# of Flights").'"},
495
                            hAxis: {showTextEvery: 2},
496
                            height:300,
497
                            colors: ["#1a3151"]
498
                        };
499
500
                        var chart = new google.visualization.AreaChart(document.getElementById("chart9"));
501
                        chart.draw(data, options);
502
                      }
503
                      $(window).resize(function(){
504
                              drawChart9();
505
                            });
506
                  </script>';
507
                  }
508
                  ?>
509
                <div class="more">
510
                    <a href="<?php print $globalURL; ?>/statistics/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
511
                </div>
512
            </div>
513
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
514
515
            <div class="col-md-6">
516
                <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
517
                <?php
518
                    $date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
519
		    if (empty($date_array)) print _("No data available");
520
		    else {
521
                  print '<div id="chart5" class="chart" width="100%"></div>
522
                    <script> 
523
                        google.load("visualization", "1", {packages:["corechart"]});
524
                      google.setOnLoadCallback(drawChart5);
525
                      function drawChart5() {
526
                        var data = google.visualization.arrayToDataTable([
527
                            ["'._("Date").'", "'._("# of Flights").'"], ';
528
                            $date_data = '';
529
                        
530
                          foreach($date_array as $date_item)
531
                                    {
532
                                        $date_data .= '[ "'.date("F j, Y", strtotime($date_item['date_name'])).'",'.$date_item['date_count'].'],';
533
                                    }
534
                                    $date_data = substr($date_data, 0, -1);
535
                                    print $date_data;
536
                        print ']);
537
538
                        var options = {
539
                            legend: {position: "none"},
540
                            chartArea: {"width": "80%", "height": "60%"},
541
                            vAxis: {title: "'._("# of Flights").'"},
542
                            hAxis: {showTextEvery: 2},
543
                            height:300,
544
                            colors: ["#1a3151"]
545
                        };
546
547
                        var chart = new google.visualization.AreaChart(document.getElementById("chart5"));
548
                        chart.draw(data, options);
549
                      }
550
                      $(window).resize(function(){
551
                              drawChart5();
552
                            });
553
                  </script>';
554
                  }
555
                  ?>
556
                <div class="more">
557
                    <a href="<?php print $globalURL; ?>/statistics/date" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
558
                </div>
559
            </div>
560
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
561
562
            <div class="col-md-6">
563
                <h2><?php echo _("Busiest Time of the Day"); ?></h2>
564
                <?php
565
                  $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
566
		    if (empty($hour_array)) print _("No data available");
567
		    else {
568
569
                  print '<div id="chart6" class="chart" width="100%"></div>
570
                    <script> 
571
                        google.load("visualization", "1", {packages:["corechart"]});
572
                      google.setOnLoadCallback(drawChart6);
573
                      function drawChart6() {
574
                        var data = google.visualization.arrayToDataTable([
575
                            ["'._("Hour").'", "'._("# of Flights").'"], ';
576
                            $hour_data = '';
577
                          foreach($hour_array as $hour_item)
578
                                    {
579
                                        $hour_data .= '[ "'.$hour_item['hour_name'].':00",'.$hour_item['hour_count'].'],';
580
                                    }
581
                                    $hour_data = substr($hour_data, 0, -1);
582
                                    print $hour_data;
583
                        print ']);
584
585
                        var options = {
586
                            legend: {position: "none"},
587
                            chartArea: {"width": "80%", "height": "60%"},
588
                            vAxis: {title: "'._("# of Flights").'"},
589
                            hAxis: {showTextEvery: 2},
590
                            height:300,
591
                            colors: ["#1a3151"]
592
                        };
593
594
                        var chart = new google.visualization.AreaChart(document.getElementById("chart6"));
595
                        chart.draw(data, options);
596
                      }
597
                      $(window).resize(function(){
598
                              drawChart6();
599
                            });
600
                  </script>';
601
                  }
602
                ?>
603
                <div class="more">
604
                    <a href="<?php print $globalURL; ?>/statistics/time" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
605
                </div>
606
            </div>
607
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
608
        </div>
609
<?php
610
    if (isset($globalAccidents) && $globalAccidents) {
611
?>
612
        <div class="row column">
613
            <div class="col-md-6">
614
                <h2><?php echo _("Fatalities by Years"); ?></h2>
615
                <?php
616
		    require_once('require/class.Accident.php');
617
            	    $Accident = new Accident();
618
                  $year_array = $Accident->countFatalitiesByYear($filter_name);
0 ignored issues
show
The call to Accident::countFatalitiesByYear() has too many arguments starting with $filter_name.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
619
		    if (count($year_array) == 0) print _("No data available");
620
		    else {
621
                  print '<div id="chart32" class="chart" width="100%"></div>
622
                    <script> 
623
                        google.load("visualization", "1", {packages:["corechart"]});
624
                      google.setOnLoadCallback(drawChart32);
625
                      function drawChart32() {
626
                        var data = google.visualization.arrayToDataTable([
627
                            ["'._("Year").'", "'._("# of Fatalities").'"], ';
628
                            $year_data = '';
629
                          foreach($year_array as $year_item)
630
                                    {
631
                                        $year_data .= '[ "'.$year_item['year'].'",'.$year_item['count'].'],';
632
                                    }
633
                                    $year_data = substr($year_data, 0, -1);
634
                                    print $year_data;
635
                        print ']);
636
637
                        var options = {
638
                            legend: {position: "none"},
639
                            chartArea: {"width": "80%", "height": "60%"},
640
                            vAxis: {title: "'._("# of Fatalities").'"},
641
                            hAxis: {showTextEvery: 2},
642
                            height:300,
643
                            colors: ["#1a3151"]
644
                        };
645
646
                        var chart = new google.visualization.AreaChart(document.getElementById("chart32"));
647
                        chart.draw(data, options);
648
                      }
649
                      $(window).resize(function(){
650
                              drawChart32();
651
                            });
652
                  </script>';
653
                  }
654
                  ?>
655
                <div class="more">
656
                    <a href="<?php print $globalURL; ?>/statistics/fatalities/year" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
657
                </div>
658
            </div>
659
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
660
661
        <div class="row column">
662
            <div class="col-md-6">
663
                <h2><?php echo _("Fatalities last 12 Months"); ?></h2>
664
                <?php
665
		    require_once('require/class.Accident.php');
666
            	    $Accident = new Accident();
667
                  $year_array = $Accident->countFatalitiesLast12Months($filter_name);
0 ignored issues
show
The call to Accident::countFatalitiesLast12Months() has too many arguments starting with $filter_name.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
668
		    if (count($year_array) == 0) print _("No data available");
669
		    else {
670
                  print '<div id="chart33" class="chart" width="100%"></div>
671
                    <script> 
672
                        google.load("visualization", "1", {packages:["corechart"]});
673
                      google.setOnLoadCallback(drawChart33);
674
                      function drawChart33() {
675
                        var data = google.visualization.arrayToDataTable([
676
                            ["'._("Month").'", "'._("# of Fatalities").'"], ';
677
                            $year_data = '';
678
                          foreach($year_array as $year_item)
679
                                    {
680
                                        $year_data .= '[ "'.date('F, Y',strtotime($year_item['year'].'-'.$year_item['month'].'-01')).'",'.$year_item['count'].'],';
681
                                    }
682
                                    $year_data = substr($year_data, 0, -1);
683
                                    print $year_data;
684
                        print ']);
685
686
                        var options = {
687
                            legend: {position: "none"},
688
                            chartArea: {"width": "80%", "height": "60%"},
689
                            vAxis: {title: "'._("# of Fatalities").'"},
690
                            hAxis: {showTextEvery: 2},
691
                            height:300,
692
                            colors: ["#1a3151"]
693
                        };
694
695
                        var chart = new google.visualization.AreaChart(document.getElementById("chart33"));
696
                        chart.draw(data, options);
697
                      }
698
                      $(window).resize(function(){
699
                              drawChart33();
700
                            });
701
                  </script>';
702
                  }
703
                  ?>
704
                <div class="more">
705
                    <a href="<?php print $globalURL; ?>/statistics/fatalities/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
706
                </div>
707
            </div>
708
    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
709
<br/>
710
<?php
711
    }
712
?>
713
714
<?php
715
    if (($airline_icao == '' || $airline_icao == 'all') && $filter_name == '') {
716
?>
717
        <div class="row column">
718
        	<?php
719
        	    $polar = $Stats->getStatsSource(date('Y-m-d'),'polar');
720
        	    if (!empty($polar)) {
721
            		print '<h2>'._("Coverage pattern").'</h2>';
722
        		foreach ($polar as $eachpolar) {
723
        		    unset($polar_data);
724
	        	    $Spotter = new Spotter();
725
        		    $data = json_decode($eachpolar['source_data']);
726
        		    foreach($data as $value => $key) {
727
        			$direction = $Spotter->parseDirection(($value*22.5));
728
        			$distance = $key;
729
        			$unit = 'km';
730
				if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
731
					$distance = round($distance*0.539957);
732
					$unit = 'nm';
733
				} elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
734
					$distance = round($distance*0.621371);
735
					$unit = 'mi';
736
				} elseif ((!isset($_COOKIE['unitdistance']) && ((isset($globalUnitDistance) && $globalUnitDistance == 'km') || !isset($globalUnitDistance))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) {
737
					$distance = $distance;
738
					$unit = 'km';
739
				}
740
        			if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
741
        	    		else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
742
        		    }
743
        	?>
744
            <div class="col-md-6">
745
                <h4><?php print $eachpolar['source_name']; ?></h4>
746
        	<div id="polar-<?php print str_replace(' ','_',strtolower($eachpolar['source_name'])); ?>" class="chart" width="100%"></div>
747
        	<script>
748
        	    (function() {
749
        	    var margin = {top: 100, right: 100, bottom: 100, left: 100},
750
			width = Math.min(700, window.innerWidth - 10) - margin.left - margin.right,
751
			height = Math.min(width, window.innerHeight - margin.top - margin.bottom - 20);
752
		    var data = [
753
				    [
754
				    <?php print $polar_data; ?>
755
				    ]
756
				];
757
		    var color = d3.scale.ordinal().range(["#EDC951","#CC333F","#00A0B0"]);
758
		    //var color = d3.scaleOrdinal().range(["#EDC951","#CC333F","#00A0B0"]);
759
		
760
		    var radarChartOptions = {
761
		      w: width,
762
		      h: height,
763
		      margin: margin,
764
		      maxValue: 0.5,
765
		      levels: 5,
766
		      roundStrokes: true,
767
		      color: color,
768
		      unit: '<?php echo $unit; ?>'
769
		    };
770
		    RadarChart("#polar-<?php print str_replace(' ','_',strtolower($eachpolar['source_name'])); ?>", data, radarChartOptions);
771
		    })();
772
		</script>
773
            </div>
774
            <?php
775
        	    }
776
        	}
777
            ?>
778
        </div>
779
        <div class="row column">
780
            <div class="col-md-6">
781
        	<?php
782
        	    $msg = $Stats->getStatsSource(date('Y-m-d'),'msg');
783
        	    if (!empty($msg)) {
784
            		print '<h2>'._("Messages received").'</h2>';
785
        		foreach ($msg as $eachmsg) {
786
        		    //$eachmsg = $msg[0];
787
        		    $data = $eachmsg['source_data'];
788
        		    if ($data > 500) $max = (round(($data+100)/100))*100;
789
        		    else $max = 500;
790
        	?>
791
        	<div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
792
        	<script>
793
		      var g = new JustGage({
794
			    id: "msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>",
795
			    value: <?php echo $data; ?>,
796
			    min: 0,
797
			    max: <?php print $max; ?>,
798
			    valueMinFontSize: 10,
799
			    height: 120,
800
			    width: 220,
801
			    symbol: ' msg/s',
802
			    title: "<?php print $eachmsg['source_name']; ?>"
803
			  });
804
		</script>
805
            <?php
806
        	   }
807
        	}
808
            ?>
809
            </div>
810
        </div>
811
        <div class="row column">
812
813
            <?php
814
		$hist = $Stats->getStatsSource(date('Y-m-d'),'hist');
815
		foreach ($hist as $hists) {
816
			$hist_data = '';
817
			$source = $hists['source_name'];
818
			$hist_array = json_decode($hists['source_data']);
819
			foreach($hist_array as $distance => $nb)
820
			{
821
				$unit = 'km';
822
				if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
823
					$distance = round($distance*0.539957);
824
					$unit = 'nm';
825
				} elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
826
					$distance = round($distance*0.621371);
827
					$unit = 'mi';
828
				} elseif ((!isset($_COOKIE['unitdistance']) && ((isset($globalUnitDistance) && $globalUnitDistance == 'km') || !isset($globalUnitDistance))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) {
829
					$distance = $distance;
830
					$unit = 'km';
831
				}
832
				$hist_data .= '[ "'.$distance.'",'.$nb.'],';
833
			}
834
			$hist_data = substr($hist_data, 0, -1);
835
            ?>
836
            <div class="col-md-6">
837
                <h2><?php echo sprintf(_("Flights Distance for %s"),$source); ?></h2>
838
                <?php
839
                  print '<div id="charthist-'.str_replace(' ','_',strtolower($source)).'" class="chart" width="100%"></div>
840
                    <script> 
841
                        google.load("visualization", "1", {packages:["corechart"]});
842
                      google.setOnLoadCallback(drawCharthist_'.str_replace(' ','_',strtolower($source)).');
843
                      function drawCharthist_'.str_replace(' ','_',strtolower($source)).'() {
844
                        var data = google.visualization.arrayToDataTable([
845
                            ["'._("Distance").'", "'._("# of Flights").'"], ';
846
                            print $hist_data;
847
                        print ']);
848
849
                        var options = {
850
                            legend: {position: "none"},
851
                            chartArea: {"width": "80%", "height": "60%"},
852
                            vAxis: {title: "'._("# of Flights").'"},
853
                            hAxis: {showTextEvery: 2,title: "'._("Distance").' ('.$unit.')"},
854
                            height:300,
855
                            colors: ["#1a3151"]
856
                        };
857
858
                        var chart = new google.visualization.AreaChart(document.getElementById("charthist-'.str_replace(' ','_',strtolower($source)).'"));
859
                        chart.draw(data, options);
860
                      }
861
                      $(window).resize(function(){
862
                              drawCharthist_'.str_replace(' ','_',strtolower($source)).'();
863
                            });
864
                  </script>';
865
        	?>
866
    	    </div>
867
	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
868
        	<?php
869
                  }
870
                ?>
871
        </div>
872
<?php
873
    }
874
?>
875
    </div>
876
</div>  
877
878
<?php
879
require_once('footer.php');
880
?>