All pastes #716520 Raw Edit

Meins

public text v1 · immutable
#716520 ·published 2007-09-26 22:17 UTC
rendered paste body
<?
  $folder_scr  = "images";
  $des_src     = "thumbs";
  $thumbx      = "100";
  $thumby      = "100";
  function mkthumb($img_src,     
                   $img_width,   
                   $img_height,  
                   $folder_scr,  
                   $des_src)     
   {
    $image = imagecreatefromjpeg($folder_scr."/".$img_src);
    list($src_width, $src_height) = getimagesize($folder_scr."/".$img_src);
    if($src_width >= $src_height)
    {
      $new_image_width = $img_width;
      $new_image_height = $src_height * $img_width / $src_width;
    }
    if($src_width < $src_height)
    {
      $new_image_height = $img_width;
      $new_image_width = $src_width * $img_height / $src_height;
    }
    $new_image = imagecreatetruecolor($new_image_width, $new_image_height);
    imagecopyresampled($new_image, $image, 0, 0, 0, 0, $new_image_width,$new_image_height, $src_width, $src_height);
    imagejpeg($new_image, $des_src."/".$img_src, 100);
  }
  $filename = $_SERVER['index.php'];
 
  $verz=opendir($folder_scr);
  $linkl = array ();
  if(!$_GET['page'])$page=1;else $page=$_GET['page'];
  $anz=0;
  $anz_max=8*$page;
  while ($file = readdir ($verz))
  {
    if($file != "." && $file != ".." && $file != $filename)
    {
      if($anz<$anz_max) array_push ($linkl, "$file");
      $anz++; 
    }
  }
  if($page!=1) {
    $linkl = array_slice($linkl,8*($page-1));
  }
  $anzahl = count($linkl);
  $x = 0;
  $y = 0;
  echo "<table border=0 align=center><tr>";
  foreach($linkl as $key => $value)
  {
    if($y==8) break;
    if(!file_exists($des_src."/".$value))
    {
      // erstelle ein thumb
      mkthumb($value, $thumbx, $thumby, $folder_scr, $des_src);
    }
    if($x==2) {
     echo "</tr><tr>";
     $x=0;
    }

   echo "<td><a href=".$folder_scr."/".$value." target=_blank ><img src=".$des_src."/".$value." border=0 class=rahmen></a><br><b>".substr($value,0,strlen($value)-4)."</b>&nbsp;</td>";
   $x++;
   $y++;
  }
  if($x!=0)echo "</tr>";
  echo "</table>";
  closedir($verz);
  for($i=1;$i<=ceil($anz/8);$i++)echo "<a href=".$PHP_SELF."?page=$i>$i</a> ";
?>
</div>