PDA

View Full Version : Resolved PHP Photo Album script v2.11 Pictures don't show up



KayLawless
09-25-2012, 05:11 PM
1) Script Title: PHP Photo Album script v2.11

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

3) Describe problem: Pictures don't show up.

I've tried everything and I just can't get this thing to work.

I tried the PHP 5.3+ fix here: http://www.dynamicdrive.com/forums/showthread.php?54416-PHP-Photo-Album-script-v2-11 it makes the problem worse. Instead of just the pictures not showing up, nothing shows up. I know I'm running 5.4.7 : http://www.klaification.com/test.php

I tried the .zip thing suggested here: http://www.dynamicdrive.com/forums/showthread.php?54442-PHP-Photo-Album-Script-V2-11-images-not-showing&p=225746#post225746 and it also doesn't show the pictures. You can see that here: http://www.4crg.org/pics.htm

I'm getting this error from both the .zip one and the one with my html: alert("Photo Album ID must contain only letters, numbers, or underscore, and cannot start with a number")
At one point I did get the right output for getalbumpics.php and the pictures still did not show. I've only been changing the getalbumpics.php file for the PHP 5.3+ fix and I tried it with both versions in the file.

The .zip install has a photo album id of 'jaguar' and mine has 'rollerderby' I haven't changed either of these ever.

Any ideas on how to get this to work?

jscheuer1
09-25-2012, 05:43 PM
The .zip version is working but the images aren't showing up. I'm not sure why. I can navigate to www.4crg.org/pics/getalbumpics.php?id=jaguar and that looks right:


var jaguar={
baseurl: "http://4crg.org/pics/",
images: [
[0, "hi.JPG", "Sep 24, 2012 20:45:04"],
[1, "howsitgoing.jpg", "Sep 24, 2012 20:46:30"],
[2, "goodhowareyou.jpg", "Sep 24, 2012 20:47:19"],
[3, "decent.jpg", "Sep 24, 2012 20:48:24"],
[4, "justdecent.jpg", "Sep 24, 2012 20:49:05"],
[5, "yup.jpg", "Sep 24, 2012 20:43:37"],
["placeholder"]
],
desc: []
}

Except that the baseurl doesn't have the www. part in it. It should. It looks like the server has some sort of rewrite engine on. I can't see any of that. But I'm seeing the results. You cannot navigate to anything on that domain without the www. part. If you try, you get redirected the the index page with www. added. Either that rewrite engine needs to be modified or www. has to be added to the baseurl when and if it's missing.

Try this getalbumpics.php file, replace the existing one in the zip installation:


<?php
Header("content-type: application/x-javascript");

function returnimages($dirname=".") {
$pattern='/\.(jpg|jpeg|png|gif|bmp)$/i';
$curimage=0;
if($handle = opendir($dirname)) {
while(false !== ($file = readdir($handle))){
if(preg_match($pattern, $file)){
$filedate=date ("M d, Y H:i:s", filemtime($file));
echo " [$curimage, \"$file\", \"$filedate\"],\n";
$curimage++;
}
}
echo ' ["placeholder"]' . "\n";
closedir($handle);
}
}

$photovar=$_GET['id'];
if (!preg_match('/^[a-z0-9_]+$/i', $photovar)){
echo "alert(\"Photo Album ID must contain only letters, numbers, or underscore, and cannot start with a number\")";
die();
}
echo "var $photovar={\n";
echo " baseurl: \"http://www." . $_SERVER["SERVER_NAME"] . dirname($_SERVER['PHP_SELF']) . "/\",\n";
echo " images: [\n";
returnimages();
echo " ],\n";
echo " desc: []\n";
echo "}\n";
?>

The browser cache may need to be cleared and/or the page refreshed to see changes. And the server might need to have its cache cleared too. On the pics.htm page you can add the highlighted:


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript" src="pics/getalbumpics.php?id=jaguar&bust=7329"></script>

<script type="text/javascript">

//Optional, manual description for . . .

to make the server fetch the file new. Each time you change the file, you need to use a different number. But that's only if the server is caching it.

KayLawless
09-25-2012, 08:25 PM
I tried those things and it's still not working. I did notice that the picture placeholder things are disappearing slower though.

jscheuer1
09-25-2012, 08:48 PM
Looks like the getalbumpics.php file has not been updated. But I cannot tell for sure.

OK, go back to the original and add this script as shown to pics.htm:


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript" src="pics/getalbumpics.php?id=jaguar&bust=7329"></script>
<script type="text/javascript">
jaguar.baseurl = 'http://www.4crg.org/pics/";
</script>
<script type="text/javascript">

//Optional, manual description for particular pictures inside album
//Syntax: albumid.desc[index]="Picture description here"
//eg: jaguar.desc[2]="This is description for the 3rd picture in the album"
//eg: jaguar.desc[6]="This is description for the 7th picture in the album"

</script>

<script type="text/javascript" src="ddphpalbum.js">

/***********************************************
* PHP Photo Album script v2.0- (c) Dynamic Drive DHTML c . . .

KayLawless
09-25-2012, 09:03 PM
Still no dice. :(

jscheuer1
09-25-2012, 09:18 PM
Sorry about that, typo on my part:


<script type="text/javascript">
jaguar.baseurl = 'http://www.4crg.org/pics/";
</script>

Needs to be:


<script type="text/javascript">
jaguar.baseurl = 'http://www.4crg.org/pics/';
</script>

The browser cache may need to be cleared and/or the page refreshed to see changes.

KayLawless
09-25-2012, 10:03 PM
Hey! It works!!! Yay! Thank you so much! So the problem is just my redirect?

jscheuer1
09-25-2012, 11:05 PM
Apparently it's a factor. However, the getalbumpics.php file in the .zip version is also updated for the major PHP 5.3+ things, so those updates most likely are also an issue and required (the code in the getalbumpics.php from the demo page probably will not work for you).

Is that your redirect, as opposed to one imposed upon you by your host? Either way, if you have access, it could probably be tweaked so that it doesn't lead to this issue. But I'm not real up on redirects, though I do know that the optimal syntax can vary depending upon host.

KayLawless
09-26-2012, 12:49 AM
I found the code somewhere. It's in htaccess. I don't really mind since it's working now.

Would you happen to know how to put a space between page and the number on the photo album navigation? Right now it's 'Page1' and I would like it to be 'Page 1'. I found where it writes it in the js file and tried all sorts of things like ' ', &nbsp;, &amp;nbsp;, \xa0 but none of that works.

jscheuer1
09-26-2012, 01:09 AM
It's making PHP report:


$_SERVER["SERVER_NAME"]

without the www. part, even while rewriting it to include that in the address bar. That would be OK if it didn't also redirect all requests without the www. part to the site's index page. If one could make exceptions for images, scripts, css files . . . Or make it report SERVER_NAME with the www. part as a server normally will when that's in the address bar . . .

But, as you say, it works.

About the page thing, find this line in the script:


document.write('<a href="#Page' + i+ '" rel="'+i+'">Page'+i+'</a> ')

The highlighted part is what's seen on the page. Change it to:


document.write('<a href="#Page' + i+ '" rel="'+i+'">Page '+i+'</a> ')

KayLawless
09-26-2012, 02:32 PM
That didn't work. Oh well.

jscheuer1
09-26-2012, 04:07 PM
The ddphpalbum.js file is unchanged. Are you sure you uploaded the changed file to the correct location? Something similar may have happened with the getalbumpics.php file.

KayLawless
09-26-2012, 04:16 PM
Weird. It worked now. Maybe I was editing one copy and uploading a different one. Thanks for all your help, John. :D