[Original] php + ajax to simulate Win file management system 3. [Original] php + ajax to achieve the simulation of Win file management system this tutorial by the site original, reproduced please indicate the author: www.drise.cn mailbox: drise@163.comQQ: 271728967 in the previous article, we talked about d [original] php + ajax to implement a simulated Win file management system.
// This tutorial is original on this site. For more information, see here.
Author: www.drise.cn
Email: drise@163.com
QQ: 271728967 //
In the previous article, we talked about the role of the dir. php file. next I will talk about the functions of every function in the rename. php file.
Refere ();
Header ("Content-type: text/html; charset = utf-8"); // sets the 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 'paast ':
Past ($ path, $ nname, $ cpath );
Break;
Default:
Filename ($ path, $ nname );
}
Here are all functions of the rename. php file. we will analyze them below.
Refere () function
VeryWhen many people see the name, they will probably know what the intention is. 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 ");
}
}
This section aims to prevent users from directly entering the rename. php file for the most basic security protection methods.
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 ");
}
} [T, ff output above. this is the result returned later. it is determined by passing the ajax value and the result is displayed to the user.]
Previous
Author // This tutorial by the site original, reproduced please indicate the author: www.drise.cn mailbox: drise@163.com QQ: 271728967 // Previous we have talked about d...