From 5881ed8227b50752cf2b389736243941c5c9a957 Mon Sep 17 00:00:00 2001 From: Curtis Hall Date: Thu, 14 Nov 2024 16:19:06 -0600 Subject: [PATCH 1/3] Update eventsIndex.php We don't use media_duration, we use video_duration! PHP message: PHP Notice: Undefined index: media_duration in /usr/share/bluecherry/www/ajax/events/eventsIndex.php on line 128 root@fvi-bcdvr1:/usr/share/bluecherry/www/ajax/events# grep "media_duration" /var/log/nginx/bluecherry-error.log |wc -l 243107 --- www/ajax/events/eventsIndex.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/ajax/events/eventsIndex.php b/www/ajax/events/eventsIndex.php index 0ae6ec0b..eb8348dc 100644 --- a/www/ajax/events/eventsIndex.php +++ b/www/ajax/events/eventsIndex.php @@ -125,7 +125,7 @@ public function getData() $entry['content'] = array( 'media_id' => $item['media_id'], 'media_size' => $item['media_size'], - 'media_duration' => $item['media_duration'], + 'media_duration' => $item['video_duration'], 'content' => (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . '/media/request.php?id=' . $item['media_id'] ); } From f0061f39d514fd2ab5cafc637efa0fb32e1a262d Mon Sep 17 00:00:00 2001 From: Andriy Utkin Date: Mon, 18 Nov 2024 15:01:02 +0000 Subject: [PATCH 2/3] www/ajax/events/eventsIndex.php: use media_duration in query For uniformity. Doesn't change the behaviour. --- www/ajax/events/eventsIndex.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www/ajax/events/eventsIndex.php b/www/ajax/events/eventsIndex.php index eb8348dc..4154e1a4 100644 --- a/www/ajax/events/eventsIndex.php +++ b/www/ajax/events/eventsIndex.php @@ -18,7 +18,7 @@ public function getData() $events_portion = 5000; $query = "SELECT EventsCam.*, Media.size AS media_size, Media.start, Media.end, Devices.device_name, ((Media.size>0 OR Media.end=0) AND Media.filepath!='') AS media_available, ". - "IFNULL(TIMESTAMPDIFF(SECOND, Media.start, Media.end), 0) AS video_duration ". + "IFNULL(TIMESTAMPDIFF(SECOND, Media.start, Media.end), 0) AS media_duration ". "FROM EventsCam ". "LEFT JOIN Media ON (EventsCam.media_id=Media.id) ". "LEFT JOIN Devices ON (EventsCam.device_id=Devices.id) ". @@ -125,7 +125,7 @@ public function getData() $entry['content'] = array( 'media_id' => $item['media_id'], 'media_size' => $item['media_size'], - 'media_duration' => $item['video_duration'], + 'media_duration' => $item['media_duration'], 'content' => (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . '/media/request.php?id=' . $item['media_id'] ); } From aef718ded2be0616989c9f83a3ce6c32fac08e9b Mon Sep 17 00:00:00 2001 From: Andriy Utkin Date: Mon, 18 Nov 2024 15:04:37 +0000 Subject: [PATCH 3/3] www/ajax/events/eventsIndex.php: document usage of getData() --- www/ajax/events/eventsIndex.php | 1 + 1 file changed, 1 insertion(+) diff --git a/www/ajax/events/eventsIndex.php b/www/ajax/events/eventsIndex.php index 4154e1a4..0197d027 100644 --- a/www/ajax/events/eventsIndex.php +++ b/www/ajax/events/eventsIndex.php @@ -8,6 +8,7 @@ public function __construct() $this->chAccess('backup'); } + // This function handles API endpoint /events/ used by client app. public function getData() { $current_user = $this->user;