Code Duplication    Length = 15-22 lines in 2 locations

require/class.ATC.php 1 location

@@ 63-77 (lines=15) @@
60
                }
61
        }
62
63
	public function deleteOldATC() {
64
                global $globalDBdriver;
65
                if ($globalDBdriver == 'mysql') {
66
                        $query  = "DELETE FROM atc WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= atc.atc_lastseen";
67
                } elseif ($globalDBdriver == 'pgsql') {
68
                        $query  = "DELETE FROM atc WHERE NOW() AT TIME ZONE 'UTC' - '1 HOUR'->INTERVAL >= atc.atc_lastseen";
69
                }
70
                try {
71
                        $sth = $this->db->prepare($query);
72
                        $sth->execute();
73
                } catch(PDOException $e) {
74
                        return "error";
75
                }
76
                return "success";
77
        }
78
}
79
?>

require/class.SpotterLive.php 1 location

@@ 488-509 (lines=22) @@
485
	* @return String success or false
486
	*
487
	*/
488
	public function deleteLiveSpotterData()
489
	{
490
		global $globalDBdriver;
491
		if ($globalDBdriver == 'mysql') {
492
			//$query  = "DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= spotter_live.date";
493
			$query  = 'DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= spotter_live.date';
494
            		//$query  = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)";
495
496
		} elseif ($globalDBdriver == 'pgsql') {
497
			$query  = "DELETE FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date";
498
		}
499
        
500
    		try {
501
			
502
			$sth = $this->db->prepare($query);
503
			$sth->execute();
504
		} catch(PDOException $e) {
505
			return "error";
506
		}
507
508
		return "success";
509
	}
510
511
	/**
512
	* Deletes all info in the table for aircraft not seen since 2 HOUR