Commit 9e4d40a9 authored by Côme Chilliet's avatar Côme Chilliet
Browse files

:sparkles: feat(core) Add init and run methods to standAlonePage to keep the object in the session

issue #5854
Showing with 49 additions and 1 deletion
+49 -1
...@@ -94,16 +94,47 @@ class standAlonePage { ...@@ -94,16 +94,47 @@ class standAlonePage {
if ($this->interactive) { if ($this->interactive) {
Language::init(); Language::init();
$ui = new userinfoNoAuth(get_class($this));
session::global_set('ui', $ui);
if (session::global_is_set('plist')) { if (session::global_is_set('plist')) {
session::global_un_set('plist'); session::global_un_set('plist');
} }
$ui = new userinfoNoAuth(get_class($this));
pluglist::load(); pluglist::load();
$ssl = $this->checkForSSL(); $ssl = $this->checkForSSL();
} }
} }
function init()
{
global $config, $ssl, $ui;
reset_errors();
static::securityHeaders();
CSRFProtection::check();
$ui = session::global_get('ui');
$config = session::global_get('config');
/* If SSL is forced, just forward to the SSL enabled site */
if (($config->get_cfg_value('forcessl') == 'TRUE') && ($ssl != '')) {
header ("Location: $ssl");
exit;
}
timezone::setDefaultTimezoneFromConfig();
Language::init();
$this->setupSmarty();
/* Prepare plugin list */
pluglist::load();
}
function loadConfig() function loadConfig()
{ {
global $BASE_DIR; global $BASE_DIR;
...@@ -155,6 +186,7 @@ class standAlonePage { ...@@ -155,6 +186,7 @@ class standAlonePage {
$smarty->assign('rtl', Language::isRTL($lang)); $smarty->assign('rtl', Language::isRTL($lang));
$smarty->assign('must', '<span class="must">*</span>'); $smarty->assign('must', '<span class="must">*</span>');
$smarty->assign('usePrototype', 'FALSE'); $smarty->assign('usePrototype', 'FALSE');
$smarty->assign('CSRFtoken', CSRFProtection::getToken());
} }
function assignSmartyVars() function assignSmartyVars()
...@@ -239,6 +271,22 @@ class standAlonePage { ...@@ -239,6 +271,22 @@ class standAlonePage {
return preg_replace('/^&amp;/', '?', $params); return preg_replace('/^&amp;/', '?', $params);
} }
static function run()
{
session::start();
$class = get_called_class();
if (session::is_set('standAlonePage_'.$class)) {
$page = session::get('standAlonePage_'.$class);
$page->init();
} else {
$page = new $class();
}
session::set('standAlonePage_'.$class, $page);
$page->execute();
}
static function securityHeaders() static function securityHeaders()
{ {
header('X-XSS-Protection: 1; mode=block'); header('X-XSS-Protection: 1; mode=block');
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment