vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Requests/Questions (Unpaid) (https://vborg.vbsupport.ru/forumdisplay.php?f=112)
-   -   Site-wide integration (https://vborg.vbsupport.ru/showthread.php?t=69540)

paulmjno 09-16-2004 10:55 PM

Site-wide integration
 
Hello,

I am moving from phpBB to vB, which I just purchased. I had a script for my phpBB which allowed me to display user information on any page on my website, and allowed users to login on any page of my website. With this script I could write my own little scripts, like:

if (user is logged in) {
do this
} else {
do this
}

The script also allowed me to retreive the users name if they were logged on. Does anything like this exist for vB?

Thank you. :)

Dark_Wizard 09-16-2004 11:51 PM

Yes it does...you may also want to check out vBAdvanced CMS

paulmjno 09-17-2004 12:08 AM

Quote:

Originally Posted by Dark_Wizard
Yes it does...you may also want to check out vBAdvanced CMS

It does, where? And vBAdvanced CMS isn't what I want, that is a portal-type system. This script I could simply include on any PHP page on my site.

paulmjno 09-17-2004 12:57 AM

<a href="http://www.ajquick.com/programming/phpbb/tutorial/" target="_blank">Here</a> is the script I used.

Tekton 09-17-2004 02:13 AM

If you include vB's global.php on your php page, it basically does what you're looking for I'm pretty sure.
PHP Code:

// Near or at the begining of the php file
require_once('./global_stock.php'); 

Then something like this....
PHP Code:

if ($bbuserinfo['userid']){
// If they are logged in, then do this
//stuff here
}
else{
// If they aren't logged in, do something else here.


.... furthermore... (correct me if I'm wrong), but you can do a check to see if someone ISN'T logged in by adding an exclamation mark...
PHP Code:

if (!$bbuserinfo['userid']){




paulmjno 09-17-2004 02:28 AM

Hey Tekton, that works. :) Is there any way to retreive the users username if they are logged in?

Tekton 09-17-2004 02:48 AM

Quote:

Originally Posted by paulmjno
Hey Tekton, that works. :) Is there any way to retreive the users username if they are logged in?

$bbuserinfo[username]

Not sure if you need the quotes like 'username'; I can't remember off-hand.

By the way, if you didn't know this is an interesting fact. You can user the $bbuserinfo[] on ANY field in your database's user table.

$bbuserinfo[posts]
$bbuserinfo[ipaddress]
$bbuserinfo[gold]
etc...

Just in case you wanted to know! ^__^;;

paulmjno 09-17-2004 02:50 AM

Tekton, thanks alot! Now I can display all sorts of user information on any page of my site when the user is logged in. :)

Tekton 09-17-2004 03:02 AM

No problem :) It's all done already in the global file, so no use running any unnecessary queries to get that data at least. Good luck!

paulmjno 09-17-2004 12:39 PM

I spotted a problem. It will display the users information even if they have not been activated by a moderator. Is there a way to write a test as to whether the user is actually active and logged in?

Edit: I guess I should say, can I write a test script if the user is apart of the "awaiting moderation" usergroup?

Tekton 09-17-2004 06:22 PM

?
PHP Code:

if ($bbuserinfo['userid'] && $bbuserinfo['usergroupid'] == x){ 



Or use not equal to if you want it to work for all EXCEPT.

paulmjno 09-17-2004 07:16 PM

Tekton, great! And will this be OK if the user is apart of multiple usergroups, it won't interfere?

Colin F 09-17-2004 08:03 PM

If the user is a member of multiple usergroups, Tektons code only checks the primary usergroup.
You'd have to use is_member_of(), but I'm not sure about the syntax.

about the (!$bbuserinfo['userid']), that should work, but iirc the userid is set to 0 if the user is a guest, so don't go using isset($bbuserinfo[userid])!!!

Brad 09-17-2004 08:23 PM

Your right $bbuserinfo['userid'] will report 0 or false if the user is a guest.

A note about is_member_of, use this function as apose to just a primary usergroup check as this function will do it anyway.

Correct syntax:

PHP Code:

$uid is_member_of($bbuserinfo6); // checks if member is in usergroupid 6 (admin) 

The $bbuserinfo var must contain at least the userid, the primary usergroupid, and the membergroupids. The second var (6 in this case, we'll call it the 'usergroup seek' var) must be a vaild usergroupid.

is_member_of(); will return true if the user belongs to a primary group that matches the usergroup seek var. If the user is not a member of the primary group, then the function will look at the membergroupids the user belongs to (secondary usergroups), if a match is found the function will return true.

In all other cases it will return false.

paulmjno 09-17-2004 10:44 PM

Hey! Thanks for the help guys! That is perfect. :)

paulmjno 09-17-2004 11:14 PM

Guys, I whipped up this script to test whether a user is logged in, and if so, if they are active.
PHP Code:

<?
require_once('./global.php'); 
if ($bbuserinfo['userid']) { 
$awaiting = is_member_of($bbuserinfo, 4);
$unreg = is_member_of($bbuserinfo, 1);
$mailconfirm = is_member_of($bbuserinfo, 3);
    if ((!$awaiting) && (!$unreg) && (!$mailconfirm)) {
    print "Logged in! Welcome " . $bbuserinfo['username'] . "!";
    } else {
    print "Your account is not currently active. It may be awaiting confirmation from the administrator, or it may be awaiting email confirmation from yourself.";
    }

else { 
print "Not logged in!";

?>

I'm sure it could be written much better, but this works. :)


All times are GMT. The time now is 05:54 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01077 seconds
  • Memory Usage 1,758KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (6)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (16)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete