PDA

View Full Version : PHP Photo Album not working



jsdeluxe
09-27-2006, 12:35 AM
1) Script Title: PHP Photo Album

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex4/php-photoalbum.htm

3) Describe problem:

I know there are thousands of posts about this script...

I cant get my Script to work. I put my site on this free webspace server with php..
http://jsdeluxe.cwsurf.de/bilder/crew/getpics.php
But the server is not reading it..
What could it be?

thx for reading this.

blm126
09-27-2006, 02:28 AM
That file looks correct to me. You understand that that file is nothing more than the javascript and needs to be referenced by an HTML file,right?

jsdeluxe
09-27-2006, 02:35 AM
Thx for posting..

It should appear on this page..

http://jsdeluxe.cwsurf.de/fotos2.html

must be something wrong with the code?

jsdeluxe
09-27-2006, 02:08 PM
I still didn't figure it out. Help

jscheuer1
09-27-2006, 04:17 PM
Click on this link in a browser such as Opera or FireFox (IE will pop up a dialogue):

http://jsdeluxe.cwsurf.de/bilder/crew/getpics.php

You will see that the array is being populated, but that the server is adding other code to the page. Many free hosts do this. Using some more Ajax, there is probably a way around this or you also may be able to put the code (in modified form) from getpics.php directly on your fotos2.html page and rename it to fotos2.php.

In addition to this problem, you have other scripts on fotos2.html which may be conflicting with the photo album script as well.

And, some of your image filenames use extended characters, it is better to use just the standard English alphabet for filenames.

First do this test and see what happens. Replace:


<script src="http://jsdeluxe.cwsurf.de/bilder/crew/getpics.php" type="text/javascript"></script>
<script type="text/javascript">
/***********************************************
* PHP Photo Album script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* Visit http://www.dynamicDrive.com for hundreds of DHTML scripts
* This notice must stay intact for legal use
***********************************************/
var dimension="3x3" //Specify dimension of gallery (number of images shown), such as 4x2, 3x1 etc

with:



<script type="text/javascript">
var galleryarray=new Array();
galleryarray[0]=["Alexander Friedrich.JPG", "Sep 27, 2006 02:20:55"];
galleryarray[1]=["Gösta.JPG", "Sep 27, 2006 01:08:18"];
galleryarray[2]=["Fred Astor.JPG", "Sep 27, 2006 01:08:00"];
galleryarray[3]=["Ina.JPG", "Sep 27, 2006 01:08:36"];
galleryarray[4]=["Christoph Hieke.JPG", "Sep 27, 2006 01:07:26"];
galleryarray[5]=["Tobias Lieckefett.JPG", "Sep 27, 2006 01:11:16"];
galleryarray[6]=["Stefan Däuwel.JPG", "Sep 27, 2006 01:10:36"];
galleryarray[7]=["Isabella Schmid.JPG", "Sep 27, 2006 01:08:55"];
galleryarray[8]=["Daniel Weber.JPG", "Sep 27, 2006 01:07:43"];
galleryarray[9]=["Bea Halasa.JPG", "Sep 27, 2006 02:21:29"];
galleryarray[10]=["Marten Werner.JPG", "Sep 27, 2006 01:09:45"];
galleryarray[11]=["Nicolai Haller.JPG", "Sep 27, 2006 01:10:19"];
galleryarray[12]=["Kim Smith.JPG", "Sep 27, 2006 01:09:28"];
galleryarray[13]=["André Garbe.JPG", "Sep 27, 2006 02:21:12"];
galleryarray[14]=["Moritz.JPG", "Sep 27, 2006 01:10:02"];
galleryarray[15]=["Julian Schmidt.JPG", "Sep 27, 2006 01:09:11"];
galleryarray[16]=["Tobias & Fred.JPG", "Sep 27, 2006 01:10:59"];
/***********************************************
* PHP Photo Album script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* Visit http://www.dynamicDrive.com for hundreds of DHTML scripts
* This notice must stay intact for legal use
***********************************************/
var dimension="3x3" //Specify dimension of gallery (number of images shown), such as 4x2, 3x1 etc

jsdeluxe
09-27-2006, 11:42 PM
Thx John for replying,

the Test works fine..
I hope I dont have to add those lines manually in future :)

I chose this server for my pics because my other one doesn't support PHP
If it is easier I could choose a different.. or maybe you know a good one for free.

blm126
09-28-2006, 01:17 AM
The easiest solution is to find another hosting company. I recommend that you just pay for some cheap hosting(I have found some hosts for less than a dollar a month), but if it must be free try http://www.funpic.org

jscheuer1
09-28-2006, 04:21 AM
Ok, some details would need to be worked out for specific features of the script but, the basic script should work on your server with these modifications. Forget about getpics.php we are putting the php code right on the page that is using it, here is a sample for your set up, save the below as test_pic.php and put it in the root of your domain:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">

.slideshow{ /*CSS for DIV containing each image*/
float: left;
margin-right: 10px;
margin-bottom: 10px;
}

.slideshow img{ /*CSS for each image tag*/
border: 0;
width: 200px;
height: 106px;
}

#navlinks{ /*CSS for DIV containing the navigational links*/
width: 400px;
}

#navlinks a{ /*CSS for each navigational link*/
margin-right: 8px;
margin-bottom: 3px;
font-size: 110%;
}

#navlinks a.current{ /*CSS for currently selected navigational link*/
background-color: yellow;
}
</style>
<script type="text/javascript">
<?
function returnimages($dirname="./bilder/crew/") {
$pattern="\.(jpg|jpeg|png|gif|bmp)$";
$files = array();
$curimage=0;
if($handle = opendir($dirname)) {
while(false !== ($file = readdir($handle))){
if(eregi($pattern, $file)){
$filedate=date ("M d, Y H:i:s", filemtime($dirname . $file));
echo 'galleryarray[' . $curimage .']=["' . $dirname . $file . '", "'.$filedate.'"];' . "\n";
$curimage++;
}
}

closedir($handle);
}
return($files);
}

echo "var galleryarray=new Array();" . "\n";
returnimages();
?>
</script>
</head>
<body>
<script type="text/javascript">

/***********************************************
* PHP Photo Album script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* Visit http://www.dynamicDrive.com for hundreds of DHTML scripts
* This notice must stay intact for legal use
***********************************************/

var dimension="3x2" //Specify dimension of gallery (number of images shown), such as 4x2, 3x1 etc
var imagepath="" //Absolute path to image directory. Include trailing slash (/)
var href_target="new" //Enter target attribute of links, if applicable

//Toggle popup link setting: popupsetting[0 or 1, "pop up window attributes" (if 1)]
var popupsetting=[1, "width=500px, height=400px, scrollbars, resizable"]

//Toggle image description: descriptionprefix[0 or 1, "Text to show" (if 1)]
var descriptionprefix=[1, "Photo "]

//Sort images by date? ("asc", "desc", or "")
//"desc" for example causes the newest images to show up first in the gallery
//"" disables this feature, so images are sorted by file name (default)
var gsortorder="desc"

//By default, each image hyperlinks to itself.
//However, if you wish them to link to larger versions of themselves
//Specify the directory in which the larger images are located
//The file names of these large images should mirror those of the original
//Enter a blank string ("") to disable this option
var targetlinkdir=""

/////No need to edit beyond here///////////////////

function sortbydate(a, b){ //Sort images function
if (gsortorder=="asc") //sort by file date: older to newer
return new Date(a[1])-new Date(b[1])
else if (gsortorder=="desc") //sort by file date: newer to older
return new Date(b[1])-new Date(a[1])
}

if (gsortorder=="asc" || gsortorder=="desc")
galleryarray.sort(sortbydate)

var totalslots=dimension.split("x")[0]*dimension.split("x")[1]

function buildimage(i){
var imagecompletepath=(targetlinkdir!="")? targetlinkdir+galleryarray[i][0] : imagepath+galleryarray[i][0]
var tempcontainer='<a href="'+imagecompletepath+'" target="'+href_target+'" onClick="return popuplinkfunc(this)">'
tempcontainer+='<img src="'+imagepath+galleryarray[i][0]+'" title="'+galleryarray[i][0]+' ['+galleryarray[i][1]+']" />'
tempcontainer+='</a><br />'
tempcontainer+=(descriptionprefix[0]==1)? descriptionprefix[1]+(i+1) : ""
return tempcontainer
}

function jumptopage(p){
var startpoint=(p-1)*totalslots
var y=1;
for (i=0; i<totalslots; i++){
document.getElementById("slide"+i).innerHTML=(typeof galleryarray[startpoint+i]!="undefined")? buildimage(startpoint+i) : ""
}
while(document.getElementById("navlink"+y)!=null){
document.getElementById("navlink"+y).className=""
y++
}
document.getElementById("navlink"+p).className="current"
}

var curimage=0
for (y=0; y<dimension.split("x")[1]; y++){
for (x=0; x<dimension.split("x")[0]; x++){
if (curimage<galleryarray.length)
document.write('<div id="slide'+curimage+'" class="slideshow">'+buildimage(curimage)+'</div>')
curimage++
}
document.write('<br style="clear: left" />')
}

function popuplinkfunc(imgsrc){
if (popupsetting[0]==1){
var popwin=open(imgsrc.href, "popwin", popupsetting[1])
popwin.focus()
return false
}
else
return true
}

</script>

<!--Below HTML code refers to the navigational links for the gallery-->

<div id="navlinks">
<script type="text/javascript">
for (i=1; i<Math.ceil(galleryarray.length/totalslots)+1; i++)
document.write('<a id="navlink'+i+'" href="javascript:jumptopage('+i+')\">Page'+i+'</a> ')
document.getElementById("navlink1").className="current"
</script>
</div>
</body>
</html>

See what happens.

jsdeluxe
09-28-2006, 09:51 AM
Very good, that works, except those with extendet characters, too bad..

http://jsdeluxe.cwsurf.de/fotos3.php

Realy thx for helping :)

jscheuer1
09-28-2006, 04:44 PM
That's great! Just a little advice, it would be a good idea to optimize or at least resize (make them smaller) your images. This will reduce the loading time.