$dh = dir($inpath);$ty1="";$ty2="";$filearr = array();while($file = $dh->read()) { //-----计算文件大小和创建时间 if($file!="." && $file!=".." && !is_dir("$inpath/$file")){ $filetime = filemtime("$inpath/$file"); $filetime = MyDate("Y-m-d H:i:s", $filetime);$filearr[] = $file;$filetimearr[] = $filetime; } if($file == ".") continue; else if($file == "..") { if($activepath == "") continue; $tmp = preg_replace("#[/][^/]*$#i", "", $activepath); $line = "n<tr> <td class='linerow' colspan='2'> <a href='select_images.php?imgstick=$imgstick&v=$v&f=$f&activepath=".urlencode($tmp).$addparm."'><img src=img/dir2.gif border=0 width=16 height=16 align=absmiddle>上级目录</a></td> <td colspan='2' class='linerow'> 当前目录:$activepath</td> </tr> "; echo $line; } else if(is_dir("$inpath/$file")) { if(preg_match("#^_(.*)$#i", $file)) continue; #屏蔽FrontPage扩展目录和linux隐蔽目录 if(preg_match("#^.(.*)$#i", $file)) continue;$dirarr[] = $file; }}//End Loop$dh->close();arsort($dirarr);foreach($dirarr as $file){$line = "n<tr> <td bgcolor='#F9FBF0' class='linerow' colspan='2'> <a href='select_images.php?imgstick=$imgstick&v=$v&f=$f&activepath=".urlencode("$activepath/$file").$addparm."'><img src=img/dir.gif border=0 width=16 height=16 align=absmiddle>$file</a></td> <td class='linerow'> </td> <td bgcolor='#F9FBF0' class='linerow'> </td> </tr>";echo "$line";}array_multisort($filetimearr,SORT_DESC,SORT_STRING, $filearr);array_multisort($filetimearr,SORT_DESC,SORT_STRING, $filetimearr);$result = array_combine($filearr,$filetimearr);foreach($result as $file => $filetime){$filesize = filesize("$inpath/$file");$filesize = $filesize / 1024;if($filesize != "")if($filesize < 0.1){@list($ty1, $ty2) = split(".", $filesize);$filesize = $ty1.".".substr($ty2, 0, 2);}else{@list($ty1, $ty2) = split(".", $filesize);$filesize = $ty1.".".substr($ty2, 0, 1);}if(preg_match("#.(gif|png)#i", $file)) { $reurl = "$activeurl/$file"; $reurl = preg_replace("#^..#", "", $reurl); if($cfg_remote_site=='Y' && $remoteuploads == 1) { $reurl = $remoteupUrl.$reurl; }else{ $reurl = $reurl; } if($file==$comeback) $lstyle = " style='color:red' "; else $lstyle = ""; $line = "n<tr> <td align='center' class='linerow' bgcolor='#F9FBF0'> <a href="#" onClick="ChangeImage('$reurl');"><img src='img/picviewnone.gif' width='16' height='16' border='0' align=absmiddle></a> </td> <td class='linerow' bgcolor='#F9FBF0'> <a href=# onclick="ReturnImg('$reurl');" $lstyle><img src=img/gif.gif border=0 width=16 height=16 align=absmiddle>$file</a></td> <td class='linerow'>$filesize KB</td> <td align='center' class='linerow' bgcolor='#F9FBF0'>$filetime</td> </tr>"; echo "$line"; } else if(preg_match("#.(jpg)#i", $file)) { $reurl = "$activeurl/$file"; $reurl = preg_replace("#^..#", "", $reurl); if($cfg_remote_site=='Y' && $remoteuploads == 1) { $reurl = $remoteupUrl.$reurl; }else{ $reurl = $reurl; } if($file==$comeback) $lstyle = " style='color:red' "; else $lstyle = ""; $line = "n<tr> <td align='center' class='linerow' bgcolor='#F9FBF0'> <a href="#" onClick="ChangeImage('$reurl');"><img src='img/picviewnone.gif' width='16' height='16' border='0' align=absmiddle></a> </td> <td class='linerow' bgcolor='#F9FBF0'> <a href=# onclick="ReturnImg('$reurl');" $lstyle><img src=img/jpg.gif border=0 width=16 height=16 align=absmiddle>$file</a> </td> <td class='linerow'>$filesize KB</td> <td align='center' class='linerow' bgcolor='#F9FBF0'>$filetime</td> </tr>"; echo "$line"; }} |