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() changes the current directory to the specified directory.
opendi() opens a directory.
readdir() reads the directory.
getcwd() gets 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'] ))//Determine whether to pass a value
{
$s=str_replace(' ','+',$_GET['id']);
$s=base64_decode($s);// The value passed is generally the absolute path of the directory to be opened
chdir($s);//Switch to the directory to be opened
}
$a=opendir('.');/ /Open the current directory
while(false!==($c=readdir($a)))//Loop through the file names of the directory contents
{
if(is_dir($c))// Determine whether it is a directory or a file {
If($c=='.. ')
{
> echo "Previous level"."
Open";//The absolute value that will be opened when clicked to open Pass the path out and use chdir to switch to the directory you want to open
. Absolute path to the directory
echo "$c"."
Open";//When clicked to open Pass the absolute path to be opened. Use chdir to switch to the directory to be opened.
🎜> echo "$c is not a directory
";
}
}
?>
http://www.bkjia.com/PHPjc/736803.html
www.bkjia.com
true
http: //www.bkjia.com/PHPjc/736803.html
TechArticle
Recently, I have been able to operate the PHP directory and made an infinite directory traversal: The functions used are: isset() determines a certain Whether each variable is defined chdir() changes the current directory to the specified directory. opened...
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