]> git.mxchange.org Git - friendica.git/blobdiff - boot.php
Removed directory setting from htconfig.md and changed the example
[friendica.git] / boot.php
index ba9d3bf496eec143a1e318ace39173f752eba21e..e47665f94d072bc9772b9c01ace9b82d928cd46f 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -29,6 +29,7 @@ use Friendica\Core\Worker;
 use Friendica\Database\DBM;
 use Friendica\Model\Contact;
 use Friendica\Database\DBStructure;
+use Friendica\Module\Login;
 
 require_once 'include/network.php';
 require_once 'include/plugin.php';
@@ -42,7 +43,7 @@ define('FRIENDICA_PLATFORM',     'Friendica');
 define('FRIENDICA_CODENAME',     'Asparagus');
 define('FRIENDICA_VERSION',      '3.6-dev');
 define('DFRN_PROTOCOL_VERSION',  '2.23');
-define('DB_UPDATE_VERSION',      1238);
+define('DB_UPDATE_VERSION',      1239);
 define('NEW_UPDATE_ROUTINE_VERSION', 1170);
 
 /**
@@ -675,7 +676,7 @@ function check_db($via_worker)
        if ($build != DB_UPDATE_VERSION) {
                // When we cannot execute the database update via the worker, we will do it directly
                if (!Worker::add(PRIORITY_CRITICAL, 'DBUpdate') && $via_worker) {
-                       update_db(get_app());
+                       update_db();
                }
        }
 }
@@ -696,11 +697,8 @@ function check_url(App $a)
        // and www.example.com vs example.com.
        // We will only change the url to an ip address if there is no existing setting
 
-       if (empty($url)) {
-               $url = Config::set('system', 'url', System::baseUrl());
-       }
-       if ((!link_compare($url, System::baseUrl())) && (!preg_match("/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/", $a->get_hostname))) {
-               $url = Config::set('system', 'url', System::baseUrl());
+       if (empty($url) || (!link_compare($url, System::baseUrl())) && (!preg_match("/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/", $a->get_hostname))) {
+               Config::set('system', 'url', System::baseUrl());
        }
 
        return;
@@ -710,7 +708,7 @@ function check_url(App $a)
  * @brief Automatic database updates
  * @param object $a App
  */
-function update_db(App $a)
+function update_db()
 {
        $build = Config::get('system', 'build');
 
@@ -799,7 +797,6 @@ function run_update_function($x)
                Config::set('system', 'build', $x + 1);
                return true;
        }
-       return true;
 }
 
 /**
@@ -878,83 +875,6 @@ function get_guid($size = 16, $prefix = "")
        }
 }
 
-/**
- * @brief Wrapper for adding a login box.
- *
- * @param bool $register If $register == true provide a registration link.
- *                                              This will most always depend on the value of $a->config['register_policy'].
- * @param bool $hiddens  optional
- *
- * @return string Returns the complete html for inserting into the page
- *
- * @hooks 'login_hook'
- *     string $o
- */
-function login($register = false, $hiddens = false)
-{
-       $a = get_app();
-       $o = "";
-       $reg = false;
-       if ($register) {
-               $reg = array(
-                       'title' => t('Create a New Account'),
-                       'desc' => t('Register')
-               );
-       }
-
-       $noid = Config::get('system', 'no_openid');
-
-       $dest_url = $a->query_string;
-
-       if (local_user()) {
-               $tpl = get_markup_template("logout.tpl");
-       } else {
-               $a->page['htmlhead'] .= replace_macros(
-                       get_markup_template("login_head.tpl"),
-                       array(
-                       '$baseurl' => $a->get_baseurl(true)
-                       )
-               );
-
-               $tpl = get_markup_template("login.tpl");
-               $_SESSION['return_url'] = $a->query_string;
-               $a->module = 'login';
-       }
-
-       $o .= replace_macros(
-               $tpl,
-               array(
-               '$dest_url'     => $dest_url,
-               '$logout'       => t('Logout'),
-               '$login'        => t('Login'),
-
-               '$lname'        => array('username', t('Nickname or Email: ') , '', ''),
-               '$lpassword'    => array('password', t('Password: '), '', ''),
-               '$lremember'    => array('remember', t('Remember me'), 0,  ''),
-
-               '$openid'       => !$noid,
-               '$lopenid'      => array('openid_url', t('Or login using OpenID: '),'',''),
-
-               '$hiddens'      => $hiddens,
-
-               '$register'     => $reg,
-
-               '$lostpass'     => t('Forgot your password?'),
-               '$lostlink'     => t('Password Reset'),
-
-               '$tostitle'     => t('Website Terms of Service'),
-               '$toslink'      => t('terms of service'),
-
-               '$privacytitle' => t('Website Privacy Policy'),
-               '$privacylink'  => t('privacy policy'),
-               )
-       );
-
-       call_hooks('login_hook', $o);
-
-       return $o;
-}
-
 /**
  * @brief Used to end the current process, after saving session state.
  */
@@ -970,13 +890,15 @@ function killme()
 /**
  * @brief Redirect to another URL and terminate this process.
  */
-function goaway($s)
+function goaway($path)
 {
-       if (!strstr(normalise_link($s), "http://")) {
-               $s = System::baseUrl() . "/" . $s;
+       if (strstr(normalise_link($path), 'http://')) {
+               $url = $path;
+       } else {
+               $url = System::baseUrl() . '/' . ltrim($path, '/');
        }
 
-       header("Location: $s");
+       header("Location: $url");
        killme();
 }
 
@@ -1125,7 +1047,6 @@ function current_theme()
 
        if ($is_mobile) {
                if (isset($_SESSION['show-mobile']) && !$_SESSION['show-mobile']) {
-                       $system_theme = $standard_system_theme;
                        $theme_name = $standard_theme_name;
                } else {
                        $system_theme = Config::get('system', 'mobile-theme', '');
@@ -1136,7 +1057,6 @@ function current_theme()
 
                        if ($theme_name === '---') {
                                // user has selected to have the mobile theme be the same as the normal one
-                               $system_theme = $standard_system_theme;
                                $theme_name = $standard_theme_name;
 
                                if ($page_theme) {
@@ -1145,7 +1065,6 @@ function current_theme()
                        }
                }
        } else {
-               $system_theme = $standard_system_theme;
                $theme_name = $standard_theme_name;
 
                if ($page_theme) {