[原創]php+ajax實現類比Win檔案管理系統
//本教程由本站原創,轉載請註明來處
作者:www.drise.cn
郵箱:drise@163.com
QQ:271728967//
接上面我們來看dir.php檔案代碼:
無標題文檔
$dir_path=isset($_GET['url'])?$_GET['url']:'..';
//$totallen = strlen($dir_path);
//$sublen = strlen(substr($dir_path,strrpos($dir_path,"/")));
$lastdir = substr($dir_path,0,strlen($dir_path)-strlen(substr($dir_path,strrpos($dir_path,"/"))));
Tool($dir_path,$lastdir);
CheckDir($dir_path);
//echo "
";
//echo substr($dir_path,0,(strlen($dir_path)-strrpos($dir_path,"/")+1));
function CheckDir($dir_path){// 這個函數是檢查並顯示目前的目錄下的檔案及檔案
if(is_dir($dir_path)){
if($dir_file=opendir($dir_path)){
while(($dir_list=readdir($dir_file))!==false)
{
if($dir_list!="." && $dir_list!=".."){//如果加這裡判斷等一在顯示檔案清單時.. .這樣.
echo("
".$dir_list."
\n");
}
}
}else{
echo($dir_path."
");
}
}else{
echo($dir_path."
");
}
Folderexp($dir_path);
}
function Getfiletype($dir){//根據副檔名顯示相應的圖片
global $_GET;
if(@$_GET['url'] !='' and is_dir(@$_GET['url'])){
$dir = $_GET['url'].'\\'.$dir;
}
//print_r( $dir);
if($dir == '' || is_null($dir) || empty($dir)){return false;}
if(is_dir($dir)){
return 'fold.jpg';
}else{
return (Getextends($dir));
}
}
function Getextends($dir){
if($dir =="" || is_null($dir)){return "unkown.jpg";}
$Extends_name = substr($dir,strrpos($dir,".")+1);
$Extends_img = array('jpg','jpeg','gif','png','bmp','psd');
if(in_array($Extends_name,$Extends_img)){return $dir;}
switch($Extends_name){
case "php":
return 'image/asp_php_jsp.jpg';
break;
case "asp":
return 'image/asp_php_jsp.jpg';
break;
case "jsp":
return 'image/asp_php_jsp.jpg';
break;
case "aspx":
return 'image/asp_php_jsp.jpg';
break;
case "xml":
return 'image/asp_php_jsp.jpg';
break;
case "htm":
return 'image/html_js.jpg';
break;
case "html":
return 'image/html_js.jpg';
break;
case "shtml":
return 'image/html_js.jpg';
break;
case "js":
return 'image/html_js.jpg';
break;
case "txt":
return 'image/txt.jpg';
break;
case "doc":
return 'image/word.jpg';
break;
default:
return 'image/fold.jpg';
}
}
function Folderexp($dir_path){//建立檔案夾
echo("");
echo("");
echo("");
echo("
");
echo("");
echo("
");
echo("");
}
function Tool($dir_path,$lastdir){//這裡顯示菜單條
echo("");
echo("");
echo("");
echo("");
echo("");
echo("");
echo("");
echo("");
echo("");
echo("");
}
?>
上一篇
http://www.bkjia.com/PHPjc/631855.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/631855.htmlTechArticle[原創]php+ajax實現類比Win檔案管理系統 //本教程由本站原創,轉載請註明來處 作者:www.drise.cn 郵箱:drise@163.com QQ:271728967// 接上面我們來看dir....