转到上级目录\n"); } } function ListPic($truePath, $nowPath) { global $listSize; $col=0; $rowdd=0; $rowdd++; $imgfile=""; $truePath = preg_replace("#\/$#", "", preg_replace("#\\\\{1,}#", "/", trim($truePath))); $nowPath = preg_replace("#\/$#", "", preg_replace("#\/{1,}#", "/", trim($nowPath))); $dh = dir($truePath); echo("\n"); while( $filename = $dh->read() ) { if(!preg_match("#\.$#", $filename)) { $fullName = $truePath."/".$filename; $fileUrl = $nowPath."/".$filename; if(is_dir($fullName)) { if($col % $listSize==0 && $col != 0) { echo("\n\n"); for($i = $rowdd-$listSize; $i < $rowdd; $i++) { echo("".$filelist[$i]."\n"); } echo("\n\n"); } $line = "
"; $filelist[$rowdd] = $filename; $col++; $rowdd++; echo $line; } else if(IsImg($filename)) { if($col % $listSize==0 && $col != 0) { echo("\n\n"); for($i=$rowdd-$listSize; $i<$rowdd; $i++) { echo("".$filelist[$i]."\n"); } echo("\n\n"); } $line = "
".GetImgFile($truePath, $nowPath, $filename)."
"; $filelist[$rowdd] = $filename; $col++; $rowdd++; echo $line; } } } echo("\n"); if( !empty($filelist) ) { echo("\n"); $t = ($rowdd-1) % $listSize; if( $t == 0 ) { $t = $listSize; } for($i = $rowdd - $t; $i < $rowdd; $i++) { echo("".$filelist[$i]."\n"); } echo("\n"); } } function GetImgFile($truePath, $nowPath, $fileName) { $toW=102; $toH=102; $srcFile = $truePath."/".$fileName; $info = ""; $data = GetImageSize($srcFile, $info); $srcW=$data[0]; $srcH=$data[1]; if($toW >= $srcW && $toH >= $srcH) { $ftoW = $srcW; $ftoH = $srcH; } else { $toWH = $toW / $toH; $srcWH = $srcW / $srcH; if($toWH <= $srcWH) { $ftoW = $toW; $ftoH = $ftoW * ( $srcH / $srcW); } else { $ftoH = $toH; $ftoW = $ftoH * ( $srcW / $srcH ); } } return(""); } function IsImg($fileName) { if(preg_match("#\.(jpg|gif|png)$#", $fileName)) return 1; else return 0; }