Php infinite traversal folder example sharing. Recently, I was able to perform a php Directory operation and made an infinite directory traversal. the functions used are: isset () to determine whether a variable defines chdir () and change the current directory to the specified directory. Opend has recently been able to perform php directory operations and has made a directory infinite traversal:
The following functions are used:
Isset () determines whether a variable is defined
Chdir () changes the current directory to the specified directory.
Open the opendi () directory.
Readdir () reads the directory.
Getcwd () to get the current directory.
We also use for if GET to transfer the value about these things:
The following code is used:
The code is as follows:
If (isset ($ _ GET ['id']) // determines whether to pass the value
{
$ S = str_replace ('', '+', $ _ GET ['id']);
$ S = base64_decode ($ s); // The passed value is generally the absolute path strength 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) // cyclically traverses the file name of the directory content
{
If (is_dir ($ c) // you can determine whether a directory or a file is used.
{
If ($ c = '.')
{
}
Else
{
If ($ c = '..')
{
$ W = base64_encode (substr (getcwd (), 0, strrpos (getcwd (), '\'); // add the directory name to the current path to indicate the absolute path of the Directory.
Echo "upper-level". "Open
"; // When you click open, the absolute path to be opened is passed out. use chdir to switch to the directory to be opened.
} Else
{
$ W = base64_encode (getcwd (). '\'. $ c); // add the directory name to the current path to indicate the absolute path of the Directory.
Echo "$ c". "Open
"; // When you click open, the absolute path to be opened is passed out. use chdir to switch to the directory to be opened.
}
}
}
Else
{
Echo "$ c is not a directory
";
}
}
?>
Isset () determines whether a variable defines chdir () to change the current directory to the specified directory. Opend...