/////////config//////////
$disp_type=1; // WinXP--'1' / Simple--'0'
$gdv=0; //GD Ver. 1.x--'1' 2.x--'0'
$title='Chiangmai.jp Image Viewer'; //Page title
$home='../'; //Home URL
$maxdist=70; //thumbnail size
$charset='Shift_JIS';
/////////////////////////
$dir = $_GET["dir"];
$t_self = explode("/",$_SERVER["SCRIPT_NAME"]); $q = count($t_self)-1; $self = $t_self[$q];
global $self;
$c = 'GDS Viewer (SPL)';
$mode = $_GET["mode"];
if ($mode == "popup"){
$filename = $_GET["filename"];
global $dir;
if (!$dir){ $d='.'; }
echo "\n
\n$filename\n\n";
echo "\n";
echo "\n";
echo " |
\n
\n\n\n";
} elseif (($mode == "thumb") AND ($c)){
$ext = $_GET["ext"];
$f = $_GET["f"];
$ow = $_GET["ow"];
$oh = $_GET["oh"];
$tw = $_GET["tw"];
$th = $_GET["th"];
$tid = $_GET["tid"];
if($ext == "2"){
$o = imagecreatefromjpeg($f);
} else {
$o = imagecreatefrompng($f);
}
if ($gdv){
$t = imagecreate($tw, $th);
} else {
$t = imagecreatetruecolor($tw, $th);
}
imagecopyresampled( $t,$o,0,0,0,0,$tw,$th,$ow,$oh);
if($ext == "2"){
header("content-type: image/jpeg"); imagejpeg($t);
} else {
header("content-type: image/png"); imagepng($t);
}
$outdir = $tid . "/" . mb_substr($dir_name, mb_strlen($dir));
if (!is_dir($outdir))
mkdir($outdir);
$ex = explode('.', $f);
$outfile = $tid . "/" . $ex[1] . "." . $ex[2];
ImageJPEG($t, $outfile);
ImageDestroy($o);
ImageDestroy($t);
}
/////////////////////////////////////////////////////////////////////////////////////////////////
function showmenu_s(){
echo "\n";
global $disp_type;
global $dir;
global $self;
global $home;
if (preg_match("/\.\./","$dir")){ $lock ='1';}
if((!$lock)&&($dir)){echo "Index of $dir";}
if(($lock)&&($dir)){echo "Wrong Action !";}
if (!$dir) {
echo "! Parent Dir";
} else {
$dd = explode("/",$dir);
echo " | 最上階層へ";
if ($dd[2]){
$tdir=array_pop($dd);
$back_dir = explode("/$tdir",$dir);
echo " | Foward to Upper Dir";
}
}
echo " | Home
\n";
}
function showmenu_w(){
global $disp_type;
global $dir;
global $self;
global $home;
global $c;
echo "
\n
\n";
}
function an_file($file_path){
global $maxdist;
$img= @getimagesize($file_path);
if (($img[0] < $maxdist) and ($img[1] < $maxdist)){$tw=$img[0]; $th=$img[1];} else {
if ($img[0] < $img[1]){$th=$maxdist; $tw=$img[0]*$th/$img[1];}
if ($img[0] > $img[1]){$tw=$maxdist; $th=$img[1]*$tw/$img[0];}
if ($img[0] == $img[1]){$tw=$maxdist; $th=$maxdist;}
}
$img_prop = "$img[2],$img[0],$img[1],$tw,$th,$img_type,$file_name";
return $img_prop;
}
function show_indx($dir_cnt){
global $dir;
global $self;
show_indx(${script_name});
ereg ( "([^/]*)$",$dir_cnt,$temp);
$td_name = ereg_replace( "$temp[1]$","", $dir_cnt);
}
function show_dir($file_path, $file_name, $filesize, $file_mtime){
global $dir;
$img_prop = an_file($file_path);
$img_prop = explode(",",$img_prop);
$ext = $img_prop[0];
$ow = $img_prop[1];
$oh = $img_prop[2];
$tw = round($img_prop[3]);
$th = round($img_prop[4]);
$ts_1 = round($filesize/1000,1);
$ts_2 = round($filesize/1000000,2);
if ($ts_1 < 1) { $show_size = 1; $t = 'KB'; $m = 1; }
if ($ts_2 > 1) { $show_size = $ts_2; $t = 'MB'; $m = 1; }
if (!$m){ $show_size = $ts_1; $t = 'KB'; }
global $self;
if (($file_name != $self) and ($file_name != 'dir.gif') and ($ext==1) or ($ext==2) or ($ext==3)){
$file=".$dir/$file_name";
echo "";
if ($ext==1){
echo "
";
echo "";
} elseif (($ext==2) or ($ext==3)){
echo "
";
echo "";
}
$fn_array = explode(".",$file_name); $l = count($fn_array)-1;
$sfn = mb_strimwidth($fn_array[0], 0, 8, "..");
echo "
$sfn.$fn_array[$l]";
echo "$ow x $oh
";
echo "$show_size $t
\n";
}
return;
}
function get_list($dir_cnt) {
$dir_handle=opendir($dir_cnt);
while ($file = readdir($dir_handle)){
$file_list = "$file_list,$file";
}
closedir($dir_handle);
return $file_list;
}
?>