Store in GIT
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
require("../../../inc/connect.php");
|
||||
require("../../../inc/session.php");
|
||||
|
||||
$alarm = $_POST['id'];
|
||||
$name = $_POST['name'];
|
||||
$time = $_POST['time'];
|
||||
$stream = $_POST['stream'];
|
||||
|
||||
//Check if alarms editing is allowed
|
||||
$sql = "SELECT `name` FROM `alarm` WHERE `dev_id`=$deviceid AND `id`=$alarm";
|
||||
$query = ExecQuery($mysqli, $sql);
|
||||
|
||||
if($query->num_rows < 1)
|
||||
{
|
||||
error("alarms", "You are not allowed to edit that alarm");
|
||||
}
|
||||
|
||||
//Check if stream is allowed
|
||||
$sql = "SELECT `name` FROM `stream` WHERE `dev_id`=$deviceid AND `id`=$stream";
|
||||
$query = ExecQuery($mysqli, $sql);
|
||||
|
||||
if($query->num_rows < 1)
|
||||
{
|
||||
error("alarms", "You are not allowed to use that stream");
|
||||
}
|
||||
|
||||
//Remove seconds
|
||||
$time = substr($time, 0, 5);
|
||||
|
||||
//Check time
|
||||
if(!preg_match("/(2[0-3]|[01][0-9]):([0-5][0-9])/", $time))
|
||||
{
|
||||
error("alarms", "Invalid time");
|
||||
}
|
||||
|
||||
$time .= ":00";
|
||||
|
||||
//Add alarm
|
||||
$sql = "UPDATE `alarm` SET `name`='$name', `time`='$time', `stream`=$stream WHERE `id`=$alarm";
|
||||
ExecQuery($mysqli, $sql);
|
||||
|
||||
success("alarms", "The alarm has been updated");
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user