1<?php 2// 3// ZoneMinder web action file 4// Copyright (C) 2019 ZoneMinder LLC 5// 6// This program is free software; you can redistribute it and/or 7// modify it under the terms of the GNU General Public License 8// as published by the Free Software Foundation; either version 2 9// of the License, or (at your option) any later version. 10// 11// This program is distributed in the hope that it will be useful, 12// but WITHOUT ANY WARRANTY; without even the implied warranty of 13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14// GNU General Public License for more details. 15// 16// You should have received a copy of the GNU General Public License 17// along with this program; if not, write to the Free Software 18// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19// 20 21// Device view actions 22if ( !canEdit('Devices') ) { 23 ajaxError('Insufficient permissions for user '.$user['Username']); 24 return; 25} 26 27if ( $action == 'device' ) { 28 if ( !empty($_REQUEST['command']) ) { 29 setDeviceStatusX10($_REQUEST['key'], $_REQUEST['command']); 30 } else if ( isset($_REQUEST['newDevice']) ) { 31 if ( isset($_REQUEST['did']) && $_REQUEST['did'] ) { 32 ZM\Warning('did value is: '.$_REQUEST['did']); 33 ZM\Warning('newDevice array value is: '.print_r($_REQUEST['newDevice'],true)); 34 dbQuery('UPDATE Devices SET Name=?, KeyString=? WHERE Id=?', 35 array($_REQUEST['newDevice']['Name'], $_REQUEST['newDevice']['KeyString'], $_REQUEST['did']) ); 36 } else { 37 38 dbQuery('INSERT INTO Devices SET Name=?, KeyString=?', 39 array($_REQUEST['newDevice']['Name'], $_REQUEST['newDevice']['KeyString']) ); 40 } 41 } 42 ajaxResponse(); 43} else { 44 ajaxError('Unrecognised action '.$_REQUEST['action']); 45} // end if action 46 47?> 48