Code Duplication    Length = 18-18 lines in 3 locations

install/class.update_db.php 3 locations

@@ 1545-1562 (lines=18) @@
1542
		return '';
1543
	}
1544
	
1545
	public static function check_last_update() {
1546
		global $globalDBdriver;
1547
		if ($globalDBdriver == 'mysql') {
1548
			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_db' AND value > DATE_SUB(DATE(NOW()), INTERVAL 15 DAY)";
1549
		} else {
1550
			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_db' AND value::timestamp > CURRENT_TIMESTAMP - INTERVAL '15 DAYS'";
1551
		}
1552
		try {
1553
			$Connection = new Connection();
1554
			$sth = $Connection->db->prepare($query);
1555
                        $sth->execute();
1556
                } catch(PDOException $e) {
1557
                        return "error : ".$e->getMessage();
1558
                }
1559
                $row = $sth->fetch(PDO::FETCH_ASSOC);
1560
                if ($row['nb'] > 0) return false;
1561
                else return true;
1562
	}
1563
1564
	public static function insert_last_update() {
1565
		$query = "DELETE FROM config WHERE name = 'last_update_db';
@@ 1576-1593 (lines=18) @@
1573
                }
1574
	}
1575
1576
	public static function check_last_notam_update() {
1577
		global $globalDBdriver;
1578
		if ($globalDBdriver == 'mysql') {
1579
			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_notam_db' AND value > DATE_SUB(DATE(NOW()), INTERVAL 1 DAY)";
1580
		} else {
1581
			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_notam_db' AND value::timestamp > CURRENT_TIMESTAMP - INTERVAL '1 DAYS'";
1582
		}
1583
		try {
1584
			$Connection = new Connection();
1585
			$sth = $Connection->db->prepare($query);
1586
                        $sth->execute();
1587
                } catch(PDOException $e) {
1588
                        return "error : ".$e->getMessage();
1589
                }
1590
                $row = $sth->fetch(PDO::FETCH_ASSOC);
1591
                if ($row['nb'] > 0) return false;
1592
                else return true;
1593
	}
1594
1595
	public static function insert_last_notam_update() {
1596
		$query = "DELETE FROM config WHERE name = 'last_update_notam_db';
@@ 1607-1624 (lines=18) @@
1604
                }
1605
	}
1606
1607
	public static function check_last_owner_update() {
1608
		global $globalDBdriver;
1609
		if ($globalDBdriver == 'mysql') {
1610
			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_owner_db' AND value > DATE_SUB(DATE(NOW()), INTERVAL 15 DAY)";
1611
		} else {
1612
			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_owner_db' AND value::timestamp > CURRENT_TIMESTAMP - INTERVAL '15 DAYS'";
1613
		}
1614
		try {
1615
			$Connection = new Connection();
1616
			$sth = $Connection->db->prepare($query);
1617
                        $sth->execute();
1618
                } catch(PDOException $e) {
1619
                        return "error : ".$e->getMessage();
1620
                }
1621
                $row = $sth->fetch(PDO::FETCH_ASSOC);
1622
                if ($row['nb'] > 0) return false;
1623
                else return true;
1624
	}
1625
1626
	public static function insert_last_owner_update() {
1627
		$query = "DELETE FROM config WHERE name = 'last_update_owner_db';