[*] Installer : added cookie mode instead of session for the installer
This commit is contained in:
@@ -30,6 +30,8 @@
|
||||
class InstallSession
|
||||
{
|
||||
protected static $_instance;
|
||||
protected static $_cookie_mode = false;
|
||||
protected static $_cookie = false;
|
||||
|
||||
public static function getInstance()
|
||||
{
|
||||
@@ -41,39 +43,72 @@ class InstallSession
|
||||
public function __construct()
|
||||
{
|
||||
session_name('install_'.md5(__PS_BASE_URI__));
|
||||
session_start();
|
||||
if (!session_start() || (!isset($_SESSION['session_mode']) && (count($_POST) || count($_GET))))
|
||||
{
|
||||
InstallSession::$_cookie_mode = true;
|
||||
InstallSession::$_cookie = new Cookie('ps_install', null, time() + 7200, null, true);
|
||||
}
|
||||
else
|
||||
$_SESSION['session_mode'] = 'session';
|
||||
}
|
||||
|
||||
public function clean()
|
||||
{
|
||||
foreach ($_SESSION as $k => $v)
|
||||
unset($_SESSION[$k]);
|
||||
if (InstallSession::$_cookie_mode)
|
||||
InstallSession::$_cookie->logout();
|
||||
else
|
||||
foreach ($_SESSION as $k => $v)
|
||||
unset($_SESSION[$k]);
|
||||
}
|
||||
|
||||
public function &__get($varname)
|
||||
{
|
||||
if (isset($_SESSION[$varname]))
|
||||
$ref = &$_SESSION[$varname];
|
||||
if (InstallSession::$_cookie_mode)
|
||||
{
|
||||
$ref = InstallSession::$_cookie->{$varname};
|
||||
if (0 === strncmp($ref, 'serialized_array:', strlen('serialized_array:')))
|
||||
$ref = unserialize(substr($ref, strlen('serialized_array:')));
|
||||
}
|
||||
else
|
||||
{
|
||||
$null = null;
|
||||
$ref = &$null;
|
||||
if (isset($_SESSION[$varname]))
|
||||
$ref = &$_SESSION[$varname];
|
||||
else
|
||||
{
|
||||
$null = null;
|
||||
$ref = &$null;
|
||||
}
|
||||
}
|
||||
return $ref;
|
||||
}
|
||||
|
||||
public function __set($varname, $value)
|
||||
{
|
||||
$_SESSION[$varname] = $value;
|
||||
if (InstallSession::$_cookie_mode)
|
||||
{
|
||||
if ($varname == 'xml_loader_ids')
|
||||
return;
|
||||
if (is_array($value))
|
||||
$value = 'serialized_array:'.serialize($value);
|
||||
InstallSession::$_cookie->{$varname} = $value;
|
||||
}
|
||||
else
|
||||
$_SESSION[$varname] = $value;
|
||||
}
|
||||
|
||||
public function __isset($varname)
|
||||
{
|
||||
return isset($_SESSION[$varname]);
|
||||
if (InstallSession::$_cookie_mode)
|
||||
return isset(InstallSession::$_cookie->{$varname});
|
||||
else
|
||||
return isset($_SESSION[$varname]);
|
||||
}
|
||||
|
||||
public function __unset($varname)
|
||||
{
|
||||
unset($_SESSION[$varname]);
|
||||
if (InstallSession::$_cookie_mode)
|
||||
unset(InstallSession::$_cookie->{$varname});
|
||||
else
|
||||
unset($_SESSION[$varname]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ class InstallControllerHttpProcess extends InstallControllerHttp
|
||||
public function process()
|
||||
{
|
||||
if (file_exists(_PS_ROOT_DIR_.'/'.self::SETTINGS_FILE))
|
||||
@require_once _PS_ROOT_DIR_.'/'.self::SETTINGS_FILE;
|
||||
require_once _PS_ROOT_DIR_.'/'.self::SETTINGS_FILE;
|
||||
|
||||
if (!$this->session->process_validated)
|
||||
$this->session->process_validated = array();
|
||||
|
||||
@@ -20,8 +20,8 @@ function start_install()
|
||||
$('.stepList li:last-child').removeClass('ok').removeClass('ko');
|
||||
process_pixel = parseInt($('#progress_bar .total').css('width')) / process_steps.length;
|
||||
$('#tabs li a').each(function() {
|
||||
this.rel=$(this).attr('href');
|
||||
this.href='#';
|
||||
this.rel = $(this).attr('href');
|
||||
this.href = '#';
|
||||
});
|
||||
process_install();
|
||||
}
|
||||
@@ -31,11 +31,11 @@ function process_install(step)
|
||||
if (!step)
|
||||
step = process_steps[0];
|
||||
|
||||
$('.installing').hide().html(step.lang+' ...').fadeIn('slow');
|
||||
$('.installing').hide().html(step.lang + ' ...').fadeIn('slow');
|
||||
|
||||
$.ajax({
|
||||
url: 'index.php',
|
||||
data: step.key+'=true',
|
||||
data: step.key + '=true',
|
||||
dataType: 'json',
|
||||
cache: false,
|
||||
success: function(json)
|
||||
@@ -51,10 +51,7 @@ function process_install(step)
|
||||
$('#progress_bar .total span').html('100%');
|
||||
|
||||
// Installation finished
|
||||
setTimeout(function()
|
||||
{
|
||||
install_success();
|
||||
}, 700)
|
||||
setTimeout(function(){install_success();}, 700);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -83,4 +83,7 @@
|
||||
<li <?php if ($this->isStepFinished($step)): ?>class="ok"<?php endif; ?>><?php echo $this->l('menu_'.$this->step) ?></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<noscript>
|
||||
<h3 class="errorBlock" style="margin-bottom:10px"><?php echo $this->l('To install PrestaShop, you need to have JavaScript enabled in your browser.') ?></h3>
|
||||
</noscript>
|
||||
Reference in New Issue
Block a user