EmbeddedServer::_canExecScripts PHP Method

_canExecScripts() public method

Check whether script execution is enabled.
public _canExecScripts ( ) : boolean
return boolean
    function _canExecScripts()
    {
        // Script execution is not allowed in safe mode.
        if (ini_get('safe_mode')) {
            return false;
        }
        // Check whether the exec() function is disabled.
        $disabled_functions = explode(',', ini_get('disable_functions'));
        $disabled_functions = array_map('trim', $disabled_functions);
        if (in_array('exec', $disabled_functions)) {
            return false;
        }
        // Check whether the management scripts are executable.
        $scriptDir = $this->_getScriptDirectory();
        foreach (array('start', 'stop', 'check') as $script) {
            $scriptPath = $this->_getScriptPath($script);
            if (Core::isWindows()) {
                if (!is_readable($scriptPath)) {
                    return false;
                }
            } else {
                if (!is_executable($scriptPath)) {
                    return false;
                }
            }
        }
        // Check whether crucial files are writable.
        $filesDir = Config::getVar('files', 'files_dir');
        foreach (array('data', 'solr-java.log', 'solr-php.log', 'solr.pid') as $fileName) {
            $filePath = $filesDir . DIRECTORY_SEPARATOR . 'lucene' . DIRECTORY_SEPARATOR . $fileName;
            if (file_exists($filePath) && !is_writable($filePath)) {
                return false;
            }
        }
        // Check whether there is an existing solr process, and if so, whether
        // it is running under the same user id as PHP. Otherwise we cannot
        // manipulate the process.
        if (function_exists('posix_getuid') && $this->isRunning()) {
            $phpUid = posix_getuid();
            if (!$this->_runScript('check', false, $phpUid)) {
                return false;
            }
        }
        return true;
    }