<?
include('../includes/header.php');
if(!
$num_pics){$num_pics '4';}
if(
stristr($d'../')){die('<script>alert("HaCkInG AttEmPt !!!")</script>');}
$dir "./".$d;
$map dir($dir);
/* Arrays opbouwen */
while($entry=$map->read()) {
 if(
is_dir($dir.$entry)  && $entry != '.' && $entry != '..' && $entry != 'thumbs')  {$dirs[]  = $entry;}
 if(
is_file($dir.$entry) && (substr($entry,-4) != '.php'))  {$files[] = $entry;}
}
/*foreach($map AS $k->$v) {

 if(is_dir($dir.$entry)  && $entry != '.' && $entry != '..' && $entry != 'thumbs')  {$dirs[]  = $entry;}
 if(is_file($dir.$entry) && (substr($entry,-4) != '.php'))  {$files[] = $entry;}

 echo $k."->".$v;
}

print_r($files); */
/* checken of er thumbs zijn gemaakt */
if(isset($files)) {
 foreach(
$files AS $key=>$val) {
  if(!
is_file($dir.'thumbs/T_'.$val) && substr($val,-4) != '.php'){
   echo 
'<br>Er is geen Thumbnail voor "'.$val.'"';
   if(
substr($val,-4) == '.gif'){ echo 'Geen poging om er een te maken, unsupported imagetype'."\n"; break; }
   if(!
is_dir($dir.'thumbs')){ mkdir($dir.'thumbs'); }
   echo 
'Thumbnail maken...';
   
$width 120;
   list(
$width_orig$height_orig) = getimagesize($dir.$val);
   
$height = (int) (($width $width_orig) * $height_orig);
   
$image_p imagecreatetruecolor($width$height);
   
$image imagecreatefromjpeg($dir.$val);
   
imagecopyresampled($image_p$image0000$width$height$width_orig$height_orig);
   
imagejpeg($image_p$dir.'thumbs/T_'.$val65);
  }
 }
}
if(!isset(
$f)) {
 
/* Terug naar overzicht link */
 
if($d != '') {
  
$expl explode('/'$d);
  for(
$i=1$i count($expl)-1$i++){$updir .= $expl[$i-1].'/';}
  echo 
'<a href="'.$_SERVER['PHP_SELF'].'?d='.$updir.'"><img src="../images/gallery/pijl_up.gif" border="0" alt="">Terug naar overzicht</a>'."\n";
 }
 echo 
'<table width="90%"><tr>'/* START */
 /* Dirs */
 
if(isset($dirs)) {
  foreach (
$dirs AS $key=>$val) {
   if((
$key $num_pics) == && $key != 0){echo "</tr><tr>";}        
   echo 
'<td align="center" width="'.floor((100/$num_pics)).'%"><a href="'.$_SERVER['PHP_SELF'].'?d='.$d.$dirs[$key].'/"><img src="../images/gallery/dir.gif" border="0" alt=""><br>'.$dirs[$key].'</a></td>'."\n";
  }
 }
 
/* Files */
 
if(isset($files)) {
  foreach (
$files AS $key=>$val){
   if((
$key $num_pics) == && $key != 0){echo "</tr><tr>";}
   echo 
'<td align="center" width="'.floor((100/$num_pics)).'%"><a href="'.$_SERVER['PHP_SELF'].'?d='.$d.'&amp;f='.$key.'"><img src="'.$d.'thumbs/T_'.$files[$key].'" alt="" border="0"></a></td>'."\n";
  }
 }
echo 
'</tr></table>';
}

if(isset(
$f)) {
 
$totaal  count($files)-1;
 echo 
"<center>";
 echo 
'<table border="0"><tr><td colspan="3"><table width="100%" border="0"><tr><td><a href="'.$_SERVER['PHP_SELF'].'?d='.$d.'"><img src="../images/gallery/pijl_up.gif" border="0" alt="">Terug naar overzicht</a></td><td align="right">';
 
 
/* Geen ScreenSaver */
 
if(!isset($ss)) {
  echo 
'Slideshow : <select onchange="document.location = \''.$_SERVER['PHP_SELF'].'?d='.$d.'&amp;f='.$f.'&amp;ss=\'+this.options[this.selectedIndex].value;">
  <option value="">----</option>
  <option value="1">1</option>
  <option value="2">2</option>
  <option value="5">5</option>
  <option value="7">7</option>
  <option value="10">10</option>
  </select> seconden.</td></tr></table></td></tr><tr>'
;
 }
 
/* Wel ScreenSaver */
 
if(isset($ss)) {
  
$extras = ($f != $totaal) ? '&ss='.$ss.'&f='.($f+1) : '';
  echo 
'<script type="text/javascript"> function go(url) { document.location = url; } setTimeout("go(\"'.$_SERVER['PHP_SELF'].'?d='.urlencode($d).$extras.'\")",'.($ss 1000).');</script>';
  
$stoplink '<a href="'.$_SERVER['PHP_SELF'].'?d='.$d.'&amp;f='.$f.'">';
  echo 
$stoplink.'<img src="../images/gallery/stop.gif" border="0" alt="">Stop de SlideShow<img src="../images/stop.gif" border="0" alt=""></a></td></tr></table></td></tr><tr>';
 }
 
  
/* Pijltjes*/
 
echo ($f == 0) ? '<td>&nbsp;</td>' '<td width="15"><a href="'.$_SERVER['PHP_SELF'].'?d='.$d.'&amp;f='.($f-1).'"><img src="../images/gallery/pijl_r.gif" alt="Previous" border="0"></a></td>';
 echo 
'<td width="100%">&nbsp;</td>';
 echo (
$f == $totaal) ? '<td>&nbsp;</td>' '<td width="15"><a href="'.$_SERVER['PHP_SELF'].'?d='.$d.'&amp;f='.($f+1).'"><img src="../images/gallery/pijl_l.gif" alt="Next" border="0"></a></td>';
 echo 
"</tr><tr>";
 
 
$alttext = (isset($ss)) ? 'Klik hier om te stoppen' $d.substr($files[$f],2);
 echo 
'<td align="center" colspan="3">'.$stoplink.'<img src="'.$d.$files[$f].'" alt="'.$alttext.'" border="0">';
 echo (isset(
$ss)) ? '</a>' '';
 echo 
'</td></tr></table></center>';
 
}
include(
'../includes/footer.php')
?>