- added checks for PHP extension modules.

- added checks for external binaries (dsmadmc, php) and logfile.
This commit is contained in:
Frank Fegert 2009-05-10 21:04:57 +00:00
parent 08c6e7d3bd
commit 228d07c602
4 changed files with 220 additions and 52 deletions

View File

@ -85,8 +85,8 @@ function initialize() {
$configarray = $_SESSION['configarray']; $configarray = $_SESSION['configarray'];
// timeout // timeout
if( !ini_get('safe_mode') && ini_get('max_execution_time') != $configarray["timeout"]) { if( !ini_get('safe_mode') && ini_get('max_execution_time') != $configarray["settings"]["timeout"]) {
ini_set('max_execution_time', $configarray["timeout"]); ini_set('max_execution_time', $configarray["settings"]["timeout"]);
} }
// set defaults if vars are empty // set defaults if vars are empty
@ -1318,7 +1318,7 @@ function getConfigArray() {
global $conn; global $conn;
$retArray = array(); $retArray = array();
//Navigation // Navigation
$query = "SELECT * from cfg_mainmenu"; $query = "SELECT * from cfg_mainmenu";
$mainmenutablerows = fetchArrayDB($query, $conn); $mainmenutablerows = fetchArrayDB($query, $conn);
@ -1387,7 +1387,7 @@ function getConfigArray() {
$adminmenuarray["q=logout"] = "Logout"; $adminmenuarray["q=logout"] = "Logout";
$retArray["adminmenuarray"] = $adminmenuarray; $retArray["adminmenuarray"] = $adminmenuarray;
//Overview Boxes // Overview Boxes
$ret = array(); $ret = array();
$query = "SELECT * from cfg_overviewboxes order by sortorder asc"; $query = "SELECT * from cfg_overviewboxes order by sortorder asc";
@ -1405,7 +1405,7 @@ function getConfigArray() {
} }
$retArray["infoboxarray"] = $ret; $retArray["infoboxarray"] = $ret;
//Queries // Queries
$dbret = array(); $dbret = array();
$query = "SELECT * from cfg_queries"; $query = "SELECT * from cfg_queries";
$querytablerows = fetchArrayDB($query, $conn); $querytablerows = fetchArrayDB($query, $conn);
@ -1414,17 +1414,21 @@ function getConfigArray() {
} }
$retArray["queryarray"] = $dbret; $retArray["queryarray"] = $dbret;
// Set Timeout // General settings
$query = "SELECT * from cfg_config where confkey='timeout'"; $query = "SELECT * from cfg_config";
$row = fetchArrayDB($query, $conn); $rows = fetchArrayDB($query, $conn);
$retArray["timeout"] = $row[0]['confval']; $ret = array();
foreach ($rows as $key => $val) {
$ret[$val['confkey']] = $val['confval'];
}
$retArray["settings"] = $ret;
// Set Stylesheet // Set Stylesheet
$query = "SELECT stylesheet from cfg_users where username='".$_SESSION["logindata"]["user"]."'"; $query = "SELECT stylesheet from cfg_users where username='".$_SESSION["logindata"]["user"]."'";
$row = fetchArrayDB($query, $conn); $row = fetchArrayDB($query, $conn);
$retArray["stylesheet"] = $row[0]['stylesheet']; $retArray["stylesheet"] = $row[0]['stylesheet'];
//Colors // Colors
$query = "SELECT * from cfg_colors"; $query = "SELECT * from cfg_colors";
$rows = fetchArrayDB($query, $conn); $rows = fetchArrayDB($query, $conn);
@ -1451,6 +1455,22 @@ function getConfigArray() {
} }
/**
* findPath - find a external program in the search path
*
* @param string $binary the external program to search for
* @param string $search_path the search path in which to look for the external program
* @return string the full path to the external program or empty string if not found
*/
function findPath($binary, $search_path) {
foreach ($search_path as $path) {
if ((file_exists($path . "/" . $binary)) && (is_readable($path . "/" . $binary))) {
return($path . "/" . $binary);
}
}
}
/** /**
* connectDB - establish a DB connection via ADODB * connectDB - establish a DB connection via ADODB
* *
@ -1670,7 +1690,7 @@ function fetchSplitArrayDB($sql, $DBconn = FALSE, $rows_per_page = '20') {
* @return string Auto-increment ID if insert was performed * @return string Auto-increment ID if insert was performed
*/ */
function updateDB($table, $cells, $keys, $DBconn = FALSE, $autoquote = TRUE) { function updateDB($table, $cells, $keys, $DBconn = FALSE, $autoquote = TRUE) {
// $DBconn->debug = true; //$DBconn->debug = true;
$DBconn->Replace($table, $cells, $keys, $autoquote); $DBconn->Replace($table, $cells, $keys, $autoquote);
return $DBconn->Insert_ID(); return $DBconn->Insert_ID();

View File

@ -57,7 +57,18 @@ $config = array();
// ** Current TSM Monitor version ** // // ** Current TSM Monitor version ** //
$config["tsm_monitor_version"] = '0.1.0'; $config["tsm_monitor_version"] = '0.1.0';
// ** Set TSM Monitor server OS to a general value (only 'unix' or 'win32') ** //
$config["server_os"] = (strstr(PHP_OS, "WIN")) ? "win32" : "unix";
// ** Search paths for external programs (dsmadmc, php, ...) ** //
if ($config["server_os"] == "win32") {
$config["search_path"] = array('c:/php', 'c:/progra~1/php', 'd:/php', 'd:/progra~1/php', 'c:/progra~1/tivoli/tsm/baclient', 'd:/progra~1/tivoli/tsm/baclient');
} elseif ($config["server_os"] == "unix") {
$config["search_path"] = array('/bin', '/sbin', '/usr/bin', '/usr/sbin', '/usr/local/bin', '/usr/local/sbin', '/usr/tivoli/tsm/client/admin/bin', '/opt/tivoli/tsm/client/ba/bin');
}
// ** Paths (libraries, includes, ...) ** // // ** Paths (libraries, includes, ...) ** //
$config["base_path"] = ereg_replace("(.*[\\\/])includes", "\\1", dirname(__FILE__));
$config["library_path"] = ereg_replace("(.*[\\\/])includes", "\\1extlib", dirname(__FILE__)); $config["library_path"] = ereg_replace("(.*[\\\/])includes", "\\1extlib", dirname(__FILE__));
$config["include_path"] = dirname(__FILE__); $config["include_path"] = dirname(__FILE__);

View File

@ -29,13 +29,37 @@
*/ */
include_once "includes/global.php"; include_once "includes/global.php";
if ($_REQUEST["step"] != "30" && $_REQUEST["step"] != "40") { if ($_REQUEST["step"] != "50" || $_REQUEST["refresh"] != "") {
include_once "includes/page_head.php"; include_once "includes/page_head.php";
} }
// allow the upgrade script to run for as long as it needs to // allow the upgrade script to run for as long as it needs to
ini_set("max_execution_time", "0"); ini_set("max_execution_time", "0");
// check if the necessary PHP extensions are loaded
$exts = array("session", "sockets");
$ext_load = true;
foreach ($exts as $ext) {
if (!extension_loaded($ext)){
$ext_load = false;
$ext_miss .= " <li style='font-size: 12px;'>$ext</li>\n";
}
}
if (!$ext_load) {
echo "
<p style='font-size: 16px; font-weight: bold; color: red;'>Error</p>
<p style='font-size: 12px;'>The following PHP extensions are missing:</p>
<ul>
$ext_miss
</ul>
<p style='font-family: Verdana, Arial; font-size: 12px;'>Please install those PHP extensions and retry the installation process.</p>
</table>
</div>
</body>
</html>";
exit;
}
$tsm_monitor_versions = array("0.1.0", "0.1.1"); $tsm_monitor_versions = array("0.1.0", "0.1.1");
$old_tsm_monitor_version = fetchCellDB("select confval from cfg_config where confkey='version'", '', $conn); $old_tsm_monitor_version = fetchCellDB("select confval from cfg_config where confkey='version'", '', $conn);
@ -43,30 +67,69 @@ $old_tsm_monitor_version = fetchCellDB("select confval from cfg_config where con
// try to find current (old) version in the array // try to find current (old) version in the array
$old_version_index = array_search($old_tsm_monitor_version, $tsm_monitor_versions); $old_version_index = array_search($old_tsm_monitor_version, $tsm_monitor_versions);
/* do a version check */ // do a version check
if ($old_tsm_monitor_version == $config["tsm_monitor_version"]) { if ($old_tsm_monitor_version == $config["tsm_monitor_version"]) {
echo " echo "
<p style='font-size: 16px; font-weight: bold; color: red;'>Error</p>\n <p style='font-size: 16px; font-weight: bold; color: red;'>Error</p>
<p>This installation is already up-to-date. Click <a href='index.php'>here</a> to use TSM Monitor.</p>\n <p>This installation is already up-to-date. Click <a href='index.php'>here</a> to use TSM Monitor.</p>
</div>\n </table>
</table>\n </div>
</body>\n </body>
</html>\n"; </html>";
exit; exit;
} elseif (empty($old_tsm_monitor_version)) { } elseif (empty($old_tsm_monitor_version)) {
echo " echo "
<p style='font-size: 16px; font-weight: bold; color: red;'>Error</p>\n <p style='font-size: 16px; font-weight: bold; color: red;'>Error</p>
<p>You have created a new database, but have not yet imported the 'tsmmonitor.sql' file. At the command line, execute the following to continue:</p>\n <p>You have created a new database, but have not yet imported the 'tsmmonitor.sql' file. At the command line, execute the following to continue:</p>
<p><pre>mysql -u $db_user -p $db_password < tsmmonitor.sql</pre></p>\n <p><pre>mysql -u $db_user -p $db_password < tsmmonitor.sql</pre></p>
<p>This error may also be generated if the TSM Monitor database user does not have correct permissions on the TSM Monitor database.<br>\n <p>This error may also be generated if the TSM Monitor database user does not have correct permissions on the TSM Monitor database.<br>
Please ensure that the TSM Monitor database user has the ability to SELECT, INSERT, DELETE, UPDATE, CREATE, ALTER, DROP, INDEX on the TSM Monitor database.</p>\n Please ensure that the TSM Monitor database user has the ability to SELECT, INSERT, DELETE, UPDATE, CREATE, ALTER, DROP, INDEX on the TSM Monitor database.</p>
</div>\n </table>
</table>\n </div>
</body>\n </body>
</html>\n"; </html>";
exit; exit;
} }
// dsmadmc binary path
$input["path_dsmadmc"] = $configarray["settings"]["path_dsmadmc"];
$input["path_dsmadmc"]["name"] = "dsmadmc Binary Path";
$input["path_dsmadmc"]["desc"] = "The path to the TSM admin client binary.";
$which_dsmadmc = findPath("dsmadmc", $config["search_path"]);
if (isset($configarray["settings"]["path_dsmadmc"])) {
$input["path_dsmadmc"]["default"] = $configarray["settings"]["path_dsmadmc"];
} else if (!empty($which_dsmadmc)) {
$input["path_dsmadmc"]["default"] = $which_dsmadmc;
} else {
$input["path_dsmadmc"]["default"] = "dsmadmc";
}
// php/php5 binary path
$input["path_php"] = $configarray["settings"]["path_php"];
$input["path_php"]["name"] = "PHP Binary Path";
$input["path_php"]["desc"] = "The path to the PHP binary.";
$which_php = findPath("php", $config["search_path"]);
if(!isset($which_php)) {
$which_php = findPath("php5", $config["search_path"]);
}
if (isset($configarray["settings"]["path_php"])) {
$input["path_php"]["default"] = $configarray["settings"]["path_php"];
} else if (!empty($which_php)) {
$input["path_php"]["default"] = $which_php;
} else {
$input["path_php"]["default"] = "php";
}
// logfile path
$input["path_tmlog"] = $configarray["settings"]["path_tmlog"];
$input["path_tmlog"]["name"] = "TSM Monitor Logfile Path";
$input["path_tmlog"]["desc"] = "The path to the TSM Monitor log file.";
if (isset($configarray["settings"]["path_tmlog"])) {
$input["path_tmlog"]["default"] = $configarray["settings"]["path_tmlog"];
} else {
$input["path_tmlog"]["default"] = $config["base_path"] . "tsmmonitor.log";
}
// 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;
@ -79,27 +142,43 @@ if ($old_tsm_monitor_version == "new_install") {
} }
// pre-processing that needs to be done for each step // pre-processing that needs to be done for each step
// Intro and license page
if (empty($_REQUEST["step"])) { if (empty($_REQUEST["step"])) {
$_REQUEST["step"] = 10; $_REQUEST["step"] = 10;
} else { } else {
// Install or update chooser
if ($_REQUEST["step"] == "10") { if ($_REQUEST["step"] == "10") {
$_REQUEST["step"] = "20"; $_REQUEST["step"] = "20";
} elseif (($_REQUEST["step"] == "20") && ($_REQUEST["install_type"] == "10")) { } elseif (($_REQUEST["step"] == "20") && ($_REQUEST["install_type"] == "10")) {
$_REQUEST["step"] = "30"; $_REQUEST["step"] = "30";
} elseif (($_REQUEST["step"] == "20") && ($_REQUEST["install_type"] == "20")) { } elseif (($_REQUEST["step"] == "20") && ($_REQUEST["install_type"] == "20")) {
$_REQUEST["step"] = "40"; $_REQUEST["step"] = "40";
// Install
} elseif ($_REQUEST["step"] == "30") { } elseif ($_REQUEST["step"] == "30") {
$_REQUEST["step"] = "90"; $_REQUEST["step"] = "50";
// Update
} elseif ($_REQUEST["step"] == "40") { } elseif ($_REQUEST["step"] == "40") {
$_REQUEST["step"] = "50";
} elseif (($_REQUEST["step"] == "50") && ($_POST["refresh"] == "Refresh")) {
$_REQUEST["step"] = "50";
// get (possibly) updated values from the forms
foreach ($input as $name => $array) {
if (isset($_POST[$name])) {
$input[$name]["default"] = $_POST[$name];
}
}
} elseif ($_REQUEST["step"] == "50") {
$_REQUEST["step"] = "90"; $_REQUEST["step"] = "90";
} }
} }
if ($_REQUEST["step"] == "90") { if ($_REQUEST["step"] == "90") {
// Flush updated data to DB // Flush updated data to DB
// ... foreach ($input as $name => $array) {
// ... if (isset($_POST[$name])) {
// ... updateDB('cfg_config', array(confkey => "$name", confval => $_POST[$name], description => $array['name']), 'confkey', $conn);
}
}
updateDB('cfg_config', array(confkey => 'version', confval => $config['tsm_monitor_version']), 'confkey', $conn); updateDB('cfg_config', array(confkey => 'version', confval => $config['tsm_monitor_version']), 'confkey', $conn);
closeDB($conn); closeDB($conn);
header("Location: index.php"); header("Location: index.php");
@ -108,21 +187,21 @@ if ($_REQUEST["step"] == "90") {
// if the version is not found, die // if the version is not found, die
if (!is_int($old_version_index)) { if (!is_int($old_version_index)) {
echo " echo "
<p style='font-size: 16px; font-weight: bold; color: red;'>Error</p>\n <p style='font-size: 16px; font-weight: bold; color: red;'>Error</p>
<p style='font-size: 12px;'>Invalid TSM Monitor version\n <p style='font-size: 12px;'>Invalid TSM Monitor version
<strong>$old_tsm_monitor_version</strong>, cannot upgrade to <strong>".$config["tsm_monitor_version"]."</strong>\n <strong>$old_tsm_monitor_version</strong>, cannot upgrade to <strong>".$config["tsm_monitor_version"]."</strong>
</p> </p>
</div>\n </table>
</table>\n </div>
</body>\n </body>
</html>\n"; </html>";
exit; exit;
} }
// 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.1") { if ($tsm_monitor_versions[$i] == "0.1.0") {
include "install/0_1_to_0_1_1.php"; include "install/0_1_0_to_0_1_1.php";
upgrade_to_0_1_1(); upgrade_to_0_1_1();
} /* elseif ($tsm_monitor_versions[$i] == "0.1.1") { } /* elseif ($tsm_monitor_versions[$i] == "0.1.1") {
include "install/0_1_1_to_0_1_2.php"; include "install/0_1_1_to_0_1_2.php";
@ -153,7 +232,7 @@ if ($_REQUEST["step"] == "90") {
<td id="tnleft"> <td id="tnleft">
<table width="100%" border="0"> <table width="100%" border="0">
<tr> <tr>
<td> <td colspan="2">
<?php // Installation Step 10 <?php // Installation Step 10
if ($_REQUEST["step"] == "10") { if ($_REQUEST["step"] == "10") {
?> ?>
@ -222,23 +301,80 @@ if ($_REQUEST["step"] == "90") {
<p> <p>
Upgrade stuff could be done here ... Upgrade stuff could be done here ...
</p> </p>
<?php } ?>
<?php // Installation Step 50
} elseif ($_REQUEST["step"] == "50") {
?>
<p>
Please check if the following values have been correctly determined for your
system and correct if necessary.
</p>
<?php
foreach ($input as $name => $array) {
if (isset($input[$name])) {
$file = $array["default"];
$resStr = "";
$capStr = "";
if (file_exists($file)) {
$resStr = "<font color='#008000'>[FOUND]</font> ";
$capStr = "<span style='color:green'><br>[OK: FILE FOUND]</span>";
} else {
$resStr = "<font color='#FF0000'>[NOT FOUND]</font> ";
$capStr = "<span style='color:red'><br>[ERROR: FILE NOT FOUND]</span>";
}
echo "
<p>
<strong>" . $resStr . $array["name"];
if (!empty($array["name"])) {
echo "</strong>: " . $array["desc"];
} else {
echo $array["desc"] . "</strong>";
}
echo "
<br>
<input type='text' id='$name' name='$name' size='50' value='". htmlspecialchars($file, ENT_QUOTES) . "'>" . $capStr . "
<br>
</p>";
}
}
?>
<p>
<strong>NOTE:</strong> Once you click "Finish", the above settings will be
saved "as-is" to the TSM Monitor database. No further validation will 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
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>
<?php
}
?>
</td> </td>
</tr> </tr>
<tr> <tr>
<td>&nbsp;</td> <td colspan="2">&nbsp;</td>
</tr> </tr>
<tr> <tr>
<td align="right"> <td width=75% align="right">
<p> <p>
<?php if ($_REQUEST["step"] == "30" || $_REQUEST["step"] == "40") { ?> <?php if ($_REQUEST["step"] == "50") { ?>
<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" 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="refresh" value="Refresh">
</p>
</td>
<td align="right">
<p>
<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 { ?>
<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" value="Next"> <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="next" value="Next">
<?php } ?> <?php } ?>
</p> </p>
@ -252,6 +388,7 @@ if ($_REQUEST["step"] == "90") {
</form> </form>
<!-- Done --> <!-- Done -->
<?php session_write_close(void); ?> <?php session_write_close(void); ?>
</td> </td>
</tr> </tr>
<?php include_once "includes/footer.php"; ?> <?php include_once "includes/footer.php"; ?>