Home > php教程 > php手册 > [原创]php+ajax实现模拟Win文件管理系统三

[原创]php+ajax实现模拟Win文件管理系统三

WBOY
Release: 2016-06-13 09:59:14
Original
1148 people have browsed it

[原创]php+ajax实现模拟Win文件管理系统

//本教程由本站原创,转载请注明来处

作者:www.drise.cn

邮箱:drise@163.com

QQ:271728967//

上一篇我们己讲了dir.php文件的作用了,下面我就讲rename.php文件每一个函数的功能.

 Refere();
 header("Content-type:text/html;charset=utf-8");//设置文档编码
 $path = isset($_GET['path'])?$_GET['path']:'';
 $nname = isset($_GET['nname'])?$_GET['nname']:'';
 $cpath = isset($_GET['copypath'])?$_GET['copypath']:'';
 $action = isset($_GET['action'])?$_GET['action']:'';
 switch($action){ 
  case 'del':  
   Deletefile($path); 
  break;
  case 'mkdir':
   Createfolder($path,$nname);
   break;
  case 'past':
   Past($path,$nname,$cpath);
   break;
  default: 
   Filename($path,$nname);
 } 
这里就是rename.php文件所有函数,下面我们来进行分析.

 Refere()函数

多人看到名称大概就知道什么用意了.下面看它的代码.

function Refere(){
 $referer=isset($_SERVER['HTTP_REFERER'])?$_SERVER['HTTP_REFERER']:'';
 if($referer =='' || is_null($referer) || empty($referer)){
  exit("Error Server Http 500");
 }

就这一小段,这里是为了,防止用户直接输入rename.php文件所做的最基本的安全保护方法,函数的就不说了.

 Deletefile()函数

function Deletefile($path){
 if(is_dir($path) && is_writable($path)){
  echo @rmdir($path)?'t':'fo';
 }else if(file_exists($path) && is_writable($path)){
  echo unlink($path)?'t':'ff';
 }else{
  exit("没有权限,Error http 404 ");
 }
}[上面输出的t,ff这是为后面返回是用ajax传值判断,显示结果给用户看的.]

上一篇

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template