Example #1
0
      </h4>
                        </div>
                        <?
                        if($dirs = "bootstrap_components_2" and strpos($_GET['link'], $dirs))
                            $t4 = "in";
                        ?>
                        <div id="4" class="panel-collapse collapse <?php 
echo $t4;
?>
">
                            <!-- Содержимое 4 панели -->
                            <div class="panel-body">
                                <table class="table-striped table-bordered table-hover col-md-12">
                                    <?
                                    $link = '';
                                    $dirsSystem = getFileSystem($dirs);
                                    ksort($dirsSystem);
                                    foreach($dirsSystem as $dirname => $files){
                                        asort($files);
                                    ?>
                                    <tr>
                                        <td>
                                        <h4><?php 
echo $dirname;
?>
</h4>
                                            <ul>
                                                <? foreach($files as $file){
                                                if(strpos($_GET['link'], "$dirname/$file"))
                                                    $active4 = "class='active'";
                                                if($file != "images"){
Example #2
0
/**
 * Recursively get the file structure of the root folder set in the config file and return it as an array
 *
 * @param $path string the path of the root folder - so where to start getting the file structure
 * @param $fileSystem array the current array of the fileSystem, exists because of recursion
 * @return array the final file structure as a graph in an array
 */
function getFileSystem($path, $fileSystem)
{
    // On first time search root directory
    if ($fileSystem == null) {
        $fileSystemArray = scandir($path);
        // Remove ., .. and .DS_Store objects
        $tempFileSystemArray = array();
        $size = count($fileSystemArray);
        for ($i = 0; $i < $size; $i++) {
            $newPath = $path . $fileSystemArray[$i] . "/";
            $tempFile = strpos($fileSystemArray[$i], "73mp") !== false;
            if ($fileSystemArray[$i] != "." && $fileSystemArray[$i] != ".." && !$tempFile && $fileSystemArray[$i] != ".DS_Store" && is_dir($newPath)) {
                array_push($tempFileSystemArray, $fileSystemArray[$i]);
            }
        }
        $fileSystemArray = $tempFileSystemArray;
        $fileSystemArray = array_values($fileSystemArray);
        $fileSystem = array('name' => "/", 'content' => null);
        $size = count($fileSystemArray);
        if ($size > 0) {
            $fileSystem['content'] = $fileSystemArray;
            return getFileSystem($path, $fileSystem);
        }
    }
    // Search all folders in the folder again
    $fileSystemArray = $fileSystem['content'];
    $size = count($fileSystemArray);
    for ($i = 0; $i < $size; $i++) {
        $tempFileSystemArray = array();
        $newPath = $path . $fileSystemArray[$i] . "/";
        $newFileSystemArray = scandir($newPath);
        // Only keep folders, ignore everything else
        $newSize = count($newFileSystemArray);
        for ($j = 0; $j < $newSize; $j++) {
            $newPathLocal = $newPath . $newFileSystemArray[$j] . "/";
            $tempFile = strpos($newFileSystemArray[$j], "73mp") !== false;
            if ($newFileSystemArray[$j] != "." && $newFileSystemArray[$j] != ".." && !$tempFile && $newFileSystemArray[$j] != ".DS_Store" && is_dir($newPathLocal)) {
                array_push($tempFileSystemArray, $newFileSystemArray[$j]);
            }
        }
        $newFileSystemArray = $tempFileSystemArray;
        $newFileSystemArray = array_values($newFileSystemArray);
        // Connect the found folder to the existing structure
        $newSize = count($newFileSystemArray);
        $folder = array('name' => $fileSystemArray[$i], 'content' => null);
        if ($newSize > 0) {
            $folder['content'] = $newFileSystemArray;
            $fileSystem['content'][$i] = getFileSystem($newPath, $folder);
        } else {
            $fileSystem['content'][$i] = $folder;
        }
    }
    // Return the found folder
    return $fileSystem;
}