Code Duplication    Length = 15-16 lines in 4 locations

require/class.Stats.php 4 locations

@@ 352-367 (lines=16) @@
349
                return $all;
350
	}
351
	
352
	public function countAllDatesLastMonth() {
353
		$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month'";
354
		$query_data = array();
355
                 try {
356
                        $sth = $this->db->prepare($query);
357
                        $sth->execute($query_data);
358
                } catch(PDOException $e) {
359
                        echo "error : ".$e->getMessage();
360
                }
361
                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
362
                if (empty($all)) {
363
            		$Spotter = new Spotter($this->db);
364
            		$all = $Spotter->countAllDatesLastMonth();
365
                }
366
                return $all;
367
	}
368
	public function countAllDatesLast7Days() {
369
		global $globalDBdriver;
370
		if ($globalDBdriver == 'mysql') {
@@ 389-404 (lines=16) @@
386
                }
387
                return $all;
388
	}
389
	public function countAllDates() {
390
		$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date'";
391
		$query_data = array();
392
                 try {
393
                        $sth = $this->db->prepare($query);
394
                        $sth->execute($query_data);
395
                } catch(PDOException $e) {
396
                        echo "error : ".$e->getMessage();
397
                }
398
                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
399
                if (empty($all)) {
400
            		$Spotter = new Spotter($this->db);
401
            		$all = $Spotter->countAllDates();
402
                }
403
                return $all;
404
	}
405
	public function countAllMonths() {
406
	    	$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth'";
407
                 try {
@@ 405-419 (lines=15) @@
402
                }
403
                return $all;
404
	}
405
	public function countAllMonths() {
406
	    	$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth'";
407
                 try {
408
                        $sth = $this->db->prepare($query);
409
                        $sth->execute();
410
                } catch(PDOException $e) {
411
                        echo "error : ".$e->getMessage();
412
                }
413
                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
414
                if (empty($all)) {
415
            		$Spotter = new Spotter($this->db);
416
            		$all = $Spotter->countAllMonths();
417
                }
418
                return $all;
419
	}
420
	public function countAllMilitaryMonths() {
421
	    	$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'military_flights_bymonth'";
422
                 try {
@@ 420-434 (lines=15) @@
417
                }
418
                return $all;
419
	}
420
	public function countAllMilitaryMonths() {
421
	    	$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'military_flights_bymonth'";
422
                 try {
423
                        $sth = $this->db->prepare($query);
424
                        $sth->execute();
425
                } catch(PDOException $e) {
426
                        echo "error : ".$e->getMessage();
427
                }
428
                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
429
                if (empty($all)) {
430
            		$Spotter = new Spotter($this->db);
431
            		$all = $Spotter->countAllMilitaryMonths();
432
                }
433
                return $all;
434
	}
435
	public function countAllHours($orderby = 'hour',$limit = true) {
436
		global $globalTimezone, $globalDBdriver;
437