diff --git a/Zotlabs/Web/WebServer.php b/Zotlabs/Web/WebServer.php index 4154656fd..754642a7d 100644 --- a/Zotlabs/Web/WebServer.php +++ b/Zotlabs/Web/WebServer.php @@ -21,21 +21,62 @@ class WebServer { sys_boot(); + $this->start_session(); - App::$language = get_best_language(); - load_translation_table(App::$language,App::$install); + $this->set_language(); + $this->set_identities(); + + $this->initialise_notifications(); + + if (App::$install) { + + /* + * During installation, only permit the view module and setup module. + * The view module is required to expand/replace variables in style.css + */ + + if (App::$module !== 'view') { + App::$module = 'setup'; + } + } + else { - /** - * - * Important stuff we always need to do. - * - * The order of these may be important so use caution if you think they're all - * intertwingled with no logical order and decide to sort it out. Some of the - * dependencies have changed, but at least at one time in the recent past - the - * order was critical to everything working properly - * - */ + /* + * check_config() is responsible for running update scripts. These automatically + * update the DB schema whenever we push a new one out. It also checks to see if + * any plugins have been added or removed and reacts accordingly. + */ + + check_config(); + } + + $this->create_channel_links(); + + $this->initialise_content(); + + $Router = new Router(); + $Router->Dispatch(); + + // if the observer is a visitor, add some javascript to the page to let + // the application take them home. + + $this->set_homebase(); + + // now that we've been through the module content, see if the page reported + // a permission problem via session based notifications and if so, a 403 + // response would seem to be in order. + + if (is_array($_SESSION['sysmsg']) && stristr(implode("", $_SESSION['sysmsg']), t('Permission denied'))) { + header($_SERVER['SERVER_PROTOCOL'] . ' 403 ' . t('Permission denied.')); + } + + construct_page(); + + killme(); + } + + private function start_session() { if (App::$session) { App::$session->start(); @@ -45,24 +86,45 @@ class WebServer { register_shutdown_function('session_write_close'); } - /** - * Language was set earlier, but we can over-ride it in the session. - * We have to do it here because the session was just now opened. + } + + private function set_language() { + + /* + * Determine the language of the interface */ + // First use the browser preference, if available. This will fall back to 'en' + // if there is no built-in language support for the preferred languagge + + + App::$language = get_best_language(); + load_translation_table(App::$language, App::$install); + + // See if there's a request to over-ride the language + // store it in the session. + if (array_key_exists('system_language',$_REQUEST)) { if (strlen($_REQUEST['system_language'])) { $_SESSION['language'] = $_REQUEST['system_language']; } else { + // reset to default if it's an empty string unset($_SESSION['language']); } } - if ((x($_SESSION, 'language')) && ($_SESSION['language'] !== $lang)) { + + // If we've over-ridden the language, set it now. + + if ((x($_SESSION, 'language')) && ($_SESSION['language'] !== App::$language)) { App::$language = $_SESSION['language']; load_translation_table(App::$language); } + } + + private function set_identities() { + if ((x($_GET,'zid')) && (! App::$install)) { App::$query_string = strip_zids(App::$query_string); if (! local_channel()) { @@ -90,7 +152,9 @@ class WebServer { if ((x($_SESSION, 'authenticated')) || (x($_POST, 'auth-params')) || (App::$module === 'login')) { require('include/auth.php'); } + } + private function initialise_notifications() { if (! x($_SESSION, 'sysmsg')) { $_SESSION['sysmsg'] = []; } @@ -98,49 +162,8 @@ class WebServer { if (! x($_SESSION, 'sysmsg_info')) { $_SESSION['sysmsg_info'] = []; } - - - if (App::$install) { - /* Allow an exception for the view module so that pcss will be interpreted during installation */ - if (App::$module !== 'view') - App::$module = 'setup'; - } - else { - - /* - * check_config() is responsible for running update scripts. These automatically - * update the DB schema whenever we push a new one out. It also checks to see if - * any plugins have been added or removed and reacts accordingly. - */ - - check_config(); - } - - $this->create_channel_links(); - - $Router = new Router(); - - $this->initialise_content(); - - $Router->Dispatch(); - - $this->set_homebase(); - - // now that we've been through the module content, see if the page reported - // a permission problem and if so, a 403 response would seem to be in order. - - if (is_array($_SESSION['sysmsg']) && stristr(implode("", $_SESSION['sysmsg']), t('Permission denied'))) { - header($_SERVER['SERVER_PROTOCOL'] . ' 403 ' . t('Permission denied.')); - } - - call_hooks('page_end', App::$page['content']); - - construct_page(); - - killme(); } - private function initialise_content() { /* initialise content region */ diff --git a/boot.php b/boot.php index 9d479cc71..71a63b54a 100755 --- a/boot.php +++ b/boot.php @@ -2182,6 +2182,8 @@ function exec_pdl() { */ function construct_page() { + call_hooks('page_end', App::$page['content']); + exec_pdl(); $comanche = ((isset(App::$layout) && is_array(App::$layout) && count(App::$layout)) ? true : false); diff --git a/include/photo_factory.php b/include/photo_factory.php index 88c6b96ed..474a6d082 100644 --- a/include/photo_factory.php +++ b/include/photo_factory.php @@ -344,7 +344,8 @@ function import_remote_xchan_photo($photo, $xchan, $thing = false) { // Assume the worst. $failed = true; - + $type = EMPTY_STR; + $path = Hashpath::path((($thing) ? $photo . $xchan : $xchan),'cache/xp',2); $hash = basename($path);