Code Duplication    Length = 18-18 lines in 4 locations

install/class.update_db.php 4 locations

@@ 1655-1672 (lines=18) @@
1652
		return '';
1653
	}
1654
	
1655
	public static function check_last_update() {
1656
		global $globalDBdriver;
1657
		if ($globalDBdriver == 'mysql') {
1658
			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_db' AND value > DATE_SUB(DATE(NOW()), INTERVAL 15 DAY)";
1659
		} else {
1660
			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_db' AND value::timestamp > CURRENT_TIMESTAMP - INTERVAL '15 DAYS'";
1661
		}
1662
		try {
1663
			$Connection = new Connection();
1664
			$sth = $Connection->db->prepare($query);
1665
                        $sth->execute();
1666
                } catch(PDOException $e) {
1667
                        return "error : ".$e->getMessage();
1668
                }
1669
                $row = $sth->fetch(PDO::FETCH_ASSOC);
1670
                if ($row['nb'] > 0) return false;
1671
                else return true;
1672
	}
1673
1674
	public static function insert_last_update() {
1675
		$query = "DELETE FROM config WHERE name = 'last_update_db';
@@ 1686-1703 (lines=18) @@
1683
                }
1684
	}
1685
1686
	public static function check_last_notam_update() {
1687
		global $globalDBdriver;
1688
		if ($globalDBdriver == 'mysql') {
1689
			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_notam_db' AND value > DATE_SUB(DATE(NOW()), INTERVAL 1 DAY)";
1690
		} else {
1691
			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_notam_db' AND value::timestamp > CURRENT_TIMESTAMP - INTERVAL '1 DAYS'";
1692
		}
1693
		try {
1694
			$Connection = new Connection();
1695
			$sth = $Connection->db->prepare($query);
1696
                        $sth->execute();
1697
                } catch(PDOException $e) {
1698
                        return "error : ".$e->getMessage();
1699
                }
1700
                $row = $sth->fetch(PDO::FETCH_ASSOC);
1701
                if ($row['nb'] > 0) return false;
1702
                else return true;
1703
	}
1704
1705
	public static function insert_last_notam_update() {
1706
		$query = "DELETE FROM config WHERE name = 'last_update_notam_db';
@@ 1717-1734 (lines=18) @@
1714
                }
1715
	}
1716
1717
	public static function check_last_owner_update() {
1718
		global $globalDBdriver;
1719
		if ($globalDBdriver == 'mysql') {
1720
			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_owner_db' AND value > DATE_SUB(DATE(NOW()), INTERVAL 15 DAY)";
1721
		} else {
1722
			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_owner_db' AND value::timestamp > CURRENT_TIMESTAMP - INTERVAL '15 DAYS'";
1723
		}
1724
		try {
1725
			$Connection = new Connection();
1726
			$sth = $Connection->db->prepare($query);
1727
                        $sth->execute();
1728
                } catch(PDOException $e) {
1729
                        return "error : ".$e->getMessage();
1730
                }
1731
                $row = $sth->fetch(PDO::FETCH_ASSOC);
1732
                if ($row['nb'] > 0) return false;
1733
                else return true;
1734
	}
1735
1736
	public static function insert_last_owner_update() {
1737
		$query = "DELETE FROM config WHERE name = 'last_update_owner_db';
@@ 1747-1764 (lines=18) @@
1744
                        return "error : ".$e->getMessage();
1745
                }
1746
	}
1747
	public static function check_last_schedules_update() {
1748
		global $globalDBdriver;
1749
		if ($globalDBdriver == 'mysql') {
1750
			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_schedules' AND value > DATE_SUB(DATE(NOW()), INTERVAL 15 DAY)";
1751
		} else {
1752
			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_owner_db' AND value::timestamp > CURRENT_TIMESTAMP - INTERVAL '15 DAYS'";
1753
		}
1754
		try {
1755
			$Connection = new Connection();
1756
			$sth = $Connection->db->prepare($query);
1757
                        $sth->execute();
1758
                } catch(PDOException $e) {
1759
                        return "error : ".$e->getMessage();
1760
                }
1761
                $row = $sth->fetch(PDO::FETCH_ASSOC);
1762
                if ($row['nb'] > 0) return false;
1763
                else return true;
1764
	}
1765
1766
	public static function insert_last_schedules_update() {
1767
		$query = "DELETE FROM config WHERE name = 'last_update_schedules';