Get Absolute Path of Server using a simple PHP Script using either a plugin or just running script on browser. Practically no knowledge of coding is required. We will use very simple logics and frequently this script is incorporated inside many WordPress Plugins to get Absolute Path of Server, like by the cache plugins to show any errors or need to change CHMOD value by the user.
Practical Usages of PHP Script to get Absolute Path of Server
The practical usage of this script to get absolute path of the root of the publicly accessible folder of the server by WordPress plugin within the plugin administration or by the hackers to get the idea of the path to attack. In this regard, any user have to understand the practical risk of keeping this kind of php script to get Absolute Path of Server or sub directory.
Example PHP Script to Get Absolute Path of Server with Simple PHP Script
We are taking a Debian Linux Server as example. To create the php script, you need to do nothing but open any text editor, copy paste or write down this code :
<?php echo $_SERVER[‘DOCUMENT_ROOT‘]; ?>
Save it with any name with php extension. For example if we give it the name knowroot.php ; and place it in the root of any of my domain like abhishekghosh.net, then to execute the script to get absolute path of the server, we will need to point the browser to :
It will return the result like this :
Again to remind you, never keep this kind of script to get absolute path of server with open CHMOD so that all can execute it, rather protect this kind of PHP script to Get Absolute Path of Server it with .htaccess to make it unusable from browser to protect yourself from the hackers.
Follow the Author of this article :