Hi there,
I am trying to implement the below script to automate the process of logging into phpbb and am still getting
problems with header files.. I'm sure its simple maybe someone could take a look?
Code is as follows:
Index3.html: -> Where i'm taking in the username and password
Login3.php -> Where i'm calling the PHPBB_Login classes
PHPBB_Login3.php -> The modified PHPBB_Login class as posted here..
Getting the following errors
Warning: Cannot modify header information - headers already sent by (output started at c:\easyphp\www\test\includes\PHPBB_login2.php:172) in c:\easyphp\www\test\forum\includes\sessions.php on line 258
Warning: Cannot modify header information - headers already sent by (output started at c:\easyphp\www\test\includes\PHPBB_login2.php:172) in c:\easyphp\www\test\forum\includes\sessions.php on line 259
Warning: Cannot modify header information - headers already sent by (output started at c:\easyphp\www\test\includes\PHPBB_login2.php:172) in c:\easyphp\www\test\login_test\login3.php on line 26
Any help greatly appreciated..
Ps. I've tryed commenting out the header line in login3.php but i still get the same errors...
index3.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<?
include '../includes/header.php';
?>
<table border="0" cellspacing="5" cellpadding="5">
<tr>
<td class="left" width="114" height="22" align="left" valign="top"><? include '../includes/menu.php'; ?></p></td>
<td class="centrearea" width="598" align="left" valign="top">
<div id='middle'>
<?php
?>
<p>Please login using your BlastBeat Login below:</p></h3>
<form action="login3.php" method="POST">
<table align="center" border="0">
<tr>
<th><div align="left">
Username:
</div></th>
<th>
<div align="left">
<input name="username" type="text" id="username">
<br>
</div></th>
</tr>
<tr>
<th>
<p align="left">Password<em> (case sensitive)</em>:</p>
</th>
<th>
<div align="left">
<input name="user_password" type="password" id="user_password">
</div></th>
</tr>
<tr>
<th colspan="2" align="right">
<div align="left">
<input type="submit" value="Submit">
</div>
</form>
<p> </p>
<p> </p>
</body>
</html>
login3.php
<?php
/* Example 1: Logging in place in your pages
*/
$username = $_POST['username'];
$user_password = $_POST['user_password'];
require_once( '../includes/PHPBB_login2.php');
//include( "./login.php");
//session_start();
/* First, login the user using your own login system, for example; */
$user = new User();
// Then login the user to the forum
$phpBB = new PHPBB_Login();
$user->login( $username, $user_password );
$phpBB->login( $user->id );
header("Location: ". "../includes/header.php");
?>
And finally PHPBB_Login2.php
<?php
// Define Your User class
// User has a method called login
class User {
function login($username,$password) {
/*
Process $username, $password and ID here
Note that phpbb is currently using md5 encryption for passwords
If your members area is not encrypted then you can do a straight replacement
of "password" with your value or var.
Otherwise you will need to decrypt your password and convert it to md5 hash.
other encryption types are sha1, mhash and md5
*/
$password = md5( "password" );
$username = "cFemailforfun";
$user_id = 19;
$this->id = $user_id;
}
}
class PHPBB_Login {
function PHPBB_Login() {
}
function login( $phpbb_user_id ) {
define('IN_PHPBB',true);
// You may need to change the following line to reflect
// your phpBB installation.
$phpbb_root_path = "../forum/";
global $db, $board_config;
global $HTTP_COOKIE_VARS, $HTTP_GET_VARS, $SID;
// Setup the phpbb environment and then
// run through the phpbb login process
require_once( $phpbb_root_path . "config.php" );
require_once( $phpbb_root_path . "extension.inc" );
require_once( $phpbb_root_path . "common.php" );
return session_begin( $phpbb_user_id, $user_ip, PAGE_INDEX, FALSE, TRUE );
}
function logout( $session_id, $phpbb_user_id ) {
define('IN_PHPBB',true);
// You may need to change the following line to reflect
// your phpBB installation.
$phpbb_root_path = "../forum/";
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( $phpbb_root_path . "config.php" );
require_once( $phpbb_root_path . "extension.inc" );
require_once( $phpbb_root_path . "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, " " );
}
}//-- END of All Classed needed to loging / logout a user
?>