From 1292217a4b8e9e9ff39917dffa25d29c140d87f9 Mon Sep 17 00:00:00 2001 From: Bastien Pujos Date: Tue, 24 Jul 2018 14:03:59 +0200 Subject: [PATCH] All the update --- include/config.php | 2 +- include/function.php | 33 +++++++++++++++++++++++++++ index.php | 1 + login.php | 1 - module/admin_notifier/db/notifier.sql | 1 + 5 files changed, 36 insertions(+), 2 deletions(-) diff --git a/include/config.php b/include/config.php index 99bc3bd..b1ac437 100644 --- a/include/config.php +++ b/include/config.php @@ -23,7 +23,7 @@ // ####################################### // # General Information // ####################################### -$version="5.2"; +$version="5.2.1"; // ####################################### // # Database config information diff --git a/include/function.php b/include/function.php index 895977c..e28c9b0 100644 --- a/include/function.php +++ b/include/function.php @@ -1312,4 +1312,37 @@ function getEonConfig($name,$type=false) } +function checkUpdateDB(){ + global $version; + global $database_eonweb; + global $database_username; + global $database_password; + + $version_sql = sqlrequest($database_eonweb,"SELECT count(value) as value FROM configs WHERE name='version'"); + if(mysqli_result($version_sql,0,"value") == 0){ + $version_sql = sqlrequest($database_eonweb,"INSERT INTO configs (name, value) VALUES('version', '".$version."')"); + + // execution de tous les .sql jusqu'à la version donné dans config + exec("ls /srv/eyesofnetwork/eonweb/appliance/updates/ | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n", $SQL_Files); + + foreach($SQL_Files as $file){ + echo "mysql -u $database_username --password=$database_password < /srv/eyesofnetwork/eonweb/appliance/updates/$file"; + exec("mysql -u $database_username --password=$database_password < /srv/eyesofnetwork/eonweb/appliance/updates/$file"); + } + + }else{ + $versionBD = mysqli_result(sqlrequest($database_eonweb,"SELECT value FROM configs WHERE name='version'"),0,"value"); + + // execution des .sql entre version en BD et celle config + exec("ls /srv/eyesofnetwork/eonweb/appliance/updates/ | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n", $SQL_Files); + foreach($SQL_Files as $file){ + if((rtrim($file,'.sql') <= $version && rtrim($file,'.sql') > $versionBD)){ + echo "mysql -u $database_username --password=$database_password < /srv/eyesofnetwork/eonweb/appliance/updates/$file"; + exec("mysql -u $database_username --password=$database_password < /srv/eyesofnetwork/eonweb/appliance/updates/$file"); + } + } + sqlrequest($database_eonweb,"UPDATE configs SET value='$version' WHERE name='version'"); + } +} + ?> diff --git a/index.php b/index.php index 9d08941..8ca0fa0 100644 --- a/index.php +++ b/index.php @@ -23,6 +23,7 @@ include("include/config.php"); include("include/function.php"); $defaultpage=getDefaultPage(); +checkUpdateDB(); header("Location: $defaultpage"); ?> diff --git a/login.php b/login.php index 0618142..eea5233 100644 --- a/login.php +++ b/login.php @@ -255,5 +255,4 @@ else { } else { display_login(); } } - ?> diff --git a/module/admin_notifier/db/notifier.sql b/module/admin_notifier/db/notifier.sql index 6545282..fe89290 100644 --- a/module/admin_notifier/db/notifier.sql +++ b/module/admin_notifier/db/notifier.sql @@ -128,6 +128,7 @@ CREATE TABLE `rules` ( `notificationnumber` varchar(255) NOT NULL DEFAULT '*', `timeperiod_id` bigint unsigned NOT NULL, `sort_key` int(32) NOT NULL default 0, + `tracking` INT(11) NULL DEFAULT '0', PRIMARY KEY (`id`), KEY `timeperiod_id` (`timeperiod_id`), CONSTRAINT `rules_ibfk_1` FOREIGN KEY (`timeperiod_id`) REFERENCES `timeperiods` (`id`) -- GitLab