<?php /** * * Friendica * */ /** * * bootstrap the application * */ require_once 'boot.php'; require_once 'object/BaseObject.php'; $a = new App(); BaseObject::set_app($a); /** * * Load the configuration file which contains our DB credentials. * Ignore errors. If the file doesn't exist or is empty, we are running in installation mode. * */ $install = file_exists('.htconfig.php') && filesize('.htconfig.php') ? false : true; @(include ".htconfig.php"); /** * * Try to open the database; * */ require_once "include/dba.php"; if (!$install) {
/** * App constructor. */ function __construct() { // we'll reset this after we read our config file date_default_timezone_set('UTC'); $this->config = array('system' => array()); $this->page = array(); $this->pager = array(); $this->query_string = ''; startup(); set_include_path('include' . PATH_SEPARATOR . 'library' . PATH_SEPARATOR . 'library/phpsec' . PATH_SEPARATOR . 'library/langdet' . PATH_SEPARATOR . '.'); $this->scheme = 'http'; if (x($_SERVER, 'HTTPS') && $_SERVER['HTTPS']) { $this->scheme = 'https'; } elseif (x($_SERVER, 'SERVER_PORT') && intval($_SERVER['SERVER_PORT']) == 443) { $this->scheme = 'https'; } if (x($_SERVER, 'SERVER_NAME')) { $this->hostname = $_SERVER['SERVER_NAME']; if (x($_SERVER, 'SERVER_PORT') && $_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443) { $this->hostname .= ':' . $_SERVER['SERVER_PORT']; } /** * Figure out if we are running at the top of a domain * or in a sub-directory and adjust accordingly */ $path = trim(dirname($_SERVER['SCRIPT_NAME']), '/\\'); if (isset($path) && strlen($path) && $path != $this->path) { $this->path = $path; } } set_include_path("include/{$this->hostname}" . PATH_SEPARATOR . get_include_path()); if (x($_SERVER, 'QUERY_STRING') && substr($_SERVER['QUERY_STRING'], 0, 2) === "q=") { $this->query_string = substr($_SERVER['QUERY_STRING'], 2); // removing trailing / - maybe a nginx problem if (substr($this->query_string, 0, 1) == "/") { $this->query_string = substr($this->query_string, 1); } } if (x($_GET, 'q')) { $this->cmd = trim($_GET['q'], '/\\'); } // unix style "homedir" if (substr($this->cmd, 0, 1) === '~') { $this->cmd = 'channel/' . substr($this->cmd, 1); } /* * Break the URL path into C style argc/argv style arguments for our * modules. Given "http://example.com/module/arg1/arg2", $this->argc * will be 3 (integer) and $this->argv will contain: * [0] => 'module' * [1] => 'arg1' * [2] => 'arg2' * * There will always be one argument. If provided a naked domain * URL, $this->argv[0] is set to "home". */ $this->argv = explode('/', $this->cmd); $this->argc = count($this->argv); if (array_key_exists('0', $this->argv) && strlen($this->argv[0])) { $this->module = str_replace(".", "_", $this->argv[0]); $this->module = str_replace("-", "_", $this->module); } else { $this->argc = 1; $this->argv = array('home'); $this->module = 'home'; } /* * See if there is any page number information, and initialise * pagination */ $this->pager['page'] = x($_GET, 'page') && intval($_GET['page']) > 0 ? intval($_GET['page']) : 1; $this->pager['itemspage'] = 60; $this->pager['start'] = $this->pager['page'] * $this->pager['itemspage'] - $this->pager['itemspage']; if ($this->pager['start'] < 0) { $this->pager['start'] = 0; } $this->pager['total'] = 0; /* * Detect mobile devices */ $mobile_detect = new Mobile_Detect(); $this->is_mobile = $mobile_detect->isMobile(); $this->is_tablet = $mobile_detect->isTablet(); $this->head_set_icon('/images/rm-32.png'); BaseObject::set_app($this); /* * register template engines */ $dc = get_declared_classes(); foreach ($dc as $k) { if (in_array("ITemplateEngine", class_implements($k))) { $this->register_template_engine($k); } } }