PHP Unlimited Traversal Directory

Source: Internet
Author: User

The functions used are:

Isset () Determines whether a variable is defined

ChDir () changes the current directory to the specified directory.

Opendir () to open the directory.

Readdir () reads the directory.

GETCWD (). Gets the current directory.

It also uses the for if get pass value about these things:

Here's the code:

<?phpif (Isset ($_get[' id "))//Determine whether the value is {$s =str_replace (', ' + ', $_get[' id ']); $s =base64_decode ($s);//The value value that is passed is generally the absolute chdir ($s) of the directory to be opened;//switch to the directory to open} $a =opendir ('. '); /Open the current directory while (false!== ($c =readdir ($a)))//Iterate through the directory contents of the file name {if (Is_dir ($c))//Determine whether the directory or the file {if ($c = =).           ') {} else {if ($c = = ' ... ') {$w =base64_encode (substr (GETCWD (), 0,strrpos (GETCWD (), ' \ \ ')), or//the current path plus the directory name is the absolute path to the directory echo "upper level". "                <a href= ' 6.php?id= $w ' > Open </a><br/> ";//When you click Open, the absolute path to open will be passed out chdir switch to the directory you want to open}else { $w =base64_encode (GETCWD (). ' \ \ '. $c);//The current path plus the directory name is the absolute path to the directory echo "$c". "               <a href= ' 6.php?id= $w ' > Open </a><br/> ";//When you click Open, the absolute path to open will be passed out with ChDir to the directory you want to open}               }} else {echo "$c is not directory <br/>"; }}?>

  

PHP Unlimited Traversal directory

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.