Why this php script cannot detect images from other directories except from where the index.php is located at?
<pre><code>&lt;?

$start = $_GET[start] ? $_GET[start] : 0 ;

$sortby = $_COOKIE[sortby] ? $_COOKIE[sortby] : "name" ;
if($_GET[sortby]){
    $sortby = $_GET[sortby];
    setcookie("sortby", $_GET[sortby], time()+86400 );
    header("location: index.php");
}




$od = opendir("./");
while($file = readdir($od)){
    if( eregi("\.(gif|jpe?g|png)$", $file) ){
        $file2 = rawurlencode($file);
        $img_arr[$file2]            = $file;
        $img_arr_filesize[$file2]   = filesize($file);
        $img_arr_filemtime[$file2]  = filemtime($file);

        list($imagex, $imagey, $type, $attr) = getimagesize($file);
        $img_arr_sizexy[$file2]     = $imagex."x".$imagey;
    }
}



asort($img_arr);
asort($img_arr_filesize);
asort($img_arr_filemtime);


switch($sortby){
    case "time":
        $img_arr_final = $img_arr_filemtime;
        break;

    case "size":
        $img_arr_final = $img_arr_filesize;
        break;

    case "name":
        $img_arr_final = $img_arr;
        break;
}

$total_images = count($img_arr_final);

foreach($img_arr_final as $k=&gt;$v){
    $i++;
    if($i &lt; $start+1) continue;
    if($i &gt; $start + $pp) break;

    $img_name = strlen($img_arr[$k]) &gt; 18 ? substr($img_arr[$k],0,16)."..." :$img_arr[$k];

    $alt = $img_arr[$k] . " -|- Last modified: " . date("Y-m-d H:i:s", $img_arr_filemtime[$k]) . " ";

    $imgl .= "&lt;div class=\"img_thumb\"&gt;&lt;a href=\"$k\"&gt;&lt;img src=\"index.php?thumb=$k\" alt=\"$alt\" title=\"$alt\" /&gt;&lt;/a&gt;&lt;p title=\"".$img_arr[$k]."\"&gt;&lt;strong&gt;".$img_name.    "&lt;/strong&gt;&lt;br /&gt;&lt;span class=\"mini\"&gt;".$img_arr_sizexy[$k].", ".round(($img_arr_filesize[$k]/1024))." KB&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;";


}




for($p=0; $p*$pp &lt;  $total_images ; $p++){
    $active = ($p*$pp) == $start ? "active" : "" ;
    $page_htmo .= "&lt;a href=\"index.php?start=".($p*$pp)."\" class=\"$active pages\"&gt;".($p+1)."&lt;/a&gt; ";
}



$arr_sortby = array("name"=&gt;"Name", "size"=&gt;"Size", "time"=&gt;"Time");    

foreach($arr_sortby as $k=&gt;$v){

    if($sortby == $k){
        $sortby_html[] = "&lt;strong&gt;$v&lt;/strong&gt;";
    } else {
        $sortby_html[] = "&lt;a href=\"index.php?sortby=$k\"&gt;$v&lt;/a&gt;";
    }

}   

$sortby_htmo = implode(" | ", $sortby_html);







function make_thumbnail($updir, $img){
global $thumb_width, $thumb_height;

$thumbnail_width    = $thumb_width ? $thumb_width : 120;
$thumbnail_height   = $thumb_height ? $thumb_height : 80;

$arr_image_details  = GetImageSize("$updir"."$img");
$original_width     = $arr_image_details[0];
$original_height    = $arr_image_details[1];

if( $original_width &gt; $original_height ){
    $new_width  = $thumbnail_width;
    $new_height = intval($original_height*$new_width/$original_width);
} else {
    $new_height = $thumbnail_height;
    $new_width  = intval($original_width*$new_height/$original_height);
}

$dest_x = intval(($thumbnail_width - $new_width) / 2);
$dest_y = intval(($thumbnail_height - $new_height) / 2);



if($arr_image_details[2]==1) { $imgt = "ImageGIF"; $imgcreatefrom = "ImageCreateFromGIF"; $imgx = "gif"; }
if($arr_image_details[2]==2) { $imgt = "ImageJPEG"; $imgcreatefrom = "ImageCreateFromJPEG"; $imgx = "jpeg"; }
if($arr_image_details[2]==3) { $imgt = "ImagePNG"; $imgcreatefrom = "ImageCreateFromPNG";  $imgx = "png"; }


if( $imgt ) { 
    $old_image  = $imgcreatefrom("$updir"."$img");
    $new_image  = ImageCreateTrueColor($thumbnail_width, $thumbnail_height);
    imageCopyResized($new_image,$old_image,$dest_x,         
    $dest_y,0,0,$new_width,$new_height,$original_width,$original_height);


    header("Content-Type: image/jpeg"); imagejpeg($new_image, NULL, 80);
}

}

if($_GET['thumb']) { 
 if( in_array($_GET['thumb'], $img_arr) ) make_thumbnail("./", $_GET['thumb']); // against file inclusion
 exit(); 
}
?&gt;
</code></pre>

<p>This is a gallery generator script, but it only shows me the pics when they are in the same directory as the script is in, how could I modify it to allow other scripts.
I've tried many tweaks but, nothing works.</p>
