Hey i finally found a much simpler and mabye sutable script and have taken your advise by takin up an acount in mandrake. Anyway i have installed the gallery and all looks good (no scary error messages) BUT i cant see my pic's. It says there are no photos in the directory??
here is the script have i done something wrong (look mainly in the bit i have to fill out... i always wreck stuff)
thanks for your help
oh btw here is some stuff u should proably know...
<a href='http://mandrake.polarhome.com/~galleryp/gallery/gallery.php' target='_blank'>http://mandrake.polarhome.com/~galleryp/gallery/gallery.php</a> is where the script is located
inside the <a href='http://mandrake.polarhome.com/~galleryp/gallery/' target='_blank'>http://mandrake.polarhome.com/~galleryp/gallery/</a> directory is another folder called New Folder... just experimenting
anyway see how u go.. thanks again
- Code: Select all
<?PHP
/******************************************************************************************
- A Picture Gallery - Version 3.1 -
Script by Matthew McConnell
maca134@hotmail.com
I have no problem with anyone using my script under the GNU conditions
But would you please email me, because I would like to know how far this script goes :P
- Requirements -
PHP Version
GD
Matthew McConnell
- History -
10 August 2003
First written, directory browsing and image filename list/links
28 August 2003
Added pages and template file
22 September 2003
Added thumbnails
13 January 2004
Cleaning script up, change index.php to a variable too allow different script filenames
*******************************************************************************************/
// The path to the top-level folder of your Gallery
$base_dir = "/gallery";
// The URL to the top-level folder of your Gallery
$base_url = "http://mandrake.polarhome.com/~galleryp/gallery";
// The URL to this file
$cur_url = "http://mandrake.polarhome.com/~galleryp/gallery/gallery.php";
// The absolute path to the template file
$path_to_template = "gallery_template.htm";
// Max thumbnail size (the biggest side in pixels eg. 100x200 would be ???x75 if the value was 75)
$tsize = 75;
// Number of columns per page
$no_img_columns = 3;
// Number of rows per page
$no_img_rows = 1;
// No more Config to do
$filename = basename($_SERVER["SCRIPT_FILENAME"]);
$base_dir = $base_dir.$pdir;
$base_url = $base_url.$pdir;
function imageThumb ($the_image) {
global $tsize, $base_dir, $im;
header ("Content-type: image/jpeg");
$image_size = getimagesize($the_image);
if ($image_size[0] > $image_size[1])
{
$size_ratio = $image_size[1] / $image_size[0];
$dest_w = $tsize;
$dest_h = intval($tsize * $size_ratio);
}
elseif ($image_size[0] < $image_size[1])
{
$size_ratio = $image_size[0] / $image_size[1];
$dest_w = intval($tsize * $size_ratio);
$dest_h = $tsize;
}
elseif ($image_size[0] = $image_size[1])
{
$dest_w = $tsize;
$dest_h = $tsize;
}
else
{
exit("Error: Image Err");
}
$src_w=$image_size[0];
$src_h=$image_size[1];
$in_jpg = imagecreatefromjpeg($the_image);
$out_jpg = imagecreatetruecolor($dest_w, $dest_h);
imagecopyresized($out_jpg, $in_jpg, 0, 0, 0, 0, $dest_w, $dest_h, $src_w, $src_h);
imagejpeg($out_jpg);
imagedestroy($in_jpg);
imagedestroy($out_jpg);
}
$template = implode("", file("$path_to_template"))."<p align=\"center\"><font size=\"-1\"><br><font
size=\"-2\">Gallery by <a href=\"mailto:maca134@hotmail.com\">Matthew McConnell</a> ©
2003</font></p>";
$perpage = $no_img_columns * $no_img_rows;
if (!$page || $page < 0)
{
$page = 0;
}
$tmp1 = explode("/", $base_dir);
$tmp2 = count($tmp1);
$pre_dir = str_replace($tmp1[($tmp2 - 2)]."/", "", $base_dir);
$tmp1 = str_replace($pdir, "", $base_dir);
$pre_dir = str_replace($tmp1, "", $pre_dir);
if ($pdir) {
$dir_list .= "<a href=\"{$filename}?f=$f&pdir=$pre_dir\">Up A Directory/</a> ";
}
if (is_dir($base_dir)) {
if ($dh = opendir($base_dir)) {
while (($dirname = readdir($dh)) !== false) {
if (@filetype($base_dir.$dirname) == "dir" && $dirname != "." && $dirname != ".." && $dirname != "")
{
$dir_list .= "<a href=\"{$filename}?f=$f&pdir=$pdir$dirname/\">$dirname/</a> ";
}
}
closedir($dh);
}
}
if ($im && file_exists($base_dir.$dir.$im))
{
imageThumb($base_dir.$dir.$im);
}
$pd = opendir($base_dir);
$counter = 0;
while ($file = readdir($pd)) {
$the_type = strrchr($file, ".");
$is_picture = eregi("jpg|jpeg", $the_type);
if ($file != "." and $file != ".." and $is_picture) {
$images[$counter] = $file;
$counter++;
}
}
closedir($pd);
if ($images) {
sort($images, 1);
}
else
{
$the_msg = "No images in the directory: $pdir/";
}
$counter = 0;
if ($cur_img && file_exists($base_dir.$cur_img))
{
$cur_img_html = "<a href=\"{$base_url}{$cur_img}\" target=\"_new\"><img src=\"{$base_url}{$cur_img}\"
border=\"0\"></a>";
}
$img_table = "<table align=\"center\"><tr><td colspan=\"{$no_img_wide}\" align=\"center\"></td></tr>";
for ($a = 0; $a <= ($perpage - 1); $a++) {
$image = $images[($perpage * $page) + $a];
if ($counter == $no_img_wide)
{
$img_table .= "</tr><tr>";
$counter = 0;
}
if ($image){
$img_table .= "<td width=\"$tsize\" height=\"$tsize\" align=\"center\" valign=\"middle\"><a
href=\"{$filename}?f=$f&cur_img=$image&pdir=$pdir&page=$page\"><img src=\"{$cur_url}Picture
Gallery.php?im=$image&dir=$pdir\" border=\"0\"></a></td>";
}
$counter++;
}
$img_table .= "</tr></table>";
if ($page != 0)
{
$npage = $page - 1;
if ($cur_img) {
$backlink = "<a href=\"{$filename}?f=$f&cur_img=$cur_img&page=$npage&pdir=$pdir\">Previous $perpage</a>";
}
if (!$cur_img) {
$backlink = "<a href=\"{$filename}?f=$f&page=$npage&pdir=$pdir\">Previous $perpage</a>";
}
}
if ((count($images) - 1) >= (($perpage * $page) + $perpage))
{
$npage = $page + 1;
if ($cur_img) {
$forwardlink = "<a href=\"{$filename}?f=$f&cur_img=$cur_img&page=".$npage."&pdir=$pdir\">Next
$perpage</a>";
}
if (!$cur_img) {
$forwardlink = "<a href=\"{$filename}?f=$f&page=".$npage."&pdir=$pdir\">Next $perpage</a>";
}
}
if ($cur_img) {
for ($a = 0; $a <= intval((count($images)-1) / $perpage); $a++) {
if ($a == $page)
{
$totallink .= " | <b>$a</b>";
}
else
{
$totallink .= "| <a href=\"{$filename}?f=$f&cur_img=$cur_img&page=$a&pdir=$pdir\">$a</a>";
}
}
}
if (!$cur_img) {
for ($a = 0; $a <= intval((count($images)-1) / $perpage); $a++) {
if ($a == $page) {
$totallink .= " | <b>$a</b>";
}
else
{
$totallink .= " | <a href=\"{$filename}?f=$f&page=$a&pdir=$pdir\">$a</a>";
}
}
}
$totallink .= " |";
$output = str_replace("%dir_list%", $dir_list, $template);
$output = str_replace("%cur_pic%", $the_msg."<br>".$cur_img_html, $output);
$output = str_replace("%img_list%", $img_table, $output);
$output = str_replace("%back_link%", $backlink, $output);
$output = str_replace("%total_link%", $totallink, $output);
$output = str_replace("%forward_link%", $forwardlink, $output);
$output = str_replace("%pdir%", $pdir, $output);
$output = str_replace("%cur_pic_file%", $cur_img, $output);
echo $output;
?>