simplify webserver logic flow, remove obsolete $a from router
This commit is contained in:
parent
03d3cbdbf8
commit
858a6270d5
@ -38,10 +38,9 @@ class Router {
|
|||||||
/**
|
/**
|
||||||
* @brief Router constructor.
|
* @brief Router constructor.
|
||||||
*
|
*
|
||||||
* @param[in,out] App &$a
|
|
||||||
* @throws Exception module not found
|
* @throws Exception module not found
|
||||||
*/
|
*/
|
||||||
function __construct(&$a) {
|
function __construct() {
|
||||||
|
|
||||||
$module = \App::$module;
|
$module = \App::$module;
|
||||||
$modname = "Zotlabs\\Module\\" . ucfirst($module);
|
$modname = "Zotlabs\\Module\\" . ucfirst($module);
|
||||||
@ -179,9 +178,8 @@ class Router {
|
|||||||
/**
|
/**
|
||||||
* @brief
|
* @brief
|
||||||
*
|
*
|
||||||
* @param[in,out] App &$a
|
|
||||||
*/
|
*/
|
||||||
function Dispatch(&$a) {
|
function Dispatch() {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call module functions
|
* Call module functions
|
||||||
|
@ -58,8 +58,7 @@ class WebServer {
|
|||||||
if((x($_GET,'zid')) && (! \App::$install)) {
|
if((x($_GET,'zid')) && (! \App::$install)) {
|
||||||
\App::$query_string = strip_zids(\App::$query_string);
|
\App::$query_string = strip_zids(\App::$query_string);
|
||||||
if(! local_channel()) {
|
if(! local_channel()) {
|
||||||
if ($_SESSION['my_address']!=$_GET['zid'])
|
if ($_SESSION['my_address']!=$_GET['zid']) {
|
||||||
{
|
|
||||||
$_SESSION['my_address'] = $_GET['zid'];
|
$_SESSION['my_address'] = $_GET['zid'];
|
||||||
$_SESSION['authenticated'] = 0;
|
$_SESSION['authenticated'] = 0;
|
||||||
}
|
}
|
||||||
@ -107,9 +106,43 @@ class WebServer {
|
|||||||
check_config();
|
check_config();
|
||||||
}
|
}
|
||||||
|
|
||||||
//nav_set_selected('nothing');
|
$this->create_channel_links();
|
||||||
|
|
||||||
$Router = new Router($a);
|
$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 */
|
||||||
|
|
||||||
|
if(! x(\App::$page, 'content'))
|
||||||
|
\App::$page['content'] = '';
|
||||||
|
|
||||||
|
call_hooks('page_content_top', \App::$page['content']);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private function create_channel_links() {
|
||||||
|
|
||||||
/* Initialise the Link: response header if this is a channel page.
|
/* Initialise the Link: response header if this is a channel page.
|
||||||
* This cannot be done inside the channel module because some protocol
|
* This cannot be done inside the channel module because some protocol
|
||||||
@ -135,26 +168,17 @@ class WebServer {
|
|||||||
\App::$channel_links = $x['channel_links'];
|
\App::$channel_links = $x['channel_links'];
|
||||||
header('Link: ' . \App::get_channel_links());
|
header('Link: ' . \App::get_channel_links());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private function set_homebase() {
|
||||||
|
|
||||||
/* initialise content region */
|
|
||||||
|
|
||||||
if(! x(\App::$page, 'content'))
|
|
||||||
\App::$page['content'] = '';
|
|
||||||
|
|
||||||
call_hooks('page_content_top', \App::$page['content']);
|
|
||||||
|
|
||||||
|
|
||||||
$Router->Dispatch($a);
|
|
||||||
|
|
||||||
|
|
||||||
// If you're just visiting, let javascript take you home
|
// If you're just visiting, let javascript take you home
|
||||||
|
|
||||||
if(x($_SESSION, 'visitor_home')) {
|
if(x($_SESSION, 'visitor_home')) {
|
||||||
$homebase = $_SESSION['visitor_home'];
|
$homebase = $_SESSION['visitor_home'];
|
||||||
} elseif(local_channel()) {
|
}
|
||||||
|
elseif(local_channel()) {
|
||||||
$homebase = z_root() . '/channel/' . \App::$channel['channel_address'];
|
$homebase = z_root() . '/channel/' . \App::$channel['channel_address'];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,17 +186,8 @@ class WebServer {
|
|||||||
\App::$page['content'] .= '<script>var homebase = "' . $homebase . '";</script>';
|
\App::$page['content'] .= '<script>var homebase = "' . $homebase . '";</script>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user