MediaWiki check if User is already Logged in phpBB?

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    php|uber.leet Forum Index // General
View previous topic :: View next topic  
Author Message
Trash-Master



Joined: 29 Jul 2009
Posts: 3

PostPosted: Wed Jul 29, 2009 2:11 pm    Post subject: MediaWiki check if User is already Logged in phpBB? Reply with quote
Hello,

your extension (http://www.mediawiki.org/wiki/Extension:PHPBB/Users_Integration) works fine at my Wiki, thank you for that.
But I have a question:
Is it possible to check if the person using the wiki is already logged into the phpbb board? And return an error message if not?

For files which stick to phpBB I check it with this code:
Code:

define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);

/*
* session management
*/
$user->session_begin();
$auth->acl($user->data);
$user->setup();

// If User not logged in return error
if ($user->data['user_id'] == ANONYMOUS)
   {
      trigger_error('NOT_AUTHORISED');
      exit;
   }


But this does not work for MediaWiki when your extension is activated. It says something like "IN_PHPBB already defined".

Can u help me?

Best Regards from Germany,
Trash-Master
Back to top
View user's profile Send private message
root
Site Admin


Joined: 24 Jun 2005
Posts: 471

PostPosted: Thu Jul 30, 2009 9:59 am    Post subject: Reply with quote
In Auth_phpBB.php go to the Constructor method. And look for

Code:
// Set some values phpBB needs.
define('IN_PHPBB', true); // We are secure.


and change it to

Code:
// Set some values phpBB needs.
if (!defined('IN_PHPBB')) {
    define('IN_PHPBB', true); // We are secure.
}


You might also want to wrap your code with the "if defined" as well. I am not sure if it is mine or yours tripping the error.
Back to top
View user's profile Send private message
Trash-Master



Joined: 29 Jul 2009
Posts: 3

PostPosted: Thu Jul 30, 2009 3:23 pm    Post subject: Reply with quote
Thank you for the fast reply.

Your solution works well, if i am not logged into the phpBB Board.

But if i try to call the wiki, when i am logged in the phpBB Board, it says:
Quote:
Fatal error: Call to undefined method user::newfromsession() in /home/www/mydomain/phpbb3/wiki/includes/StubObject.php on line 192


Whats wrong?

Best Regards
Back to top
View user's profile Send private message
root
Site Admin


Joined: 24 Jun 2005
Posts: 471

PostPosted: Fri Jul 31, 2009 12:22 am    Post subject: Reply with quote
The user object is trying to start a session from an already started session. Find what phpBB file has the "newfromsession" method in it.

Then where the code is failing add

Code:
if (!function_exists('newfromsession')) {
    include "path/to/file.php";
}


Where if the method "newfromsession" is not found then you include the file that has that method in it.
Back to top
View user's profile Send private message
Trash-Master



Joined: 29 Jul 2009
Posts: 3

PostPosted: Fri Jul 31, 2009 3:53 am    Post subject: Reply with quote
It's common.php and includes/auth.php

If I include common.php (already included in index.php) it says:
Quote:
Fatal error: Cannot redeclare deregister_globals() (previously declared in /home/www/mydomain/phpbb3/common.php:32) in /home/www/mydomain/phpbb3/common.php on line 94


If I include includes/auth.php it says:
Quote:
Fatal error: Cannot redeclare class auth in /home/www/mydomain/phpbb3/includes/auth.php on line 24


So what to do?

Best Regards
Back to top
View user's profile Send private message
root
Site Admin


Joined: 24 Jun 2005
Posts: 471

PostPosted: Fri Jul 31, 2009 4:08 pm    Post subject: Reply with quote
Honestly http://us3.php.net/namespaces

It's why I have not coded single sign-on yet. Waiting on Name Spaces. Then waiting on MW and PHPBB to use them.
Back to top
View user's profile Send private message
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    php|uber.leet Forum Index // General All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

alexisBlue v1.2 // Theme Created By: Andrew Charron and Web Hosting Bluebook
Powered by phpBB © 2001, 2002 phpBB Group