X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=boot.php;h=d82669f231a9fb12608d3855ea50ea78e7bb6ee2;hb=08a780211211c79053a710866fa2057f648a6d51;hp=c9c0f73b8686c359c477ffaf9220e57254eb9d31;hpb=b09fd2c39eaec66d6d34b3346999d316dac8a7f5;p=friendica.git diff --git a/boot.php b/boot.php index c9c0f73b86..d82669f231 100644 --- a/boot.php +++ b/boot.php @@ -17,6 +17,8 @@ * easily as email does today. */ +require_once('include/autoloader.php'); + require_once('include/config.php'); require_once('include/network.php'); require_once('include/plugin.php'); @@ -36,7 +38,7 @@ define ( 'FRIENDICA_PLATFORM', 'Friendica'); define ( 'FRIENDICA_CODENAME', 'Asparagus'); define ( 'FRIENDICA_VERSION', '3.5-dev' ); define ( 'DFRN_PROTOCOL_VERSION', '2.23' ); -define ( 'DB_UPDATE_VERSION', 1191 ); +define ( 'DB_UPDATE_VERSION', 1194 ); /** * @brief Constant with a HTML line break. @@ -467,6 +469,7 @@ class App { public $is_tablet; public $is_friendica_app; public $performance = array(); + public $callstack = array(); public $nav_sel; @@ -529,6 +532,8 @@ class App { private $cached_profile_image; private $cached_profile_picdate; + private static $a; + /** * @brief App constructor. */ @@ -554,6 +559,12 @@ class App { $this->performance["marktime"] = 0; $this->performance["markstart"] = microtime(true); + $this->callstack["database"] = array(); + $this->callstack["network"] = array(); + $this->callstack["file"] = array(); + $this->callstack["rendering"] = array(); + $this->callstack["parser"] = array(); + $this->config = array(); $this->page = array(); $this->pager= array(); @@ -579,15 +590,6 @@ class App { if(x($_SERVER,'SERVER_NAME')) { $this->hostname = $_SERVER['SERVER_NAME']; - // See bug 437 - this didn't work so disabling it - //if(stristr($this->hostname,'xn--')) { - // PHP or webserver may have converted idn to punycode, so - // convert punycode back to utf-8 - // require_once('library/simplepie/idn/idna_convert.class.php'); - // $x = new idna_convert(); - // $this->hostname = $x->decode($_SERVER['SERVER_NAME']); - //} - if(x($_SERVER,'SERVER_PORT') && $_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443) $this->hostname .= ':' . $_SERVER['SERVER_PORT']; /* @@ -703,6 +705,8 @@ class App { } } + self::$a = $this; + } function get_basepath() { @@ -727,6 +731,10 @@ class App { function get_baseurl($ssl = false) { + // Is the function called statically? + if (!is_object($this)) + return(self::$a->get_baseurl($ssl)); + $scheme = $this->scheme; if((x($this->config,'system')) && (x($this->config['system'],'ssl_policy'))) { @@ -847,11 +855,11 @@ class App { $shortcut_icon = get_config("system", "shortcut_icon"); if ($shortcut_icon == "") - $shortcut_icon = $this->get_baseurl()."/images/friendica-32.png"; + $shortcut_icon = "images/friendica-32.png"; $touch_icon = get_config("system", "touch_icon"); if ($touch_icon == "") - $touch_icon = $this->get_baseurl()."/images/friendica-128.png"; + $touch_icon = "images/friendica-128.png"; $tpl = get_markup_template('head.tpl'); $this->page['htmlhead'] = replace_macros($tpl,array( @@ -903,6 +911,10 @@ class App { } function get_cached_avatar_image($avatar_image){ + return $avatar_image; + + // The following code is deactivated. It doesn't seem to make any sense and it slows down the system. + /* if($this->cached_profile_image[$avatar_image]) return $this->cached_profile_image[$avatar_image]; @@ -922,9 +934,29 @@ class App { } } return $this->cached_profile_image[$avatar_image]; + */ } + /** + * @brief Removes the baseurl from an url. This avoids some mixed content problems. + * + * @param string $url + * + * @return string The cleaned url + */ + function remove_baseurl($url){ + + // Is the function called statically? + if (!is_object($this)) + return(self::$a->remove_baseurl($url)); + + $url = normalise_link($url); + $base = normalise_link($this->get_baseurl()); + $url = str_replace($base."/", "", $url); + return $url; + } + /** * @brief Register template engine class * @@ -1016,6 +1048,30 @@ class App { $this->performance[$value] += (float)$duration; $this->performance["marktime"] += (float)$duration; + + $callstack = $this->callstack(); + + $this->callstack[$value][$callstack] += (float)$duration; + + } + + /** + * @brief Returns a string with a callstack. Can be used for logging. + * + * @return string + */ + function callstack() { + $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 6); + + // We remove the first two items from the list since they contain data that we don't need. + array_shift($trace); + array_shift($trace); + + $callstack = array(); + foreach ($trace AS $func) + $callstack[] = $func["function"]; + + return implode(", ", $callstack); } function mark_timestamp($mark) { @@ -1382,7 +1438,7 @@ function login($register = false, $hiddens=false) { $noid = get_config('system','no_openid'); - $dest_url = $a->get_baseurl(true) . '/' . $a->query_string; + $dest_url = $a->query_string; if(local_user()) { $tpl = get_markup_template("logout.tpl"); @@ -1701,9 +1757,9 @@ function current_theme_url() { $opts = (($a->profile_uid) ? '?f=&puid=' . $a->profile_uid : ''); if (file_exists('view/theme/' . $t . '/style.php')) - return($a->get_baseurl() . '/view/theme/' . $t . '/style.pcss' . $opts); + return('view/theme/'.$t.'/style.pcss'.$opts); - return($a->get_baseurl() . '/view/theme/' . $t . '/style.css'); + return('view/theme/'.$t.'/style.css'); } function feed_birthday($uid,$tz) { @@ -2060,3 +2116,25 @@ function current_load() { return max($load_arr); } + +/** + * @brief get c-style args + * + * @return int + */ +function argc() { + return get_app()->argc; +} + +/** + * @brief Returns the value of a argv key + * + * @param int $x argv key + * @return string Value of the argv key + */ +function argv($x) { + if(array_key_exists($x,get_app()->argv)) + return get_app()->argv[$x]; + + return ''; +}