sessions.php 2.0.19 -> 2.0.20 help needed

This is an archive of the phpBB 2.0.x support forum. Support for phpBB2 has now ended.
Forum rules
Following phpBB2's EoL, this forum is now archived for reference purposes only.
Please see the following announcement for more information: viewtopic.php?f=14&t=1385785
Locked
MaddoxX
Registered User
Posts: 450
Joined: Sat May 15, 2004 4:43 pm
Location: Russia

sessions.php 2.0.19 -> 2.0.20 help needed

Post by MaddoxX » Sat Apr 08, 2006 2:54 pm

Due mods I had several changes in my sessions.php file
Therefore im unable to "mod" this file to 2.0.20, because i'm a n00b in PHP.

I'm looking for some1 who is willing to help me to update this file to the latest :)

- http://s57.yousendit.com/d.aspx?id=1M5Q ... 37UHVKHP4P

p.s. IF anyone changes / fixes the file send me an PM with the new sessions.php :)
:D

MaddoxX
Registered User
Posts: 450
Joined: Sat May 15, 2004 4:43 pm
Location: Russia

Post by MaddoxX » Sat Apr 08, 2006 6:02 pm

nobody :( ?
:D

quick5pnt0
Registered User
Posts: 1083
Joined: Sun May 16, 2004 1:16 am
Contact:

Post by quick5pnt0 » Sat Apr 08, 2006 6:16 pm

You don't need to know php to do the code changes. Go here and download the code change package for 2.0.20 and do the code changes as the install instructions say. It's just a matter of finding code and replacing it. Just follow along with what it tells you to do and you'll be fine.

quick5pnt0
Registered User
Posts: 1083
Joined: Sun May 16, 2004 1:16 am
Contact:

Post by quick5pnt0 » Sat Apr 08, 2006 6:20 pm

If sessions.php is the only file you have modded then here are the code changes for it. Obviously you still need to perform the updates to all other files and run install/update_to_latest.php from the 2.0.20 package.

Code: Select all

# 
#-----[ OPEN ]--------------------------------------------- 
# 
includes/sessions.php

#
#-----[ FIND ]---------------------------------------------
# Line 175
		list($sec, $usec) = explode(' ', microtime());
		mt_srand((float) $sec + ((float) $usec * 100000));
		$session_id = md5(uniqid(mt_rand(), true));

#
#-----[ REPLACE WITH ]---------------------------------------------
#
		$session_id = md5(dss_rand());

#
#-----[ FIND ]---------------------------------------------
# Line 208
			list($sec, $usec) = explode(' ', microtime());
			mt_srand(hexdec(substr($session_id, 0, 8)) + (float) $sec + ((float) $usec * 1000000));
			$auto_login_key = uniqid(mt_rand(), true);

#
#-----[ REPLACE WITH ]---------------------------------------------
#
			$auto_login_key = dss_rand() . dss_rand();

#
#-----[ FIND ]---------------------------------------------
# Line 488
			WHERE last_login < ' . (time() - (86400 * (int) $board_config['max_autologin_time']));
		$db->sql_query($sql);
	}

	return true;

#
#-----[ AFTER, ADD ]---------------------------------------------
#
}

/**
* Reset all login keys for the specified user
* Called on password changes
*/
function session_reset_keys($user_id, $user_ip)
{
	global $db, $userdata;

	$key_sql = ($user_id == $userdata['user_id'] && !empty($userdata['session_key'])) ? "AND key_id != '" . md5($userdata['session_key']) . "'" : '';

	$sql = 'DELETE FROM ' . SESSIONS_KEYS_TABLE . '
		WHERE user_id = ' . (int) $user_id . "
			$key_sql";

	if ( !$db->sql_query($sql) )
	{
		message_die(CRITICAL_ERROR, 'Error removing auto-login keys', '', __LINE__, __FILE__, $sql);
	}

	$where_sql = 'session_user_id = ' . (int) $user_id;
	$where_sql .= ($user_id == $userdata['user_id']) ? " AND session_id <> '" . $userdata['session_id'] . "'" : '';
	$sql = 'DELETE FROM ' . SESSIONS_TABLE . "
		WHERE $where_sql";
	if ( !$db->sql_query($sql) )
	{
		message_die(CRITICAL_ERROR, 'Error removing user session(s)', '', __LINE__, __FILE__, $sql);
	}

	if ( !empty($key_sql) )
	{
		$auto_login_key = dss_rand() . dss_rand();

		$current_time = time();
		
		$sql = 'UPDATE ' . SESSIONS_KEYS_TABLE . "
			SET last_ip = '$user_ip', key_id = '" . md5($auto_login_key) . "', last_login = $current_time
			WHERE key_id = '" . md5($userdata['session_key']) . "'";
		
		if ( !$db->sql_query($sql) )
		{
			message_die(CRITICAL_ERROR, 'Error updating session key', '', __LINE__, __FILE__, $sql);
		}

		// And now rebuild the cookie
		$sessiondata['userid'] = $user_id;
		$sessiondata['autologinid'] = $autologin_id;
		$cookiename = $board_config['cookie_name'];
		$cookiepath = $board_config['cookie_path'];
		$cookiedomain = $board_config['cookie_domain'];
		$cookiesecure = $board_config['cookie_secure'];

		setcookie($cookiename . '_data', serialize($sessiondata), $current_time + 31536000, $cookiepath, $cookiedomain, $cookiesecure);
		
		$userdata['session_key'] = $auto_login_key;
		unset($sessiondata);
		unset($auto_login_key);
	}

MaddoxX
Registered User
Posts: 450
Joined: Sat May 15, 2004 4:43 pm
Location: Russia

Post by MaddoxX » Sat Apr 08, 2006 7:16 pm

It's not that..

It's because I can't find some of the things that need to be changed.. therefore i am unable to edit it correctly.
:D

Locked

Return to “2.0.x Support Forum”