Created
September 29, 2013 23:54
-
-
Save Gomah/6757641 to your computer and use it in GitHub Desktop.
Server safetest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Config | |
$forbiden_functions = array('escapeshellarg', 'escapeshellcmd', 'exec', 'link', 'passthru', 'pcntl_exec', 'popen', 'proc_close', 'proc_get_status', 'proc_nice', 'proc_open', 'proc_terminate', 'symlink', 'shell_exec','system'); | |
$must_functions = array( 'base64_decode', 'fpassthru', 'ini_set', 'php_uname'); | |
// Start | |
$disabled_functions = array_map("trim", explode(",",@ini_get("disable_functions"))); | |
$issues = array(); | |
// Functions should be disabled | |
foreach ($forbiden_functions as $functions_ouput) | |
{ if(function_exists($functions_ouput) && !(in_array($functions_ouput, $disabled_functions))) | |
$issues[] = "Function ".$functions_ouput." should be disabled!"; } | |
unset($functions_ouput); | |
// Functions should be enabled | |
foreach ($must_functions as $functions_ouput) | |
{ if(!function_exists($functions_ouput) || in_array($functions_ouput, $disabled_functions)) | |
$issues[] = "Function ".$functions_ouput." should be enabled!"; } | |
unset($functions_ouput); | |
// Is eval here? | |
if( in_array("eval", $disabled_functions) ) | |
{ $issues[] = "Language construct eval is required to be enabled in PHP!"; } | |
// Is safe mode enabled? | |
if (ini_get('safe_mode')) | |
$issues[] = "Issue: safe_mode is On!"; | |
// Is magic_quotes_gpc enabled? | |
if (ini_get('magic_quotes_gpc')) | |
$issues[] = "Issue: magic_quotes_gpc is On!"; | |
// Output results | |
if( !count($issues) ) | |
{ echo "Your host is OK!"; } | |
else | |
{ echo "<pre>Your host have ".count($issues)." problems!\n\n"; | |
foreach($issues as $issue) | |
echo "Issue: {$issue} \n"; | |
echo "</pre>"; } | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment