Store in GIT
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
require("../../inc/connect.php");
|
||||
require("../session.php");
|
||||
|
||||
$session = $_GET['session'];
|
||||
$id = $_GET['id'];
|
||||
|
||||
if($session == "")
|
||||
{
|
||||
JError("session not set");
|
||||
}
|
||||
if($id == "")
|
||||
{
|
||||
JError("id not set");
|
||||
}
|
||||
|
||||
$name = $_GET['name'];
|
||||
$time = $_GET['time'];
|
||||
$stream = $_GET['stream'];
|
||||
|
||||
if($name == "")
|
||||
{
|
||||
JError("name not set");
|
||||
}
|
||||
if($time == "")
|
||||
{
|
||||
JError("time not set");
|
||||
}
|
||||
if($stream == "")
|
||||
{
|
||||
JError("stream not set");
|
||||
}
|
||||
|
||||
//check session
|
||||
verify_session($mysqli, $session);
|
||||
|
||||
$sql = "SELECT `id` FROM `alarm` WHERE `dev_id`=$deviceid AND `id`=$id";
|
||||
$query = ExecQuery($mysqli, $sql);
|
||||
|
||||
if($query->num_rows < 1)
|
||||
{
|
||||
JError("you cannot 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)
|
||||
{
|
||||
JError("you cannot 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))
|
||||
{
|
||||
JError("invalid time");
|
||||
}
|
||||
|
||||
$time .= ":00";
|
||||
|
||||
//update
|
||||
$sql = "UPDATE `alarm` SET `name`='$name', `time`='$time', `stream`=$stream WHERE `id`=$id";
|
||||
ExecQuery($mysqli, $sql);
|
||||
|
||||
JSuccess("true");
|
||||
?>
|
||||
Reference in New Issue
Block a user