Example #1
0
/**
 * getDirTree returns an array of files and folders
 * 
 * $dir of the folder you want to list, be sure to have an ending "/"
 * $showfiles set to 'true' includes files
 * $iterateSubDirectories set to 'true' also includes the subdirectories
 * 
 * regex ^\..* detects files starting with a dot, .htaccess for example
 * 
 * @param String $dir
 * @param Bool $showfiles [optional]
 * @param Bool $iterateSubDirectories [optional]
 * @return Array $x
 */
function getDirTree($dir, $showfiles = true, $iterateSubDirectories = true)
{
    $d = dir($dir);
    $x = array();
    while (false !== ($r = $d->read())) {
        if ($r != "." && $r != ".." && (!preg_match('/^\\..*/', $r) && !is_dir($dir . $r) || is_dir($dir . $r)) && ($showfiles == false && is_dir($dir . $r) || $showfiles == true)) {
            $x[$r] = is_dir($dir . $r) ? array() : (is_file($dir . $r) ? true : false);
        }
    }
    foreach ($x as $key => $value) {
        if (is_dir($dir . $key . "/") && $iterateSubDirectories) {
            $x[$key] = getDirTree($dir . $key . "/", $showfiles);
        } else {
            $x[$key] = is_file($dir . $key) ? preg_match("/\\.([^\\.]+)\$/", $key, $matches) ? str_replace(".", "", $matches[0]) : 'file' : "folder";
        }
    }
    uksort($x, "strnatcasecmp");
    // Sort keys in case insensitive alphabetical order
    return $x;
}
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
require_once 'functions.php';
if (isset($_REQUEST["ajax"])) {
    $selectedpath = urldecode($_REQUEST["path"]);
    if ($selectedpath = checkpath($selectedpath, $uploadpath)) {
        $dirs = getDirTree(DOCUMENTROOT . $selectedpath, true, false);
    } else {
        die('0||' . $lang["loadfolder_error_1"]);
    }
} else {
    $selectedpath = $uploadpath;
}
print '<ul id="large_images" class="files clear">';
foreach ($dirs as $key => $value) {
    if ($value != "folder") {
        if (strtolower($value) == "png" || strtolower($value) == "jpg" || strtolower($value) == "jpeg" || strtolower($value) == "gif" || strtolower($value) == "bmp") {
            $htmlFiles .= sprintf('<li>
								  		<a href="%1$s" title="%2$s" class="image">
											<span class="begin"></span>
											<span class="filename">%2$s</span>
											<span class="icon image"><img src="phpthumb/phpThumb.php?h=97&w=97&src=%4$s&far=1&bg=0000FF" /></span>
Example #3
0
?>
 value=".swf|.flv|.fla">Flash&nbsp;</option>
	            <option<?php 
echo $_GET["filter"] == "image" ? ' selected="selected"' : '';
?>
 value=".bmp|.gif|.jpg|.jpeg|.png">Images&nbsp;</option>
                <option<?php 
echo $_GET["filter"] == "media" ? ' selected="selected"' : '';
?>
 value=".avi|.flv|.mov|.mp3|.mp4|.mpeg|.mpg|.ogg|.wav|.wma|.wmv">Media&nbsp;</option>
    		</select>
            <hr />
            <div id="files">
                <?php 
// Get all folders in root upload folder but don't iterate
$dirs = getDirTree(STARTINGPATH, true, false);
switch ($viewlayout) {
    case 'large_images':
        require_once "view_images_large.php";
        break;
    case 'small_images':
        require_once "view_images_small.php";
        break;
    case 'list':
        require_once "view_list.php";
        break;
    case 'details':
        require_once "view_details.php";
        break;
    case 'tiles':
        require_once "view_tiles.php";