diff --git a/www/lib/lib.php b/www/lib/lib.php index c7daa51f..3bcd1b76 100644 --- a/www/lib/lib.php +++ b/www/lib/lib.php @@ -862,7 +862,12 @@ public static function create($rawData){ #if errors were detected -- return error if (!$data[0]) { return $data; } else { $data = $data[1]; }; #if there were no errors, add the camera - $result = data::query("INSERT INTO Devices (device_name, protocol, device, driver, rtsp_username, rtsp_password, resolutionX, resolutionY, mjpeg_path, model, rtsp_rtp_prefer_tcp, onvif_port, substream_path, hls_window_size, hls_segment_size, hls_segment_duration) VALUES ('{$data['device_name']}', '{$data['protocol']}', '{$data['device']}', '{$data['driver']}', '{$data['rtsp_username']}', '{$data['rtsp_password']}', 640, 480, '{$data['mjpeg_path']}', '{$data['model']}', {$data['rtsp_rtp_prefer_tcp']}, {$data['onvif_port']},'{$data['substream_path']}', {$data['hls_window_size']}, {$data['hls_segment_size']}, {$data['hls_segment_duration']})", true); + + $hls_segment_size = $data['hls_segment_size'] ? $data['hls_segment_size'] : 0; + $hls_segment_duration = $data['hls_segment_duration'] ? $data['hls_segment_duration'] : 0; + $inputQuery = "INSERT INTO Devices (device_name, protocol, device, driver, rtsp_username, rtsp_password, resolutionX, resolutionY, mjpeg_path, model, rtsp_rtp_prefer_tcp, onvif_port, substream_path, hls_window_size, hls_segment_size, hls_segment_duration) VALUES ('{$data['device_name']}', '{$data['protocol']}', '{$data['device']}', '{$data['driver']}', '{$data['rtsp_username']}', '{$data['rtsp_password']}', 640, 480, '{$data['mjpeg_path']}', '{$data['model']}', {$data['rtsp_rtp_prefer_tcp']}, {$data['onvif_port']},'{$data['substream_path']}', {$data['hls_window_size']}, {$hls_segment_size}, {$hls_segment_duration})"; + + $result = data::query($inputQuery, true); #try to automatically set the camera up $message = ($result) ? AIP_CAMADDED : false; if ($result)