mirror of
https://codeberg.org/mclemens/tsmmonitor2.git
synced 2025-01-30 03:06:30 -05:00
- Prepared installer upgrade routine for next release.
This commit is contained in:
parent
414af8a1eb
commit
a7b160aace
86
install.php
86
install.php
@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
include_once "includes/global.php";
|
include_once "includes/global.php";
|
||||||
$_SESSION["stylesheet"] = "style_classic.css";
|
$_SESSION["stylesheet"] = "style_classic.css";
|
||||||
if ($_REQUEST["step"] != "80" || $_REQUEST["refresh"] != "") {
|
if (($_REQUEST["step"] != "80" && $_REQUEST["step"] != "60" ) || $_REQUEST["refresh"] != "") {
|
||||||
include_once "includes/page_head.php";
|
include_once "includes/page_head.php";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ $error_head = "<p style='font-size: 16px; font-weight: bold; color: red;'>Error<
|
|||||||
$funcs = array("popen");
|
$funcs = array("popen");
|
||||||
$func_ena = true;
|
$func_ena = true;
|
||||||
foreach ($funcs as $func) {
|
foreach ($funcs as $func) {
|
||||||
if (!function_exists($func)){
|
if (!function_exists($func)) {
|
||||||
$func_ena = false;
|
$func_ena = false;
|
||||||
$func_miss .= " <li style='font-size: 12px;'>$func</li>\n";
|
$func_miss .= " <li style='font-size: 12px;'>$func</li>\n";
|
||||||
}
|
}
|
||||||
@ -71,7 +71,7 @@ $func_miss
|
|||||||
$exts = array("session", "sockets");
|
$exts = array("session", "sockets");
|
||||||
$ext_load = true;
|
$ext_load = true;
|
||||||
foreach ($exts as $ext) {
|
foreach ($exts as $ext) {
|
||||||
if (!extension_loaded($ext)){
|
if (!extension_loaded($ext)) {
|
||||||
$ext_load = false;
|
$ext_load = false;
|
||||||
$ext_miss .= " <li style='font-size: 12px;'>$ext</li>\n";
|
$ext_miss .= " <li style='font-size: 12px;'>$ext</li>\n";
|
||||||
}
|
}
|
||||||
@ -89,7 +89,7 @@ $ext_miss
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Try to find current (old) version in the array
|
// Try to find current (old) version in the array
|
||||||
$tsm_monitor_versions = array("0.1.0", "0.1.1");
|
$tsm_monitor_versions = array("0.0.1", "0.0.2");
|
||||||
$old_tsm_monitor_version = $adodb->fetchCellDB("SELECT confval FROM cfg_config WHERE confkey='version'", '');
|
$old_tsm_monitor_version = $adodb->fetchCellDB("SELECT confval FROM cfg_config WHERE confkey='version'", '');
|
||||||
$old_version_index = array_search($old_tsm_monitor_version, $tsm_monitor_versions);
|
$old_version_index = array_search($old_tsm_monitor_version, $tsm_monitor_versions);
|
||||||
|
|
||||||
@ -111,6 +111,20 @@ if ($old_tsm_monitor_version == $config["tsm_monitor_version"]) {
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function upgradeDB($version, $sql) {
|
||||||
|
global $adodb;
|
||||||
|
$sql_cache = (isset($_SESSION["install"]["sql_cache"]) ? $_SESSION["install"]["sql_cache"] : array());
|
||||||
|
|
||||||
|
if ($adodb->execDB($sql)) {
|
||||||
|
$sql_cache{sizeof($sql_cache)}[$version][1] = $sql;
|
||||||
|
} else {
|
||||||
|
$sql_cache{sizeof($sql_cache)}[$version][0] = $sql;
|
||||||
|
}
|
||||||
|
|
||||||
|
$_SESSION["install"]["sql_cache"] = $sql_cache;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Default for the install type
|
// Default for the install type
|
||||||
if (!isset($_REQUEST["install_type"])) {
|
if (!isset($_REQUEST["install_type"])) {
|
||||||
$_REQUEST["install_type"] = 0;
|
$_REQUEST["install_type"] = 0;
|
||||||
@ -288,7 +302,12 @@ if (empty($_REQUEST["step"])) {
|
|||||||
}
|
}
|
||||||
// Update page
|
// Update page
|
||||||
elseif ($_REQUEST["step"] == "60") {
|
elseif ($_REQUEST["step"] == "60") {
|
||||||
$_REQUEST["step"] = "80";
|
// set new version, disable installer and redirect to login page
|
||||||
|
$adodb->updateDB('cfg_config', array(confkey => 'version', confval => $config['tsm_monitor_version']), 'confkey');
|
||||||
|
$adodb->closeDB();
|
||||||
|
$_SESSION["stylesheet"] = "";
|
||||||
|
header("Location: index.php");
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
// Refresh on php limits page or finish and flush data to db
|
// Refresh on php limits page or finish and flush data to db
|
||||||
elseif ($_REQUEST["step"] == "80") {
|
elseif ($_REQUEST["step"] == "80") {
|
||||||
@ -342,13 +361,13 @@ if ($_REQUEST["step"] == "90") {
|
|||||||
|
|
||||||
// Loop over all versions up to the current and perform incremental updates
|
// Loop over all versions up to the current and perform incremental updates
|
||||||
for ($i = ($old_version_index+1); $i < count($tsm_monitor_versions); $i++) {
|
for ($i = ($old_version_index+1); $i < count($tsm_monitor_versions); $i++) {
|
||||||
if ($tsm_monitor_versions[$i] == "0.0.1") {
|
if ($tsm_monitor_versions[$i] == "0.0.2") {
|
||||||
include "install/0_0_1_to_0_0_2.php";
|
include "install/0_0_1_to_0_0_2.php";
|
||||||
upgrade_to_0_0_2();
|
upgrade_to_0_0_2($adodb);
|
||||||
} /* elseif ($tsm_monitor_versions[$i] == "0.0.2") {
|
} /* elseif ($tsm_monitor_versions[$i] == "0.0.3") {
|
||||||
include "install/0_0_2_to_0_0_3.php";
|
include "install/0_0_2_to_0_0_3.php";
|
||||||
upgrade_to_0_0_3();
|
upgrade_to_0_0_3();
|
||||||
} elseif ($tsm_monitor_versions[$i] == "0.0.3") {
|
} elseif ($tsm_monitor_versions[$i] == "0.0.4") {
|
||||||
include "install/0_0_3_to_0_0_4.php";
|
include "install/0_0_3_to_0_0_4.php";
|
||||||
upgrade_to_0_0_4();
|
upgrade_to_0_0_4();
|
||||||
} */
|
} */
|
||||||
@ -655,11 +674,45 @@ if ($_REQUEST["step"] == "90") {
|
|||||||
} elseif ($_REQUEST["step"] == "60") {
|
} elseif ($_REQUEST["step"] == "60") {
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<p>
|
<p>Upgrade results:</p>
|
||||||
Sorry, this is the initial TSM Monitor version, there are currently no
|
<?php
|
||||||
updates from previous versions available. Please choose "New install"
|
$current_version = "";
|
||||||
on the previous page.
|
$upgrade_results = "";
|
||||||
</p>
|
$failed_sql_query = false;
|
||||||
|
|
||||||
|
$fail_text = "<span style='color: red; font-weight: bold; font-size: 12px;'>[Fail]</span> ";
|
||||||
|
$success_text = "<span style='color: green; font-weight: bold; font-size: 12px;'>[Success]</span> ";
|
||||||
|
|
||||||
|
if (isset($_SESSION["install"]["sql_cache"])) {
|
||||||
|
while (list($index, $arr1) = each($_SESSION["install"]["sql_cache"])) {
|
||||||
|
while (list($version, $arr2) = each($arr1)) {
|
||||||
|
while (list($status, $sql) = each($arr2)) {
|
||||||
|
if ($current_version != $version) {
|
||||||
|
$version_index = array_search($version, $tsm_monitor_versions);
|
||||||
|
$upgrade_results .= "<p><strong>From version " . $tsm_monitor_versions{$version_index-1} . " to version " . $tsm_monitor_versions{$version_index} . "</strong></p>\n";
|
||||||
|
}
|
||||||
|
$upgrade_results .= "<p class='code'>" . (($status == 0) ? $fail_text : $success_text) . nl2br($sql) . "</p>\n";
|
||||||
|
|
||||||
|
if ($status == 0) {
|
||||||
|
$failed_sql_query = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$current_version = $version;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
unset($_SESSION["install"]["sql_cache"]);
|
||||||
|
} else {
|
||||||
|
print "<em>No SQL queries have been executed.</em>";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($failed_sql_query == true) {
|
||||||
|
print "<p><strong><font color='#FF0000'>WARNING:</font></strong> One or more of the SQL queries needed to upgraded your TSM Monitor installation has failed. Please see below for more details. Your TSM Monitor MySQL user must have <strong>SELECT, INSERT, UPDATE, DELETE, ALTER, CREATE, and DROP</strong> permissions. You should try executing the failed queries as 'root' on the MySQL command line to ensure that you do not have a permissions problem.</p>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
print $upgrade_results;
|
||||||
|
|
||||||
|
?>
|
||||||
<?php // Installation Step 80 (PHP Limits)
|
<?php // Installation Step 80 (PHP Limits)
|
||||||
} elseif ($_REQUEST["step"] == "80") {
|
} elseif ($_REQUEST["step"] == "80") {
|
||||||
?>
|
?>
|
||||||
@ -750,9 +803,6 @@ if ($_REQUEST["step"] == "90") {
|
|||||||
be performed, so please make sure the above settings are correct! Any of
|
be performed, so please make sure the above settings are correct! Any of
|
||||||
the above settings can later on be changed with the TSM Monitor admin web
|
the above settings can later on be changed with the TSM Monitor admin web
|
||||||
interface.
|
interface.
|
||||||
<br>
|
|
||||||
If you did choose to upgrade from a previous version of TSM Monitor, the
|
|
||||||
database will also be upgraded by clicking "Finish".
|
|
||||||
</p>
|
</p>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
@ -777,7 +827,7 @@ if ($_REQUEST["step"] == "90") {
|
|||||||
|
|
||||||
<td align="right">
|
<td align="right">
|
||||||
<p>
|
<p>
|
||||||
<?php if ($_REQUEST["step"] == "80") { ?>
|
<?php if (($_REQUEST["step"] == "80") || ($_REQUEST["step"] == "60")) { ?>
|
||||||
|
|
||||||
<input style='display: block; width: auto; background: #eaeaea; margin-bottom: 2px; padding: 3px 30px 3px 30px; color: #000000; font-size: 11px; font-weight: bold; text-decoration: none; border: 1px solid #ffffff;' type="submit" name="finish" value="Finish">
|
<input style='display: block; width: auto; background: #eaeaea; margin-bottom: 2px; padding: 3px 30px 3px 30px; color: #000000; font-size: 11px; font-weight: bold; text-decoration: none; border: 1px solid #ffffff;' type="submit" name="finish" value="Finish">
|
||||||
<?php } else { ?>
|
<?php } else { ?>
|
||||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user