Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 12239458 authored by Tim Schumacher's avatar Tim Schumacher Committed by Julian Xhokaxhiu
Browse files

Abort commandExists early if shell_exec is disabled

This function causes an Error 500 on some shared webspaces
if they have the shell_exec functionality disabled. Check
for this case before trying to run a shell command.
parent b819f546
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -326,7 +326,19 @@
         * @return boolean Return True if available, False if not
         */
        private function commandExists($cmd){
            if (!$this->functionEnabled('shell_exec'))
                return false;

            $returnVal = shell_exec("which $cmd");
            return (empty($returnVal) ? false : true);
        }

        /**
         * Checks if a php function is available on the server
         * @param string $func The function to check for
         * @return boolean true if the function is enabled, false if not
         */
        private function functionEnabled($func) {
            return is_callable($func) && false === stripos(ini_get('disable_functions'), $func);
        }
    }