I'm trying to get a gallery script i made working for a friend.
<?
print "<center><table class=\"hidden\"><TR>" ;
$number = 0 ;// counter starting at 0
$nrow = 2 ;// amount of thumbnails per row +1. So if you wanted 1 row, it'd be 0, if you wanted 6 rows you'd put 5.
$dir = ".";
$new_w = 150 ;
$new_h = 150 ;
if (is_dir($dir)){
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) != false) {
if ( preg_match( '/\.jpg$/', $file) ){
if ((preg_match( '/\_sm.jpg$/', $file)) != true){
$jpegname = str_replace(".jpg", "", $file);
if ((is_file($jpegname."_sm.jpg")) != true) {
// if ((is_file($jpegname."_sm.jpg"))== false){
$file2 = ImageCreatefromjpeg("$dir"."/"."$file");
$old_x=imageSX($file2);
$old_y=imageSY($file2);
if ($old_x > $old_y) {
$thumb_w=$new_w;
$thumb_h=$old_y*($new_h/$old_x);
}
if ($old_x < $old_y) {
$thumb_w=$old_x*($new_w/$old_y);
$thumb_h=$new_h;
}
if ($old_x == $old_y) {
$thumb_w=$new_w;
$thumb_h=$new_h;
}
$dst_img=ImageCreateTrueColor($thumb_w,$thumb_h);
imagecopyresampled($dst_img,$file2,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y);
$savefile = "$dir"."$jpegname"."_sm.jpg" ;
imagejpeg($dst_img,$savefile,100);
// imagejpeg($dst_img,$jpegname."_sm.jpg",100);
imagedestroy($file2);
imagedestroy($dst_img);
}
/* if $dir == "." {
$dir = "" ;
} */
if ($number == $nrow){
$type1 = "<TR>" ;
$type2 = "</TR>" ;
$number = 0 ;
}
else {
$type1="" ;
$type2="" ;
$number = $number + 1 ;
}
print "<TD><div class=\"gallery\"><a href = \"$dir"."/"."$file\"><img src=\"$dir/".$jpegname."_sm.jpg\" border=0></A></TD>"."$type1"."$type2"."</div>";
// echo "<a href=/".$dir."/".$file./"><img src=\"/"$dir"/".$jpegname."_sm.jpg\"></A>" ;
//<div class=\"gallery2\"></div>
}
}
}
}
}
print "</TABLE></center>" ;
?>
that's all fine and dandy and works, but when I include it (to a root directory index2.php (test file) . It screws up, now I know this is because the dir is set to "." , but if i set it in relation to the picture folder where this index file is. No Luck, im sure this is an icky includes problem. I saw people trying to "define" crap for ROOT and ROOT_URL, but that was sooo complicated, and I've ran out of brain cells. So can someone tell me what I need to do?
http://bralywood.no-ip.com/test/gallery/
this works, and shows the pictures as I want them to be included>
http://bralywood.no-ip.com/index.php , this is where it screws up, and takes a picture from his root directory rather than the /test/gallery/ folder where the original gallery script is located with pictures.