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"); ?>