Skip to content

Commit

Permalink
function for checking disabled php functions
Browse files Browse the repository at this point in the history
  • Loading branch information
bajb committed Aug 21, 2014
1 parent 594127f commit ba89e4d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/System.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,16 @@ public static function findCommand($cmd)

return self::$commandCache[$cmd];
}

/**
* Check to see if a function has been disabled through php.ini
*
* @param string $function function name to verify
*
* @return bool
*/
public static function isFunctionDisabled($function)
{
return in_array($function, explode(',', ini_get('disable_functions')));
}
}
17 changes: 17 additions & 0 deletions tests/SystemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,21 @@ public function testCommandFinder()
\Packaged\Helpers\System::commandExists('madeupcommand2')
);
}

public function testDisabledFunctionCheck()
{
$verify = explode(',', ini_get('disable_functions'));
if(empty($verify))
{
ini_set('disable_functions', 'packaged_exec');
$verify = ['packaged_exec'];
}

foreach($verify as $check)
{
$this->assertTrue(\Packaged\Helpers\System::isFunctionDisabled($check));
}

$this->assertFalse(\Packaged\Helpers\System::isFunctionDisabled('echo'));
}
}

0 comments on commit ba89e4d

Please sign in to comment.