Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

PhpBB3 authenticate agains custom database

Posted on 2008-10-15
8
756 Views
Last Modified: 2013-12-13
Hello,

I've got a website that has it's own database for authenticating users right now.  I need to add PhpBB3 onto this site.  I've got it installed already and working.

Is there a way so that when a user logs into my existing site which authenticates against my current database, they can also be logged into PhpBB3? (They would just link to the forums after logging in and be able to post)

From what I've researched, I'd need to modify the PhpBB's /includes/auth/auth_db.php file.

Has someone already completed this, or know of an easier solution?

Thanks!
0
Comment
Question by:snakeriver
  • 4
  • 4
8 Comments
 
LVL 13

Expert Comment

by:compfixer101
ID: 22726954
0
 

Author Comment

by:snakeriver
ID: 22730717
I've got the code below that others have gotten to work (Just need to modify the auth_db.php file to use my database).  When I run it, it says that the user has logged in successfully, then it redirects to the forums, but the user is NOT logged in there.

I ran this script on another hosting server, and works just fine.  Can anybody think of a reason why this wouldn't work on one hosting server versus another?  Sessions maybe?

Thanks!
<?php
    define('IN_PHPBB', true);
    $phpbb_root_path = './forums/';
    $phpEx = substr(strrchr(__FILE__, '.'), 1);
    include($phpbb_root_path . 'common.' . $phpEx);
     
    // Start session management
    $user->session_begin();
    $auth->acl($user->data);
    $user->setup();
 
    if($user->data['is_registered'])
    {
        echo "User is already logged in";
    }
    else
    {
        //$username = request_var('username', '', true);
        //$password = request_var('password', '', true);
		$username = "user";
		$password = "password";
 
        $result = $auth->login($username, $password);
 
        if ($result['status'] == LOGIN_SUCCESS)
        {
            echo "User was successfully logged into phpBB";
        }
        else
        {
            echo "User's login failed";
        }
 
    }
	
	
?>
 
 
<META http-equiv="refresh" content="2;URL=forums/">

Open in new window

0
 
LVL 13

Expert Comment

by:compfixer101
ID: 22731287
what is the difference in the servers?
different php versions?
different mysql versions?

did you purge the cache?
0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:snakeriver
ID: 22731321
Looks like the two major differences are:

Server that does NOT work:
PHP 4
Running as CGI

Server that DOES work:
PHP 5
Running as Apache module
0
 
LVL 13

Expert Comment

by:compfixer101
ID: 22731384
yeah, i would think that using php4 is the issue
Plus php.net is dropping support for php4 soon, so i highly suggest that you upgrade to version 5
0
 

Author Comment

by:snakeriver
ID: 22731440
I tried running it with PHP5 by putting a .htaccess in my main directory where the login script runs, and one in the /forums directory.  Still no luck...

Would running PHP as CGI versus module be an issue?
0
 
LVL 13

Accepted Solution

by:
compfixer101 earned 500 total points
ID: 22731680
I would assume so
http://www.phpwest.com/articles/136/Basics/Installation_of_PHP+Apache:_CGI_vs._module.html

"As it was mentioned before you SHOULD install PHP as a module for realization of functions of work with headers and authorization. Anyway, these are occurrences of the same scale. Besides that, in case of PHP as a CGI-program variable $PHP_SELF (which should save name of the script accomplished) contains everything except for name. That is not the greatest trouble which can happen but you may need to use a script of someone else in which it is widely used& It may happen that by repeated call of script on name which is contained in the variable $PHP_SELF script simply finishes its work. A beaten link. Such a pity. Maybe its possible to find some other differences but it seems to me that this difference is quite enough to make your choice in favor of a PHP-module."
0
 

Author Comment

by:snakeriver
ID: 22762623
Yeah, there is something definitely wrong with their hosting provider.  Thanks for your help.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
PHP curl issue VERBOSE output 18 87
Restricting the scope of variables to private in OOP 4 22
Link failure 16 32
simple html dom php accessing table/cell  values 4 18
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
This article discusses how to create an extensible mechanism for linked drop downs.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question