1

Topic: Integrating PunBB with website and common registration/login

I have an up and running website with nearly 40 pages. I was looking at adding PunBB forum to it.
I have a page where users can download files after login, it is a simple form. I also require users to login to use the forum. How can I use the same login?
I had considered setting up a CMS such as Drupal but it seems far too complicated although I would find a newsletter facility to all those who have registered useful.

2

Re: Integrating PunBB with website and common registration/login

I have just found this ;

Website Integration
Integrating PunBB into your website code is easy if you know a little PHP. By including PunBB's script common.php, you gain access to all PunBB global variables such as $db and $pun_user. However, in order to include this file, you need to define a constant called PUN_ROOT. This constant should be set to the relative path to your PunBB forum directory. For example, if your website front page is located in /home/user/public_html/ and your forums are located in /home/user/public_html/forums/, your PUN_ROOT should be './forums/'. The PHP code to accomplish this could look something like this:

define('PUN_ROOT', './forums/');
require PUN_ROOT.'include/common.php';Once you've included common.php, you can access and utilize all of PunBB's global variables and functions. Typically, you will be most interested in the $pun_user array. This array holds information about the current user. Another interesting variable is the database object $db. How to use these variables in your own script is out of the scope of this document, but here's a small example showing you how to print a simple message greeting the current user on your website front page:

Hello <?php echo pun_htmlspecialchars($pun_user['username']); ?>!In addition to defining PUN_ROOT, you can define a number of other constants to alter the behaviour of PunBB when including common.php. The two most interesting of these constants are PUN_TURN_OFF_MAINT and PUN_QUIET_VISIT. If PUN_TURN_OFF_MAINT is defined when including common.php, PunBB will not exit and display the maintenance message if the forums are placed into maintenance mode. You generally don't want this message to appear on your website front page, so defining that constant is a good idea. The other constant, PUN_QUIET_VISIT, prevents PunBB from updating the current user's last visit data in the database so that a visit to the front page doesn't count as a visit in the forums. This is also desirable behaviour in most cases. It doesn't matter what value you set these constants to, but setting them to a value of 1 is probably a good idea. Example:

define('PUN_TURN_OFF_MAINT', 1);
define('PUN_QUIET_VISIT', 1);Please note that these constants must be defined before common.php is included.

It sort of makes sense, but how exactly do I implement this. Where do I paste the code?

3

Re: Integrating PunBB with website and common registration/login

at the top of your file were you want it on

4

Re: Integrating PunBB with website and common registration/login

I know next to nothing about php apart from being able to upload it with FTP to the server.

Would I paste this;

define('PUN_ROOT', './forums/');
require PUN_ROOT.'include/common.php';

at the top of my html page before the DOC type and should there be some more code to go with it ?

I assume that this code will take me to the registration/login page!

Re: Integrating PunBB with website and common registration/login

alanb , look in to the wiki part at punres.org click wiki...
there alot of useful informations there.
if need help holla..

Q

My stuff or my style might sux, but atleast I'm willing to help when I can.
Don't be stupid and help ! We are the stupid one's !!!

6

Re: Integrating PunBB with website and common registration/login

I have been doing some experimenting;
I have managed to get a login form on a test page on my website. If I login here and then go the forum I am already logged in (ok), if I logout (ok).
If I now go the forum I need to login (ok), everything is ok.
The problem is redirect...
If I login using "Forum Login", obviously I am redirected to the forum.
If I login on my test page I don't necessary want to go to the forum!
I have a page which I want to allow file downloads but only if user is logged in.

Now I think I will have to combine my site with PunBB, include all my site navigation alongside the forum menu and modify the css to get it all looking the same, relatively easy. People don't naturally login unless prompted to do so, on my file download page I want a message "you must login to use this application". How do I do this?

7 (edited by quaker 2007-04-17 16:53)

Re: Integrating PunBB with website and common registration/login

search viewtopic, misc,login viewforum for redirect you will find a index i just replace index with the link you want the to go to..

login.php line 102

redirect('index.php', $lang_login['Logout redirect']);

change the index.php to anything you want...

Q

My stuff or my style might sux, but atleast I'm willing to help when I can.
Don't be stupid and help ! We are the stupid one's !!!

8

Re: Integrating PunBB with website and common registration/login

So if I was to login from the forum the redirect would take me back into the forum after logging in, but if I went to the download page and logged in I would need to redirect back to the download page? These are obviously different URLs so do I need separate login.php files, say forum_login.php and download_login.php, and choose the appropriate redirect URL.

Re: Integrating PunBB with website and common registration/login

how about doing a login to the index and links to the download files.
Q

My stuff or my style might sux, but atleast I'm willing to help when I can.
Don't be stupid and help ! We are the stupid one's !!!

10

Re: Integrating PunBB with website and common registration/login

You mean after login you are redirected back to the "homepage" where you can navigate wherever? i.e.forum, downloads etc. (There are about 30 files available for download)

How would I get the message "you need to login before you can do this" message?

11

Re: Integrating PunBB with website and common registration/login

there is a script that you can add to the top of the page  err search the punbb for it


http://modelcrowd.com is my site i have a file directory for people to download stuff..

im looking for that script for you
Q

My stuff or my style might sux, but atleast I'm willing to help when I can.
Don't be stupid and help ! We are the stupid one's !!!

12

Re: Integrating PunBB with website and common registration/login

I have added this snippet into my index.php file at the beginning;

if ($pun_user['is_guest'])
redirect('login.php', 'Redirecting to login page...');

So if I am not logged in and i go to the forum I am taken to the login page...

I could instead put a message;

message("You must login to use this application");

once logged in all seems ok.

when I logout I'm not sure if there are any problems.

13

Re: Integrating PunBB with website and common registration/login

kewl so far is it working right for you?
can u give me a link?
Q

My stuff or my style might sux, but atleast I'm willing to help when I can.
Don't be stupid and help ! We are the stupid one's !!!