003
14.06.2005, 17:26 Uhr
mike
Pinguinhüpfer (Operator)
|
Hi! Das hab ich mal geschrieben - damit funtzt super:
PHP 4: |
<h1>Galerie</h1> <?php function doini($dir) { if(is_dir($dir.'/klein')) return;
mkdir($dir.'/klein', 0777); include_once('include/pic.php'); $direcini = opendir($dir); while(false !== ($file = readdir($direcini))) { if(!is_dir($dir.'/'.$file)) { createthumb(($dir.'/'.$file), ($dir.'/klein/'.$file)); } } }
function enum_pics($dir) { echo '<div align="center">'; echo '<table cellpadding="0" cellspacing="5" border="0">'; $direcini = opendir($dir); $i=0; while(false !== ($file = readdir($direcini))) { if(!is_dir($dir.'/klein/'.$file) && $file != 'klein') { list($width, $height) = getimagesize(($dir.'/klein/'.$file)); if(!($i%2)) echo "<tr>\n";
echo '<td><a href="'.($dir.'/'.$file).'" alt="" target="_blank"><img src="'.($dir.'/klein/'.$file).'" width="'.$width.'" height="'.$height.'"></a></td>';
if($i%2) echo "</tr>\n"; $i++; }
}
if($i%2) echo '<td> </td></tr>'; echo '</table>'; echo '</div>'; } /*********** HAUPTTEIL **************/ $directory = 'galerie/'; $direc = opendir($directory); while(false !== ($file = readdir($direc))) { if($file !="." && $file != "..") { echo '<a href="index.php?module=galerie&galerie='.$file.'" alt="">'.$file.'</a><br>'; } }
closedir($direc); echo '<hr>'; if(strstr($_GET['galerie'], "..")) return;
if(strlen($_GET['galerie'])) { doini($directory.$_GET['galerie']); enum_pics($directory.$_GET['galerie']); } ?> <span class="tiny">FF Raaba Galerie by mike 2005</span>
|
include/pic.php
PHP 4: |
<?php function createthumb($source, $target) { $size = getimagesize($source); $fak = $size[0] / 200; $w = round($size[0] / $fak); $h = round($size[1] / $fak); $resize = imagecreatetruecolor($w, $h); switch ($size['mime']) { case 'image/jpeg': $im = imagecreatefromjpeg($source); imagecopyresampled($resize, $im, 0, 0, 0, 0, $w, $h, $size[0], $size[1]); imagejpeg($resize, $target, 80); break; case 'image/png': $im = imagecreatefrompng($source); imagecopyresampled($resize, $im, 0, 0, 0, 0, $w, $h, $size[0], $size[1]); imagepng($resize, $target, 80); break; case 'image/gif': $im = imagecreatefromgif($source); imagecopyresampled($resize, $im, 0, 0, 0, 0, $w, $h, $size[0], $size[1]); imagegif($resize, $target); break; } imagedestroy($im); }
?>
|
mfg --
|