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

Home » FUDforum Development » Plugins and Code Hacks » A question about FUD API
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
A question about FUD API [message #20554] Tue, 19 October 2004 14:37 Go to next message
JamesS is currently offline  JamesS   United States
Messages: 275
Registered: July 2002
Location: Atlanta, GA
Karma: 0
Senior Member
My board is still running 2.5.2 for various reasons that were discussed a long time ago. However, I am now considering upgrading to the "latest and greatest" version and am reading through all the announcements since 2.5.2. I have noticed that an API was introduced. This has piqued my interest because I have already written a gallery application that works in conjuction with 2.5.2 which only allows registered, logged in, users to use it.

My question is, does the API provide a way to see if a user is logged in? I am currently using the FUD cookies to determine this but if I can do it via the API that would be great; I could then rewrite my gallery to do some much cooler things than it currently does.
Re: A question about FUD API [message #20555 is a reply to message #20554] Tue, 19 October 2004 14:50 Go to previous messageGo to next message
Abraxa is currently offline  Abraxa   Germany
Messages: 72
Registered: August 2004
Location: Germany
Karma: 0
Member
From what I understand the constant __fud_real_user__ is set if a forum member is logged in when requesting that page:

if (__fud_real_user__) {
		is_allowed_user($usr);
	} else {
		std_error('login');
	}


I'm not sure when that constant was introduced but seeing how it's so essential I assume that it should be existing in your version, too.

Out of curiosity: I have plans to integrate a gallery into my forums as well - would it be possible for me to see what your gallery looks like and what functions it has?

-Soeren

[Updated on: Tue, 19 October 2004 14:51]

Report message to a moderator

Re: A question about FUD API [message #20556 is a reply to message #20554] Tue, 19 October 2004 14:54 Go to previous messageGo to next message
JamesS is currently offline  JamesS   United States
Messages: 275
Registered: July 2002
Location: Atlanta, GA
Karma: 0
Senior Member
There is not an API per se in 2.5.2 other than what you invent yourself. So, checking the cookies was the easiest route.

If you want to you can sign up at http://ug.dyndns.org/forum/ and take a look around.
Re: A question about FUD API [message #20557 is a reply to message #20554] Tue, 19 October 2004 15:15 Go to previous messageGo to next message
Abraxa is currently offline  Abraxa   Germany
Messages: 72
Registered: August 2004
Location: Germany
Karma: 0
Member
Well the code I took isn't from FUDAPI, it's merely taken from ie. pmsg.php.t (other template scripts check that constant, too) - so seeing how it's an essential part of the forum you should be able to use it, too Smile

And thanks for the link, I'm gonna check it out =)

-Soeren
Re: A question about FUD API [message #20558 is a reply to message #20554] Tue, 19 October 2004 15:36 Go to previous messageGo to next message
JamesS is currently offline  JamesS   United States
Messages: 275
Registered: July 2002
Location: Atlanta, GA
Karma: 0
Senior Member
I don't use the FUD template system and I don't include any FUD source in the gallery. I determined how FUD expires a cookie, and sets a cookie for anonymous users, and query FUD's session table in the database to determine if the user should be allowed to access the gallery. It is a poor hack and one that I would love to fix.

Another thing I need to know is if the API can tell me if the user browsing is an admin or not.
Re: A question about FUD API [message #20560 is a reply to message #20558] Tue, 19 October 2004 15:55 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
The api has a function fud_fetch_online_users() that will return an list of online users, if you wanted to see if any of those users was an admin you'd need to add another field to the query.

Alternatively you can use another function, fud_fetch_user() to fetch complete user information about 1 or more users.

__fud_real_user__ is a define unrealted to FUDAPI that tells the forum whether this is a registered user. Another define, _uid will tell you if this is a authorized registered users which is not pending approval, e-mail confirmation or coppa.


FUDforum Core Developer
Re: A question about FUD API [message #20565 is a reply to message #20554] Tue, 19 October 2004 16:57 Go to previous messageGo to next message
JamesS is currently offline  JamesS   United States
Messages: 275
Registered: July 2002
Location: Atlanta, GA
Karma: 0
Senior Member
It is quite probable that I am going to upgrade so I will be able to look at this first hand soon. The introduction of a an API was a very good idea and has renewed my interest in this project quite a bit.
Re: A question about FUD API [message #20681 is a reply to message #20554] Mon, 25 October 2004 20:26 Go to previous messageGo to next message
JamesS is currently offline  JamesS   United States
Messages: 275
Registered: July 2002
Location: Atlanta, GA
Karma: 0
Senior Member
Have you tested fud_fetch_online_users()? I am coming to the conclusion that it returns a valid object if there is only one person online but an invalid object if there is more than one.
Re: A question about FUD API [message #20682 is a reply to message #20681] Mon, 25 October 2004 20:30 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
If there is >1 online user it will return an array of objects, each object representing a currently online user.

FUDforum Core Developer
Re: A question about FUD API [message #20721 is a reply to message #20554] Tue, 26 October 2004 14:30 Go to previous messageGo to next message
JamesS is currently offline  JamesS   United States
Messages: 275
Registered: July 2002
Location: Atlanta, GA
Karma: 0
Senior Member
Give this a try:

<?php
include('forum/GLOBALS.php');
include(
'forum/scripts/fudapi.inc.php');

$online_users = fud_fetch_online_users();

/* Works just fine when only one user logged in. */
print('<pre>'); print_r($online_users); print('</pre>');

/* Works just fine when only one user logged in.
   Returns an invalid argument when >1.
foreach ( $online_users as $key => $val ) {
        print($key . '[' . $val . ']<br>');
}*/

/* Interesting results when >1 user logged in. */
print('Serialized: '. serialize($online_users));
?>
Re: A question about FUD API [message #20722 is a reply to message #20721] Tue, 26 October 2004 14:40 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're right there was a bug in there...
Here is the fix:
http://cvs.prohost.org/c/index.cgi/FUDforum/chngview?cn=3060


FUDforum Core Developer
Re: A question about FUD API [message #20723 is a reply to message #20554] Tue, 26 October 2004 14:47 Go to previous message
JamesS is currently offline  JamesS   United States
Messages: 275
Registered: July 2002
Location: Atlanta, GA
Karma: 0
Senior Member
Much better Smile
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: another proposal: use DB to store post messages
Next Topic: the login procedure
Goto Forum:
  

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

Current Time: Sat May 18 21:54:44 GMT 2024

Total time taken to generate the page: 0.02212 seconds