Location: PHPKode > scripts > JO Image Gallery > FWcgen.php
<?php
/*********************************************************
* Image Gallery - FWcgen.php                             *
* Copyright 2004 by Florida Webcrafters                  *
* All Rights Reserved                                    *
**********************************************************
* Call from an HTML page using the following construct:  *
*     <a href="FWcgen.php?dir=[location]">Photos</a>     *
*                                                        *
* where [location] is the pathname of the picture files  *
* directory.                                             *
**********************************************************
* Change the following values in FWcgen.inc in the       *
* picture directory:                                     *
*     $pgtitle = "Your Page Title here";                 *
*     $picsrow = "Number of pictures per row";           *
*     $tbwidth = "Thumbnail width in pixels";            *
*     $stylesheet = "full pathname of stylesheet";       *
*     $bgcolor = "Background color as #RRGGBB";          *
*     $textcolor = "Text color as #RRGGBB";              *
*     $exten = "file extension of pictures";             *
*     $text = "file extension of associated captions";   *
*                                                        *
* The defaults can be found in the FWcgen.inc file       *
* included in the zip file.                              *
*********************************************************/
session_start();
session_cache_limiter();
error_reporting(0);
include "FWcgen.inc";
$picturedir = $_GET['dir'];
$strtdir = getcwd();
$ch = chdir ($picturedir);
$myhost = $_SERVER['HTTP_HOST'];
if ($ch) include "FWcgen.inc";
$mydir = getcwd();
$tmp = chdir ($strtdir);
?>
<html>
<head>
<meta http-equiv="Pragma" content="no-cache">
<?php echo "<title>".$pgtitle."</title>\n"; ?>
<?php if ($stylesheet) echo $stylesheet; ?>
</head>
<?php echo "<body bgcolor=".$bgcolor." text=".$textcolor.">\n"; ?>
<H3 align="center">
Click on a picture to see it full-size.<br>
Use your browser BACK button to return here.</H3>
<center>
<table cellpadding=0 cellspacing=4>
<?php
$cellcount = 0;
$piccount = 0;
if (is_dir($picturedir)) {
    if ($dh = opendir($picturedir)) {
        while ($filename = readdir($dh)) {
            if (basename($filename) != basename($filename,$exten)) {
				$cellcount++;
				$piccount++;
				$picpath = $picturedir."/".$filename;
				if ($cellcount == 1) echo "<tr>\n";
				echo "<td align=\"center\" valign=\"bottom\"><a href=\"http://".$myhost."/".$picturedir."/".$filename."\">\n";
				echo "<img src=\"http://".$myhost."/".$picpath."\" width=".$tbwidth." border=0>";
				echo "</a><br>\n";
				$fnbase = basename ($filename,$exten);
				$capname = $picturedir."/".$fnbase.$text;
				$caption = "";
				$fhandle = fopen ($capname, "r");
				$caption = fgets ($fhandle, 80);
				fclose ($fhandle);
				echo $caption."</td>\n";
				if ($cellcount == $picsrow) {
					echo "</tr>\n";
					$cellcount = 0;
				}
            }
        }
        closedir($dh);
    }
}
if ($cellcount != 0) echo "</tr>\n";
echo "</table>\n";
?>
</body>
</html>

Return current item: JO Image Gallery