phpBB

Code Changes

File: phpbb/session.php

  Unmodified   Added   Modified   Removed
Line 439Line 439

// Is user banned? Are they excluded? Won't return on ban, exists within method
$this->check_ban_for_current_session($config);


// Is user banned? Are they excluded? Won't return on ban, exists within method
$this->check_ban_for_current_session($config);

 

// Update user last active time accordingly, but in a minute or so
if ((int) $this->data['session_time'] - (int) $this->data['user_last_active'] > 60)
{
$this->update_last_active_time();
}


return true;
}


return true;
}

Line 688Line 694
				if ($this->time_now - $this->data['session_time'] > 60 || ($this->update_session_page && $this->data['session_page'] != $this->page['page']))
{
// Update the last visit time

				if ($this->time_now - $this->data['session_time'] > 60 || ($this->update_session_page && $this->data['session_page'] != $this->page['page']))
{
// Update the last visit time

					$sql = 'UPDATE ' . USERS_TABLE . '
SET user_lastvisit = ' . (int) $this->data['session_time'] . '
WHERE user_id = ' . (int) $this->data['user_id'];
$db->sql_query($sql);

					$this->update_user_lastvisit();




				}

$SID = '?sid=';

				}

$SID = '?sid=';

Line 815Line 818
				$this->data['user_form_salt'] = unique_id();
// Update the form key
$sql = 'UPDATE ' . USERS_TABLE . '

				$this->data['user_form_salt'] = unique_id();
// Update the form key
$sql = 'UPDATE ' . USERS_TABLE . '

					SET user_form_salt = \'' . $db->sql_escape($this->data['user_form_salt']) . '\'


					SET user_form_salt = \'' . $db->sql_escape($this->data['user_form_salt']) . '\',
user_last_active = ' . (int) $this->data['session_time'] . '

					WHERE user_id = ' . (int) $this->data['user_id'];
$db->sql_query($sql);

					WHERE user_id = ' . (int) $this->data['user_id'];
$db->sql_query($sql);

 
			}
else
{
$this->update_last_active_time();

			}
}
else
{
$this->data['session_time'] = $this->data['session_last_visit'] = $this->time_now;


			}
}
else
{
$this->data['session_time'] = $this->data['session_last_visit'] = $this->time_now;


			// Update the last visit time
$sql = 'UPDATE ' . USERS_TABLE . '
SET user_lastvisit = ' . (int) $this->data['session_time'] . '
WHERE user_id = ' . (int) $this->data['user_id'];
$db->sql_query($sql);

			$this->update_user_lastvisit();






$SID = '?sid=';
$_SID = '';


$SID = '?sid=';
$_SID = '';

Line 960Line 964
		}

/**

		}

/**

		 * Get expired sessions for registered users, only most recent for each user
* Inner SELECT gets most recent expired sessions for unique session_user_id

		 * Get most recent session for each registered user to sync user last visit with it
* Inner SELECT gets most recent sessions for each unique session_user_id

		 * Outer SELECT gets data for them
*/
$sql_select = 'SELECT s1.session_page, s1.session_user_id, s1.session_time AS recent_time

		 * Outer SELECT gets data for them
*/
$sql_select = 'SELECT s1.session_page, s1.session_user_id, s1.session_time AS recent_time

Line 969Line 973
			INNER JOIN (
SELECT session_user_id, MAX(session_time) AS recent_time
FROM ' . SESSIONS_TABLE . '

			INNER JOIN (
SELECT session_user_id, MAX(session_time) AS recent_time
FROM ' . SESSIONS_TABLE . '

				WHERE session_time < ' . ($this->time_now - (int) $config['session_length']) . '
AND session_user_id <> ' . ANONYMOUS . '

				WHERE session_user_id <> ' . ANONYMOUS . '


				GROUP BY session_user_id
) AS s2
ON s1.session_user_id = s2.session_user_id

				GROUP BY session_user_id
) AS s2
ON s1.session_user_id = s2.session_user_id

Line 1475Line 1478
		}

$dnsbl_check = array(

		}

$dnsbl_check = array(

			'sbl.spamhaus.org'	=> ['http://www.spamhaus.org/query/bl?ip=', 'check_dnsbl_spamhaus'],

			'sbl.spamhaus.org'	=> ['https://check.spamhaus.org/listed/?searchterm=', 'check_dnsbl_spamhaus'],

		);

if ($mode == 'register')
{

		);

if ($mode == 'register')
{

			$dnsbl_check['bl.spamcop.net'] = ['http://spamcop.net/bl.shtml?', 'check_dnsbl_ipv4_generic'];

			$dnsbl_check['bl.spamcop.net'] = ['https://www.spamcop.net/bl.shtml?', 'check_dnsbl_ipv4_generic'];

		}

if ($ip)

		}

if ($ip)

Line 1760Line 1763
		}

// Do not update the session page for ajax requests, so the view online still works as intended

		}

// Do not update the session page for ajax requests, so the view online still works as intended

		$page_changed = $this->update_session_page && (!isset($this->data['session_page']) || $this->data['session_page'] != $this->page['page']) && !$request->is_ajax();

		$page_changed = $this->update_session_page && (!isset($this->data['session_page']) || $this->data['session_page'] != $this->page['page'] || $this->data['session_forum_id'] != $this->page['forum']) && !$request->is_ajax();


// Only update session DB a minute or so after last update or if page changes
if ($this->time_now - (isset($this->data['session_time']) ? $this->data['session_time'] : 0) > 60 || $page_changed)


// Only update session DB a minute or so after last update or if page changes
if ($this->time_now - (isset($this->data['session_time']) ? $this->data['session_time'] : 0) > 60 || $page_changed)

Line 1796Line 1799
	public function id() : int
{
return isset($this->data['user_id']) ? (int) $this->data['user_id'] : ANONYMOUS;

	public function id() : int
{
return isset($this->data['user_id']) ? (int) $this->data['user_id'] : ANONYMOUS;

 
	}

/**
* Update user last visit time
*/
public function update_user_lastvisit()
{
global $db;

if (isset($this->data['session_time'], $this->data['user_id']))
{
$sql = 'UPDATE ' . USERS_TABLE . '
SET user_lastvisit = ' . (int) $this->data['session_time'] . ',
user_last_active = ' . (int) $this->data['session_time'] . '
WHERE user_id = ' . (int) $this->data['user_id'];
$db->sql_query($sql);
}
}

/**
* Update user's last active time
*
* @return void
*/
public function update_last_active_time()
{
global $db;

if (isset($this->data['session_time'], $this->data['user_id']))
{
$sql = 'UPDATE ' . USERS_TABLE . '
SET user_last_active = ' . (int) $this->data['session_time'] . '
WHERE user_id = ' . (int) $this->data['user_id'];
$db->sql_query($sql);
}

	}
}


	}
}