mikeyzc
05-28-2004, 08:32 AM
Here is the php file.
<?php
/* This is a script that list all image files on a given directory, and displays the thumbnails nicely formated within an HTML table. It also make use of JavScript to open pop up windows when the users want to see the full photo */
//***********************************************************//
//******** STARTOF VARIABLES CONFIGURATION SECTION **********//
//***********************************************************//
// DON'T FORGET TO INCLUDE THE CLASS.FILE
// You can download it from:
// http://www.thewebmasters.net/php/File-1_0.tar.gz
include("http://www.mydomain.com/testing/class.file.php3");
// RELATIVE PATH TO IMAGES DIRECTORY (Other than gallery.php3's)
$path = "http://www.mydomain.com/testing/";
// NUMBER OF COLUMNS TO BE DISPLAYED
$colunas = 3;
// THUMBNAIL WIDTH
$thumb_width = "100";
// THUMBNAIL HEIGHT
$thumb_height = "";
/* COORDINATES FOR THE FULL SIZE PHOTO POP-UP WINDOW
YOU CAN USE (MINUS) TO INVERT THE REFERENCES
(RIGHTMARGIN AND BOTTOMMARGIN). PREETY COOL, ISN'T IT? */
// LEFTMARGIN OFFSET (RIGTHMARGIN IF YOU USE NEGATIVE VALUES)
$pop_leftmargin = "1";
// TOPMARGIN OFFSET (BOTTOMMARGIN IF YOU USE NEGATIVE VALUES)
$pop_topmargin = "1";
//***********************************************************//
//******** ENDOF VARIABLES CONFIGURATION SECTION ************//
//***********************************************************//
$file = new File();
$images = array();
$jpgs = $file->get_files("$path","jpg");
if( !empty($jpgs) ) {
while ( list( $key, $filename ) = each( $jpgs ) ) {
$images[] = $filename;
}
}
$gifs = $file->get_files("$path","gif");
if( !empty($gifs) ) {
while ( list( $key, $filename ) = each( $gifs ) ) {
$images[] = $filename;
}
}
$pngs = $file->get_files("$path","png");
if( !empty($pngs) ) {
while ( list( $key, $filename ) = each( $pngs ) ) {
$images[] = $filename;
}
}
$bmps = $file->get_files("$path","bmp");
if( !empty($bmps) ) {
while ( list( $key, $filename ) = each( $bmps ) ) {
$images[] = $filename;
}
}
$count = 1;
$break = $colunas;
?>
<!-- STARTOF HTML CODE - CUSTOMIZE AS YOU WISH -->
<!-- JUST DON'T TOUCH THE JAVA CODE -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<TITLE>The PHP Photo Gallery</TITLE>
<SCRIPT Language="JavaScript">
<!--
var popWin = null
var winCount = 0
var winName = "popWin"
function openPopWin(winURL, winWidth, winHeight, winFeatures, winLeft, winTop){
var d_winLeft = 20
var d_winTop = 20
winName = "popWin" + winCount++
closePopWin()
if (openPopWin.arguments.length >= 4)
winFeatures = "," + winFeatures
else
winFeatures = ""
if (openPopWin.arguments.length == 6)
winFeatures += getLocation(winWidth, winHeight, winLeft, winTop)
else
winFeatures += getLocation(winWidth, winHeight, d_winLeft, d_winTop)
popWin = window.open(winURL, winName, "width=" + winWidth
+ ",height=" + winHeight + winFeatures)
}
function closePopWin(){
if (navigator.appName != "Microsoft Internet Explorer"
|| parseInt(navigator.appVersion) >=4)
if(popWin != null) if(!popWin.closed) popWin.close()
}
function getLocation(winWidth, winHeight, winLeft, winTop){
return ""
}
//-->
</SCRIPT>
<SCRIPT Language="JavaScript1.2">
<!--
function getLocation(winWidth, winHeight, winLeft, winTop){
var winLocation = ""
if (winLeft < 0)
winLeft = screen.width - winWidth + winLeft
if (winTop < 0)
winTop = screen.height - winHeight + winTop
if (winTop == "cen")
winTop = (screen.height - winHeight)/2 - 20
if (winLeft == "cen")
winLeft = (screen.width - winWidth)/2
if (winLeft>0 & winTop>0)
winLocation = ",screenX=" + winLeft + ",left=" + winLeft
+ ",screenY=" + winTop + ",top=" + winTop
else
winLocation = ""
return winLocation
}
//-->
</SCRIPT>
<style>
<!--
BODY {
font-family: Verdana,Arial;
font-style: none;
font-size: 16px;
}
BIG {
font-size: 28px;
font-weight: bold;
}
TABLE {
font-size: 16px;
}
SMALL {
font-size: 12px;
}
A:LINK {
text-decoration: none;
font-weight: bold;
}
-->
</style>
</HEAD>
<BODY onUnload="closePopWin()">
<div align="center">
<BIG>PHP Photo Gallery</BIG><br>
<br>
<b>(Click the thumbnails to enlarge Total in this page:
<?php echo count($images); ?> images)</b></small>
<table border="5" cellspacing="0" cellpadding="6">
<tr>
<!-- STARTOF TABLE CELL DISPLAY PHP CODE -->
<!-- DO NOT ALTER IT -->
<?php
while ( list( $key, $fileName ) = each( $images ) )
{
if( !empty($fileName) )
{
$tamanho = GetImageSize("$path/$fileName");
$largura = $tamanho[0] + 18;
$altura = $tamanho[1] + 28;
echo " <td align=\"CENTER\" valign=\"TOP\"><a href='javascript:openPopWin(\"$path/$fileName\", $largura, $altura, \"\", $pop_leftmargin, $pop_topmargin)'><IMG SRC=\"$path/$fileName\" border=0 alt=\"$count\"";
if (!empty($thumb_width)) {echo " width=\"$thumb_width\"";}
if (!empty($thumb_height)) {echo " height=\"$thumb_height\"";}
echo "></a><br><small>$count</small>";
if ($count == $break) {
echo "\n </td>\n</tr>\n<tr>\n";
$break = $count + $colunas;
}
else { echo "</td>\n"; }
}
$count++;
}
?>
<!-- ENDOF TABLE CELL CODE PHP-->
</tr>
</table>
</div>
<hr>
<div align="CENTER">
<b>The PHP Photo Gallery</b><br>
</div>
</BODY>
</HTML>
<?php
/* This is a script that list all image files on a given directory, and displays the thumbnails nicely formated within an HTML table. It also make use of JavScript to open pop up windows when the users want to see the full photo */
//***********************************************************//
//******** STARTOF VARIABLES CONFIGURATION SECTION **********//
//***********************************************************//
// DON'T FORGET TO INCLUDE THE CLASS.FILE
// You can download it from:
// http://www.thewebmasters.net/php/File-1_0.tar.gz
include("http://www.mydomain.com/testing/class.file.php3");
// RELATIVE PATH TO IMAGES DIRECTORY (Other than gallery.php3's)
$path = "http://www.mydomain.com/testing/";
// NUMBER OF COLUMNS TO BE DISPLAYED
$colunas = 3;
// THUMBNAIL WIDTH
$thumb_width = "100";
// THUMBNAIL HEIGHT
$thumb_height = "";
/* COORDINATES FOR THE FULL SIZE PHOTO POP-UP WINDOW
YOU CAN USE (MINUS) TO INVERT THE REFERENCES
(RIGHTMARGIN AND BOTTOMMARGIN). PREETY COOL, ISN'T IT? */
// LEFTMARGIN OFFSET (RIGTHMARGIN IF YOU USE NEGATIVE VALUES)
$pop_leftmargin = "1";
// TOPMARGIN OFFSET (BOTTOMMARGIN IF YOU USE NEGATIVE VALUES)
$pop_topmargin = "1";
//***********************************************************//
//******** ENDOF VARIABLES CONFIGURATION SECTION ************//
//***********************************************************//
$file = new File();
$images = array();
$jpgs = $file->get_files("$path","jpg");
if( !empty($jpgs) ) {
while ( list( $key, $filename ) = each( $jpgs ) ) {
$images[] = $filename;
}
}
$gifs = $file->get_files("$path","gif");
if( !empty($gifs) ) {
while ( list( $key, $filename ) = each( $gifs ) ) {
$images[] = $filename;
}
}
$pngs = $file->get_files("$path","png");
if( !empty($pngs) ) {
while ( list( $key, $filename ) = each( $pngs ) ) {
$images[] = $filename;
}
}
$bmps = $file->get_files("$path","bmp");
if( !empty($bmps) ) {
while ( list( $key, $filename ) = each( $bmps ) ) {
$images[] = $filename;
}
}
$count = 1;
$break = $colunas;
?>
<!-- STARTOF HTML CODE - CUSTOMIZE AS YOU WISH -->
<!-- JUST DON'T TOUCH THE JAVA CODE -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<TITLE>The PHP Photo Gallery</TITLE>
<SCRIPT Language="JavaScript">
<!--
var popWin = null
var winCount = 0
var winName = "popWin"
function openPopWin(winURL, winWidth, winHeight, winFeatures, winLeft, winTop){
var d_winLeft = 20
var d_winTop = 20
winName = "popWin" + winCount++
closePopWin()
if (openPopWin.arguments.length >= 4)
winFeatures = "," + winFeatures
else
winFeatures = ""
if (openPopWin.arguments.length == 6)
winFeatures += getLocation(winWidth, winHeight, winLeft, winTop)
else
winFeatures += getLocation(winWidth, winHeight, d_winLeft, d_winTop)
popWin = window.open(winURL, winName, "width=" + winWidth
+ ",height=" + winHeight + winFeatures)
}
function closePopWin(){
if (navigator.appName != "Microsoft Internet Explorer"
|| parseInt(navigator.appVersion) >=4)
if(popWin != null) if(!popWin.closed) popWin.close()
}
function getLocation(winWidth, winHeight, winLeft, winTop){
return ""
}
//-->
</SCRIPT>
<SCRIPT Language="JavaScript1.2">
<!--
function getLocation(winWidth, winHeight, winLeft, winTop){
var winLocation = ""
if (winLeft < 0)
winLeft = screen.width - winWidth + winLeft
if (winTop < 0)
winTop = screen.height - winHeight + winTop
if (winTop == "cen")
winTop = (screen.height - winHeight)/2 - 20
if (winLeft == "cen")
winLeft = (screen.width - winWidth)/2
if (winLeft>0 & winTop>0)
winLocation = ",screenX=" + winLeft + ",left=" + winLeft
+ ",screenY=" + winTop + ",top=" + winTop
else
winLocation = ""
return winLocation
}
//-->
</SCRIPT>
<style>
<!--
BODY {
font-family: Verdana,Arial;
font-style: none;
font-size: 16px;
}
BIG {
font-size: 28px;
font-weight: bold;
}
TABLE {
font-size: 16px;
}
SMALL {
font-size: 12px;
}
A:LINK {
text-decoration: none;
font-weight: bold;
}
-->
</style>
</HEAD>
<BODY onUnload="closePopWin()">
<div align="center">
<BIG>PHP Photo Gallery</BIG><br>
<br>
<b>(Click the thumbnails to enlarge Total in this page:
<?php echo count($images); ?> images)</b></small>
<table border="5" cellspacing="0" cellpadding="6">
<tr>
<!-- STARTOF TABLE CELL DISPLAY PHP CODE -->
<!-- DO NOT ALTER IT -->
<?php
while ( list( $key, $fileName ) = each( $images ) )
{
if( !empty($fileName) )
{
$tamanho = GetImageSize("$path/$fileName");
$largura = $tamanho[0] + 18;
$altura = $tamanho[1] + 28;
echo " <td align=\"CENTER\" valign=\"TOP\"><a href='javascript:openPopWin(\"$path/$fileName\", $largura, $altura, \"\", $pop_leftmargin, $pop_topmargin)'><IMG SRC=\"$path/$fileName\" border=0 alt=\"$count\"";
if (!empty($thumb_width)) {echo " width=\"$thumb_width\"";}
if (!empty($thumb_height)) {echo " height=\"$thumb_height\"";}
echo "></a><br><small>$count</small>";
if ($count == $break) {
echo "\n </td>\n</tr>\n<tr>\n";
$break = $count + $colunas;
}
else { echo "</td>\n"; }
}
$count++;
}
?>
<!-- ENDOF TABLE CELL CODE PHP-->
</tr>
</table>
</div>
<hr>
<div align="CENTER">
<b>The PHP Photo Gallery</b><br>
</div>
</BODY>
</HTML>