first step of migration to object oriented version of TSM Monitor

deleted functions.php, replaced with tsmmonitor.php which includes new class TSMMonitor
This commit is contained in:
Michael Clemens 2009-05-12 00:30:45 +00:00
parent 59246091e1
commit 19d46e48b4
10 changed files with 1707 additions and 1822 deletions

View File

@ -57,7 +57,7 @@ if ($_POST["css"] != "") {
<!-- Start left cik navigation menu -->
<td id="menue">
<div class="menuelinks">
<?php echo getMenu( $adminmenu, "admin.php?q=".$GETVars['qq']."&m=".$GETVars['menu'], "admin" ); ?>
<?php echo $tsmmonitor->getMenu( $tsmmonitor->adminmenu, "admin.php?q=".$tsmmonitor->GETVars['qq']."&m=".$tsmmonitor->GETVars['menu'], "admin" ); ?>
</div>
<br>
<img src="/images/trans.gif" alt="" width="150" height="1" border="0"><br>
@ -68,14 +68,14 @@ if ($_POST["css"] != "") {
<?php
// main content, right of menu
if (isset($_SESSION["logindata"]["user"]) && isset($_SESSION["logindata"]["pass"]) && $GETVars['qq'] != "logout" && $_SESSION["logindata"]["loggedin"]) {
if ($GETVars['qq'] != "" && $GETVars['qq'] != "overview") {
if (isset($_SESSION["logindata"]["user"]) && isset($_SESSION["logindata"]["pass"]) && $tsmmonitor->GETVars['qq'] != "logout" && $_SESSION["logindata"]["loggedin"]) {
if ($tsmmonitor->GETVars['qq'] != "" && $tsmmonitor->GETVars['qq'] != "overview") {
// show overview page
if ($GETVars['qq'] == "index") {
if ($tsmmonitor->GETVars['qq'] == "index") {
// do nothing
// show settings page
} else if ($GETVars['qq'] == "settings") {
} else if ($tsmmonitor->GETVars['qq'] == "settings") {
$tmonpolld = new PollD();
$tmonpolld->setDBParams($db_host, $db_name, $db_user, $db_password);
$tmonpolld->initialize();
@ -98,7 +98,7 @@ if (isset($_SESSION["logindata"]["user"]) && isset($_SESSION["logindata"]["pass"
}
echo "<b>PollD Control</b><br>";
echo "<form action=".$_SERVER['PHP_SELF']."?q=".$GETVars['qq']."&m=".$GETVars['menu']." method='post'>";
echo "<form action=".$_SERVER['PHP_SELF']."?q=".$tsmmonitor->GETVars['qq']."&m=".$tsmmonitor->GETVars['menu']." method='post'>";
echo "<table class='zebra'>";
echo "<tr><th>Start/Stop</th><th>Status</th></tr>";
echo "<tr class='d0'><td>";
@ -114,9 +114,9 @@ if (isset($_SESSION["logindata"]["user"]) && isset($_SESSION["logindata"]["pass"
$i = 0;
// show Add New Entry Form
if ($_POST['Add'] == "Add") {
$sqlth = "SHOW COLUMNS from cfg_".$GETVars['qq'];
$sqlresth = fetchArrayDB($sqlth, $conn);
echo "<form action=".$_SERVER['PHP_SELF']."?q=".$GETVars['qq']."&m=".$GETVars['menu']." method='post'>";
$sqlth = "SHOW COLUMNS from cfg_".$tsmmonitor->GETVars['qq'];
$sqlresth = $tsmmonitor->fetchArrayDB($sqlth, $conn);
echo "<form action=".$_SERVER['PHP_SELF']."?q=".$tsmmonitor->GETVars['qq']."&m=".$tsmmonitor->GETVars['menu']." method='post'>";
echo "<table class='zebra'>";
echo "<tr><th>Key</th><th>Value</th></tr>";
foreach ($sqlresth as $col) {
@ -144,8 +144,8 @@ echo "TEST: ".$col['Field']." -> $colval<br>\n";
// show Edit Existing Entry Form
} else {
$tablearray = getAdminTables("edit");
echo "<form action=".$_SERVER['PHP_SELF']."?q=".$GETVars['qq']."&m=".$GETVars['menu']." method='post'>";
$tablearray = $tsmmonitor->getAdminTables("edit");
echo "<form action=".$_SERVER['PHP_SELF']."?q=".$tsmmonitor->GETVars['qq']."&m=".$tsmmonitor->GETVars['menu']." method='post'>";
echo "<table class='zebra'>";
echo "<tr><th>Key</th><th>Value</th></tr>";
foreach ($tablearray as $row) {
@ -182,12 +182,12 @@ echo "TEST: ".$col['Field']." -> $colval<br>\n";
if ($_GET['action'] == "delete") {
echo $_POST['hidfield'];
$sql = "DELETE from cfg_".$_GET['q']." where id='".$_GET['id']."' LIMIT 1";
execDB($sql, $conn);
$tsmmonitor->execDB($sql, $conn);
}
// Process update of an existing item or insert of a new one
} else if ($_POST['EditSave'] == "Save" || $_POST['AddSave'] == "Save") {
$sqlth = "SHOW COLUMNS from cfg_".$_GET['q'];
$sqlresth = fetchArrayDB($sqlth, $conn);
$sqlresth = $tsmmonitor->fetchArrayDB($sqlth, $conn);
$colarray = array();
$colarray['id'] = $_POST['id'];
$set = "";
@ -228,13 +228,13 @@ echo "TEST: ".$col['Field']." -> $colval<br>\n";
} else if ($_POST['EditSave'] == "Save") {
$sql = "UPDATE cfg_".$_GET['q']." set ".$set." where id='".$_POST['id']."' LIMIT 1";
}
updateDB("cfg_".$_GET['q'], $colarray, 'id', $conn);
$tsmmonitor->updateDB("cfg_".$_GET['q'], $colarray, 'id', $conn);
}
echo "<form action=".$_SERVER['PHP_SELF']."?q=".$GETVars['qq']."&m=".$GETVars['menu']." method='post'>";
echo "<form action=".$_SERVER['PHP_SELF']."?q=".$tsmmonitor->GETVars['qq']."&m=".$tsmmonitor->GETVars['menu']." method='post'>";
echo "<table class='zebra'>";
echo getTableheader();
echo getAdminTables("list");
$nav = showPageNavigation("40");
echo $tsmmonitor->getTableheader();
echo $tsmmonitor->getAdminTables("list");
$nav = $tsmmonitor->showPageNavigation("40");
if ($nav!="") {
echo "<tr><td colspan='0' align='center' class='footer'><a class='navhead'>".$nav."</a></td></tr>";
}
@ -256,7 +256,7 @@ echo "TEST: ".$col['Field']." -> $colval<br>\n";
include_once "includes/login.php";
}
$_SESSION['from'] = $GETVars['qq'];
$_SESSION['from'] = $tsmmonitor->GETVars['qq'];
session_write_close(void);
?>

File diff suppressed because it is too large Load Diff

View File

@ -84,20 +84,26 @@ header("Pragma: no-cache");
// ** Include generic code and external libraries ** //
include ($config["library_path"] . "/adodb5/adodb.inc.php");
include_once($config["include_path"] . "/functions.php");
//include_once($config["include_path"] . "/functions.php");
include_once($config["include_path"] . "/tsmmonitor.php");
include_once($config["include_path"] . "/polld.php");
// ** instantiate TSMMonitor Class ** //
$tsmmonitor = new TSMMonitor();
// ** Connect to the database ** //
$conn = connectDB($db_host, $db_port, $db_user, $db_password, $db_name, $db_type);
//$conn = connectDB($db_host, $db_port, $db_user, $db_password, $db_name, $db_type);
$tsmmonitor->conn = $tsmmonitor->connectDB($db_host, $db_port, $db_user, $db_password, $db_name, $db_type);
// check to see if this is a new installation
$version = fetchCellDB("select confval from cfg_config where confkey='version'", '', $conn);
$version = $tsmmonitor->fetchCellDB("select confval from cfg_config where confkey='version'", '', $tsmmonitor->conn);
if ($version != $config["tsm_monitor_version"] && basename($_SERVER['REQUEST_URI']) != 'install.php') {
header("Location: install.php");
exit;
}
// ** Initialize PHP session ** //
initialize();
//initialize();
$tsmmonitor->initialize();
// ** Include generic code and external libraries ** //
// ... more includes here

View File

@ -39,7 +39,7 @@
<td width='48%' valign='top'>
<table class='zebra'>
<tr><th colspan="2">Health Status</th></tr>
<?php echo getOverviewRows($configarray["infoboxarray"]["healthdata"]); ?>
<?php echo $tsmmonitor->getOverviewRows($tsmmonitor->configarray["infoboxarray"]["healthdata"]); ?>
</table>
</td>
<td width='4%'>
@ -48,7 +48,7 @@
<table class='zebra'>
<tr><th colspan="2">TSM Database</th></tr>
<?php //echo getOverviewRows(getInfobox("database")); ?>
<?php echo getOverviewRows($configarray["infoboxarray"]["database"]); ?>
<?php echo $tsmmonitor->getOverviewRows($tsmmonitor->configarray["infoboxarray"]["database"]); ?>
</table>
</td>
</tr>
@ -58,7 +58,7 @@
<table class='zebra'>
<tr><th colspan="2">Total Data</th></tr>
<?php //echo getOverviewRows(getInfobox("totaldata")); ?>
<?php echo getOverviewRows($configarray["infoboxarray"]["totaldata"]); ?>
<?php echo $tsmmonitor->getOverviewRows($tsmmonitor->configarray["infoboxarray"]["totaldata"]); ?>
</table>
</td>
<td width='4%'>
@ -67,7 +67,7 @@
<table class='zebra'>
<tr><th colspan="2">Schedule Status</th></tr>
<?php //echo getOverviewRows(getInfobox("schedules")); ?>
<?php echo getOverviewRows($configarray["infoboxarray"]["schedules"]); ?>
<?php echo $tsmmonitor->getOverviewRows($tsmmonitor->configarray["infoboxarray"]["schedules"]); ?>
</table>
</td>
</tr>

View File

@ -160,16 +160,16 @@ function AddCol($field=-1,$width=-1,$caption='',$align='L')
* @param array $prop
*/
function Table($query,$prop=array(),$DBconn)
function Table($query,$prop=array(),$dbresult)
{
//Issue query
$res=fetchArrayDB($query, $DBconn);
//$res=fetchArrayDB($query, $DBconn);
//Add all columns if none was specified
if(count($this->aCols)==0)
{
foreach($res[0] as $colname => $col) {
foreach($dbresult[0] as $colname => $col) {
$this->AddCol(-1,-1,ucfirst($colname));
}
}
}
//Handle properties
@ -199,7 +199,7 @@ function Table($query,$prop=array(),$DBconn)
$this->SetFont('Arial','',6);
$this->ColorIndex=0;
$this->ProcessingTable=true;
foreach($res as $key => $row) {
foreach($dbresult as $key => $row) {
$row_num = array_values($row);
$row_comb = array_merge($row, $row_num);
$this->Row($row_comb);
@ -247,7 +247,6 @@ class PDF extends PDF_MySQL_Table
}
}
$pdf=new PDF();
$pdf->Open();
$pdf->AddPage();
@ -257,7 +256,9 @@ $prop=array('HeaderColor'=>array(180,180,180),
'color2'=>array(230,230,230),
'padding'=>2);
//$pdf->Table('select * from res_'.$_SESSION["GETVars"]["qq"].'_'.$_SESSION["GETVars"]["server"],$prop);
$pdf->Table($_SESSION["lastsql"],$prop,$conn);
$res = $tsmmonitor->fetchArrayDB($_SESSION["lastsql"], $tsmmonitor->conn);
//var_dump($res);
$pdf->Table($_SESSION["lastsql"],$prop,$res);
$pdf->Output();
?>

View File

@ -85,6 +85,7 @@ function setDBParams($db_host, $db_name, $db_user, $db_password){
function initialize() {
$this->setDBParams("localhost", "tsmmonitor", "tsmmonitor", "tsmmonitor");
$this->servers = $this->getServers();
$this->queries = $this->getQueries();
$this->overviewqueries = $this->getOverviewQueries();

View File

@ -31,19 +31,19 @@
?>
<form action="<?php echo $_SERVER['PHP_SELF']."?q=".$GETVars['qq']."&m=".$GETVars['menu']."&s=".$GETVars['server']; ?>" method="post">
<form action="<?php echo $_SERVER['PHP_SELF']."?q=".$tsmmonitor->GETVars['qq']."&m=".$tsmmonitor->GETVars['menu']."&s=".$tsmmonitor->GETVars['server']; ?>" method="post">
<?php
//if ($GETVars['qq'] != "admin" && !$_POST["edit"] == "edit") {
if ($GETVars['qq'] != "index" && $GETVars['qq'] != "overview" && $GETVars['qq'] != "serverlist") {
//if ($tsmmonitor->GETVars['qq'] != "admin" && !$_POST["edit"] == "edit") {
if ($tsmmonitor->GETVars['qq'] != "index" && $tsmmonitor->GETVars['qq'] != "overview" && $tsmmonitor->GETVars['qq'] != "serverlist") {
echo "<input type='button' value='PDF' onclick='genPDF()' class='button'>";
}
if ($GETVars['qq'] != "polldstat" && $GETVars['qq'] != "serverlist") {
if ($tsmmonitor->GETVars['qq'] != "polldstat" && $tsmmonitor->GETVars['qq'] != "serverlist") {
echo "<select name='s' size=1 onChange='submit();' class='button'>";
while(list($servername,$serveritems) = each($configarray["serverlist"])) {
while(list($servername,$serveritems) = each($tsmmonitor->configarray["serverlist"])) {
echo '<option value="'.$servername.'"';
if ($GETVars['server'] == $servername){echo "SELECTED";}
if ($tsmmonitor->GETVars['server'] == $servername){echo "SELECTED";}
echo '> '.$servername.' ('.$serveritems["description"].')</option>';
}
echo "</select>";

1620
includes/tsmmonitor.php Normal file

File diff suppressed because it is too large Load Diff

View File

@ -49,8 +49,8 @@ if ($_POST["css"] != "") {
<div id="tnbox1">
<?php
if ( $_SESSION["logindata"]["loggedin"] && !in_array($GETVars['qq'], array("admin", "serverlist", "custom", "polldstat", "index", "overview")) && !strstr($GETVars['qq'], 'table') ) {
echo getSearchfield();
if ( $_SESSION["logindata"]["loggedin"] && !in_array($tsmmonitor->GETVars['qq'], array("admin", "serverlist", "custom", "polldstat", "index", "overview", "")) && !strstr($tsmmonitor->GETVars['qq'], 'table') ) {
echo $tsmmonitor->getSearchfield();
}
?>
@ -66,15 +66,15 @@ if ($_POST["css"] != "") {
<!-- Start left cik navigation menu -->
<td id="menue">
<div class="menuelinks">
<?php echo getMenu( $submenu, "index.php?q=".$GETVars['qq']."&m=".$GETVars['menu']."&s=".$GETVars['server'], "index" ); ?>
<?php echo $tsmmonitor->getMenu( $tsmmonitor->submenu, "index.php?q=".$tsmmonitor->GETVars['qq']."&m=".$tsmmonitor->GETVars['menu']."&s=".$tsmmonitor->GETVars['server'], "index" ); ?>
</div>
<br>
<div class='menuelinks' id='datechooser'>
<?php echo getTimemachine(); ?>
<?php echo $tsmmonitor->getTimemachine(); ?>
</div>
<br>
<div class="menuelinks">
<?php echo getInfo(); ?>
<?php echo $tsmmonitor->getInfo(); ?>
</div>
<img src="/images/trans.gif" alt="" width="150" height="1" border="0"><br>
</td>
@ -84,27 +84,23 @@ if ($_POST["css"] != "") {
<?php
// main content, right of menu
if (isset($_SESSION["logindata"]["user"]) && isset($_SESSION["logindata"]["pass"]) && $GETVars['qq'] != "logout" && $_SESSION["logindata"]["loggedin"]){
if ($GETVars['qq'] != "" && $GETVars['qq'] != "overview"){
if (isset($_SESSION["logindata"]["user"]) && isset($_SESSION["logindata"]["pass"]) && $tsmmonitor->GETVars['qq'] != "logout" && $_SESSION["logindata"]["loggedin"]){
if ($tsmmonitor->GETVars['qq'] != "" && $tsmmonitor->GETVars['qq'] != "overview"){
// show overview page
if ($GETVars['qq'] == "index") {
if ($tsmmonitor->GETVars['qq'] == "index") {
include_once "includes/overview.php" ;
// show polld status
} else if ($GETVars['qq'] == "polldstat") {
echo getPollDStat();
} else if ($tsmmonitor->GETVars['qq'] == "polldstat") {
echo $tsmmonitor->getPollDStat();
// show custom query
} else if ($GETVars['qq'] == "custom") {
echo getCustomQuery();
// show serverlist
} else if ( $GETVars['qq'] == "serverlist" ) {
echo getServerlist();
} else if ( $tsmmonitor->GETVars['qq'] == "serverlist" ) {
echo $tsmmonitor->getServerlist();
// show graphical chart (timetable)
} else if ( strstr($GETVars['qq'], 'timetable')) {
} else if ( strstr($tsmmonitor->GETVars['qq'], 'timetable')) {
if ($_POST["back"] != "") {
$_SESSION['timeshift'] += $_SESSION['selectedtimestep'];
@ -116,16 +112,16 @@ if (isset($_SESSION["logindata"]["user"]) && isset($_SESSION["logindata"]["pass"
$_SESSION['timeshift'] = 0;
}
$tablearray = execute('timetable');
$headerarray = $queryarray[$GETVars['qq']]["header"]["column"];
echo generateTimetable($tablearray, $headerarray[0]);
$tablearray = $tsmmonitor->execute('timetable');
$headerarray = $queryarray[$tsmmonitor->GETVars['qq']]["header"]["column"];
echo $tsmmonitor->generateTimetable($tablearray, $headerarray[0]);
// "vertical" table
} else if ( strstr($GETVars['qq'], 'vertical')) {
} else if ( strstr($tsmmonitor->GETVars['qq'], 'vertical')) {
$i = 0;
$tablearray = execute('verticaltable');
$tablearray = $tsmmonitor->execute('verticaltable');
echo "<table class='zebra'>";
echo "<tr><th>Key</th><th>Value</th></tr>";
foreach ($tablearray as $row) {
@ -156,22 +152,22 @@ if (isset($_SESSION["logindata"]["user"]) && isset($_SESSION["logindata"]["pass"
//}
if ($whereclause["field"]!="" && $whereclause["val"]!="") {
if ($_POST["Clear"] == "Clear") {
$_SESSION["search"][$GETVars['qq']] = "";
$_SESSION["search"][$tsmmonitor->GETVars['qq']] = "";
} else {
if (!isset($_SESSION["search"])){
$temp = array();
$temp[$GETVars['qq']] = $whereclause;
$temp[$tsmmonitor->GETVars['qq']] = $whereclause;
$_SESSION["search"] = $temp;
} else {
$_SESSION["search"][$GETVars['qq']] = $whereclause;
$_SESSION["search"][$tsmmonitor->GETVars['qq']] = $whereclause;
}
}
}
echo "<table class='zebra'>";
//echo get_tableheader($queryarray[$GETVars['qq']]["header"]["column"]);
echo getTableheader();
echo execute('table');
$nav = showPageNavigation("40");
//echo get_tableheader($queryarray[$tsmmonitor->GETVars['qq']]["header"]["column"]);
echo $tsmmonitor->getTableheader();
echo $tsmmonitor->execute('table');
$nav = $tsmmonitor->showPageNavigation("40");
if ($nav!="") {
echo "<tr><td colspan='999' align='center' class='footer'><a class='navhead'>".$nav."</a></td></tr>";
}
@ -192,7 +188,7 @@ if (isset($_SESSION["logindata"]["user"]) && isset($_SESSION["logindata"]["pass"
include_once "includes/login.php";
}
$_SESSION['from'] = $GETVars['qq'];
$_SESSION['from'] = $tsmmonitor->GETVars['qq'];
session_write_close(void);
?>

View File

@ -62,7 +62,7 @@ $ext_miss
$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 = $tsmmonitor->fetchCellDB("select confval from cfg_config where confkey='version'", '', $tsmmonitor->conn);
// try to find current (old) version in the array
$old_version_index = array_search($old_tsm_monitor_version, $tsm_monitor_versions);
@ -94,9 +94,9 @@ if ($old_tsm_monitor_version == $config["tsm_monitor_version"]) {
// dsmadmc binary path
$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"];
$which_dsmadmc = $tsmmonitor->findPath("dsmadmc", $config["search_path"]);
if (isset($tsmmonitor->configarray["settings"]["path_dsmadmc"])) {
$input["path_dsmadmc"]["default"] = $tsmmonitor->configarray["settings"]["path_dsmadmc"];
} else if (!empty($which_dsmadmc)) {
$input["path_dsmadmc"]["default"] = $which_dsmadmc;
} else {
@ -106,12 +106,12 @@ if (isset($configarray["settings"]["path_dsmadmc"])) {
// php/php5 binary path
$input["path_php"]["name"] = "PHP Binary Path";
$input["path_php"]["desc"] = "The path to the PHP binary.";
$which_php = findPath("php", $config["search_path"]);
$which_php = $tsmmonitor->findPath("php", $config["search_path"]);
if(!isset($which_php)) {
$which_php = findPath("php5", $config["search_path"]);
$which_php = $tsmmonitor->findPath("php5", $config["search_path"]);
}
if (isset($configarray["settings"]["path_php"])) {
$input["path_php"]["default"] = $configarray["settings"]["path_php"];
if (isset($tsmmonitor->configarray["settings"]["path_php"])) {
$input["path_php"]["default"] = $tsmmonitor->configarray["settings"]["path_php"];
} else if (!empty($which_php)) {
$input["path_php"]["default"] = $which_php;
} else {
@ -121,8 +121,8 @@ if (isset($configarray["settings"]["path_php"])) {
// logfile path
$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"];
if (isset($tsmmonitor->configarray["settings"]["path_tmlog"])) {
$input["path_tmlog"]["default"] = $tsmmonitor->configarray["settings"]["path_tmlog"];
} else {
$input["path_tmlog"]["default"] = $config["base_path"] . "tsmmonitor.log";
}
@ -173,11 +173,11 @@ if ($_REQUEST["step"] == "90") {
// 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);
$tsmmonitor->updateDB('cfg_config', array(confkey => "$name", confval => $_POST[$name], description => $array['name']), 'confkey', $tsmmonitor->conn);
}
}
updateDB('cfg_config', array(confkey => 'version', confval => $config['tsm_monitor_version']), 'confkey', $conn);
closeDB($conn);
$tsmmonitor->updateDB('cfg_config', array(confkey => 'version', confval => $config['tsm_monitor_version']), 'confkey', $tsmmonitor->conn);
$tsmmonitor->closeDB($tsmmonitor->conn);
header("Location: index.php");
exit;
} elseif (($_REQUEST["step"] == "40") && ($_REQUEST["install_type"] == "20")) {