. ************************************************************************ */ /** * * admin.php, TSM Monitor * * admin backend * * @author Michael Clemens * @package tsmmonitor */ include_once "includes/global.php"; include_once "includes/page_head.php"; if ($_SESSION["logindata"]["role"]!="admin") { $_SESSION["logindata"] = ""; } if ($_POST["css"] != "") { $_SESSION['stylesheet'] = $_POST["css"]; } ?>

GETVars['qq'] != "logout" && $_SESSION["logindata"]["loggedin"]) { if ($tsmmonitor->GETVars['qq'] != "" && $tsmmonitor->GETVars['qq'] != "overview") { // show overview page if ($tsmmonitor->GETVars['qq'] == "index") { // do nothing // show settings page } else if ($tsmmonitor->GETVars['qq'] == "settings") { $tmonpolld = new PollD($adodb, $config["server_os"]); $tmonpolld->adodb->setDebug($_SESSION["debug"]); // If start/stop button was pressed if ($_POST["PollDControl"] != "") { if ($_POST["PollDControl"] == "Start") { $tmonpolld->controlPollD("on"); } else if ($_POST["PollDControl"] == "Stop") { $tmonpolld->controlPollD("off"); } } if ($tmonpolld->isEnabled()=="1") { $polldenabled = "enabled and ".$tmonpolld->getStatus(); } else { $polldenabled = "disabled"; } echo "
"; echo ""; echo ""; echo ""; echo " "; echo " "; echo " "; echo ""; echo ""; echo " "; echo " "; echo " "; echo ""; echo ""; echo " "; echo " "; echo " "; echo ""; echo "
ConfigurationActionStatus
PollD Control"; echo " "; echo " "; echo " PollD is ".$polldenabled."
Debug Mode"; echo " "; echo " "; echo " ".$_SESSION["debug"]."
PollD Control"; echo " "; echo " "; echo "
"; echo " "; echo " "; echo " "; echo " "; echo " "; echo " "; echo " "; echo " "; echo " "; echo "
"; echo "
"; echo "
"; } else { if ( ($_GET['action'] != "" && ($_GET['action'] == "edit" && $_GET['id'] != "")) || $_POST['Add'] == "Add") { $i = 0; // show Add New Entry Form if ($_POST['Add'] == "Add") { $sqlth = "SHOW COLUMNS from cfg_".$tsmmonitor->GETVars['qq']; $sqlresth = $adodb->fetchArrayDB($sqlth); echo "
"; echo ""; echo ""; foreach ($sqlresth as $col) { if ($col['Field'] != "id") { if ($i == 0) { echo ""; $i = 1; } else { echo ""; $i = 0; } if ($col['Field'] == "password") { echo ""; } else { echo ""; } } } echo ""; echo "
KeyValue
".$col['Field']."
".$col['Field']."
"; // show Edit Existing Entry Form } else { $tablearray = $tsmmonitor->getAdminTables("edit"); echo "
"; echo ""; echo ""; foreach ($tablearray as $row) { while(list($keycell, $valcell) = each($row)) { if ($i == 0) { echo ""; $i = 1; } else { echo ""; $i = 0; } if ($keycell == "password") { echo "\n"; } else if ($keycell == "id") { $id = $valcell; } else { echo "\n"; } } } echo ""; echo "
KeyValue
".$keycell."
".$keycell.""; if (strlen($valcell) < 150) { echo ""; } else { echo ""; } echo "
"; } // show List of all entries } else { // Process deletion of an item if ( $_GET['id'] != "" && $_GET['action'] != "") { if ($_GET['action'] == "delete") { echo $_POST['hidfield']; $sql = "DELETE from cfg_".$_GET['q']." where id='".$_GET['id']."' LIMIT 1"; $adodb->execDB($sql); } // 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 = $adodb->fetchArrayDB($sqlth); $colarray = array(); $colarray['id'] = $_POST['id']; $set = array(); $sqlcols = array(); $sqlvals = array(); // get all table fields to be selected foreach ($sqlresth as $col) { if (get_magic_quotes_gpc() != 0) { $_POST["txt".$col['Field']] = stripslashes($_POST["txt".$col['Field']]); } if ($col['Field'] != "id") { if ($col['Field'] == "password" && $tsmmonitor->GETVars['qq'] != 'servers') { if ($_POST["txt".$col['Field']] != "") { $val = md5($_POST["txt".$col['Field']]); } else { $pwerr = "

Password cannot be empty! Password was not reset.

"; continue; } } else { $val = $_POST["txt".$col['Field']]; } if ($_POST['AddSave'] == "Save") { $colarray["`".$col['Field']."`"] = $val; $val = "'".$val."'"; array_push($sqlcols, $col['Field']); array_push($sqlvals, $val); } else if ($_POST['EditSave'] == "Save") { $colarray["`".$col['Field']."`"] = $val; array_push($set, $col['Field']."='".$val."'"); } } } if ($_POST['AddSave'] == "Save") { $sql = "INSERT into cfg_".$_GET['q']." (".(implode(",", $sqlcols)).") values (".(implode(",", $sqlvals)).")"; } else if ($_POST['EditSave'] == "Save") { $sql = "UPDATE cfg_".$_GET['q']." set ".(implode(",", $set))." where id='".$_POST['id']."' LIMIT 1"; } $adodb->updateDB("cfg_".$_GET['q'], $colarray, 'id'); } if (!empty($pwerr)) echo $pwerr; echo "
"; echo ""; $thead = $tsmmonitor->getTableheader(); echo $thead["header"]; $tbody = $tsmmonitor->getAdminTables("list"); if ($tbody != "") { echo $tbody; } else { echo ""; } echo "
No entries found in database.
"; echo ""; echo "
"; } } } } else { if (isset($_SESSION["logindata"])) { $errormsg = "Login failed!"; } else { $errormsg = "Login"; } session_unset(); $_SESSION=array(); include_once "includes/login.php"; } $_SESSION['from'] = $tsmmonitor->GETVars['qq']; session_write_close(void); ?>