Skip to content

Commit

Permalink
Non-database handler + Ajax component integration
Browse files Browse the repository at this point in the history
  • Loading branch information
Kubik-Rubik committed Jul 7, 2015
1 parent 257ecfb commit 711e64c
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions libraries/cms/html/behavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -634,16 +634,32 @@ public static function keepalive()
return;
}

$life_time = JFactory::getConfig()->get('lifetime') * 60000;
$refresh_time = ($life_time <= 60000) ? 45000 : $life_time - 60000;

// The longest refresh period is one hour to prevent integer overflow.
if ($refresh_time > 3600000 || $refresh_time <= 0)
// If the handler is not 'Database', we set a fixed, small refresh value (here: 5 min)
if (JFactory::getConfig()->get('session_handler') != 'database')
{
$refresh_time = 300000;
}
else
{
$refresh_time = 3600000;
$life_time = JFactory::getConfig()->get('lifetime') * 60000;
$refresh_time = ($life_time <= 60000) ? 45000 : $life_time - 60000;

// The longest refresh period is one hour to prevent integer overflow.
if ($refresh_time > 3600000 || $refresh_time <= 0)
{
$refresh_time = 3600000;
}
}

$url = JUri::root(true) . '/index.php?option=com_ajax&format=json';
// If we are in the frontend or logged in as a user, we can use the ajax component to reduce the load
if (JFactory::getApplication()->isSite() || !JFactory::getUser()->guest)
{
$url = JUri::base(true) . '/index.php?option=com_ajax&format=json';
}
else
{
$url = JUri::base(true) . '/index.php';
}

$script = 'window.setInterval(function(){';
$script .= 'var r;';
Expand Down

0 comments on commit 711e64c

Please sign in to comment.