PHP Classes

mmmmmmm....it doesn't work....

Recommend this page to a friend!

      PHPBB Login Integration  >  All threads  >  mmmmmmm....it doesn't work....  >  (Un) Subscribe thread alerts  
Subject:mmmmmmm....it doesn't work....
Summary:mmmmmmm....it doesn't work
Messages:1
Author:Santissimo
Date:2008-08-02 06:55:39
 

  1. mmmmmmm....it doesn't work....   Reply   Report abuse  
Picture of Santissimo Santissimo - 2008-08-02 06:55:41
hi everyone, i'm a litle n00b and i'm looking for someone with time to spend on my prob.

i'm trying to integrate a login session for my site with phpbb 2.0.22 (Categories hierarchy 2.1.6d installed)

i wrote a simple page to try PHPBB_Login class:

//log.php file
<?php
session_start();
session_register("login");
include 'PHPBB_Login.php';
if (!isset($login)) {
if ((!isset($nickname)) && (!isset($password))) {
echo"
<form action=\"log.php\" method=\"post\">
<fieldset>
nickname:<br><input name=\"nickname\" type=\"text\" maxlength=\"20\">
<br>
<br>
password:<br>
<input name=\"password\" type=\"text\" maxlength=\"20\">
<br>
<br>
<button type=\"submit\" value=\"invia\">submit</button>
</fieldset>
</form>";
}
elseif ((isset($nickname)) && (isset($password))) {
if (($nickname != "Admin") || ($password != "password")) {
echo"error.";
}
elseif (($nickname == "Admin") && ($password == "password")) {

/* First, login the user using your own login system, for example; */
$login = 1;

// Then login the user to the forum
$phpBB = new PHPBB_Login();

$phpBB->login( 2 );
//2 is the user_id for Admin on my forum
echo"<a href=\"http://www.mysite.it/forum/\">correct</a>";
}
}
}

?>

when i give the correct parameters in log.php (nickname = Admin and password = password) the output i obtain is the following:

Warning: main(includes/class_db.php) [function.main]: failed to open stream: No such file or directory in /web/htdocs/www.mysite.it/home/forum/includes/db.php on line 67

Warning: main() [function.include]: Failed opening 'includes/class_db.php' for inclusion (include_path='.:/php/lib/php/') in /web/htdocs/www.mysite.it/home/forum/includes/db.php on line 67

Fatal error: Cannot instantiate non-existent class: db_class in /web/htdocs/www.mysite.it/home/forum/includes/db.php on line 68


i've modified the PHPBB_Login.php file in this way:

<?

/*
* PHPBB_Login allows you to integrate your own login system
* with phpBB. Meaning that you can have one login valid across
* both your website and phpBB.
*
* To take full advantage of this PHPBB_Login class you just
* need to modify your own login system to include a call
* to the relevant methods in here.
*
* This system is reliant on the website username being exactly
* the same as the phpBB username. To insure this, I recommend
* disabling the ability to change usernames from within the
* phpBB admin control panel.
*
* Distributed under the LGPL license:
* http://www.gnu.org/licenses/lgpl.html
*
* Duncan Gough
* 3rdSense.com
*
* Home http://www.suttree.com
* Work http://www.3rdsense.com
* Play! http://www.playaholics.com
*/

class PHPBB_Login {

function PHPBB_Login() {
}

function login( $phpbb_user_id ) {
global $db, $board_config;
global $HTTP_COOKIE_VARS, $HTTP_GET_VARS, $SID;

// Setup the phpbb environment and then
// run through the phpbb login process

// You may need to change the following line to reflect
// your phpBB installation.
require_once( '../../forum/config.php' );

define('IN_PHPBB',true);

// You may need to change the following line to reflect
// your phpBB installation.
require_once("../../forum/extension.inc" );
require_once("../../forum/common.php" );

return session_begin( $phpbb_user_id, $user_ip, PAGE_INDEX, FALSE, TRUE );

}

function logout( $session_id, $phpbb_user_id ) {
global $db, $lang, $board_config;
global $HTTP_COOKIE_VARS, $HTTP_GET_VARS, $SID;

// Setup the phpbb environment and then
// run through the phpbb login process

// You may need to change the following line to reflect
// your phpBB installation.
require_once( '../../forum/config.php' );

define('IN_PHPBB',true);

// You may need to change the following line to reflect
// your phpBB installation.

require_once("../../forum/extension.inc" );
require_once("../../forum/common.php" );

session_end( $session_id, $phpbb_user_id );

// session_end doesn't seem to get rid of these cookies,
// so we'll do it here just in to make certain.
setcookie( $board_config[ "cookie_name" ] . "_sid", "", time() - 3600, " " );
setcookie( $board_config[ "cookie_name" ] . "_mysql", "", time() - 3600, " " );

}

}

?>


thanks for the help and sorry for my poor english :oops: