<?
  
if ($_GET["source"]==1){

echo 
"<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?>\n"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html>
  <head>
    <title>www.devrieze.net Source code</title>
  </head>
  <body bgcolor="#ffffef">
<?
    highlight_file
("index.php");
?>
  <br /><br />
  <div style="text-align:center">
  <a href="">Result of this sourcecode</a>
  </div>
  </body>
</html>
<?
    
exit();
  }
?>
<?
  
require("../ptlib.php");
  
chdir("..");
  
libBase("../");
  
$currentsub=2;
  
$columns=4;
  
$maxrows=5;
  
$fotodir="photo";

  if (isset(
$_GET["tag"])) {
    
$tag=str_replace("/","",urldecode($_GET["tag"]));
    
$tagfile=fopen($fotodir."/".$tag.".tagtxt","r");
    if (
$tagfile!=false) {
      
$footer="$tag";
      while ((
$line=fgets($tagfile))!=false){
        
$files[]=trim($line);
      }
      
fclose($tagfile);
    }
    
$theTag=urlencode($tag);
  }

  if (! isset(
$files)) {
    
$mydir=opendir($fotodir);
    while ((
$file=readdir($mydir))){
      if ( 
strtolower(strrchr($file,"."))==".jpg"){
        
$files[]=$file;
      }
    }
  }
  
rsort($files);

  
$fn=$_GET["fn"];

  if (
$fn==""){
    
$offset=$_GET["offset"];
    
setTitle("Foto's of the de Vrieze familly");
    
addCSS("table, tbody, tr { display:inline; }\ntd { display: inline-block; }");
    
addCSS("#content { text-align: center; }");
    
addCSS("td a { display: table-cell; width: 150px; height: 150px; vertical-align: middle; }");

    
ptheader();
    if (
$offset>|| count($files)>($offset+$maxrows*$columns)) {
      echo 
"<div style=\"text-align:center;\">";
      if (
$offset>0) {
        echo 
"<a style=\"margin: 0px 20px 10px 20px;\" href=\"?offset=".($offset-$maxrows*$columns);
        if (isset(
$theTag)) {
          echo 
"&tag=$theTag";
        }
        echo 
"\" class=\"btn\">previous</a>";
      }
      if (
count($files)>($offset+$maxrows*$columns)) {
        echo 
"<a style=\"margin: 0px 20px 10px 20px;\" href=\"?offset=".($offset+$maxrows*$columns);
        if (isset(
$theTag)) {
          echo 
"&tag=$theTag";
        }
        echo 
"\" class=\"btn\">next</a>";
      }
      echo 
"</div>";
    }
?>
    <table style="margin-left:auto; margin-right:auto; text-align:center">
<?
    $rows
=min($maxrows,ceil(count($files)/$columns));
    for (
$y=0$y<$rows;$y++){
      echo 
"      <tr>\n";
      for (
$x=0;$x<$columns;$x++){
        
$fileno=$y*$columns+$x+$offset;
        if (
$fileno count($files)){
          echo 
"        <td><a href=\"index.php?fn=".$files[$fileno];
          if (isset(
$theTag)) {
            echo 
"&tag=$theTag";
          }
          echo 
"\">";
          if (
file_exists("$fotodir/thumbs/".$files[$fileno])){
            
$f=$files[$fileno];
            
$caption=exifCaption("$fotodir/$f");
            echo 
"<img class=\"photo\" src=\"thumbs/$f\" alt=\"\" title=\"$caption\"";
            if (
function_exists("imagecreatefromjpeg")) {
              
$im=imagecreatefromjpeg("$fotodir/thumbs/".$f);
              if (
$im) {
                
$w=ImageSX($im);
                
$h=ImageSY($im);
                echo 
" width=\"$w\" height=\"$h\"";
              }
            }
            echo 
" />";
          } else {
            echo 
$files[$fileno];
          }
          echo 
"</a></td>\n";
        } else {
          echo 
"        <td></td>\n";
        }
      }
      echo 
"      </tr>\n ";
    }
?>
    </table>
<?
    
echo "    <br/><div style=\"text-align:center\"><a href=\"".$PHP_SELF."?source=1\">show sourcecode</a></div>\n";
  } else {
    
// Single photo
    
$title=$fn;
    
$title=exifCaption("$fotodir/$fn");
    if (
is_null($title)) {
      
$title=$fn;
    }
    
setTitle($title);
    
$myindex=array_search($fn,$files);
    
hideSubmenu();

    
ptheader();

    echo 
"    <table style=\"height:100%;\" width=\"100%\">\n";
    echo 
"      <tr style=\"height:10%;\"><td style=\"text-align:center\">";

    if (
$myindex>0) {
      echo 
"<a href=\"".$_SERVER["PHP_SELF"]."?fn="$files[$myindex-1];
      if (isset(
$theTag)) {
        echo 
"&tag=$theTag";
      }
      echo 
"\" class=\"btn\">previous</a> ";
    } else {
      echo 
"<span class=\"btn\">previous</span> ";
    }
    echo 
"<a href=\"".$_SERVER["PHP_SELF"];
    if (isset(
$theTag)) {
      echo 
"?tag=$theTag";
    }
    echo 
"\" class=\"btn\">index</a> ";
    if (
$myindex+count($files)) {
      echo 
"<a href=\"".$_SERVER["PHP_SELF"]."?fn="$files[$myindex+1];
      if (isset(
$theTag)) {
        echo 
"&tag=$theTag";
      }
      echo 
"\" class=\"btn\">next</a>";
    } else {
      echo 
"<span class=\"btn\">next</span>";
    }
    echo 
"</td></tr>\n";
    echo 
"      <tr style=\"height:80%;\">\n        <td align=\"center\" valign=\"middle\">\n";
    if (
function_exists("imagecreatefromjpeg")){
      
$im=imagecreatefromjpeg("$fotodir/$fn");
      echo 
"          ";
      if (! 
$im){
        echo 
"Invalid picture !!! ($fn)\n";
      } else {
        
$w=ImageSX($im);
        
$h=ImageSY($im);
        echo 
"<img class=\"photo\" src=\"".$fn."\" width=\"".$w."\" height=\"".$h."\" alt=\"\" title=\"".$title."\" />\n";
      }
    } else {
        echo 
"<img class=\"photo\" src=\"".$fn."\" alt=\"".$fn."\" />\n";
    }
    echo 
"        </td>\n      </tr>\n";
    echo 
"      <tr><td style=\"height:10%;\" align=\"center\"><a href=\"".$_SERVER["PHP_SELF"]."\">Back to index</a>";
    echo 
"    </td></tr></table>\n";
  }
  
ptfooter();
?>


Result of this sourcecode