rework logic of functions to be more verbose about errors. Implement javascript Nonce support when view=none
This commit is contained in:
parent
1f3da476b8
commit
599769b701
|
@ -20,31 +20,41 @@
|
||||||
|
|
||||||
|
|
||||||
// Monitor edit actions, require a monitor id and edit permissions for that monitor
|
// Monitor edit actions, require a monitor id and edit permissions for that monitor
|
||||||
if ( !empty($_REQUEST['mid']) && canEdit('Monitors', $_REQUEST['mid']) ) {
|
if ( empty($_REQUEST['mid']) ) {
|
||||||
$mid = validInt($_REQUEST['mid']);
|
Error("Must specify mid");
|
||||||
if ( $action == 'function' ) {
|
return;
|
||||||
$monitor = dbFetchOne('SELECT * FROM Monitors WHERE Id=?', NULL, array($mid));
|
}
|
||||||
|
$mid = validInt($_REQUEST['mid']);
|
||||||
|
if ( !canEdit('Monitors', $mid) ) {
|
||||||
|
Error("You do not have permission to edit monitor $mid");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$newFunction = validStr($_REQUEST['newFunction']);
|
if ( $action == 'function' ) {
|
||||||
# Because we use a checkbox, it won't get passed in the request. So not being in _REQUEST means 0
|
$monitor = dbFetchOne('SELECT * FROM Monitors WHERE Id=?', NULL, array($mid));
|
||||||
$newEnabled = ( !isset($_REQUEST['newEnabled']) or $_REQUEST['newEnabled'] != '1' ) ? '0' : '1';
|
|
||||||
$oldFunction = $monitor['Function'];
|
|
||||||
$oldEnabled = $monitor['Enabled'];
|
|
||||||
if ( $newFunction != $oldFunction || $newEnabled != $oldEnabled ) {
|
|
||||||
dbQuery('UPDATE Monitors SET Function=?, Enabled=? WHERE Id=?',
|
|
||||||
array($newFunction, $newEnabled, $mid));
|
|
||||||
|
|
||||||
$monitor['Function'] = $newFunction;
|
$newFunction = validStr($_REQUEST['newFunction']);
|
||||||
$monitor['Enabled'] = $newEnabled;
|
# Because we use a checkbox, it won't get passed in the request. So not being in _REQUEST means 0
|
||||||
if ( daemonCheck() && ($monitor['Type'] != 'WebSite') ) {
|
$newEnabled = ( !isset($_REQUEST['newEnabled']) or $_REQUEST['newEnabled'] != '1' ) ? '0' : '1';
|
||||||
$restart = ($oldFunction == 'None') || ($newFunction == 'None') || ($newEnabled != $oldEnabled);
|
$oldFunction = $monitor['Function'];
|
||||||
zmaControl($monitor, 'stop');
|
$oldEnabled = $monitor['Enabled'];
|
||||||
zmcControl($monitor, $restart?'restart':'');
|
if ( $newFunction != $oldFunction || $newEnabled != $oldEnabled ) {
|
||||||
zmaControl($monitor, 'start');
|
dbQuery('UPDATE Monitors SET Function=?, Enabled=? WHERE Id=?',
|
||||||
}
|
array($newFunction, $newEnabled, $mid));
|
||||||
$refreshParent = true;
|
|
||||||
|
$monitor['Function'] = $newFunction;
|
||||||
|
$monitor['Enabled'] = $newEnabled;
|
||||||
|
if ( daemonCheck() && ($monitor['Type'] != 'WebSite') ) {
|
||||||
|
$restart = ($oldFunction == 'None') || ($newFunction == 'None') || ($newEnabled != $oldEnabled);
|
||||||
|
zmaControl($monitor, 'stop');
|
||||||
|
zmcControl($monitor, $restart?'restart':'');
|
||||||
|
zmaControl($monitor, 'start');
|
||||||
}
|
}
|
||||||
} // end if action
|
$refreshParent = true;
|
||||||
$view = 'none';
|
} else {
|
||||||
} // end if $mid and canEdit($mid)
|
Logger::Debug("No change to function, not doing anything.");
|
||||||
|
}
|
||||||
|
} // end if action
|
||||||
|
$view = 'none';
|
||||||
|
$closePopup = true;
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -25,14 +25,13 @@ $skinJsFile = getSkinFile( 'js/skin.js' );
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
<head>
|
<head>
|
||||||
<title><?php echo ZM_WEB_TITLE_PREFIX ?></title>
|
<title><?php echo ZM_WEB_TITLE_PREFIX ?></title>
|
||||||
<script type="text/javascript">
|
<script nonce="<?php echo $cspNonce ?>">
|
||||||
<?php
|
<?php
|
||||||
require_once( $skinJsPhpFile );
|
require_once( $skinJsPhpFile );
|
||||||
?>
|
?>
|
||||||
</script>
|
</script>
|
||||||
|
<script src="<?php echo $skinJsFile ?>"></script>
|
||||||
<script type="text/javascript" src="<?php echo $skinJsFile ?>"></script>
|
<script nonce="<?php echo $cspNonce ?>">
|
||||||
<script type="text/javascript">
|
|
||||||
<?php
|
<?php
|
||||||
if ( !$debug ) {
|
if ( !$debug ) {
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in New Issue