Jump to content

srider

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

srider's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. srider

    sorting

    Success!! Thank you so much guys. I know that's a fairly simple problem but I'm sure you saved me hours of surfing!! If either of you are ever near Regina, Saskatchewan, Canada...let me know, cause I owe you a beer!! Thanks!
  2. srider

    sorting

    Thank you so much for the reply. It still doesn't work. I apologize if I'm missing something easy but I really know nothing about php. I added that line: $dir = $doc_root.$web_dir; sort($list); echo utf8_encode(create_tree($dir, $web_dir)); ?> Yet it still does not work. The files are still being added into flash randomly. Any more thoughts on it? Thanks!
  3. srider

    sorting

    Hi, I really don't know much about php but need a quick fix. The code below creates a list of images in a directory and outputs an XML file. The only issue I have is that they are not sorted. Can anyone tell me how to change this file so that it outputs the image names to the XML file alphabetically? <?php require_once('JPEG-Meta.php'); header('Content-type: text/xml'); function create_tree($file_dir, $web_dir){ $masterXML = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; $fileXML = ""; if ($handle = @opendir($file_dir)){ $i=0; while (false !== ($file = @readdir($handle))){ if ($file != "." && $file != ".."){ $list[$i]=$file; $i++; } } $dir_length = count($list); $dirXML = "<gallery>\n"; for($i=0; $i<$dir_length; $i++){ if(strrpos($list[$i], ".") != FALSE && strrpos($list[$i], ".jpg") != FALSE){ $jpegMeta = new JPEG($file_dir.$list[$i]); $caption = $jpegMeta->getIPTCField("Caption"); $metaWidth = $jpegMeta->getWidth(); $metaHeight = $jpegMeta->getHeight(); $info = getimagesize($file_dir.$list[$i]); $imgW = $info[0] > 0 ? $info[0] : $metaWidth; $imgH = $info[1]> 0 ? $info[1] : $metaHeight; $fileXML .= "\t<img width=\"".$imgW."\" height=\"".$imgH."\" src=\"".$web_dir.$list[$i]."\" caption=\"".$caption."\" filename=\"".$list[$i]."\" />\n"; } } $masterXML .= $dirXML.$fileXML."</gallery>"; closedir($handle); } return $masterXML; } $web_dir = $_GET['dir']; if(substr($web_dir, 0, 1) == "/"){ $doc_root = str_replace($_SERVER['PHP_SELF'], '', str_replace('\\', '/',$_SERVER["SCRIPT_FILENAME"])); } else { $doc_root = str_replace(basename($_SERVER['PHP_SELF']), '', str_replace('\\', '/',$_SERVER["SCRIPT_FILENAME"])); } if(substr($web_dir, -1) != "/"){ $web_dir .= "/"; } $dir = $doc_root.$web_dir; echo utf8_encode(create_tree($dir, $web_dir)); ?> Thanks a lot!
×
×
  • Create New...

Important Information

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.