Webmastersite.net
Register Log In

Integration things again

Comments on Integration things again

nelgin


Usergroup: Customer
Joined: Jul 17, 2003

Total Topics: 39
Total Comments: 100
nelgin
Posted Sep 21, 2007 - 10:29 PM:

I never did get this fully working, but now I have a better idea of how phpBB2 does its tracking, maybe I can pass this by everyone.

Let's examine phpBB2. I have
Cookie Domain: british-expats.com
Cookie Name: britnetcookie
Cookie Path: /

When logged in two cookies are created:
britnetcookie_sid
Contest: = my session id
Path: /

The 2nd is
britnetcookie_data
Content: a%3A2%3A%7Bs%3A11%3A%22autologinid%22%3Bs%3A0%3A%22%22%3Bs%3A6%3A%22userid%22%3Bs%3A1%3A%222%22%3B%7D
(this decodes to be:
a:2:{s:11:"autologinid";s:0:"";s:6:"userid";s:1:"2";}
Domain: .british-expats.com

Can someone tell me how I'd translate that into an integration file? It doesn't use passwords at all, just a session id.

The query to get the sid is
SELECT session_user_id FROM phpbb_sessions WHERE session_id={SESSIONID}

TIA,
Nigel
Paul
developer

Usergroup: Administrator
Joined: Dec 20, 2001
Location: Diamond Springs, California

Total Topics: 61
Total Comments: 7868
Paul
Posted Sep 22, 2007 - 11:33 AM:

phpBB behaves differently depending on whether you check the remember box or not, so if you make it work without the check I believe it'll stop working with the check.

Still, you can set
$cookietype = 'session';
$sessionquery = 'SELECT session_user_id FROM phpbb_sessions WHERE session_id={SESSIONID}';
nelgin


Usergroup: Customer
Joined: Jul 17, 2003

Total Topics: 39
Total Comments: 100
nelgin
Posted Sep 22, 2007 - 5:14 PM:

Quite possibly.

What is happening that if I logout and clear cookies on both phpBB & wsnlinks and then just login via wsnlinks, it will log me in using the phpbb username & password but not log me in automatically to the phpBB side. It seems like the cookie that wsnlinks writes isn't what phpBB is looking for. I'll play around with the cookie creation and see what I can come up with.

Thanks,
Nigel
nelgin


Usergroup: Customer
Joined: Jul 17, 2003

Total Topics: 39
Total Comments: 100
nelgin
Posted Sep 23, 2007 - 11:41 AM:

OK, I fixed part of the problem. The $sessionquery query fails since the session_id is alphanumeric, you need double quotes around it:


$sessionquery = 'select session_user_id from phpbb_sessions where session_id="{SESSIONID}"';


So I can login to phpBB and it will log me into wsnlinks but not the other way around. My guess is that there's still something about the wrong cookie being written out, or I've forgotten something?

Paul
developer

Usergroup: Administrator
Joined: Dec 20, 2001
Location: Diamond Springs, California

Total Topics: 61
Total Comments: 7868
Paul
Posted Sep 23, 2007 - 3:21 PM:

It seems like the cookie that wsnlinks writes isn't what phpBB is looking for.

Wrong path? What's your cookie domain path settings at Admin -> Settings -> System?
nelgin


Usergroup: Customer
Joined: Jul 17, 2003

Total Topics: 39
Total Comments: 100
nelgin
Posted Sep 23, 2007 - 7:25 PM:

The path is: /
domain is: british-expats.com

This is what I have set for phpBB also.
nelgin


Usergroup: Customer
Joined: Jul 17, 2003

Total Topics: 39
Total Comments: 100
nelgin
Posted Sep 23, 2007 - 8:18 PM:

I just looked at the cookie, you're writing the user_id rather than the session_id into the cookie. So the content of the cookie is "2" which is my user_id rather than my session id.
Also, since phpBB doesn't use usernames & passwords, you would need to write the session id and user_id into the phpBB session table.

phpBB will pick up the session id from the cookie and then refer to the sessions table to get the userid so without writing to the table, there's no way phpBB will know who is logging in.

I just proved that theory right by logging into wsnlinks and then creating a session entry in the sessions table with the session_id=2 (same as my user id).

So, to get this to work you need to generate a session number, write it to the cookie and update the sessions table with that inforamtion. smiling face

When all this is done, I'll document everything so that it will be easy for the next poor person who wants to try this out!
nelgin


Usergroup: Customer
Joined: Jul 17, 2003

Total Topics: 39
Total Comments: 100
nelgin
Posted Sep 25, 2007 - 9:50 AM:

Any news?
Paul
developer

Usergroup: Administrator
Joined: Dec 20, 2001
Location: Diamond Springs, California

Total Topics: 61
Total Comments: 7868
Paul
Posted Sep 25, 2007 - 11:46 AM:

I'll make the login cookie creation into a pluggable function which can be included in the integration file, much like the registration function available there already.
nelgin


Usergroup: Customer
Joined: Jul 17, 2003

Total Topics: 39
Total Comments: 100
nelgin
#10 - Quote - Permalink
Posted Sep 25, 2007 - 12:06 PM:

Cool.

The only thing to be aware of is that you don't need to create a cookie as long as one already exists smiling face

Do you know when that might be ready for testing? My 4.1.x is in a test environment right now so can pretty much try anything.

Thanks,
Nigel
Paul
developer

Usergroup: Administrator
Joined: Dec 20, 2001
Location: Diamond Springs, California

Total Topics: 61
Total Comments: 7868
Paul
#11 - Quote - Permalink
Posted Sep 26, 2007 - 4:27 PM:

It'd be something vaguely like this:
function setlogincookies($id, $row)
{
global $cookienames, $db;
$sid = md5(time());
$db->query("INSERT INTO session_user_id(`session_id`,`userid`) VALUES(`$sid`,`$id`)");
makecookie($cookienames['id'], $sid);
}


I don't have time to look through phpbb to find the exact query at the moment.
nelgin


Usergroup: Customer
Joined: Jul 17, 2003

Total Topics: 39
Total Comments: 100
nelgin
#12 - Quote - Permalink
Posted Sep 26, 2007 - 10:25 PM:

The default phpbb_sessions table looks like this


+-------------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------------+--------------+------+-----+---------+-------+
| session_id | char(32) | NO | PRI | | |
| session_user_id | mediumint(8) | NO | MUL | 0 | |
| session_start | int(11) | NO | | 0 | |
| session_time | int(11) | NO | | 0 | |
| session_ip | char(8) | NO | | 0 | |
| session_page | int(11) | NO | | 0 | |
| session_logged_in | tinyint(1) | NO | | 0 | |
| session_admin | tinyint(2) | NO | | 0 | |
+-------------------+--------------+------+-----+---------+-------+


The session_id is created using a function called dss_rand in includes/functions of the phpBB installation.


function dss_rand()
{
global $db, $board_config, $dss_seeded;

$val = $board_config['rand_seed'] . microtime();
$val = md5($val);
$board_config['rand_seed'] = md5($board_config['rand_seed'] . $val . 'a'
);

if($dss_seeded !== true)
{
$sql = "UPDATE " . CONFIG_TABLE . "
SET config_value = '" . $board_config['rand_seed'] . "'
WHERE config_name = 'rand_seed'";
if( !$db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Unable to reseed PRNG", "",
__LINE__, __FILE__, $sql);
}

// Remove cache file
@unlink($phpbb_root_path . 'cache/config_board.'.$phpEx);

$dss_seeded = true;
}

return substr($val, 4, 16);
}


Not sure if any of that is helpful to you at all.

BTW. If we can get this integration working both ways, I'll gladly cough up another $25 or however much it is to upgrade smiling face

Regards
Nigel
Paul
developer

Usergroup: Administrator
Joined: Dec 20, 2001
Location: Diamond Springs, California

Total Topics: 61
Total Comments: 7868
Paul
#13 - Quote - Permalink
Posted Sep 27, 2007 - 11:45 AM:

Apparently then it's quite complicated. I could only take it on as a custom project, and I'm busy with three at the moment so I can't take on more at the moment.
nelgin


Usergroup: Customer
Joined: Jul 17, 2003

Total Topics: 39
Total Comments: 100
nelgin
#14 - Quote - Permalink
Posted Sep 28, 2007 - 1:07 AM:

Can you give me a little insight into how/where cookies are created in wsnlinks currently? I find myself changing file after file and really not getting anywhere.

One of the big appeals of wsnlinks was the possibility to later integrate it with my phpBB system.

Thanks,
Nigel
Paul
developer

Usergroup: Administrator
Joined: Dec 20, 2001
Location: Diamond Springs, California

Total Topics: 61
Total Comments: 7868
Paul
#15 - Quote - Permalink
Posted Sep 28, 2007 - 7:59 PM:

In 4.1.4 (expect the release around the 30th) you'll be able to create login cookies with the helper function as I've already edited the manual to explain: scripts.webmastersite.net/w...an-integrationspan-75.html . The SMF integration will illustrate it -- see attached if you want a head start. That still leaves you to write the session creation mess.

If you want easy phpBB integration, just: (a) force-check the "remember" box as I seem to recall reading that others have done or (b) stick with non-cookie integration and let people login.

Of course phpBB is never going to integrate as fully as WSN Forum, which also integrates PMs, IMs, online users, the chat room, shouts, quotes, and can share a bunch of templates if so requested (even the wrapper with some extra work).

Attached Files:
Search thread for
Download thread as
  • 0/5
  • 1
  • 2
  • 3
  • 4
  • 5



This thread is closed, so you cannot post a reply.