Jump to content
xisto Community
Sign in to follow this  
ERICOSMAN

Sort Files Of A Directory And Max Size

Recommended Posts

Hello,

I got a script but i cant get 2 things working :

* Sort on alphabet
* Set the MAX size to 950 x 636

i hope some one can help me ...

This script i m using :


<?php// Path to the folder which contains all of your image folders$directory = "gallery";// this is the page that you run the script on$path = "index.php" . "?gallery=";// This is the path to "thumbs.php" change this accordingly$thumb_path = "thumb_gen.php";// define opendir as a var$scan = @opendir($directory) or die("Unable to open $directory");// This array is used for storing the folder list, we will also use it to output a default directory if no gallery has been requested$folders = array();//This function lists all deirectories within the path specified by $directoryfunction genFolders($scan,$directory) {     // Define these as global vatrs, so that we can use / update them inside the function     global $path, $folders;    // Open list tag, if you want to add css classes etc, alter the tag here    echo '<ul>';        while (false !== ($file = readdir($scan))) {        $dir =$directory.'/'.$file;            if(is_dir($dir) && $file != '.' && $file !='..' ) {            array_push($folders, $dir);                    $handle = @opendir($dir) or die("unable to open file $file");            // output a link containing the folder name                    //echo '<li><a href="' . $path .  $dir . '">' . $file . '</a></li>';                    // Run function on file again if it is a folder, to check for other folders within            genFolders($handle, $dir);            }    }    //close list        echo "</ul>";    //close directory        closedir($scan);}// This function outputs the thumbnailsfunction thumbOutput($target) {    // define as global vars, so that we can use and update them in the function    global $thumb_path;    // open target directory, and output all image files within    if ($handle = opendir($target)) {         while (false !== ($file = readdir($handle))) {             if (strpos($file, '.gif',1) ||strpos($file, '.jpg',1) || strpos($file, '.png',1) || strpos($file, '.JPG',1) || strpos($file, '.PNG',1) || strpos($file, '.GIF',1) ) {                     echo '<a href="' . $target . '/' . $file . '" rel="launch"><img src="' . $thumb_path . '?target=' . $target . '/' . $file . '" class="thumb_img" border="0" /></a>';            }        }         closedir($handle);     } }// this function checks to see whether a specific directory has been requested, if not it uses the first value of the $folders arrayfunction genThumbs() {global $folders;if(!empty($_GET['gallery'])) {        thumbOutput($_GET['gallery']);        } else {        thumbOutput($folders[0]);        }}

greez,eric

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.