aboutsummaryrefslogtreecommitdiffstats
path: root/lib/public/Util.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/public/Util.php')
-rw-r--r--lib/public/Util.php24
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/public/Util.php b/lib/public/Util.php
index e5bb2a955ae..6cd3eaa7f85 100644
--- a/lib/public/Util.php
+++ b/lib/public/Util.php
@@ -48,6 +48,7 @@ namespace OCP;
use OC\AppScriptDependency;
use OC\AppScriptSort;
+use bantu\IniGetWrapper\IniGetWrapper;
/**
* This class provides different helper functions to make the life of a developer easier
@@ -604,4 +605,27 @@ class Util {
}
return $temp;
}
+
+ /**
+ * Check if a function is enabled in the php configuration
+ *
+ * @since 25.0.0
+ */
+ public static function isFunctionEnabled(string $functionName): bool {
+ if (!function_exists($functionName)) {
+ return false;
+ }
+ $ini = \OCP\Server::get(IniGetWrapper::class);
+ $disabled = explode(',', $ini->get('disable_functions') ?: '');
+ $disabled = array_map('trim', $disabled);
+ if (in_array($functionName, $disabled)) {
+ return false;
+ }
+ $disabled = explode(',', $ini->get('suhosin.executor.func.blacklist') ?: '');
+ $disabled = array_map('trim', $disabled);
+ if (in_array($functionName, $disabled)) {
+ return false;
+ }
+ return true;
+ }
}