FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum » How To » Using fudforum throughout a website  () 1 Vote
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
Using fudforum throughout a website [message #9565] Thu, 10 April 2003 04:01 Go to next message
philip is currently offline  philip   United States
Messages: 21
Registered: December 2002
Karma: 0
Junior Member
I'd like to use fudforum's authentication throughout a website but not include tons of fudforum code everywhere. Ideally it will involve a simple include, and keep visitors properly authenticated. Basically I need a simple auth function, and a way to get the sid. Cookies are properly set (path = '/', domain = .me.com).

Has someone else done this or must I spend some time staring at fudforum code until figured it out? :)
Re: Using fudforum throughout a website [message #9619 is a reply to message #9565] Sun, 13 April 2003 15:00 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
Hmm...

Well, 1st thing you need to modify Cookie Path setting and make the path '/' so that the forum's cookie can be read from anywhere on your site.
Then you need to include
db.inc
err.inc
users.inc
cookies.inc

In your script, user will be automatically authenticated if they have a cookie or have a session passed via get, otherwise they will be 'initialized' as anon users. You can access the session id via a 'S' define.


FUDforum Core Developer
Re: Using fudforum throughout a website [message #9718 is a reply to message #9619] Tue, 15 April 2003 22:59 Go to previous messageGo to next message
philip is currently offline  philip   United States
Messages: 21
Registered: December 2002
Karma: 0
Junior Member
I've started this process and here's what I have thus far, this might help people in the future or perhaps be streamlined by someone but it appears all these files are required. This is just a simple example:

<?php 
include_once '/path/to/your/GLOBALS.php';
include_once 
$DATA_DIR 'sql/mysql/db.inc';
include_once 
$INCLUDE  'core.inc';
include_once 
$INCLUDE  'theme/default/err.inc';
include_once 
$INCLUDE  'theme/default/cookies.inc';
include_once 
$INCLUDE  'theme/default/time.inc';
include_once 
$INCLUDE  'theme/default/users.inc';

// Initiate user, returns an array of objects with user info
$userinfo init_user();

echo 
"Visit the <a href='{$WWW_ROOT}?S=" "'>forum</a>
"
;

// Only logged in users have $userinfo[1] set
if (empty($userinfo[1])) {
    include_once 
$INCLUDE 'theme/default/quicklogin.inc';
    print 
$quick_login;
} else {
    print 
'You are logged in as ' $userinfo[1]->alias;
    print 
'<pre>';
    
print_r($userinfo);
}
?>
Re: Using fudforum throughout a website [message #9719 is a reply to message #9718] Tue, 15 April 2003 23:14 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
Few issue with this code, GLOBALS.php will automatically include core.inc, so including it manually is not necessary.
core.inc has a nice function called fud_use() that can be used to include forum's .inc file.
users.inc will automaticall initialize the user and store the data inside $usr variable unless the 'forum_debug' constant is defined.
So the code could be simplified to:
<?php 
include_once '/path/to/your/GLOBALS.php';
fud_use('db.inc');
fud_use('err.inc');
fud_use('cookies.inc');
fud_use('time.inc');
fud_use('users.inc');
$userinfo $usr;

if (!
_uid) {
    
fud_use('quicklogin.inc');
    print 
$quick_login;
} else {
/* registered user stuff */
}
?>


FUDforum Core Developer
Re: Using fudforum throughout a website [message #9721 is a reply to message #9719] Tue, 15 April 2003 23:28 Go to previous messageGo to next message
philip is currently offline  philip   United States
Messages: 21
Registered: December 2002
Karma: 0
Junior Member
Ahh, very nice and good to know, thank you! :)
Re: Using fudforum throughout a website [message #16666 is a reply to message #9719] Wed, 11 February 2004 01:17 Go to previous messageGo to next message
WhiteFire is currently offline  WhiteFire   United States
Messages: 16
Registered: March 2002
Karma: 0
Junior Member
Unless I'm mistaken defining user_reg should cause users.inc to load the extended version of the fud_user, thus giving access to things like the avatar_loc... but, I can't seem to get that to work?
Re: Using fudforum throughout a website [message #16669 is a reply to message #16666] Wed, 11 February 2004 03:58 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
You need to create fud_user_reg class.

FUDforum Core Developer
Re: Using fudforum throughout a website [message #16676 is a reply to message #16669] Wed, 11 February 2004 23:06 Go to previous messageGo to next message
WhiteFire is currently offline  WhiteFire   United States
Messages: 16
Registered: March 2002
Karma: 0
Junior Member
Ok, after the code you provide before, I'm trying to do the following:

$userinfo = $usr;

fud_use('users_reg.inc');
$moreinfo = new fud_user_reg;
$moreinfo->get_user_by_id($usr->id);

fud_use('users_adm.inc');
$moremoreinfo = new fud_user_adm;
$moremoreinfo->get_user_by_id($usr->id);


$moreinfo and $moremoreinfo do not contain anything in the fields for, say, avatar_loc (the one I'm after), though they have everything I see in $usr.

Re: Using fudforum throughout a website [message #16678 is a reply to message #16676] Thu, 12 February 2004 03:10 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
all you need is this:

<?php
fud_use
('users_reg.inc')
$usr_info =& usr_reg_get_full($usr->id);
?>


FUDforum Core Developer

[Updated on: Thu, 12 February 2004 03:11]

Report message to a moderator

Re: Using fudforum throughout a website [message #16689 is a reply to message #9565] Thu, 12 February 2004 22:52 Go to previous message
WhiteFire is currently offline  WhiteFire   United States
Messages: 16
Registered: March 2002
Karma: 0
Junior Member
Ahh!

Thanks for putting up with my ignorant questions, BTW. Wink
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: How to display latest post/topic on another page
Next Topic: CHANGE MY HOME URL??
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Sep 20 04:29:19 GMT 2024

Total time taken to generate the page: 0.02904 seconds