library/Haste/Util/Files.php
public static function getFileList($strDir, $baseUrl, $protectedBaseUrl = null)
    {
        $arrResult = [];
        if (is_dir($strDir))
        {
            if ($handler = opendir($strDir))
            {
                while (($strFile = readdir($handler)) !== false)
                {
                    if (substr($strFile, 0, 1) == '.')
                    {
                        continue;
                    }
                    $arrFile             = [];
                    $arrFile['filename'] = htmlentities($strFile);
                    if ($protectedBaseUrl)
                    {
                        $arrFile['absUrl'] = $protectedBaseUrl . (empty($_GET) ? '?' : '&') . 'file=' . urlencode($arrFile['absUrl']);
                    }
                    else
                    {
                        $arrFile['absUrl'] = str_replace('\\', '/', str_replace('//', '', $baseUrl . '/' . $strFile));
                    }
                    $arrFile['path']     = str_replace($arrFile['filename'], '', $arrFile['absUrl']);
                    $arrFile['filesize'] =
                        self::formatSizeUnits(filesize(str_replace('\\', '/', str_replace('//', '', $strDir . '/' . $strFile))), true);

                    $arrResult[] = $arrFile;
                }
                closedir($handler);
            }
        }
        Arrays::aasort($arrResult, 'filename');

        return $arrResult;
    }
public static function getFileList($strDir, $baseUrl, $protectedBaseUrl = null)
    {
        $arrResult = [];
        if (is_dir($strDir))
        {
            if ($handler = opendir($strDir))
            {
                while (($strFile = readdir($handler)) !== false)
                {
                    if (substr($strFile, 0, 1) == '.')
                    {
                        continue;
                    }
                    $arrFile             = [];
                    $arrFile['filename'] = htmlentities($strFile);
                    if ($protectedBaseUrl)
                    {
                        $arrFile['absUrl'] = $protectedBaseUrl . (empty($_GET) ? '?' : '&') . 'file=' . urlencode($arrFile['absUrl']);
                    }
                    else
                    {
                        $arrFile['absUrl'] = str_replace('\\', '/', str_replace('//', '', $baseUrl . '/' . $strFile));
                    }
                    $arrFile['path']     = str_replace($arrFile['filename'], '', $arrFile['absUrl']);
                    $arrFile['filesize'] =
                        self::formatSizeUnits(filesize(str_replace('\\', '/', str_replace('//', '', $strDir . '/' . $strFile))), true);

                    $arrResult[] = $arrFile;
                }
                closedir($handler);
            }
        }
        Arrays::aasort($arrResult, 'filename');

        return $arrResult;
    }
public static function getFileList ( $ strDir , $ baseUrl , $ protectedBaseUrl = null ) { $ arrResult = [ ] ; if ( is_dir ( $ strDir ) ) { if ( $ handler = opendir ( $ strDir ) ) { while ( ( $ strFile = readdir ( $ handler ) ) !== false ) { if ( substr ( $ strFile , 0 , 1 ) == '.' ) { continue ; } $ arrFile = [ ] ; $ arrFile [ 'filename' ] = htmlentities ( $ strFile ) ; if ( $ protectedBaseUrl ) { $ arrFile [ 'absUrl' ] = $ protectedBaseUrl . ( empty ( $ _GET ) ? '?' : '&' ) . 'file=' . urlencode ( $ arrFile [ 'absUrl' ] ) ; } else { $ arrFile [ 'absUrl' ] = str_replace ( '\\' , '/' , str_replace ( '//' , '' , $ baseUrl . '/' . $ strFile ) ) ; } $ arrFile [ 'path' ] = str_replace ( $ arrFile [ 'filename' ] , '' , $ arrFile [ 'absUrl' ] ) ; $ arrFile [ 'filesize' ] = self :: formatSizeUnits ( filesize ( str_replace ( '\\' , '/' , str_replace ( '//' , '' , $ strDir . '/' . $ strFile ) ) ) , true ) ; $ arrResult [ ] = $ arrFile ; } closedir ( $ handler ) ; } } Arrays :: aasort ( $ arrResult , 'filename' ) ; return $ arrResult ; }
Returns the file list for a given directory

@param string $strDir           - the absolute local path to the directory (e.g. /dir/mydir)
@param string $baseUrl          - the relative uri (e.g. /tl_files/mydir)
@param string $protectedBaseUrl - domain + request uri -> absUrl will be domain + request uri + ?file=$baseUrl/filename.ext

@return array file list containing file objects.
Returns the file list for a given directory