2007-08-30 02:11:09 +08:00
|
|
|
<?php
|
2019-09-20 22:36:38 +08:00
|
|
|
require_once('includes/control_functions.php');
|
|
|
|
require_once('includes/Monitor.php');
|
2009-09-28 21:34:10 +08:00
|
|
|
|
2007-08-30 02:11:09 +08:00
|
|
|
// Monitor control actions, require a monitor id and control view permissions for that monitor
|
2008-10-17 00:12:23 +08:00
|
|
|
if ( empty($_REQUEST['id']) )
|
2019-09-20 22:36:38 +08:00
|
|
|
ajaxError('No monitor id supplied');
|
2007-08-30 02:11:09 +08:00
|
|
|
|
2019-09-20 22:36:38 +08:00
|
|
|
if ( canView('Control', $_REQUEST['id']) ) {
|
|
|
|
$monitor = new ZM\Monitor($_REQUEST['id']);
|
2007-08-30 02:11:09 +08:00
|
|
|
|
2019-09-20 22:36:38 +08:00
|
|
|
$ctrlCommand = buildControlCommand($monitor);
|
2007-08-30 02:11:09 +08:00
|
|
|
|
2019-09-20 22:36:38 +08:00
|
|
|
if ( !$ctrlCommand ) {
|
|
|
|
ajaxError('No command received');
|
|
|
|
return;
|
|
|
|
}
|
2008-10-17 00:12:23 +08:00
|
|
|
|
2019-10-09 06:07:33 +08:00
|
|
|
if ( $monitor->sendControlCommand($ctrlCommand) ) {
|
|
|
|
ajaxResponse('Success');
|
2019-09-20 22:36:38 +08:00
|
|
|
} else {
|
2019-10-09 06:07:33 +08:00
|
|
|
ajaxError('Failed');
|
2019-09-20 22:36:38 +08:00
|
|
|
}
|
2007-08-30 02:11:09 +08:00
|
|
|
}
|
|
|
|
|
2019-09-20 22:36:38 +08:00
|
|
|
ajaxError('Unrecognised action or insufficient permissions');
|
2007-08-30 02:11:09 +08:00
|
|
|
?>
|