Hello everybody, I recently pulled some code that I wrote for a site on a Linux server and tried to use it for a site on a Windows server. As a quick solution for a friends site, its a bunch of html with the php in the middle that is supposed to display a few images as pop-up links in a table. The strange thing is the that not only does the code not work and provides no error messages, but it prevents any of the html from being parsed, outputting nothing but the open and closed html and body tags. Heres the code:
<html>
<body>
<!----------- html header --------->
<?php
function makeThmb ($neWdth, $file) {
$origImgPth = $_SERVER['HTTP_HOST']."/ga
llery/".$f
ile.;
$thmbImgPth = $_SERVER['HTTP_HOST']."/ga
llery/thmb
s/".$file.
"-thmb.jpg
";
if (!file_exists($thmbImgPth)
&& file_exists($origImgPth)) {
$quality = "50";
list($origWdth, $origHght, $imgTpe) = getimagesize($origImgPth);
//$imgTpe = ($imgTpe === "1" ? "gif" : ($imgTpe === "2" ? "jpg" : ""));
$ratio = ($origWdth / $neWdth);
$newHght = round($origHght / $ratio);
switch ($imgTpe) {
case "2": //jpg
$image_p = imagecreatetruecolor($neWd
th, $newHght);
$image = imagecreatefromjpeg($origI
mgPth);
imagecopyresampled($image_
p, $image, 0, 0, 0, 0, $neWdth, $newHght, $origWdth, $origHght);
imagejpeg($image_p, $thmbImgPth, $quality);
return ("true");
break;
default: //not jpg
return ("false");
break;
}
} elseif (file_exists($thmbImgPth))
{
return ("true");
} else {
return ("false");
}
}
$folder = "/gallery/";
if ($handle = opendir($folder)) {
/* loop over the directory. */
$images = array();
$arr = 0;
while (false !== ($file = readdir($handle))) {
$fileext = substr(strrchr($file, "."), 1);
if(strtolower($fileext) == "jpg" || strtolower($fileext) == "gif"){
$images[$arr] = $file;
$arr++;
}
}
closedir($handle);
$thmbNail = "";
$content = "<table border=\"0\" cellpadding=\"3\" cellspacing=\"3\" align=\"center\">\n<tr>\n<
td>Click on a pic below to blow it up in a new window</td>\n</tr>\n";
$cnt = 0;
for ($i=0; $i<=ceil($arr/4); $i++) {
$content .= "<tr>\n";
for ($x=0; $x<=4; $x++) {
if (isset($arr[$cnt]) {
//create thumb
$thmbNail = (makeThmb("100", $images[$cnt]) === "true" ? "gallery/thmbs/".$images[$
cnt]."-thm
b.jpg" : "gallery/".$images[$cnt]);
//display thmb
$content .= "<td><a class=\"press\" href=\"#\" onclick=\"window.open('gal
lery/".$im
ages[$cnt]
."', 'newwindow', 'width=600, height=500, status=no, resizable=yes, scrollbars=no'); return false;\"><img src=\"".$thmbNail."\" border=\"0\" width=\"83\" height=\"63\"></a></td>\n"
;
$cnt++;
} else {
$content .= "<td> </td>\n";
$cnt++;
}
}
$content .= "</tr>\n";
}
$content .= "</table>";
} else {
$content = "Images Coming Soon";
}
echo $content;
?>
<!------- html footer ---------->
</body>
</html>
I know the opendir function doesn't work. I learned this by completely commenting out the makeThmb function, which seems to be the reason none of the html is parsed. Any help would be greatly appreciated.
Start Free Trial