I have downloaded a galary script from http://www.arwscripts.com.It is added in my website.The problem is that the thumbnail on the album is coming but when clicked on the album the images are not displayed.The problem can be observed at http://www.lionsclubofsantiniketan.pratik.frih.net/photoalbum/.
The php file used for this purpose are--
1. config.inc
2. index.php
3. browse.php
4. preview.php
5. header.php
6. function-library.php
Sorry, the code segment became too long, but that is the total code.Please help.
PS-All the images are in JPEG format.
Late Additions:
Some problems observed by me while comparing the source script originaly hosted and my hosting.They are listed below--
Original script--
My script output
and the code responsible for this is in browse.php in line number 58
This much information could be found out by my little knowledge of PHP.
The php file used for this purpose are--
1. config.inc
| Code: |
| <?php
error_reporting(0); set_time_limit(600); // site details $site_name = "Your Site Name"; // site name/title $site_path = "http://www.yourdomain.com/"; // site url. Lowercase. Including the http://www. and the ending forward slash '/'. i.e. 'http://www.mysitename.com/'. $storage_location = "pictures/"; $cache_location = "cache/"; // album browsing pages $hover_style = 1; // 1 or 0 to display pop-up preview or not $perpage = 30; // number of items to display on the page $browse_cols = 6; // number of columns on the browsing page $thumbnail_w = 90; // width of the thumb on browsing album page - max 800 // image preview pages $image_w = 600; // width of the viewed images - max 1200 // page style $main_bg = "#C7AB7B"; // main site background color if there's no bg image $album_hover_on = "#6666CC"; // album thumbnail bg hover on color - on index.html $album_hover_off = "#FFFFFF"; // album thumbnail bg hover off color - on index.html $listing_hover_on = "#FFFF99"; // listing thumbnail bg hover on color - on browse.php $listing_hover_off = "#FFFFFF"; // listing thumbnail bg hover off color - on browse.php ?> |
2. index.php
| Code: |
|
<?php include_once("config.inc.php"); include_once("function-library.php"); $pagetitle = "Welcome to ".$site_name; $meta_keywords = str_replace(" ", ", ", $site_name).", photos, images, pictures"; $meta_description = "Welcome to ".$site_name; include_once("header.php"); // get album listing $dir_handle = @opendir($storage_location) or die("Unable to open image storage location. (".$storage_location.")"); $album_listing = array(); while ($file = readdir($dir_handle)) { if(($file != ".") && ($file != "..")) { $album_listing[] = $file; } } closedir($dir_handle); sort($album_listing); // display albums echo "<div align=\"center\" class=\"indexhead\"><b>".$site_name."</b></div><br>"; echo "<div align=\"center\">Choose an album to browse the images:</div><br><br>"; $r = 1; echo "<table width=\"100%\" cellpadding=\"2\" cellspacing=\"0\">"; foreach($album_listing AS $value) { if($r == 1) echo "<tr><td align=\"center\" width=\"20%\">"; else echo "<td align=\"center\" width=\"20%\">"; // get total photos echo "<b>".$value."</b><br><font style=\"font-size:9px;color:#666666;\">(".count_photos($value)." photos)</font>"; echo "<table width=\"106\" cellpadding=\"2\" cellspacing=\"0\" bgcolor=\"".$album_hover_off."\" style=\"border:1px solid #999999;padding-top:2px;\" style=\"cursor:hand;\" onMouseOver=\"this.style.backgroundColor='".$album_hover_on."';\" onMouseOut=\"this.style.backgroundColor='".$album_hover_off."';\" onClick=\"window.location='".urlencode($value)."';\"><tr height=\"106\"><td valign=\"middle\" align=\"center\">"; if(count_photos($value) > 0) { // get first image as thumbnail $photos = load_photos($value); $cover_photo = galleryImage($photos[0][path], 100); $picid = mysql_result($temp6, 0, id); echo "<a href='".urlencode($value)."'>".$cover_photo."</a>"; } else echo "No pics"; echo "</td></tr></table>"; if($r == 5) { echo "</td></tr>"; $r = 1; } else { echo "</td>"; $r++; } } echo "</table></div><br>"; include_once("footer.php"); ?> |
3. browse.php
| Code: |
|
<?php include_once("config.inc.php"); include_once("function-library.php"); // get vars $catname = $_GET['catname']; $next = $_GET['next']; $prev = $_GET['prev']; $catname = urldecode($catname); if(!$next) $next = 0; if(!$prev) $prev = 0; if($thumbnail_w > 800) $thumbnail_w = 800; $pagetitle = "Browsing ".UCWords(strtolower($catname))." Album"; $meta_keywords = str_replace(" ", ", ", $catname); $meta_description = "Browsing ".UCWords(strtolower($catname))." Album"; include_once("header.php"); // count images $total = count_photos($catname); if($total == 0) { echo "<div align=\"center\" class=\"indexhead\"><b>".$catname." Album</b></div><br>"; echo "<div align=\"center\">No images in this category.</div><br><br>"; } else { $r = 1; echo "<table width=\"100%\" cellpadding=\"2\" cellspacing=\"0\" align=\"center\">"; echo "<div align=\"center\" class=\"indexhead\"><b>".$catname." Album</b></div><br>"; echo "<div align=\"center\">There are ".$total." images in this album.</div><br><br>"; $tracker = 1; $photos = load_photos($catname); foreach($photos AS $row) { if(($tracker > $next) && ($tracker <= ($next+$perpage))) { if($r == 1) echo "<tr>"; echo "<td align=\"center\" valign=\"bottom\">"; echo "<table width=\"".$thumbnail_w."\" cellpadding=\"0\" cellspacing=\"0\"><tr><td align=\"center\" class=\"thumbtitle\">"; echo $row[title]; echo "</td></tr></table>"; echo "<table width=\"".$thumbnail_w."\" cellpadding=\"2\" cellspacing=\"0\" bgcolor=\"".$listing_hover_off."\" style=\"border:1px solid #999999;\" style=\"cursor:hand;\" onMouseOver=\""; if($hover_style == 1) { if(($row[ext] == "jpg") || ($row[ext] == "jpeg") || ($row[ext] == "pjpg") || ($row[ext] == "png") || ($row[ext] == "gif")) { $image_data = galleryImage($row[path], 220); $image_data = str_replace("'", "\'", $image_data); $image_data = str_replace("\"", "\'", $image_data); echo "ddrivetip('".$image_data."','white', 160);"; } } echo "this.style.backgroundColor='".$listing_hover_on."';\" onMouseOut=\""; if($hover_style != 0) echo "hideddrivetip();"; echo "this.style.backgroundColor='#ffffff';\" onClick=\"window.location='".urlencode($catname)."/".urlencode($row[filename]).".html';\"><tr height=\"".$thumbnail_w."\"><td valign=\"middle\" align=\"center\"><a href='".urlencode($catname)."/".urlencode($row[filename]).".html'>"; if(($row[ext] == "jpg") || ($row[ext] == "jpeg") || ($row[ext] == "pjpg") || ($row[ext] == "png") || ($row[ext] == "gif")) echo galleryImage($row[path], $thumbnail_w); else echo "<img src=\"images/uns-thumb.jpg\" alt=\"keywords: $row[title]\" border='0'>"; echo "</a></td></tr></table>"; if($r == $browse_cols) { echo "</td></tr>"; $r = 1; } else { echo "</td>"; $r++; } } $tracker++; } echo "</table>"; } if(isset($next)) { $next = $next + $perpage; $prev = $next - $perpage*2; } elseif(isset($prev)) { $next = $prev + $perpage; $prev = $prev - $perpage; } echo "<br><div align=\"center\" class=\"headtext\" style=\"margin-top:7px;\">"; if($prev >= 0) echo "<- <a href=\"".urlencode($catname)."?prev=$prev\">BACK PAGE</a> "; if($next < $total) echo " <a href=\"".urlencode($catname)."?next=$next\">NEXT PAGE</a> ->"; echo "<br><br><div align=\"center\" class=\"headtext\" style=\"margin-top:7px;\"><a href=\"".$site_path."\">HOME</a><br>"; include_once("footer.php"); ?> |
4. preview.php
| Code: |
|
<?php include_once("config.inc.php"); include_once("function-library.php"); // get vars $catname = $_GET['catname']; $catname = urldecode($catname); $imageid = $_GET['id']; $imageid = urldecode($imageid); $path = $storage_location.$catname."/".$imageid; if($image_w > 1200) $image_w = 1200; $pagetitle = "Viewing image ".UCWords(strtolower($imageid))." in ".$catname." Album"; $meta_keywords = str_replace(" ", ", ", $imageid).", ".str_replace(" ", ", ", $catname); $meta_description = "Viewing image ".UCWords(strtolower($imageid))." in ".$catname." Album"; include_once("header.php"); echo "<table width=\"100%\" cellpadding=\"2\" cellspacing=\"0\" align=\"center\"><tr>"; echo "<td align=\"center\" valign=\"top\">"; echo "<b><font class='viewhead'>".$imageid."</font></b><br><br>"; echo str_replace("cache", "../cache", galleryImage($path, $image_w, FALSE)); echo "<br><br><br><a href=\"../".urlencode($catname)."\">RETURN TO THUMBNAILS</a>"; echo "</td>"; echo "</tr></table>"; include_once("footer.php"); ?> |
5. header.php
| Code: |
|
<?php if (strlen($pagetitle) == 0) $pagetitle = $site_name; $pagetitle = $pagetitle." - ".$site_name; ?> <html> <head> <title><?php echo $pagetitle; ?></title> <META http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <META NAME="keywords" CONTENT="<?php echo $meta_keywords; ?>"> <META NAME="description" CONTENT="<?php echo $meta_description; ?>"> <script type="text/javascript" src="<?php echo $site_path; ?>flashobject.js"></script> <link rel="stylesheet" href="<?php echo $site_path; ?>styles.css"> <style type="text/css"> #dhtmltooltip{ position: absolute; width: 200px; border: 2px solid black; padding: 2px; background-color: lightyellow; visibility: hidden; z-index: 100; } #flashcontent { height: 100%; } </style> </head> <body style="background: <?php echo $main_bg; ?> url('<?php echo $site_path; ?>images/main-bg.jpg'); background-repeat: no-repeat; margin:0px; margin-top:15px;" <?php if($hover_style != 0) echo 'onLoad="cacheOff()"'; ?>> <div id="dhtmltooltip"></div> <?php if($hover_style != 0) { ?> <script type="text/javascript"> var offsetxpoint=-60 var offsetypoint=20 var ie=document.all var ns6=document.getElementById && !document.all var enabletip=false if (ie||ns6) var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : "" function ietruebody(){ return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body } function ddrivetip(thetext, thecolor, thewidth){ if (ns6||ie){ if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px" if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor tipobj.innerHTML=thetext enabletip=true return false } } function positiontip(e){ if (enabletip){ var curX=(ns6)?e.pageX : event.x+ietruebody().scrollLeft; var curY=(ns6)?e.pageY : event.y+ietruebody().scrollTop; var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20 var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20 var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000 if (rightedge<tipobj.offsetWidth) tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px" else if (curX<leftedge) tipobj.style.left="5px" else tipobj.style.left=curX+offsetxpoint+"px" if (bottomedge<tipobj.offsetHeight) tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px" else tipobj.style.top=curY+20+offsetypoint+"px" tipobj.style.visibility="visible" } } function hideddrivetip(){ if (ns6||ie){ enabletip=false tipobj.style.visibility="hidden" tipobj.style.left="-1000px" tipobj.style.backgroundColor='' tipobj.style.width='' } } document.onmousemove=positiontip </script> <STYLE TYPE="text/css"> #cache { position:absolute; left=0; top:170px; z-index:10; visibility:hidden; } </STYLE> <SCRIPT LANGUAGE="JavaScript"> ver = navigator.appVersion.substring(0,1) if (ver >= 4) { document.write('<DIV ID="cache"><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" align=\"center\"><tr><td width=\"25%\"></td><td width=\"50%\"><TABLE WIDTH=100% BGCOLOR=#000000 BORDER=0 CELLPADDING=2 CELLSPACING=0 align=\"center\"><TR><TD ALIGN=center VALIGN=middle><TABLE WIDTH=100% BGCOLOR=#FFFFFF BORDER=0 CELLPADDING=0 CELLSPACING=0><TR><TD ALIGN=center VALIGN=middle><FONT FACE="Arial, Verdana" SIZE=4><B><BR>LOADING IMAGE INFORMATION, PLEASE WAIT... <BR><BR> <img src=\"<?php echo $site_path; ?>images/boy.gif\"><br><br></B></FONT></TD> </TR></TABLE></TD> </TR></TABLE></td><td width=\"25%\"></td></tr></table></DIV>'); var navi = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) >= 4); var HIDDEN = (navi) ? 'hide' : 'hidden'; var VISIBLE = (navi) ? 'show' : 'visible'; var cache = (navi) ? document.cache : document.all.cache.style; largeur = screen.width; cache.visibility = VISIBLE; } function cacheOff() { if (ver >= 4) { cache.visibility = HIDDEN; } } </SCRIPT> <?php } ?> <table width="100%" cellpadding="0" cellspacing="0" align="center" style="background: url('<?php echo $site_path; ?>images/main-bg-bottom.gif'); background-repeat: no-repeat; background-position: bottom right;" height="100%"><tr><td valign="top"> <table width="740" cellpadding="2" cellspacing="0" align="center"><tr><td> |
6. function-library.php
| Code: |
|
<?php function createhtmlname($name) { $replace_values = array(" ", "'", "\"", "\\", "/", "?", "|", "@", "#", "~", "!", "£", "$", "%", "^", "&", "*", "(", ")", "[", "]", "{", "}", "+", "=", "-"); $name = str_replace($replace_values, "_", $name); $name = str_replace(".", "", $name); $name = str_replace(",", "", $name); return strtolower($name); } function randomfilename() { $salt = "0123456789abcdefghijklmnopqrstuvwxyz"; srand((double)microtime()*1000000); $i = 0; while ($i <= 25) { $num = rand() % 33; $tmp = substr($salt, $num, 1); $nname = $nname . $tmp; $i++; } return $nname; } function count_photos($folder) { global $storage_location; $dir_handle = @opendir($storage_location.$folder); $total = 0; while ($file = readdir($dir_handle)) { if(($file != ".") && ($file != "..")) { $exp = explode(".", $file); $where = COUNT($exp)-1; $ext = $exp[$where]; if(($ext == "jpg") || ($ext == "jpeg") || ($ext == "pjpg") || ($ext == "png") || ($ext == "gif")) $total++; } } closedir($dir_handle); return $total; } function load_photos($folder) { global $storage_location; $file_listing = array(); $dir_handle = @opendir($storage_location.$folder); while ($file = readdir($dir_handle)) { if(($file != ".") && ($file != "..")) { $exp = explode(".", $file); $where = COUNT($exp)-1; $ext = $exp[$where]; $title = $exp[0]; if(($ext == "jpg") || ($ext == "jpeg") || ($ext == "pjpg") || ($ext == "png") || ($ext == "gif")) $file_listing[] = array('path'=>$storage_location.$folder."/".$file, 'filename'=>$file, 'title'=>$title, 'ext'=>$ext); } } closedir($dir_handle); return $file_listing; } function galleryImage ($path, $max_x, $justurl = FALSE) { include_once("config.inc.php"); $sourceImagePath = $path; $targetImagePath = "cache/".MD5($path.$max_x).".jpg"; $outputImageQuality = 80; /* Check if file is already cached, if so just deliver existing image */ if(!file_exists($targetImagePath)) { /* MAIN RESIZING SCRIPT */ /* Load Dimensions of Original Image */ $originalImageSize = getimagesize($sourceImagePath); $original_x = $originalImageSize[0]; $original_y = $originalImageSize[1]; if($original_x > $original_y) { $max_y = 0; $max_x = $max_x; } else if($original_x < $original_y) { $max_y = $max_x; $max_x = 0; } else { $max_y = $max_x; $max_x = $max_x; } /* Work out ratios and which way to crop */ $state = 0; if($square == 1) { if($max_x == 0) $max_x = $max_y; elseif($max_y == 0) $max_y = $max_x; } if($max_x == 0) $state = 1; elseif($max_y == 0) $state = 2; if($state == 0) { $testratio = $max_x / $max_y; $origratio = $original_x / $original_y; if($origratio > $testratio) $state = 1; elseif($origratio < $testratio) $state = 2; else $state = 3; } /* With ratios sorted, plot co-ordinates */ if($state == 1) { /* make new-y = max-y OR crop sides */ if($square == 0) { if(($original_y > $max_y) || ($enlarge == 1)) $new_y = $max_y; else $new_y = $original_y; $new_x = round(($original_x / ($original_y / $new_y)), 0); $srcx = 0; $srcy = 0; $srcw = $original_x; $srch = $original_y; } else { if(($original_y > $max_y) || ($enlarge == 1)) $new_y = $max_y; else $new_y = $original_y; $new_x = $new_y; $tempratio = ($original_y / $new_y); $sectionwidth = $new_y * $tempratio; $srcy = 0; $srch = $original_y; $srcx = floor(($original_x - $sectionwidth) / 2); $srcw = floor($sectionwidth); } } elseif($state == 2) { /* make new-x = max-x OR crop top & bottom */ if($square == 0) { if(($original_x > $max_x) || ($enlarge == 1)) $new_x = $max_x; else $new_x = $original_x; $new_y = round(($original_y / ($original_x / $new_x)), 0); $srcx = 0; $srcy = 0; $srcw = $original_x; $srch = $original_y; } else { if(($original_x > $max_x) || ($enlarge == 1)) $new_x = $max_x; else $new_x = $original_x; $new_y = $new_x; $tempratio = ($original_x / $new_x); $sectionheight = $new_x * $tempratio; $srcx = 0; $srcw = $original_x; $srcy = floor(($original_y - $sectionheight) / 2); $srch = floor($sectionheight); } } elseif($state == 3) { /* original image ratio = new image ratio - use all of image */ if($square == 0) { if(($original_x > $max_x) || ($enlarge == 1)) $new_x = $max_x; else $new_x = $original_x; $new_y = round(($original_y / ($original_x / $new_x)), 0); $srcx = 0; $srcy = 0; $srcw = $original_x; $srch = $original_y; } else { if(($original_x > $max_x) || ($enlarge == 1)) $new_x = $max_x; else $new_x = $original_x; $new_y = $new_x; $srcx = 0; $srcy = 0; $srcw = $original_x; $srch = $original_y; } } /* Do Conversion */ if(strstr(strtolower($path), ".jpg")) $originalImage = ImageCreateFromJPEG($sourceImagePath); elseif(strstr(strtolower($path), ".jpeg")) $originalImage = ImageCreateFromJPEG($sourceImagePath); elseif(strstr(strtolower($path), ".pjpg")) $originalImage = ImageCreateFromJPEG($sourceImagePath); elseif(strstr(strtolower($path), ".png")) $originalImage = ImageCreateFromPNG($sourceImagePath); elseif(strstr(strtolower($path), ".gif")) $originalImage = ImageCreateFromGIF($sourceImagePath); $newImage = ImageCreateTrueColor($new_x, $new_y); ImageCopyResampled ($newImage, $originalImage, 0, 0, $srcx, $srcy, $new_x, $new_y, $srcw, $srch); ImageJPEG ($newImage, $targetImagePath, $outputImageQuality); ImageDestroy($newImage); ImageDestroy($originalImage); } /* Output Image */ $imageSize = getimagesize($targetImagePath); if($justurl == TRUE) return $targetImagePath; else return "<img src=\"$targetImagePath\" width=\"$imageSize[0]\" height=\"$imageSize[1]\" border=\"0\" style=\"border:1px solid #000000;\">"; } ?> |
Sorry, the code segment became too long, but that is the total code.Please help.
PS-All the images are in JPEG format.
Late Additions:
Some problems observed by me while comparing the source script originaly hosted and my hosting.They are listed below--
Original script--
| Code: |
| onClick="window.location='Light+Auras/Light+-+01.html';"> |
My script output
| Code: |
| onClick="window.location='installation/100_0942.jpg.html';"> |
and the code responsible for this is in browse.php in line number 58
| Code: |
| echo "this.style.backgroundColor='#ffffff';\" onClick=\"window.location='".urlencode($catname)."/".urlencode($row[filename]).".html';\"><tr height=\"".$thumbnail_w."\"><td valign=\"middle\" align=\"center\"><a href='".urlencode($catname)."/".urlencode($row[filename]).".html'>"; |
This much information could be found out by my little knowledge of PHP.
