2017-05-22 11:24:21 +02:00
|
|
|
<?php
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// NagiosQL
|
|
|
|
//
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2019-04-17 11:40:50 +02:00
|
|
|
// (c) 2005-2018 by Martin Willisegger
|
2017-05-22 11:24:21 +02:00
|
|
|
//
|
|
|
|
// Project : NagiosQL
|
|
|
|
// Component : Admin time definition list
|
2019-04-17 11:40:50 +02:00
|
|
|
// Website : https://sourceforge.net/projects/nagiosql/
|
|
|
|
// Version : 3.4.0
|
|
|
|
// GIT Repo : https://gitlab.com/wizonet/NagiosQL
|
2017-05-22 11:24:21 +02:00
|
|
|
//
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2019-04-17 11:40:50 +02:00
|
|
|
// Path settings
|
|
|
|
// ===================
|
|
|
|
$strPattern = '(admin/[^/]*.php)';
|
|
|
|
$preRelPath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING));
|
|
|
|
$preBasePath = preg_replace($strPattern, '', filter_input(INPUT_SERVER, 'SCRIPT_FILENAME', FILTER_SANITIZE_STRING));
|
|
|
|
//
|
2017-05-22 11:24:21 +02:00
|
|
|
// Define common variables
|
|
|
|
// =======================
|
2019-04-17 11:40:50 +02:00
|
|
|
$preAccess = 1;
|
|
|
|
$preNoMain = 1;
|
2017-05-22 11:24:21 +02:00
|
|
|
//
|
|
|
|
// Include preprocessing file
|
|
|
|
// ==========================
|
2019-04-17 11:40:50 +02:00
|
|
|
require $preBasePath.'functions/prepend_adm.php';
|
2017-05-22 11:24:21 +02:00
|
|
|
//
|
|
|
|
// Process post parameters
|
|
|
|
// =======================
|
2019-04-17 11:40:50 +02:00
|
|
|
$chkTipId = filter_input(INPUT_GET, 'tipId', FILTER_VALIDATE_INT, array('options' => array('default' => 0)));
|
|
|
|
$chkVersion = filter_input(INPUT_GET, 'version', FILTER_VALIDATE_INT, array('options' => array('default' => 0)));
|
|
|
|
$chkMode = filter_input(INPUT_GET, 'mode', FILTER_SANITIZE_STRING);
|
|
|
|
$chkDef = filter_input(INPUT_GET, 'def', FILTER_SANITIZE_STRING);
|
|
|
|
$chkRange = filter_input(INPUT_GET, 'range', FILTER_SANITIZE_STRING);
|
|
|
|
$chkId = filter_input(INPUT_GET, 'id', FILTER_SANITIZE_STRING);
|
2017-05-22 11:24:21 +02:00
|
|
|
if (get_magic_quotes_gpc() == 0) {
|
2019-04-17 11:40:50 +02:00
|
|
|
$chkDef = addslashes($chkDef);
|
|
|
|
$chkRange = addslashes($chkRange);
|
2017-05-22 11:24:21 +02:00
|
|
|
}
|
|
|
|
//
|
|
|
|
// Get data
|
|
|
|
// ========
|
2019-04-17 11:40:50 +02:00
|
|
|
$strSQL = "SELECT * FROM `tbl_timedefinition` WHERE `tipId`=$chkTipId ORDER BY `definition`";
|
|
|
|
$booReturn = $myDBClass->hasDataArray($strSQL, $arrDataLines, $intDataCount);
|
2017-05-22 11:24:21 +02:00
|
|
|
//
|
|
|
|
// Store data to session
|
|
|
|
// ============================
|
2019-04-17 11:40:50 +02:00
|
|
|
if ($chkMode == '') {
|
|
|
|
$_SESSION['timedefinition'] = array();
|
|
|
|
if ($booReturn && ($intDataCount != 0)) {
|
|
|
|
foreach ($arrDataLines as $elem) {
|
|
|
|
$arrTemp['id'] = $elem['id'];
|
|
|
|
$arrTemp['definition'] = addslashes($elem['definition']);
|
|
|
|
$arrTemp['range'] = addslashes($elem['range']);
|
|
|
|
$arrTemp['status'] = 0;
|
|
|
|
$_SESSION['timedefinition'][] = $arrTemp;
|
|
|
|
}
|
|
|
|
}
|
2017-05-22 11:24:21 +02:00
|
|
|
}
|
|
|
|
//
|
|
|
|
// Add mode
|
|
|
|
// =========
|
2019-04-17 11:40:50 +02:00
|
|
|
if ($chkMode == 'add') {
|
|
|
|
if (isset($_SESSION['timedefinition']) && is_array($_SESSION['timedefinition'])) {
|
|
|
|
$intCheck = 0;
|
|
|
|
foreach ($_SESSION['timedefinition'] as $key => $elem) {
|
|
|
|
if (($elem['definition'] == $chkDef) && ($elem['status'] == 0)) {
|
|
|
|
$_SESSION['timedefinition'][$key]['definition'] = $chkDef;
|
|
|
|
$_SESSION['timedefinition'][$key]['range'] = $chkRange;
|
|
|
|
$intCheck = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($intCheck == 0) {
|
|
|
|
$arrTemp['id'] = 0;
|
|
|
|
$arrTemp['definition'] = $chkDef;
|
|
|
|
$arrTemp['range'] = $chkRange;
|
|
|
|
$arrTemp['status'] = 0;
|
|
|
|
$_SESSION['timedefinition'][] = $arrTemp;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$arrTemp['id'] = 0;
|
|
|
|
$arrTemp['definition'] = $chkDef;
|
|
|
|
$arrTemp['range'] = $chkRange;
|
|
|
|
$arrTemp['status'] = 0;
|
|
|
|
$_SESSION['timedefinition'][] = $arrTemp;
|
|
|
|
}
|
2017-05-22 11:24:21 +02:00
|
|
|
}
|
|
|
|
//
|
|
|
|
// Deletion mode
|
|
|
|
// =============
|
2019-04-17 11:40:50 +02:00
|
|
|
if ($chkMode == 'del' && isset($_SESSION['timedefinition']) && is_array($_SESSION['timedefinition'])) {
|
|
|
|
foreach ($_SESSION['timedefinition'] as $key => $elem) {
|
|
|
|
if (($elem['definition'] == $chkDef) && ($elem['status'] == 0)) {
|
|
|
|
$_SESSION['timedefinition'][$key]['status'] = 1;
|
|
|
|
}
|
|
|
|
}
|
2017-05-22 11:24:21 +02:00
|
|
|
}
|
|
|
|
?>
|
|
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
|
|
<html>
|
2019-04-17 11:40:50 +02:00
|
|
|
<head>
|
|
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
|
|
<title>None</title>
|
|
|
|
<link href="<?php
|
|
|
|
echo $_SESSION['SETS']['path']['base_url']; ?>config/main.css" rel="stylesheet" type="text/css">
|
|
|
|
<!--suppress JSUnresolvedVariable -->
|
|
|
|
<script type="text/javascript">
|
|
|
|
<!--
|
|
|
|
function doEdit(key,range) {
|
2017-05-22 11:24:21 +02:00
|
|
|
<?php
|
|
|
|
if ($chkVersion == 3) {
|
|
|
|
?>
|
2019-04-17 11:40:50 +02:00
|
|
|
parent.document.frmDetail.txtTimedefinition.value = decodeURIComponent(key);
|
|
|
|
parent.document.frmDetail.txtTimerange2.value = decodeURIComponent(range);
|
2017-05-22 11:24:21 +02:00
|
|
|
<?php
|
|
|
|
} else {
|
|
|
|
?>
|
2019-04-17 11:40:50 +02:00
|
|
|
if (key === "monday") {
|
|
|
|
parent.document.frmDetail.selTimedefinition.selectedIndex = 0;
|
|
|
|
} else if (key === "tuesday") {
|
|
|
|
parent.document.frmDetail.selTimedefinition.selectedIndex = 1;
|
|
|
|
} else if (key === "wednesday") {
|
|
|
|
parent.document.frmDetail.selTimedefinition.selectedIndex = 2;
|
|
|
|
} else if (key === "thursday") {
|
|
|
|
parent.document.frmDetail.selTimedefinition.selectedIndex = 3;
|
|
|
|
} else if (key === "friday") {
|
|
|
|
parent.document.frmDetail.selTimedefinition.selectedIndex = 4;
|
|
|
|
} else if (key === "saturday") {
|
|
|
|
parent.document.frmDetail.selTimedefinition.selectedIndex = 5;
|
|
|
|
} else if (key === "sunday") {
|
|
|
|
parent.document.frmDetail.selTimedefinition.selectedIndex = 6;
|
|
|
|
}
|
|
|
|
parent.document.frmDetail.txtTimerange1.value = range;
|
2017-05-22 11:24:21 +02:00
|
|
|
<?php
|
|
|
|
}
|
|
|
|
?>
|
2019-04-17 11:40:50 +02:00
|
|
|
}
|
|
|
|
function doDel(key) {
|
|
|
|
document.location.href = "<?php
|
|
|
|
echo $_SESSION['SETS']['path']['base_url']; ?>admin/timedefinitions.php?tipId=<?php
|
|
|
|
echo $chkTipId; ?>&mode=del&def="+key;
|
|
|
|
}
|
|
|
|
//-->
|
|
|
|
</script>
|
|
|
|
<style type="text/css">
|
|
|
|
.tablerow {
|
|
|
|
border-bottom:1px solid #009900;
|
|
|
|
font-size:12px;
|
|
|
|
height:20px;
|
|
|
|
padding-top:2px;
|
|
|
|
padding-left:5px;
|
|
|
|
padding-right:5px;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
</head>
|
|
|
|
<body style="margin:0">
|
|
|
|
<table cellpadding="0" cellspacing="0" border="0" width="100%">
|
2017-05-22 11:24:21 +02:00
|
|
|
<?php
|
2019-04-17 11:40:50 +02:00
|
|
|
if (isset($_SESSION['timedefinition']) && is_array($_SESSION['timedefinition']) &&
|
|
|
|
(count($_SESSION['timedefinition']) != 0)) {
|
|
|
|
foreach ($_SESSION['timedefinition'] as $elem) {
|
|
|
|
if ($elem['status'] == 0) {
|
2017-05-22 11:24:21 +02:00
|
|
|
?>
|
2019-04-17 11:40:50 +02:00
|
|
|
<tr>
|
|
|
|
<td class="tablerow" style="padding-bottom:2px; width:260px"><?php
|
|
|
|
echo htmlentities(stripslashes($elem['definition']), ENT_COMPAT, 'UTF-8'); ?></td>
|
|
|
|
<td class="tablerow" style="padding-bottom:2px; width:260px"><?php
|
|
|
|
echo htmlentities(stripslashes($elem['range']), ENT_COMPAT, 'UTF-8'); ?></td>
|
|
|
|
<td class="tablerow" style="width:50px" align="right"><img src="<?php
|
|
|
|
echo $_SESSION['SETS']['path']['base_url']; ?>images/edit.gif" width="18" height="18" alt="<?php
|
|
|
|
echo translate('Modify'); ?>" title="<?php echo translate('Modify'); ?>" onClick="doEdit('<?php
|
|
|
|
echo rawurlencode(stripslashes($elem['definition'])); ?>','<?php
|
|
|
|
echo rawurlencode(stripslashes($elem['range'])); ?>')" style="cursor:pointer"> <img src="<?php
|
|
|
|
echo $_SESSION['SETS']['path']['base_url']; ?>images/delete.gif" width="18" height="18" alt="<?php
|
|
|
|
echo translate('Delete'); ?>" title="<?php echo translate('Delete'); ?>" onClick="doDel('<?php
|
|
|
|
echo rawurlencode(stripslashes($elem['definition'])); ?>')" style="cursor:pointer"></td>
|
|
|
|
</tr>
|
2017-05-22 11:24:21 +02:00
|
|
|
<?php
|
2019-04-17 11:40:50 +02:00
|
|
|
}
|
|
|
|
}
|
2017-05-22 11:24:21 +02:00
|
|
|
} else {
|
|
|
|
?>
|
2019-04-17 11:40:50 +02:00
|
|
|
<tr>
|
|
|
|
<td class="tablerow"><?php echo translate('No data'); ?></td>
|
|
|
|
<td class="tablerow"> </td>
|
|
|
|
<td class="tablerow" align="right"> </td>
|
|
|
|
</tr>
|
2017-05-22 11:24:21 +02:00
|
|
|
<?php
|
|
|
|
}
|
|
|
|
?>
|
2019-04-17 11:40:50 +02:00
|
|
|
</table>
|
|
|
|
</body>
|
2017-05-22 11:24:21 +02:00
|
|
|
</html>
|