The problem is that at the end of the __construct function, a function call is not working for some reason. I have the correct code and it has worked before, but I'm just unable to fie the problem, mybe its my approch to the problem, anyhow, It would help loads if someone coud take a look at the class in the fille attached and reveal the correct code to me.
I have doc'ed the code as much as will be helpfull, this is a work in progerss I know the code is scruffy.
Code: Select all
<?
session_start();
// get gallery mnam from session var galID
// test session var
$_SESSION['galID'] = "maya";
class gallery{
# Gallery class 0.9/2.2006
# DEBUG VERSION, NOT FOR RELEASE
# PLEASE DO NOT USE THIS CODE IN ANY PRODUNCTION SCRIPTS.
# THIS CODE HAS NOT BEEN TESTED AND MY BE UNSTABLE
#THE PROBLEM IS THAT THE FUNCTION CALL TO showDIR AT THE END
#OF THE __CONSTRUCT FUNCTION
# THE GOAL IS TO DISPLAY THE CONTENTS OF THE A DIRECTORY NAMED IN THE $galName VAR PASSED TO
# THE CLASS WHEN ITS USED TO CREATE AN OBJECT, THE CODE SHOULD THEN DISPLAY A SET OF THUMBNAILS
# OF THE IMAGES IN THE $location/$galName FOLDER
# gallery class for php 5+ by leigh edwards Feb 25 2006
# Please send any information on any problems you encounter to
# leighjedwards@msn.com
# Note Some of this code was taken from open scorce files and is not the work of the auther,
# if you see any of your code here, please let me know and i'll add the propper credits where needed
private $maxDirSize;
private $window;
private $maxcols;
private $location;
private $imagemaxwidth;
private $extensions;
private $browsedir;
private $galleryName;
private $adirectory;
function __construct($galName){
// set gallery defaults here
$this->maxDirSize = 200;
// set open option 0 = same window, 1 = new window
$this->window = 1;
// change layout options here
$this->maxcols = 3;
$this->imagemaxwidth = 100;
// set to the dir where you will store your galleries, remember the ending slash
$this->location = "galleries/";
# list allowed extensions here
$this->extensions[1] = "jpeg";
$this->extensions[2] = "jpg";
$this->extensions[3] = "gif";
$this->extensions[4] = "txt";
// the problem is with this line here or the function it links to, I think.
// All other parts of this code are working fine when tested alone
$this->showDir( $this->dirToArray($this->galName) ); // display the gallery
}
# dirToArray
#
# directory to array extractor
# $browsedir (string - path name)
# $extentions (array - extensions to be listed)
function dirToArray ($galleryName)
{
$maxDirSize = 200;
$nextensions = sizeof($this->extensions);
$idirectory = 0;
$this->browsedir = $this->location . $galName; // set the gallery to view
$directory = dir ($browsedir);
while ($entry = $directory->read())
{
for ($i=1; $i<=$nextensions; $i++)
{
$compare = stristr ($entry, $this->extensions[$i]);
if (strlen($compare) == strlen($this->extensions[$i]))
{
$adirectory[++$idirectory] = $entry;
break;
}
}
}
$directory->close();
return $adirectory;
}
# showDir
#
# show table with images and links
# $browsedir (string - path name)
# $adirectory (array - filenames w/o path)
function showDir ($adirectory)
{
//global $browsedir;
# change layout options here
$maxcols = 3;
$imagemaxwidth = 100;
$imagemaxheight = 80;
$imagemaxratio = $imagemaxwidth / $imagemaxheight;
$ndirectory = sizeof ($adirectory);
echo ("<table width=100%>");
for ($i=0; $i<=$ndirectory;)
{
echo (" <tr>");
for ($icols=1; $icols<=$maxcols; $icols++)
{
echo (" <td align=center>");
$imagefilename = $this->adirectory[++$i];
if (strlen($imagefilename)>0)
{
$this->imagepath = $browsedir."/".$imagefilename;
$imagesize = GetImageSize ($this->imagepath);
if ($imagesize)
{
$imagewidth = $imagesize[0];
$imageheight = $imagesize[1];
$imageratio = $imagewidth / $imageheight;
if ($imageratio > $imagemaxratio)
{
$imageoutputwidth = $imagemaxwidth;
$imageoutputheight = ceil ($imagemaxwidth/$imagewidth*$imageheight);
}
else if ($imageratio < $imagemaxratio)
{
$imageoutputheight = $imagemaxheight;
$imageoutputwidth = ceil ($imagemaxheight/$imageheight*$imagewidth);
} else
{
$imageoutputwidth = $imagemaxwidth;
$imageoutputheight = $imagemaxheight;
}
$out = "<a href=\"".$this->imagepath."\"";
// check to see if link to open in a window or not
// default 0
if ($this->window ==1){ $out .= "target=\"_blank\">";}
$out .= "<img src=\"".$this->imagepath;
$out .= "\" width=\"".$imageoutputwidth;
$out .= "\" height=\"".$imageoutputheight;
$out .= "\" border=\"0\"><br>";
$out .= $adirectory[$i]."</a>";
echo $out;
}
echo "</td>";
}
}
echo "</tr>";
}
echo "</table>";
}
}
$galName = $_SESSION['galID'];
$gal = new gallery($galName);
?>