Re: Login integration: Logging in on an existing site and punBB

Sounds like there's some whitespace where there shouldn't be.

27 (edited by giil 2008-02-06 12:14)

Re: Login integration: Logging in on an existing site and punBB

Correct.

There was one space before my  <?php tag

Thanks

28

Re: Login integration: Logging in on an existing site and punBB

Okay here is my questions:

First Smartys how do I integrate the dblayer command (I know I'm dumb but I can't seem to wrap my head around this code at all) I've tried the login (from waaay back) that exists but that wont work for me at all.

Secondly I'm guessing that I can use this in a method post call right?

Please disregard any of this if it makes no sense tongue

Re: Login integration: Logging in on an existing site and punBB

You have to be more specific about what you're trying to do and what you want to know or I can't help you smile

30

Re: Login integration: Logging in on an existing site and punBB

Well here is the thing: I've used Punbb since god knows when, and I want my webpage to have a login and a register on the mainpage. I've tried the other script that has been here for a while but that just don't work.

So what I really need is a easy guide and some nice copy-pasta code that I can use. But To learn more I just want to know how to use the dblayer in a file were I've called for common.php I know php (a fairly small bit) and I know how to connect to a db but I want it secure and i certainly don't want alot of connect to db scripts lying around in my webfolder if I can call the db with a simple $dblayer function?

31

Re: Login integration: Logging in on an existing site and punBB

Including common.php opens the connection to the database so you should not have to do it again

32

Re: Login integration: Logging in on an existing site and punBB

Okay so just check in what the tables are and such?

33

Re: Login integration: Logging in on an existing site and punBB

http://punbb.org/docs/dev.html

Re: Login integration: Logging in on an existing site and punBB

zentropy wrote:

Furthermore for people who will stumble upon this thread and try to accomplish the same, here is the full working code


Thanks a bunch for this, but where does this code go? Is this the new login.php? Or where should I put it? I am trying to integrate the existing login of our site with punbb. Thanks!

35

Re: Login integration: Logging in on an existing site and punBB

I know this is bringing up an old post, but I'm hoping someone can help me.  This is the code I've posted into my login.php:

define('FORUM_ROOT', './punbb/');
include 'punbb/include/common.php';    //Include this file so that $pun_user['is_guest'] can be used and that (some?) functions from punbb/include/functions.php can also be used in this script


if (($websitelogin==true) && ($pun_users['is_guest'])) {
    
    $username = $user->Username;  //Get the username of the logged in user and put it in a variable     ($user->Username comes from code from the website which is intended to get login integration with punbb through this script)
    
    $queryFromPunbb = "SELECT * FROM pun_users WHERE username='$username'";    //get the row with the id from the logged in user. This id is the primary key of the punbb_users table in the punbb database
    $result = mysql_query($queryFromPunbb, $conn) or die (mysql_error());    //Run the query
    $row = mysql_fetch_array($result) or die(mysql_error());    //Put the result of the query in an array called $row  
    
    $user_id = $row['id'];    //Put the id from the $row array into the variable $user_id
    $hashedPassword = forum_hash($user->password);    //hash the user's password using the punbb hash function 
    $expirationTime = time()+24*60*60;
    
    forum_setcookie($user_id, $hashedPassword, $expirationTime);  //Set the punBB cookie, which is called punbb_cookie
    

header("Location: ./punbb"); //send the browser to the /punbb directory
}
elseif (($websitelogin==true) && !($pun_users['is_guest'])) {
    header("Location: ./punbb"); //send the browser to the /punbb directory
}
elseif (!($websitelogin) && ($pun_users['is_guest'])) {
    header("Location: ./punbb"); //send the browser to the /punbb directory
}

When I login from my site, it returns the following error:

Fatal error: Call to a member function escape() on a non-object in /home/clistaff/celebratelife.org/punbb/include/functions.php on line 1350

Any thoughts?  I'm using v. 1.3

Thanks.

36

Re: Login integration: Logging in on an existing site and punBB

First of all, I think, you need to check the file paths.

37

Re: Login integration: Logging in on an existing site and punBB

Slavok wrote:

First of all, I think, you need to check the file paths.

Slavok,

Checked the file paths, but couldn't find anything out of order.  What stood out to you?  I had to adapt this code for 1.3, hence the reason I changed the PUN_ROOT to FORUM_ROOT, etc.

Re: Login integration: Logging in on an existing site and punBB

I to am recieving this error