Store in GIT
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
require("../../inc/connect.php");
|
||||
require("../session.php");
|
||||
|
||||
$session = $_GET['session'];
|
||||
|
||||
if($session == "")
|
||||
{
|
||||
JError("no session");
|
||||
}
|
||||
|
||||
$schedule = $_GET['id'];
|
||||
$name = $_GET['name'];
|
||||
$time = $_GET['time'];
|
||||
$duration = $_GET['duration'];
|
||||
$stream = $_GET['stream'];
|
||||
|
||||
if($schedule == "")
|
||||
{
|
||||
JError("no id");
|
||||
}
|
||||
if($name == "")
|
||||
{
|
||||
JError("no name");
|
||||
}
|
||||
if($time == "")
|
||||
{
|
||||
JError("no time");
|
||||
}
|
||||
if($duration == "")
|
||||
{
|
||||
JError("no duration");
|
||||
}
|
||||
if($stream == "")
|
||||
{
|
||||
JError("no stream");
|
||||
}
|
||||
|
||||
//check session
|
||||
verify_session($mysqli, $session);
|
||||
|
||||
//Check if alarms editing is allowed
|
||||
$sql = "SELECT `name` FROM `schedule` WHERE `dev_id`=$deviceid AND `id`=$schedule";
|
||||
$query = ExecQuery($mysqli, $sql);
|
||||
|
||||
if($query->num_rows < 1)
|
||||
{
|
||||
JError("cannot edit schedule");
|
||||
}
|
||||
|
||||
//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("cannot use 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";
|
||||
|
||||
|
||||
//Remove seconds
|
||||
$duration = substr($duration, 0, 5);
|
||||
|
||||
//Check duration
|
||||
if(!preg_match("/(2[0-3]|[01][0-9]):([0-5][0-9])/", $duration))
|
||||
{
|
||||
JError("invalid duration");
|
||||
}
|
||||
|
||||
$duration .= ":00";
|
||||
|
||||
//Add schedule
|
||||
$sql = "UPDATE `schedule` SET `name`='$name', `time`='$time', `duration`='$duration', `stream`=$stream WHERE `id`=$schedule";
|
||||
ExecQuery($mysqli, $sql);
|
||||
|
||||
JSuccess("true");
|
||||
?>
|
||||
Reference in New Issue
Block a user