Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 02-12-2006, 04:41 AM
ShayA ShayA is offline
 
Join Date: Feb 2006
Posts: 18
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default How do you check if a user is already login (API)?

I have integrated VB in my website.
I imported all user to VB and use the VB login process whenever its necessary.

My question is how do you check if a user is already logged in (outside the VB script scope)?
Is there any VB API for that?

Thanks,
Reply With Quote
  #2  
Old 02-12-2006, 07:55 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

First include global.php to load the vB environment, then check if $vbulletin->userinfo['userid'] > 0
Reply With Quote
  #3  
Old 02-12-2006, 08:04 AM
ShayA ShayA is offline
 
Join Date: Feb 2006
Posts: 18
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you very much.
I tried that and I have a problem with it:

The folder structure is like that

web homepage
web/forum VB

I need to call the include in the "web" folder.
When I do so I get an error:
Warning: main(*****\web/includes/init.php): failed to open stream: No such file or directory in ****\web\forum\global.php on line 20

Is there an API interface for VB where I can get that info?

On the same subject.
Can I get from this array the user statistics. Meaning when he was last logged in, if he has unread private message, How many post he has.

If not, where I can get that info.

Thank you.
Reply With Quote
  #4  
Old 02-12-2006, 08:35 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by ShayA
I need to call the include in the "web" folder.
When I do so I get an error:
Use the following snippet:
PHP Code:
......
chdir('./forum');
require_once(
'./global.php');
...... 
Quote:
Originally Posted by ShayA
Is there an API interface for VB where I can get that info?
You can find the official documentation in the API reference in the member area at vb.com. Also have a look in our vB3.5 Tutorial section. Most things are covered in there.

Quote:
Originally Posted by ShayA
On the same subject.
Can I get from this array the user statistics. Meaning when he was last logged in, if he has unread private message, How many post he has.
Yes all that info you can find in the $vbulletin->userinfo array. For non-user information, see the rest of the $vbulletin object.
Reply With Quote
  #5  
Old 02-12-2006, 08:51 AM
ShayA ShayA is offline
 
Join Date: Feb 2006
Posts: 18
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Unfortunately I get an error.
I created a test.php file. placed on the root folder.
In that file:
PHP Code:
chdir('./forum');
require_once(
'./global.php'); 
When I run it I get an error
Quote:
Unable to add cookies, header already sent.
File: ****\web\forum\includes\class_core.php
Line: 1906
BTW, I looked at the API. Is there a way to downloaded it.
Any code samples ?

Thanks,
Reply With Quote
  #6  
Old 02-12-2006, 09:02 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by ShayA
When I run it I get an error
This means that you already have some output, global.php must be called before anything is sent.
Quote:
Originally Posted by ShayA
BTW, I looked at the API. Is there a way to downloaded it.
Any code samples ?
Not sure if it is downloadable. You can find coding examples in our Tutorial section, or by looking at hacks all around this board.
Reply With Quote
  #7  
Old 02-12-2006, 09:09 AM
ShayA ShayA is offline
 
Join Date: Feb 2006
Posts: 18
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by MarcoH64
This means that you already have some output, global.php must be called before anything is sent.
I know what it means, but as you can see above, nothing on the file but those 2 lines.
Could be that the chdir() send output to the user side?
Reply With Quote
  #8  
Old 02-12-2006, 09:18 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try the following code, it should not give you any errors:
PHP Code:
<?php
error_reporting
(E_ALL & ~E_NOTICE);
chdir('./forum');
require_once(
'./global.php');
echo 
"<br />Userid: " $vbulletin->userinfo['userid'];
?>
Reply With Quote
  #9  
Old 02-13-2006, 04:32 AM
ShayA ShayA is offline
 
Join Date: Feb 2006
Posts: 18
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I think I found the problem.

Few days ago I was looking for a way to include a custom header using php include.
I was told that the best way is to define a new plug-in and to call it on global_start. This is what I did
PHP Code:

ob_start
();
include(
'../header_top.php');
$my_header ob_get_contents(); 
ob_end_clean(); 
Then on the header template I call the $my_header variable.
I am guessing that the ob_get_contents() causing this problem.

So back to start.
How do I include a php file not using this method.

Thanks,

anyone can help on this please ?
Reply With Quote
  #10  
Old 03-03-2006, 12:38 PM
hidjra hidjra is offline
 
Join Date: Jan 2002
Location: Amsterdam
Posts: 48
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

try this
PHP Code:
$my_header implode(""file("../header_top.php"));
echo 
$my_header
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:26 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.03918 seconds
  • Memory Usage 2,261KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (5)bbcode_php
  • (7)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete