Hey,
I posted this on PHP freaks but all they did was move my post around and not reply to it so I am here now. I have been trying to get an integrated login with invisionboard to work forever!!! I cannnot seem to get it to work in that I need to create a session that matches the one the invision sets. I need to know what I am doing wrong, it is something with the object.
This is my script:
<?
session_start();
include("./forum/sources/functions.php");
//var_dump($_POST);
//var_dump($_SESSION);
//exit;
if (isset($_SESSION['db_is_logged_in']))
{
echo ("<center>Welcome <b> {$_SESSION['username']}</b>");
echo ("<br><center><a href=\"logout.php\">LogOut</a></center>");
exit;
}
else
{
$loginSuccess = false;
if (isset($_POST['UserName']) && isset($_POST['PassWord']))
{
include_once('config2.php');
$userId = $_POST['UserName'];
$password = $_POST['PassWord'];
$password2 = md5($password);
// check if the user id and password combination exist in database
$sql = "SELECT mgroup, id FROM ibf_members WHERE name = '$userId' AND password = '$password2'";
$result = mysql_query($sql) or die('Query failed. ' . mysql_error());
if( mysql_num_rows($result) == 1 )
{
//print("<h1>Got here</h1>");
//exit;
// the user id and password match,
if( $row = mysql_fetch_object($result) )
{
// set the session
$loginSuccess = true;
$_SESSION['db_is_logged_in'] = true;
$_SESSION['memberId'] = $row->id;
$_SESSION['username'] = $userId;
setcookie("UserName", $userId, time()+720000000);
setcookie("pass_hash", $password2, time()+720000000);
setcookie("member_id", $_SESSION['memberId'], time()+720000000);
$session = new session();
$the_session_id = $session->create_member_session();
setcookie("session_id", $_SESSION['the_session_id'], time()+720000000);
if( $row->mgroup == "4" )
$_SESSION['admin_is_logged_in'] = true;
}
mysql_free_result($result);
}
else
RedirWithError('Invalid Login', 'index.php');
}
else
{
RedirWithError('', 'index.php');
}
if( $loginSuccess )
RedirWithError('Login Successful', 'index.php');
else
RedirWithError('Login Failed', 'index.php');
}
function RedirWithError( $iErrorMessage, $iRedirURL )
{
$_SESSION["errMsg"] = trim($iErrorMessage);
header("Location: $iRedirURL");
exit;
}
?>
This is the script that I am using for the function. It is included in the forum's functions.php file.
<? <? function create_member_session()
{
global $DB, $INFO, $std, $ibforums;
if ($this->member['id'])
{
//---------------------------------
// Remove the defunct sessions
//---------------------------------
$INFO['session_expiration'] = $INFO['session_expiration'] ? (time() - $INFO['session_expiration']) : (time() - 3600);
$DB->query( "DELETE FROM ibf_sessions WHERE running_time < {$INFO['session_expiration']} or member_id='".$this->member['id']."'");
$this->session_id = md5( uniqid(microtime()) );
//---------------------------------
// Insert the new session
//---------------------------------
$DB->query("INSERT INTO ibf_sessions (id, member_name, member_id, ip_address, browser, running_time, location, login_type, member_group) ".
"VALUES ('".$this->session_id."', '".$this->member['name']."', '".$this->member['id']."', '".$this->ip_address."', '".$this->user_agent."', '".$this->time_now."', ".
"',,', '".$ibforums->input['Privacy']."', ".$this->member['mgroup'].")");
// If this is a member, update their last visit times, etc.
if (time() - $this->member['last_activity'] > 300)
{
//---------------------------------
// Reset the topics read cookie..
//---------------------------------
$std->my_setcookie('topicsread', '');
$DB->query("UPDATE ibf_members SET last_visit=last_activity, last_activity='".$this->time_now."' WHERE id='".$this->member['id']."'");
//---------------------------------
// Fix up the last visit/activity times.
//---------------------------------
$ibforums->input['last_visit'] = $this->member['last_activity'];
$ibforums->input['last_activity'] = $this->time_now;
}
}
else
{
$this->create_guest_session();
}
}?>
This is the error I get:
Fatal error: Call to a member function on a non-object in c:\easyphp\www\forum\sources\functions.php on line 2986
I am new to classes and that sort of thing. Can you see anything I am doing wrong?