Installing with phpBB2.0.18

This mod will register when the user last logged in, allong with the info about how meny users have visited the board

Moderator: Moderators

Forum rules
The content in this forum is dated Dec. 21 2005 and can be used as Archive only. This Forum is LOCKED and READ ONLY !

Installing with phpBB2.0.18

Postby Eddy Matthews on Mon 31. Oct, 2005 23:20

I'd like to use this mod, but I cannot find the lines I need to edit in sessions.php - Can anyone help with a working setup for phpBB2.0.18 please?

Regards
Eddy
Eddy Matthews
Poster
Poster
 
Posts: 6
Joined: Mon 31. Oct, 2005 22:09

Postby NorthernMike on Tue 01. Nov, 2005 17:47

You wont find those lines in sessions.php if you have updated to 2.0.18. Those lines got wiped out with the new update code. I already installed this mod prior to the 2.0.18 update and the mod is not working correctly anymore. In fact it is acting so wacky I cannot even find a specific pattern.

Hopefully, Niels will come up with an update for this mod. This is truley a fantastic mod and I would really hate for it not to work.
NorthernMike
Poster
Poster
 
Posts: 5
Joined: Mon 24. Oct, 2005 17:41

Postby seb31 on Tue 01. Nov, 2005 19:36

Hello,

In this part

Code: Select all
/**
* Terminates the specified session
* It will delete the entry in the sessions table for this session,
* remove the corresponding auto-login key and reset the cookies
*/
function session_end($session_id, $user_id)
{
   global $db, $lang, $board_config, $userdata;
   global $HTTP_COOKIE_VARS, $HTTP_GET_VARS, $SID;

   $cookiename = $board_config['cookie_name'];
   $cookiepath = $board_config['cookie_path'];
   $cookiedomain = $board_config['cookie_domain'];
   $cookiesecure = $board_config['cookie_secure'];

   $current_time = time();

   if (!preg_match('/^[A-Za-z0-9]*$/', $session_id))
   {
      return;
   }
   
   //
   // Delete existing session
   //
   $sql = 'DELETE FROM ' . SESSIONS_TABLE . "
      WHERE session_id = '$session_id'
         AND session_user_id = $user_id";
   if ( !$db->sql_query($sql) )
   {
      message_die(CRITICAL_ERROR, 'Error removing user session', '', __LINE__, __FILE__, $sql);
   }

   //
   // Remove this auto-login entry (if applicable)
   //
   if ( isset($userdata['session_key']) && $userdata['session_key'] != '' )
   {
      $autologin_key = md5($userdata['session_key']);
      $sql = 'DELETE FROM ' . SESSIONS_KEYS_TABLE . '
         WHERE user_id = ' . (int) $user_id . "
            AND key_id = '$autologin_key'";
      if ( !$db->sql_query($sql) )
      {
         message_die(CRITICAL_ERROR, 'Error removing auto-login key', '', __LINE__, __FILE__, $sql);
      }
   }

   //
   // We expect that message_die will be called after this function,
   // but just in case it isn't, reset $userdata to the details for a guest
   //
   $sql = 'SELECT *
      FROM ' . USERS_TABLE . '
      WHERE user_id = ' . ANONYMOUS;
   if ( !($result = $db->sql_query($sql)) )
   {
      message_die(CRITICAL_ERROR, 'Error obtaining user details', '', __LINE__, __FILE__, $sql);
   }
   if ( !($userdata = $db->sql_fetchrow($result)) )
   {
      message_die(CRITICAL_ERROR, 'Error obtaining user details', '', __LINE__, __FILE__, $sql);
   }
   $db->sql_freeresult($result);


   setcookie($cookiename . '_data', '', $current_time - 31536000, $cookiepath, $cookiedomain, $cookiesecure);
   setcookie($cookiename . '_sid', '', $current_time - 31536000, $cookiepath, $cookiedomain, $cookiesecure);

   return true;
}

/**
* Removes expired sessions and auto-login keys from the database
*/
function session_clean($session_id)
{
   global $board_config, $db;

   //
   // Delete expired sessions
   //
   $sql = 'DELETE FROM ' . SESSIONS_TABLE . '
      WHERE session_time < ' . (time() - (int) $board_config['session_length']) . "
         AND session_id <> '$session_id'";
   if ( !$db->sql_query($sql) )
   {
      message_die(CRITICAL_ERROR, 'Error clearing sessions table', '', __LINE__, __FILE__, $sql);
   }

   //
   // Delete expired auto-login keys
   // If max_autologin_time is not set then keys will never be deleted
   // (same behaviour as old 2.0.x session code)
   //
   if (!empty($board_config['max_autologin_time']) && $board_config['max_autologin_time'] > 0)
   {
      $sql = 'DELETE FROM ' . SESSIONS_KEYS_TABLE . '
         WHERE last_login < ' . (time() - (86400 * (int) $board_config['max_autologin_time']));
      $db->sql_query($sql);
   }

   return true;
}


search :

Code: Select all
   //
   // Delete expired sessions
   //
   $sql = 'DELETE FROM ' . SESSIONS_TABLE . '
      WHERE session_time < ' . (time() - (int) $board_config['session_length']) . "
         AND session_id <> '$session_id'";


Replace with :

Code: Select all
//
   // Delete expired sessions
   //

$sql = "DELETE FROM " . SESSIONS_TABLE . "
         WHERE UNIX_TIMESTAMP() - session_time >=172800
         AND session_id <> '$session_id'";


Excuse me for my english but i'm french.
Try this manipulation

seb
seb31
Poster
Poster
 
Posts: 5
Joined: Tue 01. Nov, 2005 12:37

Postby NorthernMike on Tue 01. Nov, 2005 19:46

seb31 wrote:Hello,

In this part

Code: Select all
/**
* Terminates the specified session
* It will delete the entry in the sessions table for this session,
* remove the corresponding auto-login key and reset the cookies
*/
function session_end($session_id, $user_id)
{
   global $db, $lang, $board_config, $userdata;
   global $HTTP_COOKIE_VARS, $HTTP_GET_VARS, $SID;

   $cookiename = $board_config['cookie_name'];
   $cookiepath = $board_config['cookie_path'];
   $cookiedomain = $board_config['cookie_domain'];
   $cookiesecure = $board_config['cookie_secure'];

   $current_time = time();

   if (!preg_match('/^[A-Za-z0-9]*$/', $session_id))
   {
      return;
   }
   
   //
   // Delete existing session
   //
   $sql = 'DELETE FROM ' . SESSIONS_TABLE . "
      WHERE session_id = '$session_id'
         AND session_user_id = $user_id";
   if ( !$db->sql_query($sql) )
   {
      message_die(CRITICAL_ERROR, 'Error removing user session', '', __LINE__, __FILE__, $sql);
   }

   //
   // Remove this auto-login entry (if applicable)
   //
   if ( isset($userdata['session_key']) && $userdata['session_key'] != '' )
   {
      $autologin_key = md5($userdata['session_key']);
      $sql = 'DELETE FROM ' . SESSIONS_KEYS_TABLE . '
         WHERE user_id = ' . (int) $user_id . "
            AND key_id = '$autologin_key'";
      if ( !$db->sql_query($sql) )
      {
         message_die(CRITICAL_ERROR, 'Error removing auto-login key', '', __LINE__, __FILE__, $sql);
      }
   }

   //
   // We expect that message_die will be called after this function,
   // but just in case it isn't, reset $userdata to the details for a guest
   //
   $sql = 'SELECT *
      FROM ' . USERS_TABLE . '
      WHERE user_id = ' . ANONYMOUS;
   if ( !($result = $db->sql_query($sql)) )
   {
      message_die(CRITICAL_ERROR, 'Error obtaining user details', '', __LINE__, __FILE__, $sql);
   }
   if ( !($userdata = $db->sql_fetchrow($result)) )
   {
      message_die(CRITICAL_ERROR, 'Error obtaining user details', '', __LINE__, __FILE__, $sql);
   }
   $db->sql_freeresult($result);


   setcookie($cookiename . '_data', '', $current_time - 31536000, $cookiepath, $cookiedomain, $cookiesecure);
   setcookie($cookiename . '_sid', '', $current_time - 31536000, $cookiepath, $cookiedomain, $cookiesecure);

   return true;
}

/**
* Removes expired sessions and auto-login keys from the database
*/
function session_clean($session_id)
{
   global $board_config, $db;

   //
   // Delete expired sessions
   //
   $sql = 'DELETE FROM ' . SESSIONS_TABLE . '
      WHERE session_time < ' . (time() - (int) $board_config['session_length']) . "
         AND session_id <> '$session_id'";
   if ( !$db->sql_query($sql) )
   {
      message_die(CRITICAL_ERROR, 'Error clearing sessions table', '', __LINE__, __FILE__, $sql);
   }

   //
   // Delete expired auto-login keys
   // If max_autologin_time is not set then keys will never be deleted
   // (same behaviour as old 2.0.x session code)
   //
   if (!empty($board_config['max_autologin_time']) && $board_config['max_autologin_time'] > 0)
   {
      $sql = 'DELETE FROM ' . SESSIONS_KEYS_TABLE . '
         WHERE last_login < ' . (time() - (86400 * (int) $board_config['max_autologin_time']));
      $db->sql_query($sql);
   }

   return true;
}


search :

Code: Select all
   //
   // Delete expired sessions
   //
   $sql = 'DELETE FROM ' . SESSIONS_TABLE . '
      WHERE session_time < ' . (time() - (int) $board_config['session_length']) . "
         AND session_id <> '$session_id'";


Replace with :

Code: Select all
//
   // Delete expired sessions
   //

$sql = "DELETE FROM " . SESSIONS_TABLE . "
         WHERE UNIX_TIMESTAMP() - session_time >=172800
         AND session_id <> '$session_id'";


Excuse me for my english but i'm french.
Try this manipulation

seb


Thank you Seb. It looks like this will work. :D This is a piece of the code that got replaced during the update.
NorthernMike
Poster
Poster
 
Posts: 5
Joined: Mon 24. Oct, 2005 17:41

Postby seb31 on Tue 01. Nov, 2005 19:50

at home that functions
seb31
Poster
Poster
 
Posts: 5
Joined: Tue 01. Nov, 2005 12:37

Postby Mehrpack on Tue 01. Nov, 2005 20:24

hi,
i had finde the code that have seb post in my sessions.php after editing too.
and the chance work.

Mehrpack
Warning: If you read my English, runaway, its dangerous *g*
Mehrpack
Poster
Poster
 
Posts: 34
Joined: Wed 25. Feb, 2004 06:37
Location: germany

Postby seb31 on Tue 01. Nov, 2005 20:45

It's good ? It's right ?
seb31
Poster
Poster
 
Posts: 5
Joined: Tue 01. Nov, 2005 12:37

Postby ErnadoO on Tue 01. Nov, 2005 20:53

Hello seb, ta modife est effectivement bonne, c'est c'elle que j'ai adopté hier lors de la mise à jour ;)
ErnadoO
Poster
Poster
 
Posts: 14
Joined: Wed 13. Apr, 2005 22:52
Location: France

Next

Return to Last visit [2.0.10/EM]

Who is online

Users browsing this forum: No registered users and 1 guest

cron