Hi, my host recently moved my web site to a server which has register_globals set to Off. And yes, I know I should be coding my scripts to conform to this directive, but I don't exactly have all of the free time in the world to do so...
But this one aspect of my site, the gallery, which helps me keep my traffic up, is not working properly and I don't know why. I've tried to fix all of the environmental variables, but it still won't display the large pictures. Any one see what I'm missing?
perhaps I need to have a $_GET placed somewhere?
Here's a sample page: http://www.mzanime.com/aw/azumanga/index.php
And here's the PHP code I'm using, I call to the header/footer and this file for each gallery page, via includes:
<?php
####################################################
# Quick Gallery
# By Joe Herbert / Digital Shrine Productions
# www.digitalshrine.com
# Last Modified: Monday, May 27, 2002
####################################################
#Atleast let people see this in the page source code, don't remove.
print "<!--# Quick Gallery -->\n";
print "<!--# PHP Script By Joe Herbert / Digital Shrine Productions -->\n";
print "<!--# www.digitalshrine.com -->\n\n";
#
# DISPLAY SETTINGS
$iconsperpage = 12;
$iconsperrow = 4;
/* custom PHP code */
if($_SERVER['PHP_SELF'] == "/aw/aika/index.php") {
$isdynamic = "Agent Aika";
} elseif($_SERVER['PHP_SELF'] == "/aw/azumanga/index.php") {
$isdynamic = "Azumanga Daioh";
} elseif($_SERVER['PHP_SELF'] == "/aw/battleangel/index.php") {
$isdynamic = "Battle Angel";
} elseif($_SERVER['PHP_SELF'] == "/aw/athletes/index.php") {
$isdynamic = "Battle Athletes";
// etc. etc.....
} else
$isdynamic = "ERROR!";
# GALLERY TITLE
$title = $isdynamic;
# IMAGE DIRECTORY
# This is the directory your images are in, if they are in.
# Use "." if they are in the same directory as this file.
$imagedir =".";
# ICON DIRECTORY
# This is the directory your thumbnails are in, if they are in.
# Use "." if they are in the same directory as this file.
$icondir =".";
# ICON SUFFIX
# if you name your thumbnails like 'image-tn.jpg' use '-tn' here.
$iconsuffix ="-tn";
# SHOW FILE NAMES
# This will display the image file names under the icons and the large view.
$showfilenames = "yes";
# LINK TO IMAGE
# If you want people to be able to click on the large image to view it directly...
$linktoimage = "no";
# DESCRIPTION TABLE WIDTH
# This will be the set width of the table the description text is shown in to
# keep it from having a centered look. You may use a percentage.
$desctablewidth = "80%";
####################################################
$x = 0;
if(is_dir($icondir)) {
$thisdir = dir($icondir);
$x = 0; $icon[$x] = "0"; $image[$x] = "0";
while($entry=$thisdir->read()) {
if(($entry!='.')&&($entry!='..')&&(stristr($entry,"$iconsuffix.jpg")||stristr($entry,"$iconsuffix.gif"))&&file_exists("$imagedir/$entry")) {
$x++;
$icon[$x] = $entry;
if ($iconsuffix) { $entry = str_replace($iconsuffix, "", $entry); }
$image[$x] = $entry;
}
}
} else {
print "Check the settings."; exit;
}
$imgcount = $x;
array_multisort ($icon, $image);
######################################################
if ($iconsperpage == "all" || $iconsperpage == "0") {
$iconsperpage = $x;
}
if (!$showimage && $showimage != "0") {
/* Set Default page */
if (!$page) { $page = 1; }
/* Set the start and end and check for true page */
$start = (($page - 1) * $iconsperpage) + 1;
if ($start > $imgcount) { header("Location: http://".$_SERVER['HTTP_HOST'] . $_SERVER['PATH_INFO'].""); exit; }
$end = $page * $iconsperpage;
if ($end > $imgcount) { $end = $imgcount; }
print "<h4 style=\"display:block; margin:0; margin-bottom:5px\">\n\n<a href=\"/aw/\">Wallpapers</a> : $title</h4>\n\nNow showing images {$start} to {$end} of {$imgcount} images.<br /><br />\n\n";
$width = round(100 / $iconsperrow);
print "<table border=\"0\" width=\"100%\" style=\"margin:0;\">\n";
$tmp = $start - 1;
$rtmp = 0;
while($tmp < $end) {
$rtmp++;
$tmp++;
if ($rtmp == "1") {
print "<tr>\n";
}
print "<td align=\"center\" width=\"{$width}%\">\n<a href=\"{$_SERVER['PATH_INFO']}?showimage={$tmp}\"><img src=\"{$icondir}/{$icon[$tmp]}\" border=\"1\" alt=\"{$image[$tmp]}\" /></a>";
if ($showfilenames == "yes") {
print "\n<br /><a href=\"{$_SERVER['PATH_INFO']}?showimage=$tmp\">600x800</a>\n";
}
print "</td>\n\n";
if ($rtmp == $iconsperrow) {
$rtmp = 0;
print "</tr>\n<tr><td colspan=\"$iconsperrow\" align=\"center\"> </td></tr>\n";
}
}
if ($rtmp != "0") {
print "</tr>\n";
}
print "</table>\n";
if ($page > 1) {
$previous = $page - 1;
$previous = "[ <a href=\"{$_SERVER['PATH_INFO']}?page=$previous\">Previous Page</a> ]</font>";
} else {
$previous = " ";
}
if ($imgcount > $end) {
$next = $page + 1;
$next = "[ <a href=\"$PATH_INFO?page=$next\">Next Page</a> ]";
} else {
$next = " ";
}
if ( $imgcount > $iconsperpage ) {
$tmp = 0; $xtmp = 0;
$pages = "[";
while($tmp < $imgcount) {
$tmp = $tmp + $iconsperpage;
$xtmp++;
if ($xtmp != $page) {
$pages = $pages . " <a href=\"$PATH_INFO?page=$xtmp\">$xtmp</a> ";
} else {
$pages = $pages . " <b>$xtmp</b> ";
}
if ($tmp < $imgcount) { $pages = $pages . "|"; }
}
$pages = $pages . "]";
}
if ($pages) {
print "<table width=\"100%\">\n<tr>\n<td width=\"50%\" align=\"center\">$previous</td>\n<td width=\"50%\" align=\"center\">$next</td>\n</tr>\n</table>\n";
print "<center>$pages</center><br />\n";
}
######################################################################################
} elseif ($showimage || $showimage == "0") {
$tmp =0;
while (!$previouspage) {
$tmp++;
if ($showimage > ($iconsperpage * $tmp) - $iconsperpage && $showimage <= ($iconsperpage * $tmp) ) {
$previouspage = $tmp;
}
if ($tmp > 100) { print "there is an error!"; exit; }
}
print "<h4 style=\"display:block; margin:0; margin-bottom:5px\">\n\n<a href=\"/aw/\">Wallpapers</a> : $title</h4>";
print "\n";
print "[";
if ($showimage > 1) {
$previmage = $showimage - 1;
print " <a href=\"{$_SERVER['PATH_INFO']}?showimage={$previmage}\">Previous Image</a> ";
}
if ($previmage && $showimage < $imgcount) {
print "|";
}
if ($showimage < $imgcount) {
$nextimage = $showimage + 1;
print " <a href=\"{$_SERVER['PATH_INFO']}?showimage={$nextimage}\">Next Image</a> ";
}
print "]";
print"<P>";
print "<div align=\"center\">\n";
if ($linktoimage == "yes") {
print "<a href=\"{imagedir}/{$image[$showimage]}\">";
}
print "<img src=\"{$imagedir}/{$image[$showimage]}\" height=\"600\" width=\"800\" border=\"1\" />";
if ($linktoimage == "yes") {
print "</A>";
}
print "<P>\n";
if (strstr($image[$showimage], ".jpg")) {
$descname = str_replace(".jpg", ".txt", $image[$showimage]);
} elseif (strstr($image[$showimage], ".gif")) {
$descname = str_replace(".gif", ".txt", $image[$showimage]);
}
if (file_exists("$imagedir/$descname")){
if (!$desctablewidth) { $desctablewidth = "90%"; }
print "<p><table width=\"{$desctablewidth}\"><tr><td>\n";
readfile("$imagedir/$descname");
print "</td></tr></table><p>\n";
}
print "<p style=\"margin:3px; text-align:center\"><a href=\"{$_SERVER['PATH_INFO']}?page=$previouspage\">Back to {$title} index page # {$previouspage}</a></p></div>\n";
}
?>