Skip to content

Instantly share code, notes, and snippets.

@lewisgoddard
Last active August 29, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lewisgoddard/acce162e2ce91bf31970 to your computer and use it in GitHub Desktop.
Save lewisgoddard/acce162e2ce91bf31970 to your computer and use it in GitHub Desktop.
<?php
//// IS exec() enabled
// A simple `is` script to determine if
// exec() is enabled and working.
//
// Inputs: None;
//
// Outputs:
// - $Exec_Enabled
// true if enabled
// false if not
//
// MIT Licensed
if (
// IF Function Exists
function_exists('exec') &&
// AND NOT in the array of disabled functions
!in_array('exec', array_map('trim', explode(', ', ini_get('disable_functions')))) &&
// AND NOT in safe mode
strtolower(ini_get('safe_mode')) != 1 &&
// AND it actually works
// (this will generate a warning if it doesn't, but we tried to check)
exec('echo WORKING') == 'WORKING'
) {
// exec() is enalbed
$Exec_Enabled = true;
} else {
// exec() is NOT enalbed
$Exec_Enabled = false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment