- private function determineURLPath()
- {
- /* Relative script path to the web server root
- * Not all of those $_SERVER properties can be present, so we do by inverse priority order
- */
- $relative_script_path = '';
- $relative_script_path = defaults($_SERVER, 'REDIRECT_URL' , $relative_script_path);
- $relative_script_path = defaults($_SERVER, 'REDIRECT_URI' , $relative_script_path);
- $relative_script_path = defaults($_SERVER, 'REDIRECT_SCRIPT_URL', $relative_script_path);
- $relative_script_path = defaults($_SERVER, 'SCRIPT_URL' , $relative_script_path);
- $relative_script_path = defaults($_SERVER, 'REQUEST_URI' , $relative_script_path);
-
- $this->urlPath = $this->config->get('system', 'urlpath');
-
- /* $relative_script_path gives /relative/path/to/friendica/module/parameter
- * QUERY_STRING gives pagename=module/parameter
- *
- * To get /relative/path/to/friendica we perform dirname() for as many levels as there are slashes in the QUERY_STRING
- */
- if (!empty($relative_script_path)) {
- // Module
- if (!empty($_SERVER['QUERY_STRING'])) {
- $path = trim(rdirname($relative_script_path, substr_count(trim($_SERVER['QUERY_STRING'], '/'), '/') + 1), '/');
- } else {
- // Root page
- $path = trim($relative_script_path, '/');
- }
-
- if ($path && $path != $this->urlPath) {
- $this->urlPath = $path;
- }
- }
- }
-
- public function loadDatabase()
- {
- if (DBA::connected()) {
- return;
- }
-
- $db_host = $this->config->get('database', 'hostname');
- $db_user = $this->config->get('database', 'username');
- $db_pass = $this->config->get('database', 'password');
- $db_data = $this->config->get('database', 'database');
- $charset = $this->config->get('database', 'charset');
-
- // Use environment variables for mysql if they are set beforehand
- if (!empty(getenv('MYSQL_HOST'))
- && !empty(getenv('MYSQL_USERNAME') || !empty(getenv('MYSQL_USER')))
- && getenv('MYSQL_PASSWORD') !== false
- && !empty(getenv('MYSQL_DATABASE')))
- {
- $db_host = getenv('MYSQL_HOST');
- if (!empty(getenv('MYSQL_PORT'))) {
- $db_host .= ':' . getenv('MYSQL_PORT');
- }
- if (!empty(getenv('MYSQL_USERNAME'))) {
- $db_user = getenv('MYSQL_USERNAME');
- } else {
- $db_user = getenv('MYSQL_USER');
- }
- $db_pass = (string) getenv('MYSQL_PASSWORD');
- $db_data = getenv('MYSQL_DATABASE');
- }
-
- $stamp1 = microtime(true);
-
- if (DBA::connect($this->config, $db_host, $db_user, $db_pass, $db_data, $charset)) {
- // Loads DB_UPDATE_VERSION constant
- Database\DBStructure::definition($this->basePath, false);
- }
-
- unset($db_host, $db_user, $db_pass, $db_data, $charset);
-
- $this->saveTimestamp($stamp1, 'network');
- }
-