]> git.mxchange.org Git - friendica.git/blobdiff - boot.php
Merge branch 'develop' into utf8mb4
[friendica.git] / boot.php
index 57d265711d6a6d19ff1663d6fa1a694009f2151a..becb9bd570e895172d7a6e0465517eaccf4169c3 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -17,7 +17,7 @@
  * easily as email does today.
  */
 
-require_once('include/autoloader.php');
+require_once(__DIR__ . DIRECTORY_SEPARATOR. 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php');
 
 use \Friendica\Core\Config;
 
@@ -29,7 +29,6 @@ require_once('include/datetime.php');
 require_once('include/pgettext.php');
 require_once('include/nav.php');
 require_once('include/cache.php');
-require_once('library/Mobile_Detect/Mobile_Detect.php');
 require_once('include/features.php');
 require_once('include/identity.php');
 require_once('update.php');
@@ -39,7 +38,7 @@ define ( 'FRIENDICA_PLATFORM',     'Friendica');
 define ( 'FRIENDICA_CODENAME',     'Asparagus');
 define ( 'FRIENDICA_VERSION',      '3.5.2-dev' );
 define ( 'DFRN_PROTOCOL_VERSION',  '2.23'    );
-define ( 'DB_UPDATE_VERSION',      1216      );
+define ( 'DB_UPDATE_VERSION',      1219      );
 
 /**
  * @brief Constant with a HTML line break.
@@ -383,6 +382,7 @@ define ( 'ACTIVITY_UPDATE',      NAMESPACE_ACTIVITY_SCHEMA . 'update' );
 define ( 'ACTIVITY_TAG',         NAMESPACE_ACTIVITY_SCHEMA . 'tag' );
 define ( 'ACTIVITY_FAVORITE',    NAMESPACE_ACTIVITY_SCHEMA . 'favorite' );
 define ( 'ACTIVITY_SHARE',       NAMESPACE_ACTIVITY_SCHEMA . 'share' );
+define ( 'ACTIVITY_DELETE',      NAMESPACE_ACTIVITY_SCHEMA . 'delete' );
 
 define ( 'ACTIVITY_POKE',        NAMESPACE_ZOT . '/activity/poke' );
 define ( 'ACTIVITY_MOOD',        NAMESPACE_ZOT . '/activity/mood' );
@@ -647,22 +647,21 @@ class App {
                startup();
 
                set_include_path(
-                               'include' . PATH_SEPARATOR
+                               get_include_path() . PATH_SEPARATOR
+                               . 'include' . PATH_SEPARATOR
                                . 'library' . PATH_SEPARATOR
-                               . 'library/phpsec' . PATH_SEPARATOR
                                . 'library/langdet' . PATH_SEPARATOR
                                . '.' );
 
-
                $this->scheme = 'http';
-               /// @TODO x() should be better used here ...
+
                if ((x($_SERVER, 'HTTPS') && $_SERVER['HTTPS']) ||
-                  (x($_SERVER['HTTP_FORWARDED']) && preg_match("/proto=https/", $_SERVER['HTTP_FORWARDED'])) ||
-                  (x($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') ||
-                  (x($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') ||
-                  (x($_SERVER['FRONT_END_HTTPS']) && $_SERVER['FRONT_END_HTTPS'] == 'on') ||
-                  (x($_SERVER, 'SERVER_PORT') && (intval($_SERVER['SERVER_PORT']) == 443)) // XXX: reasonable assumption, but isn't this hardcoding too much?
-                  ) {
+                               (x($_SERVER, 'HTTP_FORWARDED') && preg_match("/proto=https/", $_SERVER['HTTP_FORWARDED'])) ||
+                               (x($_SERVER, 'HTTP_X_FORWARDED_PROTO') && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') ||
+                               (x($_SERVER, 'HTTP_X_FORWARDED_SSL') && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') ||
+                               (x($_SERVER, 'FRONT_END_HTTPS') && $_SERVER['FRONT_END_HTTPS'] == 'on') ||
+                               (x($_SERVER, 'SERVER_PORT') && (intval($_SERVER['SERVER_PORT']) == 443)) // XXX: reasonable assumption, but isn't this hardcoding too much?
+                               ) {
                        $this->scheme = 'https';
                }
 
@@ -694,19 +693,15 @@ class App {
                }
 
                if ((x($_SERVER, 'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'], 0, 9) === "pagename=") {
-                       $this->query_string = substr($_SERVER['QUERY_STRING'],9);
+                       $this->query_string = substr($_SERVER['QUERY_STRING'], 9);
+
                        // removing trailing / - maybe a nginx problem
-                       /// @TODO can be shortened by trim($str, '/') !
-                       if (substr($this->query_string, 0, 1) == "/") {
-                               $this->query_string = substr($this->query_string, 1);
-                       }
+                       $this->query_string = ltrim($this->query_string, '/');
                } elseif ((x($_SERVER, 'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'], 0, 2) === "q=") {
-                       $this->query_string = substr($_SERVER['QUERY_STRING'],2);
+                       $this->query_string = substr($_SERVER['QUERY_STRING'], 2);
+
                        // removing trailing / - maybe a nginx problem
-                       /// @TODO can be shortened by trim($str, '/') !
-                       if (substr($this->query_string, 0, 1) == "/") {
-                               $this->query_string = substr($this->query_string, 1);
-                       }
+                       $this->query_string = ltrim($this->query_string, '/');
                }
 
                if (x($_GET, 'pagename')) {
@@ -717,7 +712,7 @@ class App {
 
 
                // fix query_string
-               $this->query_string = str_replace($this->cmd."&",$this->cmd."?", $this->query_string);
+               $this->query_string = str_replace($this->cmd . "&", $this->cmd . "?", $this->query_string);
 
                // unix style "homedir"
                if (substr($this->cmd, 0, 1) === '~') {
@@ -725,14 +720,12 @@ class App {
                }
 
                // Diaspora style profile url
-
-               if (substr($this->cmd,0,2) === 'u/') {
-                       $this->cmd = 'profile/' . substr($this->cmd,2);
+               if (substr($this->cmd, 0, 2) === 'u/') {
+                       $this->cmd = 'profile/' . substr($this->cmd, 2);
                }
 
 
                /*
-                *
                 * 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:
@@ -743,12 +736,11 @@ class App {
                 *
                 * 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->argv = explode('/', $this->cmd);
                $this->argc = count($this->argv);
-               if ((array_key_exists('0',$this->argv)) && strlen($this->argv[0])) {
+               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 {
@@ -762,9 +754,10 @@ class App {
                 * pagination
                 */
 
-               $this->pager['page'] = ((x($_GET,'page') && intval($_GET['page']) > 0) ? intval($_GET['page']) : 1);
+               $this->pager['page'] = ((x($_GET, 'page') && intval($_GET['page']) > 0) ? intval($_GET['page']) : 1);
                $this->pager['itemspage'] = 50;
                $this->pager['start'] = ($this->pager['page'] * $this->pager['itemspage']) - $this->pager['itemspage'];
+
                if ($this->pager['start'] < 0) {
                        $this->pager['start'] = 0;
                }
@@ -1234,7 +1227,12 @@ class App {
        }
 
        function get_useragent() {
-               return (FRIENDICA_PLATFORM." '".FRIENDICA_CODENAME."' ".FRIENDICA_VERSION."-".DB_UPDATE_VERSION."; ".$this->get_baseurl());
+               return
+                       FRIENDICA_PLATFORM . " '" .
+                       FRIENDICA_CODENAME . "' " .
+                       FRIENDICA_VERSION . "-" .
+                       DB_UPDATE_VERSION . "; " .
+                       $this->get_baseurl();
        }
 
        function is_friendica_app() {
@@ -1250,34 +1248,29 @@ class App {
         * @return bool Is it a known backend?
         */
        function is_backend() {
-               /// @Should be made static to speedup things
-               $backend = array();
-               $backend[] = "_well_known";
-               $backend[] = "api";
-               $backend[] = "dfrn_notify";
-               $backend[] = "fetch";
-               $backend[] = "hcard";
-               $backend[] = "hostxrd";
-               $backend[] = "nodeinfo";
-               $backend[] = "noscrape";
-               $backend[] = "p";
-               $backend[] = "poco";
-               $backend[] = "post";
-               $backend[] = "proxy";
-               $backend[] = "pubsub";
-               $backend[] = "pubsubhubbub";
-               $backend[] = "receive";
-               $backend[] = "rsd_xml";
-               $backend[] = "salmon";
-               $backend[] = "statistics_json";
-               $backend[] = "xrd";
-
-               /// @TODO Maybe rewrite this part: return (in_array() || $this->backend); ?
-               if (in_array($this->module, $backend)) {
-                       return(true);
-               } else {
-                       return($this->backend);
-               }
+               static $backends = array();
+               $backends[] = "_well_known";
+               $backends[] = "api";
+               $backends[] = "dfrn_notify";
+               $backends[] = "fetch";
+               $backends[] = "hcard";
+               $backends[] = "hostxrd";
+               $backends[] = "nodeinfo";
+               $backends[] = "noscrape";
+               $backends[] = "p";
+               $backends[] = "poco";
+               $backends[] = "post";
+               $backends[] = "proxy";
+               $backends[] = "pubsub";
+               $backends[] = "pubsubhubbub";
+               $backends[] = "receive";
+               $backends[] = "rsd_xml";
+               $backends[] = "salmon";
+               $backends[] = "statistics_json";
+               $backends[] = "xrd";
+
+               // Check if current module is in backend or backend flag is set
+               return (in_array($this->module, $backends) || $this->backend);
        }
 
        /**
@@ -1367,7 +1360,6 @@ class App {
                // add baseurl to args. cli scripts can't construct it
                $args[] = $this->get_baseurl();
 
-               /// @TODO let's replace these with a foreach($key => $value) loop
                for ($x = 0; $x < count($args); $x ++) {
                        $args[$x] = escapeshellarg($args[$x]);
                }
@@ -1457,7 +1449,7 @@ function get_app() {
  */
 function x($s,$k = NULL) {
        if ($k != NULL) {
-               if ((is_array($s)) && (array_key_exists($k,$s))) {
+               if ((is_array($s)) && (array_key_exists($k, $s))) {
                        if ($s[$k]) {
                                return (int) 1;
                        }
@@ -2481,7 +2473,7 @@ function get_temppath() {
        // Check if it is usable
        if (($temppath != "") AND App::directory_usable($temppath)) {
                // To avoid any interferences with other systems we create our own directory
-               $new_temppath .= "/".$a->get_hostname();
+               $new_temppath = $temppath."/".$a->get_hostname();
                if (!is_dir($new_temppath)) {
                        /// @TODO There is a mkdir()+chmod() upwards, maybe generalize this (+ configurable) into a function/method?
                        mkdir($new_temppath);