Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel authored and daniel committed Oct 13, 2023
1 parent a8d9cbd commit 3f04386
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions view/listFiles.json.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,38 @@
require_once dirname(__FILE__) . '/../videos/configuration.php';
require_once $global['systemRootPath'] . 'objects/Login.php';
header('Content-Type: application/json');

// Ensure extensions are in lowercase and unique
$global['allowed'] = array_map('strtolower', $global['allowed']);
$global['allowed'] = array_unique($global['allowed']);

$files = array();
if(Login::canBulkEncode()){
if (!empty($_POST['path'])) {
$path = $_POST['path'];
if (substr($path, -1) !== DIRECTORY_SEPARATOR) {
$path .= DIRECTORY_SEPARATOR;
}
//var_dump($path, file_exists($path));

if (file_exists($path)) {
if (defined( 'GLOB_BRACE' )) {
if (defined('GLOB_BRACE')) {
$extn = implode(",*.", $global['allowed']);
$extnLower = strtolower($extn);
$extnUpper = strtoupper($extn);
$filesStr = "{*." . $extn . ",*" . $extnLower . ",*" . $extnUpper . "}";
//var_dump($filesStr);
//echo $files;
$video_array = glob($path . $filesStr, GLOB_BRACE);
} else {
//var_dump($global['allowed']);
$video_array = array();
foreach ($global['allowed'] as $value) {
$video_array += glob($path . "*." . $value);
$video_array = array_merge($video_array, glob($path . "*." . $value));
}
}

$id = 0;
foreach ($video_array as $key => $value) {
$path_parts = pathinfo($value);
$obj = new stdClass();
$obj->id = $id++;
//$obj->path_clean = ($value);
$obj->path = _utf8_encode($value);
$obj->name = _utf8_encode($path_parts['basename']);
$files[] = $obj;
Expand Down

0 comments on commit 3f04386

Please sign in to comment.