]> git.mxchange.org Git - friendica.git/blobdiff - boot.php
Introduced is_filled_array() + added some missing array initialization
[friendica.git] / boot.php
index 0217750136b194235e9e462e8d35b7f05c0f8e84..a1f29398f690f39f52bd7cbbd116967e5425c2f0 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -465,11 +465,12 @@ class App {
        public  $plugins;
        public  $apps = array();
        public  $identities;
-       public  $is_mobile;
-       public  $is_tablet;
+       public  $is_mobile = false;
+       public  $is_tablet = false;
        public  $is_friendica_app;
        public  $performance = array();
        public  $callstack = array();
+       public  $theme_info = array();
 
        public $nav_sel;
 
@@ -590,15 +591,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'];
                        /*
@@ -864,11 +856,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(
@@ -920,10 +912,6 @@ class App {
        }
 
        function get_cached_avatar_image($avatar_image){
-               // Just remove the base url. This avoid mixed content
-               $avatar_image = normalise_link($avatar_image);
-               $base = normalise_link($this->get_baseurl());
-               $avatar_image = str_replace($base."/", "", $avatar_image);
                return $avatar_image;
 
                // The following code is deactivated. It doesn't seem to make any sense and it slows down the system.
@@ -951,6 +939,25 @@ class App {
        }
 
 
+       /**
+        * @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
         * 
@@ -1040,11 +1047,21 @@ class App {
        function save_timestamp($stamp, $value) {
                $duration = (float)(microtime(true)-$stamp);
 
+               if (!isset($this->performance[$value])) {
+                       // Prevent ugly E_NOTICE
+                       $this->performance[$value] = 0;
+               }
+
                $this->performance[$value] += (float)$duration;
                $this->performance["marktime"] += (float)$duration;
 
                $callstack = $this->callstack();
 
+               if (!isset($this->callstack[$value][$callstack])) {
+                       // Prevent ugly E_NOTICE
+                       $this->callstack[$value][$callstack] = 0;
+               }
+
                $this->callstack[$value][$callstack] += (float)$duration;
 
        }
@@ -1432,7 +1449,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");
@@ -1751,9 +1768,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) {
@@ -2132,3 +2149,7 @@ function argv($x) {
 
        return '';
 }
+
+function is_filled_array ($array) {
+       return (is_array($array) && count($array) > 0);
+}