phpinfo() the right way!
This is how to secure any file that calls phpinfo() function. If the developer passes a get parameter to the script with a correct value he will see the server environment information, otherwise respond with a 404 error not found.
<?php
if(isset($_GET['phpinfo']) && $_GET['phpinfo'] == 'true'){
phpinfo();
}else{
header("HTTP/1.0 404 Not Found");
}Written by Alex Goretoy
Related protips
2 Responses
Interesting idea, but it might be a bit safer to lock it down based on IP or hostname rather than a simple flag.
Or better still - only allow the script to be run on localhost.
Or better...don't have the script on your public facing server at all!
Very good points and nice elaboration, thanks
Have a fresh tip? Share with Coderwall community!
Most application security programs still stop at the repository. The page a visitor loads can run third-party scripts that read the DOM, change a checkout, or steal a session after the deploy already looks clean.
Security insights from Cside