Rolling release in progress... (Added minor releases)
This commit is contained in:
parent
c29cc92587
commit
0618dbbab3
|
@ -26,8 +26,22 @@ if (! file_exists ($config["homedir"] . $license_file)) {
|
|||
$license_file = 'general/license/pandora_info_en.html';
|
||||
}
|
||||
|
||||
if (!$config["minor_release_open"]) {
|
||||
$config["minor_release_open"] = 0;
|
||||
}
|
||||
if (enterprise_installed()) {
|
||||
if (!$config["minor_release_enterprise"]) {
|
||||
$config["minor_release_enterprise"] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
echo '<a class="white_bold footer" target="_blank" href="' . $config["homeurl"] . $license_file. '">';
|
||||
echo sprintf(__('Pandora FMS %s - Build %s', $pandora_version, $build_version));
|
||||
if (enterprise_installed()) {
|
||||
echo sprintf(__('Pandora FMS %s - Build %s - MR %s', $pandora_version, $build_version, $config["minor_release_enterprise"]));
|
||||
}
|
||||
else {
|
||||
echo sprintf(__('Pandora FMS %s - Build %s - MR %s', $pandora_version, $build_version, $config["minor_release_open"]));
|
||||
}
|
||||
echo '</a><br />';
|
||||
echo '<a class="white footer">'. __('Page generated at') . ' '. ui_print_timestamp ($time, true, array ("prominent" => "timestamp")); //Always use timestamp here
|
||||
echo '</a>';
|
||||
|
|
|
@ -1175,4 +1175,239 @@ function mysql_db_process_file ($path, $handle_error = true) {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// Initiates a transaction and run the queries of an sql file
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
function db_run_sql_file ($location) {
|
||||
global $config;
|
||||
|
||||
// Load file
|
||||
$commands = file_get_contents($location);
|
||||
|
||||
// Delete comments
|
||||
$lines = explode("\n", $commands);
|
||||
$commands = '';
|
||||
foreach ($lines as $line) {
|
||||
$line = trim($line);
|
||||
if ($line && !preg_match('/^--/', $line) && !preg_match('/^\/\*/', $line)) {
|
||||
$commands .= $line;
|
||||
}
|
||||
}
|
||||
|
||||
// Convert to array
|
||||
$commands = explode(";", $commands);
|
||||
|
||||
// Run commands
|
||||
mysql_db_process_sql_begin(); // Begin transaction
|
||||
foreach ($commands as $command) {
|
||||
if (trim($command)) {
|
||||
$result = mysql_query($command);
|
||||
|
||||
if (!$result) {
|
||||
break; // Error
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($result) {
|
||||
mysql_db_process_sql_commit(); // Save results
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
mysql_db_process_sql_rollback(); // Undo results
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the file or files in /extras/mr and apply minor releases.
|
||||
*
|
||||
* @return string Return error/success message.
|
||||
*/
|
||||
function db_update_schema () {
|
||||
global $config;
|
||||
|
||||
$dir = $config["homedir"]."/extras/mr";
|
||||
$message = '';
|
||||
|
||||
if (file_exists($dir) && is_dir($dir)) {
|
||||
if (is_readable($dir)) {
|
||||
if (enterprise_installed()) {
|
||||
$files = scandir($dir); // Get all the files from the directory ordered by asc
|
||||
|
||||
if ($files !== false) {
|
||||
$pattern = "/^\d+\.open\.sql$/";
|
||||
$sqlfiles = preg_grep($pattern, $files); // Get the name of the correct files
|
||||
$pattern = "/\.open\.sql$/";
|
||||
$replacement = "";
|
||||
$sqlfiles_num = preg_replace($pattern, $replacement, $sqlfiles); // Get the number of the file
|
||||
$sqlfiles = null;
|
||||
|
||||
if ($sqlfiles_num) {
|
||||
foreach ($sqlfiles_num as $sqlfile_num) {
|
||||
|
||||
$file = "$dir/$sqlfile_num.open.sql";
|
||||
|
||||
if ($config["minor_release_open"] >= $sqlfile_num) {
|
||||
if (!file_exists($dir."/updated") || !is_dir($dir."/updated")) {
|
||||
mkdir($dir."/updated");
|
||||
}
|
||||
$file_dest = "$dir/updated/$sqlfile_num.open.sql";
|
||||
if (copy($file, $file_dest)) {
|
||||
unlink($file);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$result = db_run_sql_file($file);
|
||||
|
||||
if ($result) {
|
||||
$update_config = update_config_token("minor_release_open", $sqlfile_num);
|
||||
if ($update_config) {
|
||||
$config["minor_release_open"] = $sqlfile_num;
|
||||
}
|
||||
|
||||
if ($config["minor_release_open"] == $sqlfile_num) {
|
||||
if (!file_exists($dir."/updated") || !is_dir($dir."/updated")) {
|
||||
mkdir($dir."/updated");
|
||||
}
|
||||
|
||||
$file_dest = "$dir/updated/$sqlfile_num.open.sql";
|
||||
|
||||
if (copy($file, $file_dest)) {
|
||||
unlink($file);
|
||||
}
|
||||
}
|
||||
|
||||
$message = "<h3 class='suc'>".__('The database schema has been updated to the minor release')." $sqlfile_num</h3>";
|
||||
}
|
||||
else {
|
||||
$message = "<h3 class='error'>".__('An error occurred while updating the database schema to the minor release')." $sqlfile_num</h3>";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$pattern2 = "/^\d+\.ent\.sql$/";
|
||||
$sqlfiles2 = preg_grep($pattern2, $files); // Get the name of the correct files
|
||||
$files = null;
|
||||
$pattern2 = "/\.ent\.sql$/";
|
||||
$replacement2 = "";
|
||||
$sqlfiles_num2 = preg_replace($pattern2, $replacement2, $sqlfiles2); // Get the number of the file
|
||||
$sqlfiles2 = null;
|
||||
|
||||
if ($sqlfiles_num2) {
|
||||
foreach ($sqlfiles_num2 as $sqlfile_num2) {
|
||||
|
||||
$file = "$dir/$sqlfile_num2.ent.sql";
|
||||
|
||||
if ($config["minor_release_enterprise"] >= $sqlfile_num2) {
|
||||
if (!file_exists($dir."/updated") || !is_dir($dir."/updated")) {
|
||||
mkdir($dir."/updated");
|
||||
}
|
||||
$file_dest = "$dir/updated/$sqlfile_num2.ent.sql";
|
||||
if (copy($file, $file_dest)) {
|
||||
unlink($file);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$result = db_run_sql_file($file);
|
||||
|
||||
if ($result) {
|
||||
$update_config2 = update_config_token("minor_release_enterprise", $sqlfile_num2);
|
||||
if ($update_config2) {
|
||||
$config["minor_release_enterprise"] = $sqlfile_num2;
|
||||
}
|
||||
|
||||
if ($config["minor_release_enterprise"] == $sqlfile_num2) {
|
||||
if (!file_exists($dir."/updated") || !is_dir($dir."/updated")) {
|
||||
mkdir($dir."/updated");
|
||||
}
|
||||
$file_dest = "$dir/updated/$sqlfile_num2.ent.sql";
|
||||
if (copy($file, $file_dest)) {
|
||||
unlink($file);
|
||||
}
|
||||
}
|
||||
|
||||
$message = "<h3 class='suc'>".__('The database schema has been updated to the minor release')." $sqlfile_num2</h3>";
|
||||
}
|
||||
else {
|
||||
$message = "<h3 class='error'>".__('An error occurred while updating the database schema to the minor release')." $sqlfile_num2</h3>";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$files = scandir($dir); // Get all the files from the directory ordered by asc
|
||||
|
||||
if ($files !== false) {
|
||||
$pattern = "/^\d+\.open\.sql$/";
|
||||
$sqlfiles = preg_grep($pattern, $files); // Get the name of the correct files
|
||||
$files = null;
|
||||
$pattern = "/\.open\.sql$/";
|
||||
$replacement = "";
|
||||
$sqlfiles_num = preg_replace($pattern, $replacement, $sqlfiles); // Get the number of the file
|
||||
$sqlfiles = null;
|
||||
|
||||
if ($sqlfiles_num) {
|
||||
foreach ($sqlfiles_num as $sqlfile_num) {
|
||||
|
||||
$file = "$dir/$sqlfile_num.open.sql";
|
||||
|
||||
if ($config["minor_release_open"] >= $sqlfile_num) {
|
||||
if (!file_exists($dir."/updated") || !is_dir($dir."/updated")) {
|
||||
mkdir($dir."/updated");
|
||||
}
|
||||
$file_dest = "$dir/updated/$sqlfile_num.open.sql";
|
||||
if (copy($file, $file_dest)) {
|
||||
unlink($file);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$result = db_run_sql_file($file);
|
||||
|
||||
if ($result) {
|
||||
$update_config = update_config_token("minor_release_open", $sqlfile_num);
|
||||
if ($update_config) {
|
||||
$config["minor_release_open"] = $sqlfile_num;
|
||||
}
|
||||
|
||||
if ($config["minor_release_open"] == $sqlfile_num) {
|
||||
if (!file_exists($dir."/updated") || !is_dir($dir."/updated")) {
|
||||
mkdir($dir."/updated");
|
||||
}
|
||||
|
||||
$file_dest = "$dir/updated/$sqlfile_num.open.sql";
|
||||
if (copy($file, $file_dest)) {
|
||||
unlink($file);
|
||||
}
|
||||
}
|
||||
|
||||
$message = "<h3 class='suc'>".__('The database schema has been updated to the minor release')." $sqlfile_num</h3>";
|
||||
}
|
||||
else {
|
||||
$message = "<h3 class='error'>".__('An error occurred while updating the database schema to the minor release ')." $sqlfile_num</h3>";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$message = "<h3 class='error'>".__('The directory '.$dir.' should have read permissions in order to update the database schema')."</h3>";
|
||||
}
|
||||
}
|
||||
else {
|
||||
$message = "<h3 class='error'>".__('The directory '.$dir.' does not exist')."</h3>";
|
||||
}
|
||||
|
||||
return $message;
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -2619,4 +2619,18 @@ function pandora_setlocale() {
|
|||
setlocale(LC_ALL,
|
||||
str_replace(array_keys($replace_locale), $replace_locale, $user_language));
|
||||
}
|
||||
|
||||
function update_config_token ($cfgtoken, $cfgvalue) {
|
||||
global $config;
|
||||
|
||||
$delete = db_process_sql ("DELETE FROM tconfig WHERE token = '$cfgtoken'");
|
||||
$insert = db_process_sql ("INSERT INTO tconfig (token, value) VALUES ('$cfgtoken', '$cfgvalue')");
|
||||
|
||||
if ($delete && $insert) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -1292,9 +1292,9 @@ function db_check_minor_relase_available () {
|
|||
if ($files !== false) {
|
||||
// Enterprise installed
|
||||
if (enterprise_installed()) {
|
||||
$pattern = "/^\d+\.open.sql$/";
|
||||
$pattern = "/^\d+\.open\.sql$/";
|
||||
$sqlfiles = preg_grep($pattern, $files); // Get the name of the correct files
|
||||
$pattern = "/\.open.sql$/";
|
||||
$pattern = "/\.open\.sql$/";
|
||||
$replacement = "";
|
||||
$sqlfiles_num = preg_replace($pattern, $replacement, $sqlfiles); // Get the number of the file
|
||||
|
||||
|
@ -1302,17 +1302,16 @@ function db_check_minor_relase_available () {
|
|||
|
||||
if ($sqlfiles_num) {
|
||||
foreach ($sqlfiles_num as $sqlfile_num) {
|
||||
$file = "$dir/$sqlfile_num.sql";
|
||||
if ($config["minor_release_open"] < $sqlfile_num) {
|
||||
$have_open_minor = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$pattern2 = "/^\d+\.ent.sql$/";
|
||||
$pattern2 = "/^\d+\.ent\.sql$/";
|
||||
$sqlfiles2 = preg_grep($pattern2, $files); // Get the name of the correct files
|
||||
$files = null;
|
||||
$pattern2 = "/\.ent.sql$/";
|
||||
$pattern2 = "/\.ent\.sql$/";
|
||||
$replacement2 = "";
|
||||
$sqlfiles_num2 = preg_replace($pattern2, $replacement2, $sqlfiles2); // Get the number of the file
|
||||
|
||||
|
@ -1320,7 +1319,6 @@ function db_check_minor_relase_available () {
|
|||
|
||||
if ($sqlfiles_num2) {
|
||||
foreach ($sqlfiles_num2 as $sqlfile_num2) {
|
||||
$file = "$dir/$sqlfile_num2.sql";
|
||||
if ($config["minor_release_enterprise"] < $sqlfile_num2) {
|
||||
$have_ent_minor = true;
|
||||
}
|
||||
|
@ -1339,7 +1337,6 @@ function db_check_minor_relase_available () {
|
|||
|
||||
if ($sqlfiles_num) {
|
||||
foreach ($sqlfiles_num as $sqlfile_num) {
|
||||
$file = "$dir/$sqlfile_num.sql";
|
||||
if ($config["minor_release"] < $sqlfile_num) {
|
||||
$have_open_minor = true;
|
||||
}
|
||||
|
|
|
@ -174,6 +174,7 @@ if ($change_pass == 1) {
|
|||
$changed_pass = login_update_password_check ($password_old, $password_new, $password_confirm, $id);
|
||||
}
|
||||
|
||||
$minor_release_message = false;
|
||||
$searchPage = false;
|
||||
$search = get_parameter_get("head_search_keywords");
|
||||
if (strlen($search) > 0) {
|
||||
|
@ -430,6 +431,8 @@ if (! isset ($config['id_user'])) {
|
|||
db_logon ($nick_in_db, $_SERVER['REMOTE_ADDR']);
|
||||
$_SESSION['id_usuario'] = $nick_in_db;
|
||||
$config['id_user'] = $nick_in_db;
|
||||
|
||||
$minor_release_message = db_update_schema();
|
||||
|
||||
//==========================================================
|
||||
//-------- SET THE CUSTOM CONFIGS OF USER ------------------
|
||||
|
@ -596,6 +599,26 @@ if ($old_global_counter_chat != $now_global_counter_chat) {
|
|||
$_SESSION['new_chat'] = true;
|
||||
}
|
||||
|
||||
if ($minor_release_message) {
|
||||
echo "<div class= 'dialog ui-dialog-content' title='".__("Minor release update")."' id='mr_dialog'>$minor_release_message</div>";
|
||||
echo "<script type='text/javascript'>";
|
||||
echo "$(document).ready (function () {";
|
||||
echo "$('#mr_dialog').dialog ({
|
||||
resizable: true,
|
||||
draggable: true,
|
||||
modal: true,
|
||||
overlay: {
|
||||
opacity: 0.5,
|
||||
background: 'black'
|
||||
},
|
||||
width: 400,
|
||||
height: 150
|
||||
});";
|
||||
echo "$('#mr_dialog').dialog('open');";
|
||||
echo " });";
|
||||
echo "</script>";
|
||||
}
|
||||
|
||||
if (get_parameter ('login', 0) !== 0) {
|
||||
// Display news dialog
|
||||
include_once("general/news_dialog.php");
|
||||
|
|
Loading…
Reference in New Issue