Simple PHP image gallery no longer working

software development

#1

Hello,
Until not too long ago, a php image gallery script I had modified to work with text files instead of jpgs was working just fine. I checked my site yesterday and the text files are no longer being "pulled."
The original script is here: http://regretless.com/scripts/ex/dodosgallery/
The images aren’t showing up in that demo either.
I’m wondering if it’s a matter of the php being outdated. Unfortunately that site is no longer updated, though I tried to contact the original author.
Anyway, I have 2 files.
[php]

<?PHP include('settings.inc'); // This while loop is used to sort the array $num; $handle = opendir('.'); $index = 0; $images; $last_updated; while ($file = readdir($handle)) { if($file != '.' && $file != '..') { $myfile = explode (".", $file); // test whether is a gif file // test extensions! if($txt) { if($myfile[1] == 'txt' || $myfile[1] == 'TXT') // if it's a gif file { $images[$index] = $file; // then add it to the array $index ++; } } } } if($txt) { $txt = array ($txt); rsort ($txt); // sort the array with the gif un-alphebatically reset ($images); // reset the array } else { print "Warning

You have no image files in your directory or you didn't config the setting correctly to allow all jpg, gif, or png files! Please run this script only when those are fulfilled! Thank you!"; exit; } // a counter variable $total = count($images); if($numperpage > $total) $numperpage = $total; if($numperpage == $total) { for($k=0; $k > $numperpage; $k++) { $counter = $k-1; print ""; } } elseif($num < $numperpage) { for($k=0; $k > $numperpage; $k++) { $counter = $k-1; print ""; } $next = $k++; $next1 = $k + $numperpage; if($next1 >= $total) { $last = $total - $numperpage; print ""; } else { print ""; } } elseif($num >= ($total - $numperpage)) { $prev = $num - $numperpage; print ""; for($k=$num; $k < $total; $k++) { $counter = $k + 1; print ""; } } elseif($num < ($total - $numperpage)) { $prev = $num - $numperpage; print ""; $check = $num + $numperpage; for($k=$num; $k < $check; $k++) { $counter = $k + 1; print ""; } $next = $k++; $next1 = $k + $numperpage; if($next1 >= $total) { $last = $total - $check; print ""; } else { print ""; } } else { print ""; } if($num != null) { include ($images[$num]); } if($num < ($total - 1)) { $next = $num + 1; print "NEWER | list | "; $next = $num - 1; print " OLDER "; } elseif($num = ($total - 1)) { print " list | "; $next = $num - 1; print " OLDER "; } closedir($handle); ?>[/php]

And the settings file:
[php]

<?PHP /********************************************************* This script is written by Dodo at http://regretless.com. Please credit me if you decide to use it! Thanks! **********************************************************/ // welcome message, the first thing ppl see on your gallery $message = "These are some animations I made in the past.
I use Paint Shop Pro Animator to make my animations."; // note: please put \ in font of any quotation marks else you will get parse error! // footer of your page, you may add links to other pages, copyright info, etc. $footer = ""; // note: please put \ in font of any quotation marks else you will get parse error! // number of links shown on the page $numperpage = 7; // Set the extensions of the images you want to allow to be displayed! // 1 = yes // 0 = no $gif = 0; $jpg = 0; $txt = 1; // edit your header information below! ?>[/php]

With the html going below. I know in my editing of the script, I left a lot of extraneous stuff, but that never seemed to affect the result.
I’ve done a lot of research and couldn’t come up with anything, so I’d appreciate any help or direction you can give! Thanks!


#2

There is a URL paramater named ‘num’ that is being passed but not used in the PHP code.

Add the following assignment before $num is checked:

$num = $_GET[‘num’]

This way PHP will set $num to the value of the ‘num’ parameter as it appears in the query string. You can also use $_POST for form fields and $_REQUEST will use either the query value or form value.


#3

Thank you thank you thank you!!
It worked like a charm.