Home >Backend Development >PHP Tutorial >PHP infinite directory traversal example_PHP tutorial

PHP infinite directory traversal example_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-13 10:24:55841browse

Recently, I have been able to operate the PHP directory and created an infinite directory traversal:

The functions used are:

isset() determines whether a variable is defined

chdir() Change the current directory to the specified directory.

opendir() opens a directory.

readdir() reads a directory.

getcwd(). Get the current directory.

For if GET is also used to pass the value. Probably these things:

Here is the code:

Copy code The code is as follows:

if(isset($_GET['id'] ))
{

$s=$_GET['id'];
chdir($s);
}
echo 'Currently in'.getcwd(),'
';
$a=opendir('.');
while($c=readdir($a))
{
if(is_dir($c))
{
$w =getcwd().'\'.$c;
echo $c."Open
" ;
}
else
{
echo $c.'
';
}

}

?>


If you have any suggestions, please give them! ! Thanks! !

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/825271.htmlTechArticleRecently, I have been able to operate the PHP directory and made an infinite directory traversal: The functions used are: isset() to determine a certain Whether a variable is defined chdir() changes the current directory to the specified directory. ...
Statement:
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