-
Notifications
You must be signed in to change notification settings - Fork 1
/
feedlist.php
51 lines (45 loc) · 2.14 KB
/
feedlist.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
include("config.inc");
/*
Returns a JSON encoded list of feeds and subfodlers for each feed
*/
/*
This file is part of motion-webplayer
motion-webplayer is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2as published by
the Free Software Foundation
motion-webplayer is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with motion-webplayer. If not, see <http://www.gnu.org/licenses/>.
Author: Matthew Watts 2015
*/
$feeds = array(); // the output array which will be a numer of sub arrays listing availible dates for each feed
$excluded_names = array('.', '..', 'lost+found'); // exclude these folders from scan
// iterate through each feed/camera fodler
$directory_handler = opendir( realpath($image_root) );
while( $current_directory = readdir( $directory_handler ) ) {
$directory_path = realpath($image_root) . "/" . $current_directory;
if( !in_array($current_directory, $excluded_names, true) && is_dir( $directory_path )) {
$subdirectory_handler = opendir( realpath($image_root) . "/" .$current_directory );
$subfolder_list = array();
$files[] = $current_directory;
// iterate through each folder in the feed folder
while( $subdirectory = readdir( $subdirectory_handler ) ) {
$subdirectory_path = realpath($image_root) . "/" . $current_directory . "/" . $subdirectory;
if( !in_array($subdirectory, $excluded_names, true) && is_dir($subdirectory_path)) {
$subfolder_list[$subdirectory] = $subdirectory;
} elseif( is_file($subdirectory_path) && strpos($subdirectory_path, ".frames") !== false ) {
$subdirectory_string = str_replace( ".frames", "", $subdirectory);
$subfolder_list[$subdirectory_string] = $subdirectory_string;
}
}
sort($subfolder_list);
array_unshift($subfolder_list, $current_directory);
$feeds[$current_directory] = $subfolder_list;
}
}
sort($feeds);
echo json_encode($feeds);