. ************************************************************************ */ /** * * 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); $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(); //$cellcolor = "green"; } else { $polldenabled = "disabled"; //$cellcolor = "red"; } 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) { echo "TEST: ".$col['Field']." -> $colval
\n"; 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 ""; } else if ($keycell == "id") { $id = $valcell; } else { echo ""; } } } echo ""; echo "
KeyValue
".$keycell."
".$keycell."
"; } // 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 = ""; $sqlcols = ""; $sqlvals = ""; // get all table fields to be selected foreach ($sqlresth as $col) { if ($col['Field'] != "id") { if ($col['Field'] == "password") { if ($_POST["txt".$col['Field']] != "") { $val = md5($_POST["txt".$col['Field']]); } else { $val = ""; } } else { $val = $_POST["txt".$col['Field']]; } // if ($val != "") { if ($_POST['AddSave'] == "Save") { $colarray["`".$col['Field']."`"] = $val; $sqlcols .= $col['Field']; $sqlvals .= "'".$val."'"; $sqlcols .= ", "; $sqlvals .= ", "; } else if ($_POST['EditSave'] == "Save") { $colarray["`".$col['Field']."`"] = $val; $set .= $col['Field']."='".$val."'"; $set .= ", "; } // } } } $sqlcols = ereg_replace(", $", "", $sqlcols); $sqlvals = ereg_replace(", $", "", $sqlvals); if ($_POST['AddSave'] == "Save") { $sql = "INSERT into cfg_".$_GET['q']." (".$sqlcols.") values (".$sqlvals.")"; } else if ($_POST['EditSave'] == "Save") { $sql = "UPDATE cfg_".$_GET['q']." set ".$set." where id='".$_POST['id']."' LIMIT 1"; } $adodb->updateDB("cfg_".$_GET['q'], $colarray, 'id'); } echo "
"; echo ""; echo $tsmmonitor->getTableheader(); echo $tsmmonitor->getAdminTables("list"); $nav = $tsmmonitor->showPageNavigation("40"); if ($nav!="") { echo ""; } echo "
"; 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); ?>