$h) { $newW = $maxSize; $newH = $h/($w/$maxSize); } else { $newW = $w/($h/$maxSize); $newH = $maxSize; } $newImg = imagecreatetruecolor($newW, $newH); imagecopyresampled($newImg, $img, 0, 0, 0, 0, $newW, $newH, $w, $h); imagejpeg($newImg, $newImgFile); imagedestroy($img); imagedestroy($newImg); } return dirname($_SERVER["SCRIPT_NAME"])."/".$newImgFile; } function getAlbumPreview($dir) { foreach (scandir($dir) as $file) if ($file != '.' and $file != '..') { if (mime_content_type("$dir/$file") == "image/jpeg") return getPreview("$dir/$file", 100); } return ''; } $shortPath = isset($_SERVER["PATH_INFO"]) ? $_SERVER["PATH_INFO"] : ""; if ($shortPath == '/') $shortPath = ''; $scriptUrlPath = substr($_SERVER["SCRIPT_NAME"], 0, -4); // trim .php $folders = array(); $imageFiles = array(); $otherFiles = array(); $realDir = "images$shortPath"; foreach (scandir($realDir) as $file) if ($file != '.') { if ($file == '..') { echo "
..
\n"; } elseif (is_dir("$realDir/$file")) { $folders[] = array( "name" => $file, "link" => "$scriptUrlPath$shortPath/$file", "preview" => getAlbumPreview("$realDir/$file") ); } else { $mime = mime_content_type("$realDir/$file"); if ($mime == "image/jpeg") $imageFiles[] = array( "name" => $file, "url" => getPreview("$realDir/$file", 100), "link" => dirname($scriptUrlPath)."/view/$shortPath/$file" ); else $otherFiles[] = array( "name" => $file, "link" => dirname($scriptUrlPath)."/$realDir/$file" ); } } ?>
"> " />
">" alt="" />
">