Home > Backend Development > PHP Tutorial > [Original] PHP+ajax implements simulated Win file management system 3_PHP tutorial

[Original] PHP+ajax implements simulated Win file management system 3_PHP tutorial

WBOY
Release: 2016-07-13 10:59:59
Original
1242 people have browsed it

[Original] php+ajax implements simulated Win file management system

//This tutorial is original from this site, please indicate the source when reprinting

Author: www.drise.cn

Email:drise@163.com

QQ:271728967//

We have already talked about the function of the dir.php file in the previous article. Now I will talk about the function of each function of the rename.php file.

Refere();
header("Content-type:text/html;charset=utf-8");//Set document encoding
$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);
}
Here are all the functions of the rename.php file, let’s analyze them below.

Refere() function

Very many people will probably know the purpose when they see the name. Let’s look at its code below.

function Refere(){
$referer=isset($_SERVER['HTTP_REFERER'])?$_SERVER['HTTP_REFERER']:'';
if($referer =='' || is_null($referer) || empty($referer)){
exit("Error Server Http 500");
}
}
In this short paragraph, here is the most basic security protection method to prevent users from directly entering the rename.php file. I will not talk about the functions.

Deletefile() function

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("No permission, Error http 404 ");
}
}[The t and ff outputted above are used to judge the subsequent returns by passing values ​​using ajax, and display the results to the user.]

Previous article

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/631854.htmlTechArticle[Original]php+ajax implements simulated Win file management system//This tutorial is original from this site, please note when reprinting Ming Lai Chu Author: www.drise.cn Email: drise@163.com QQ: 271728967// We have already talked about d in the previous article...
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template