Check everything except the database

@param array $originalIni
@return array
325151
public function check($originalIni)
    {
        $this->originalIni = $originalIni;
        $this->errors = [];
        $isApache = $this->isApache();
        $isIIS = $this->isIIS();
        $webserver = $this->findWebserver();

        // Get project dirs to inspect
        $projectDir = $this->getProjectDir();
        $projectSrcDir = $this->getProjectSrcDir();

        $this->requirePHPVersion('5.5.0', '5.5.0', array(
            "PHP Configuration",
            "PHP5 installed",
            null,
            "PHP version " . phpversion()
        ));

        // Check that we can identify the root folder successfully
        $this->requireFile('vendor/silverstripe/framework/src/Dev/Install/config-form.html', array(
            "File permissions",
            "Does the webserver know where files are stored?",
            "The webserver isn't letting me identify where files are stored.",
            $this->getBaseDir()
        ));

        $this->requireModule($projectDir, [
            "File permissions",
            "{$projectDir}/ directory exists?",
            ''
        ]);
        $this->requireModule('vendor/silverstripe/framework', array(
            "File permissions",
            "vendor/silverstripe/framework/ directory exists?",
            '',
        ));


        $this->requireWriteable(
            $this->getPublicDir() . 'index.php',
            [
                "File permissions",
                "Is the index.php file writeable?",
                null,
            ],
            true
        );

        $this->requireWriteable('.env', ["File permissions", "Is the .env file writeable?", null], false, false);

        if ($isApache) {
            $this->checkApacheVersion(array(
                "Webserver Configuration",
                "Webserver is not Apache 1.x",
                "SilverStripe requires Apache version 2 or greater",
                $webserver
            ));
            $this->requireWriteable(
                $this->getPublicDir() . '.htaccess',
                array("File permissions", "Is the .htaccess file writeable?", null),
                true
            );
        } elseif ($isIIS) {
            $this->requireWriteable(
                $this->getPublicDir() . 'web.config',
                array("File permissions", "Is the web.config file writeable?", null),
                true
            );
        }

        $this->requireWriteable("{$projectDir}/_config.php", [
            "File permissions",
            "Is the {$projectDir}/_config.php file writeable?",
            null,
        ]);

        $this->requireWriteable("{$projectDir}/_config/theme.yml", [
            "File permissions",
            "Is the {$projectDir}/_config/theme.yml file writeable?",
            null,
        ]);

        if (!$this->checkModuleExists('cms')) {
            $this->requireWriteable("{$projectSrcDir}/RootURLController.php", [
                "File permissions",
                "Is the {$projectSrcDir}/RootURLController.php file writeable?",
                null,
            ]);
        }

        // Check public folder exists
        $this->requireFile(
            'public',
            [
                'File permissions',
                'Is there a public/ directory?',
                'It is recommended to have a separate public/ web directory',
            ],
            false,
            false
        );

        // Ensure root assets dir is writable
        $this->requireWriteable(
            ASSETS_PATH,
            array("File permissions", "Is the assets/ directory writeable?", null),
            true
        );
        // Make sure asset path actually exists
        if (!file_exists(ASSETS_PATH)) {
            mkdir(ASSETS_PATH);
        }

        // Ensure all assets files are writable
        $innerIterator = new RecursiveDirectoryIterator(ASSETS_PATH, RecursiveDirectoryIterator::SKIP_DOTS);
        $iterator = new RecursiveIteratorIterator($innerIterator, RecursiveIteratorIterator::SELF_FIRST);
        /** @var SplFileInfo $file */
        foreach ($iterator as $file) {
            // Only report file as error if not writable
            if ($file->isWritable()) {
                continue;
            }
            $relativePath = substr($file->getPathname(), strlen($this->getBaseDir()));
            $message = $file->isDir()
                ? "Is the {$relativePath} directory writeable?"
                : "Is the {$relativePath} file writeable?";
            $this->requireWriteable($relativePath, array("File permissions", $message, null));
        }

        try {
            $tempFolder = TempFolder::getTempFolder($this->getBaseDir());
        } catch (Exception $e) {
            $tempFolder = false;
        }

        $this->requireTempFolder(array('File permissions', 'Is a temporary directory available?', null, $tempFolder));
        if ($tempFolder) {
            // in addition to the temp folder being available, check it is writable
            $this->requireWriteable($tempFolder, array(
                "File permissions",
                sprintf("Is the temporary directory writeable?", $tempFolder),
                null
            ), true);
        }

        // Check for web server, unless we're calling the installer from the command-line
        $this->isRunningWebServer(array("Webserver Configuration", "Server software", "Unknown", $webserver));

        if ($isApache) {
            $this->requireApacheRewriteModule('mod_rewrite', array(
                "Webserver Configuration",
                "URL rewriting support",
                "You need mod_rewrite to use friendly URLs with SilverStripe, but it is not enabled."
            ));
        } elseif ($isIIS) {
            $this->requireIISRewriteModule('IIS_UrlRewriteModule', array(
                "Webserver Configuration",
                "URL rewriting support",
                "You need to enable the IIS URL Rewrite Module to use friendly URLs with SilverStripe, "
                . "but it is not installed or enabled. Download it for IIS 7 from http://www.iis.net/expand/URLRewrite"
            ));
        } else {
            $this->warning(array(
                "Webserver Configuration",
                "URL rewriting support",
                "I can't tell whether any rewriting module is running.  You may need to configure a rewriting rule yourself."
            ));
        }

        $this->requireServerVariables(array('SCRIPT_NAME', 'HTTP_HOST', 'SCRIPT_FILENAME'), array(
            "Webserver Configuration",
            "Recognised webserver",
            "You seem to be using an unsupported webserver.  "
            . "The server variables SCRIPT_NAME, HTTP_HOST, SCRIPT_FILENAME need to be set."
        ));

        $this->requirePostSupport(array(
            "Webserver Configuration",
            "POST Support",
            'I can\'t find $_POST, make sure POST is enabled.'
        ));

        // Check for GD support
        if (!$this->requireFunction("imagecreatetruecolor", array(
            "PHP Configuration",
            "GD2 support",
            "PHP must have GD version 2."
        ))
        ) {
            $this->requireFunction("imagecreate", array(
                "PHP Configuration",
                "GD2 support",
                "GD support for PHP not included."
            ));
        }

        // Check for XML support
        $this->requireFunction('xml_set_object', array(
            "PHP Configuration",
            "XML support",
            "XML support not included in PHP."
        ));
        $this->requireClass('DOMDocument', array(
            "PHP Configuration",
            "DOM/XML support",
            "DOM/XML support not included in PHP."
        ));
        $this->requireFunction('simplexml_load_file', array(
            'PHP Configuration',
            'SimpleXML support',
            'SimpleXML support not included in PHP.'
        ));

        // Check for INTL support
        $this->requireClass('IntlTimeZone', array(
            'PHP Configuration',
            'Intl support',
            'Internationalization (php-intl) support not included in PHP.'
        ));

        // Check for token_get_all
        $this->requireFunction('token_get_all', array(
            "PHP Configuration",
            "Tokenizer support",
            "Tokenizer support not included in PHP."
        ));

        // Check for CType support
        $this->requireFunction('ctype_digit', array(
            'PHP Configuration',
            'CType support',
            'CType support not included in PHP.'
        ));

        // Check for session support
        $this->requireFunction('session_start', array(
            'PHP Configuration',
            'Session support',
            'Session support not included in PHP.'
        ));

        // Check for iconv support
        $this->requireFunction('iconv', array(
            'PHP Configuration',
            'iconv support',
            'iconv support not included in PHP.'
        ));

        // Check for hash support
        $this->requireFunction('hash', array('PHP Configuration', 'hash support', 'hash support not included in PHP.'));

        // Check for mbstring support
        $this->requireFunction('mb_internal_encoding', array(
            'PHP Configuration',
            'mbstring support',
            'mbstring support not included in PHP.'
        ));

        // Check for Reflection support
        $this->requireClass('ReflectionClass', array(
            'PHP Configuration',
            'Reflection support',
            'Reflection support not included in PHP.'
        ));

        // Check for Standard PHP Library (SPL) support
        $this->requireFunction('spl_classes', array(
            'PHP Configuration',
            'SPL support',
            'Standard PHP Library (SPL) not included in PHP.'
        ));

        $this->requireDateTimezone(array(
            'PHP Configuration',
            'date.timezone setting and validity',
            'date.timezone option in php.ini must be set correctly.',
            $this->getOriginalIni('date.timezone')
        ));

        $this->suggestClass('finfo', array(
            'PHP Configuration',
            'fileinfo support',
            'fileinfo should be enabled in PHP. SilverStripe uses it for MIME type detection of files. '
            . 'SilverStripe will still operate, but email attachments and sending files to browser '
            . '(e.g. export data to CSV) may not work correctly without finfo.'
        ));

        $this->suggestFunction('curl_init', array(
            'PHP Configuration',
            'curl support',
            'curl should be enabled in PHP. SilverStripe uses it for consuming web services'
            . ' via the RestfulService class and many modules rely on it.'
        ));

        $this->suggestClass('tidy', array(
            'PHP Configuration',
            'tidy support',
            'Tidy provides a library of code to clean up your html. '
            . 'SilverStripe will operate fine without tidy but HTMLCleaner will not be effective.'
        ));

        $this->suggestPHPSetting('asp_tags', array(false), array(
            'PHP Configuration',
            'asp_tags option',
            'This should be turned off as it can cause issues with SilverStripe'
        ));
        $this->requirePHPSetting('magic_quotes_gpc', array(false), array(
            'PHP Configuration',
            'magic_quotes_gpc option',
            'This should be turned off, as it can cause issues with cookies. '
            . 'More specifically, unserializing data stored in cookies.'
        ));
        $this->suggestPHPSetting('display_errors', array(false), array(
            'PHP Configuration',
            'display_errors option',
            'Unless you\'re in a development environment, this should be turned off, '
            . 'as it can expose sensitive data to website users.'
        ));
        // on some weirdly configured webservers arg_separator.output is set to &amp;
        // which will results in links like ?param=value&amp;foo=bar which will not be i
        $this->suggestPHPSetting('arg_separator.output', array('&', ''), array(
            'PHP Configuration',
            'arg_separator.output option',
            'This option defines how URL parameters are concatenated. '
            . 'If not set to \'&\' this may cause issues with URL GET parameters'
        ));

        // always_populate_raw_post_data should be set to -1 if PHP < 7.0
        if (version_compare(PHP_VERSION, '7.0.0', '<')) {
            $this->suggestPHPSetting('always_populate_raw_post_data', ['-1'], [
                'PHP Configuration',
                'always_populate_raw_post_data option',
                'It\'s highly recommended to set this to \'-1\' in php 5.x, as $HTTP_RAW_POST_DATA is removed in php 7'
            ]);
        }

        // Check memory allocation
        $this->requireMemory(32 * 1024 * 1024, 64 * 1024 * 1024, array(
            "PHP Configuration",
            "Memory allocation (PHP config option 'memory_limit')",
            "SilverStripe needs a minimum of 32M allocated to PHP, but recommends 64M.",
            $this->getOriginalIni("memory_limit")
        ));

        return $this->errors;
    }
551362
public static function check($uri)
  {
    try
    {
      $uri = new self(strval($uri));
    }
    catch(\Exception $e)
    {
      return FALSE;
    }

    return $uri->valid();
  }
214338
public static function getMissingDatabases()
    {
        $result = array();
        foreach (self::getConfiguredUrls() as $key => $url) {
            if (!empty($url)) {
                // if a database of the type does not exist, but there's a url to update, then
                // a database is missing
                $path = LocationProviderGeoIp2::getPathToGeoIpDatabase(
                    LocationProviderGeoIp2::$dbNames[$key]);
                if ($path === false) {
                    $result[] = $key;
                }
            }
        }
        return $result;
    }
1281707
public function listDatabases()
    {
        $sql = $this->_platform->getListDatabasesSQL();

        $databases = $this->_conn->fetchAll($sql);

        return $this->_getPortableDatabasesList($databases);
    }
1352119
public function haveLinkInDatabase(array $overrides = [])
    {
        $tableName = $this->grabLinksTableName();
        $defaults = Links::getDefaults();
        $overrides = array_merge($defaults, array_intersect_key($overrides, $defaults));

        return $this->haveInDatabase($tableName, $overrides);
    }
134588
public function remove(
        $table = null,
        SqlInterface $database = null,
        $primary = null
    ) {
        //if no table
        if (is_null($table)) {
            //if no default table either
            if (!$this->table) {
                //throw error
                throw SqlException::forTableNotSet();
            }

            $table = $this->table;
        }

        //if no database
        if (is_null($database)) {
            //and no default database
            if (!$this->database) {
                throw SqlException::forDatabaseNotSet();
            }

            $database = $this->database;
        }

        //get the meta data and valid columns
        $meta = $this->getMeta($table, $database);
        $data = $this->getValidColumns(array_keys($meta[self::COLUMNS]));

        if (is_null($primary)) {
            $primary = $meta[self::PRIMARY];
        }

        if (is_string($primary)) {
            $primary = [$primary];
        }

        $filter = [];
        //for each primary key
        foreach ($primary as $column) {
            //if the primary is not set
            if (!isset($data[$column])) {
                //we can't do a remove
                //do nothing more
                return $this;
            }

            //add the condition to the filter
            $filter[] = [$column.'=%s', $data[$column]];
        }

        //we delete it
        $database->deleteRows($table, $filter);

        return $this;
    }
960796
public static function check(): bool
  {
	  return
      isset(self::$user, self::$table, self::$db) &&
      self::is_init() &&
      self::_get_db();
  }
835255
private function getDatabaseInstance($id = null)
    {
        $config = App::getOption('db');
        $Database = 'Josantonius\\Database\\Database';

        if (! class_exists($Database) || ! is_array($config)) {
            return;
        }

        $id = $id ?: array_keys($config)[0];

        $required = ['provider', 'host', 'user', 'name', 'password', 'settings'];

        if (! array_diff($required, array_keys($config[$id]))) {
            $this->db = $Database::getConnection(
                $id,
                $config[$id]['provider'],
                $config[$id]['host'],
                $config[$id]['user'],
                $config[$id]['name'],
                $config[$id]['password'],
                $config[$id]['settings']
            );
        }
    }
495236
public function listDatabases($condition = [], $options = [])
    {
        if ($this->databaseName === null) {
            $this->databaseName = 'admin';
        }
        $this->document = $this->db->getQueryBuilder()->listDatabases($condition, $options);

        $cursor = $this->execute();
        $result = current($cursor->toArray());

        if (empty($result['databases'])) {
            return [];
        }
        return $result['databases'];
    }
1365436
protected function getExplicitRoutes($originalRules)
    {
        $queryParam = static::config()->get('query_param');
        $rules = [];
        /** @var Locale $localeObj */
        foreach (Locale::getCached() as $localeObj) {
            $locale = $localeObj->getLocale();
            $url = $localeObj->getURLSegment();

            // apply encode so we could route urls that contain multi-byte charaters
            $url = urlencode($url);

            // Apply to nested page url
            $controller = $this->getRuleController($originalRules['$URLSegment//$Action/$ID/$OtherID'], $localeObj);
            $rules[$url . '/$URLSegment!//$Action/$ID/$OtherID'] = [
                'Controller' => $controller,
                $queryParam => $locale,
            ];

            // Home url for that locale
            $controller = $this->getRuleController($originalRules[''], $localeObj);
            $rules[$url] = [
                'Controller' => $controller,
                $queryParam => $locale,
            ];
        }
        return $rules;
    }
299155
protected function getLocalRecordUidFromOverlay($localTableName, $originalRecord)
    {
        $overlayRecord = $this->getOverlay($localTableName, $originalRecord);

        // when there is a _PAGES_OVERLAY_UID | _LOCALIZED_UID in the overlay, we return it
        if ($localTableName === 'pages' && isset($overlayRecord['_PAGES_OVERLAY_UID'])) {
            return (int)$overlayRecord['_PAGES_OVERLAY_UID'];
        } elseif (isset($overlayRecord['_LOCALIZED_UID'])) {
            return (int)$overlayRecord['_LOCALIZED_UID'];
        }

        return 0;
    }
533818
public function fetchAll($type = null)
    {
        try {
            if ($this->res === false) {
                throw new DatabaseException(__METHOD__ . " No ressource has been given", MySQL::NO_RESSOURCE, MySQL::SEVERITY_DEBUG, __FILE__, __LINE__);
            }

            switch ($type) {
                case MySQL::FETCH_ASSOC:
                    return $this->_db->fetch_assoc_list($this->res);
                    break;
                case MySQL::FETCH_NUM:
                    return $this->_db->fetch_num_list($this->res);
                    break;
                case MySQL::FETCH_OBJ:
                default:
                    return $this->_db->fetch_object_list($this->res);
                    break;
            }
        } catch (DatabaseException $e) {
            throw $e;
        }


    }
804405
private function getAbstractProxiedMethods(ReflectionClass $originalClass) : array
    {
        return array_map(
            static function (ReflectionMethod $method) : ProxyManagerMethodGenerator {
                $generated = ProxyManagerMethodGenerator::fromReflectionWithoutBodyAndDocBlock(
                    new MethodReflection($method->getDeclaringClass()->getName(), $method->getName())
                );

                $generated->setAbstract(false);

                return $generated;
            },
            ProxiedMethodsFilter::getAbstractProxiedMethods($originalClass)
        );
    }
788728
private function getFromCache($original)
    {
        $cacheContent = $this->cache->fetch($this->getCacheKey($original));
        if (is_array($cacheContent) && isset($cacheContent[$original])) {
            return $cacheContent[$original];
        }

        return null;
    }
1221980
public function getDatabases(): array
    {
        $result = [];

        //Include manually added databases
        foreach ($this->config->databaseNames() as $name) {
            $result[] = $this->database($name);
        }

        return $result;
    }
623891
private function _checkdatabase($database)
    {

        if (count($this->_collection) == 0) {
            $this->_collection[$database] = new $database();

            return $this->_collection[$database];
        }

        $new = false;
        foreach ($this->_collection as $db) {
            if ($db === $database) continue;
            $new = true;
        }

        if ($new === true) {
            $this->_collection[$database] = new $database();
        }

        return false;
    }
744476
public function getAllNotDeleted(): array
    {
        if (!$this->entityImplements(SoftDeleteInterface::class)) {
            throw new \Exception(sprintf('Entities of class "%s" do not implement interface "%s"', $this->getEntityClassName(), SoftDeleteInterface::class));
        }

        return $this->getEntitiesBy(['deleted' => false]);
    }