[Original] php + ajax to simulate Win file management system 3 _ PHP Tutorial

Source: Internet
Author: User
[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...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.