vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   How do you check if a user is already login (API)? (https://vborg.vbsupport.ru/showthread.php?t=107764)

ShayA 02-12-2006 04:41 AM

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,

Marco van Herwaarden 02-12-2006 07:55 AM

First include global.php to load the vB environment, then check if $vbulletin->userinfo['userid'] > 0

ShayA 02-12-2006 08:04 AM

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.

Marco van Herwaarden 02-12-2006 08:35 AM

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.

ShayA 02-12-2006 08:51 AM

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,

Marco van Herwaarden 02-12-2006 09:02 AM

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.

ShayA 02-12-2006 09:09 AM

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?

Marco van Herwaarden 02-12-2006 09:18 AM

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'];
?>


ShayA 02-13-2006 04:32 AM

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 ?

hidjra 03-03-2006 12:38 PM

try this
PHP Code:

$my_header implode(""file("../header_top.php"));
echo 
$my_header



All times are GMT. The time now is 03:35 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.01056 seconds
  • Memory Usage 1,747KB
  • 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
  • (5)bbcode_php_printable
  • (7)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete