public $query_string = '';
public $config = [];
public $page = [];
- public $pager = [];
- public $page_offset;
public $profile;
public $profile_uid;
public $user;
public $argv;
public $argc;
public $module;
- public $hooks = [];
public $timezone;
public $interactive = true;
- public $addons;
- public $addons_admin = [];
- public $apps = [];
public $identities;
public $is_mobile = false;
public $is_tablet = false;
public $performance = [];
public $callstack = [];
public $theme_info = [];
- public $nav_sel;
public $category;
// Allow themes to control internal parameters
// by changing App values in theme.php
$this->module = 'home';
}
- // See if there is any page number information, and initialise pagination
- $this->pager['page'] = !empty($_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;
- }
- $this->pager['total'] = 0;
-
// Detect mobile devices
$mobile_detect = new MobileDetect();
$this->is_mobile = $mobile_detect->isMobile();
Core\Config::load();
if ($this->getMode()->has(App\Mode::DBAVAILABLE)) {
- Core\Addon::loadHooks();
+ Core\Hook::loadHooks();
$this->loadAddonConfig();
}
Core\L10n::init();
- $this->page = [
- 'aside' => '',
- 'bottom' => '',
- 'content' => '',
- 'footer' => '',
- 'htmlhead' => '',
- 'nav' => '',
- 'page_title' => '',
- 'right_aside' => '',
- 'template' => '',
- 'title' => ''
- ];
-
$this->process_id = Core\System::processID('log');
}
$stamp1 = microtime(true);
- DBA::connect($db_host, $db_user, $db_pass, $db_data, $charset);
+ if (DBA::connect($db_host, $db_user, $db_pass, $db_data, $charset)) {
+ // Loads DB_UPDATE_VERSION constant
+ Database\DBStructure::definition(false);
+ }
+
unset($db_host, $db_user, $db_pass, $db_data, $charset);
$this->saveTimestamp($stamp1, 'network');
return $this->urlPath;
}
- public function setPagerTotal($n)
- {
- $this->pager['total'] = intval($n);
- }
-
- public function setPagerItemsPage($n)
- {
- $this->pager['itemspage'] = ((intval($n) > 0) ? intval($n) : 0);
- $this->pager['start'] = ($this->pager['page'] * $this->pager['itemspage']) - $this->pager['itemspage'];
- }
-
- public function setPagerPage($n)
- {
- $this->pager['page'] = $n;
- $this->pager['start'] = ($this->pager['page'] * $this->pager['itemspage']) - $this->pager['itemspage'];
- }
-
/**
* Initializes App->page['htmlhead'].
*
$touch_icon = 'images/friendica-128.png';
}
- // get data wich is needed for infinite scroll on the network page
- $infinite_scroll = infinite_scroll_data($this->module);
-
Core\Addon::callHooks('head', $this->page['htmlhead']);
$tpl = get_markup_template('head.tpl');
'$update_interval' => $interval,
'$shortcut_icon' => $shortcut_icon,
'$touch_icon' => $touch_icon,
- '$infinite_scroll' => $infinite_scroll,
'$block_public' => intval(Core\Config::get('system', 'block_public')),
'$stylesheets' => $this->stylesheets,
]) . $this->page['htmlhead'];
} else {
$this->checkURL();
check_db(false);
- Core\Addon::check();
+ Core\Addon::loadAddons();
+ Core\Hook::loadHooks();
}
- Content\Nav::setSelected('nothing');
-
- //Don't populate apps_menu if apps are private
- $privateapps = Core\Config::get('config', 'private_addons');
- if ((local_user()) || (! $privateapps === "1")) {
- $arr = ['app_menu' => $this->apps];
-
- Core\Addon::callHooks('app_menu', $arr);
-
- $this->apps = $arr['app_menu'];
- }
+ $this->page = [
+ 'aside' => '',
+ 'bottom' => '',
+ 'content' => '',
+ 'footer' => '',
+ 'htmlhead' => '',
+ 'nav' => '',
+ 'page_title' => '',
+ 'right_aside' => '',
+ 'template' => '',
+ 'title' => ''
+ ];
if (strlen($this->module)) {
// Compatibility with the Android Diaspora client
if ($this->module == 'stream') {
- goaway('network?f=&order=post');
+ $this->internalRedirect('network?f=&order=post');
}
if ($this->module == 'conversations') {
- goaway('message');
+ $this->internalRedirect('message');
}
if ($this->module == 'commented') {
- goaway('network?f=&order=comment');
+ $this->internalRedirect('network?f=&order=comment');
}
if ($this->module == 'liked') {
- goaway('network?f=&order=comment');
+ $this->internalRedirect('network?f=&order=comment');
}
if ($this->module == 'activity') {
- goaway('network/?f=&conv=1');
+ $this->internalRedirect('network/?f=&conv=1');
}
if (($this->module == 'status_messages') && ($this->cmd == 'status_messages/new')) {
- goaway('bookmarklet');
+ $this->internalRedirect('bookmarklet');
}
if (($this->module == 'user') && ($this->cmd == 'user/edit')) {
- goaway('settings');
+ $this->internalRedirect('settings');
}
if (($this->module == 'tag_followings') && ($this->cmd == 'tag_followings/manage')) {
- goaway('search');
+ $this->internalRedirect('search');
}
// Compatibility with the Firefox App
}
$privateapps = Core\Config::get('config', 'private_addons', false);
- if (is_array($this->addons) && in_array($this->module, $this->addons) && file_exists("addon/{$this->module}/{$this->module}.php")) {
+ if (Core\Addon::isEnabled($this->module) && file_exists("addon/{$this->module}/{$this->module}.php")) {
//Check if module is an app and if public access to apps is allowed or not
- if ((!local_user()) && Core\Addon::isApp($this->module) && $privateapps) {
+ if ((!local_user()) && Core\Hook::isAddonApp($this->module) && $privateapps) {
info(Core\L10n::t("You must be logged in to use addons. "));
} else {
include_once "addon/{$this->module}/{$this->module}.php";
if (!empty($_SERVER['QUERY_STRING']) && ($_SERVER['QUERY_STRING'] === 'q=internal_error.html') && isset($dreamhost_error_hack)) {
logger('index.php: dreamhost_error_hack invoked. Original URI =' . $_SERVER['REQUEST_URI']);
- goaway($this->getBaseURL() . $_SERVER['REQUEST_URI']);
+ $this->internalRedirect($_SERVER['REQUEST_URI']);
}
logger('index.php: page not found: ' . $_SERVER['REQUEST_URI'] . ' ADDRESS: ' . $_SERVER['REMOTE_ADDR'] . ' QUERY: ' . $_SERVER['QUERY_STRING'], LOGGER_DEBUG);
require_once $theme_info_file;
}
-
// initialise content region
if ($this->getMode()->isNormal()) {
Core\Addon::callHooks('page_content_top', $this->page['content']);
// Add the navigation (menu) template
if ($this->module != 'install' && $this->module != 'maintenance') {
- Content\Nav::build($this);
+ $this->page['htmlhead'] .= replace_macros(get_markup_template('nav_head.tpl'), []);
+ $this->page['nav'] = Content\Nav::build($this);
}
// Build the page - now that we have all the components
/// @TODO Looks unsafe (remote-inclusion), is maybe not but Core\Theme::getPathForFile() uses file_exists() but does not escape anything
require_once $template;
}
+
+ /**
+ * Redirects to another module relative to the current Friendica base.
+ * If you want to redirect to a external URL, use System::externalRedirectTo()
+ *
+ * @param string $toUrl The destination URL (Default is empty, which is the default page of the Friendica node)
+ * @param bool $ssl if true, base URL will try to get called with https:// (works just for relative paths)
+ *
+ * @throws InternalServerErrorException In Case the given URL is not relative to the Friendica node
+ */
+ public function internalRedirect($toUrl = '', $ssl = false)
+ {
+ if (filter_var($toUrl, FILTER_VALIDATE_URL)) {
+ throw new InternalServerErrorException("'$toUrl is not a relative path, please use System::externalRedirectTo");
+ }
+
+ $redirectTo = $this->getBaseURL($ssl) . '/' . ltrim($toUrl, '/');
+ Core\System::externalRedirect($redirectTo);
+ }
+
+ /**
+ * Automatically redirects to relative or absolute URL
+ * Should only be used if it isn't clear if the URL is either internal or external
+ *
+ * @param string $toUrl The target URL
+ *
+ */
+ public function redirect($toUrl)
+ {
+ if (filter_var($toUrl, FILTER_VALIDATE_URL)) {
+ Core\System::externalRedirect($toUrl);
+ } else {
+ $this->internalRedirect($toUrl);
+ }
+ }
}