vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=251)
-   -   identify user in a different folder then the forum (https://vborg.vbsupport.ru/showthread.php?t=287417)

ohadpartuck 09-03-2012 03:01 PM

identify user in a different folder then the forum
 
Hi,
I have a another site which is not a part of the vbulletin forum but it's located in the parent directory.
vbulletin forum => s-maof/Forum dir
another site => s-maof/aaa dir

I want to idintify users that are logged in the forum in the other site.
I have included this code:
PHP Code:

$dir  dirname(dirname(__DIR__)).'/Forum';
chdir($dir);
include 
dirname(dirname(__DIR__)).'/Forum/global.php';
print_r($arr $vbulletin->userinfo);
$userid = isset($arr['userid']) && $arr['userid'] != $arr['userid'] : -1;
echo 
"userid = " $arr['userid'];
echo 
"username = " $arr['username']; 

I get the $vbulletin->userinfo array, but I am seen as not logged in,
even though I am.

Any help?

kh99 09-03-2012 03:08 PM

Since it works using cookies, that will only work if you set "Path to Save Cookies" to "/" (should be one of the choices in the dropdown menu). That's in "Cookies and HTTP Header Options" section of the options. You might have to log out and back in again for it to take effect.

Lynne 09-03-2012 03:08 PM

You need to actually activate a session. Are you seen in the session table at all?

ohadpartuck 09-06-2012 09:39 AM

Quote:

Originally Posted by kh99 (Post 2362255)
Since it works using cookies, that will only work if you set "Path to Save Cookies" to "/" (should be one of the choices in the dropdown menu). That's in "Cookies and HTTP Header Options" section of the options. You might have to log out and back in again for it to take effect.

whouldn't that ruin my normal/Forum users.
The domain that I am talking about is in :
mydmoain.com/myFolder/app

wheras my regular vbulletin forum users are in
mydomain.com/Forum

I want to detect my users in both urls!

kh99 09-06-2012 09:57 AM

Quote:

Originally Posted by ohadpartuck (Post 2363059)
whouldn't that ruin my normal/Forum users.

It shouldn't. It should just make it so that the vbulletin cookies are sent on any request to your server, instead of being sent only if the request starts with /Forum. I think your problem is that if your custom script is in /myFolder/app, the cookies aren't being sent because it doesn't start with /Forum.

It could cause a problem if you have more than one forum installed on your server, but if you do, I think you could fix that by using a unique cookie prefix for each one.

ohadpartuck 09-06-2012 10:17 AM

Quote:

Originally Posted by kh99 (Post 2363060)
It shouldn't. It should just make it so that the vbulletin cookies are sent on any request to your server, instead of being sent only if the request starts with /Forum.

My site is live and contain many users, The configuration suggested has a warning stating
Entering an invalid setting can leave you unable to login to your forum


so i'm a little hesitent about changing it (leaving my users unable to login and me unable to change it).
isn't there another way. something like:
PHP Code:

$dir dirname(dirname(dirname(dirname(__DIR__)))) . '/Forum/';
chdir($dir);
include 
$dir .'global.php';
$arr $vbulletin->userinfo;
$userid = isset($arr['userid']) && $arr['userid'] != $arr['userid'] : -1;
echo 
"userid = " $arr['userid'];
echo 
"username = " $arr['username']; 

The $dir variable is correct and I am able to inlcude the global.php file.
(I get an empty username and id..)

kh99 09-06-2012 11:04 AM

I understand your concern, but I'm not sure what else to tell you. I think you either need to change the cookie path, or else your custom script needs to be under the /Forum directory. The issue has to do with when the user's browser decides to send the cookies, so you can't fix that by doing a chdir() in your script (because by the time your script is running, the cookies have either been sent with the request, or they weren't).

There is a file that comes with the vb distribution, in the "do not upload" folder, called tools.php. It allows you to fix certain things without neding to log in, by uploading that file to your admincp directory and then pointing your browser to admincp/tools.php (don't do it until you need it, because some other things won't work when the tools.php file is present). Anyway, one of the things it lets you do is reset the cookie path, so if you run in to a problem you should be able to fix it that way.

ohadpartuck 09-06-2012 01:27 PM

hi kh99,
I have changed the setting to 'Path to Save Cookies' to '\'
logged out and back in again.
with the browser tried this sctipt again:
PHP Code:

$dir dirname(dirname(dirname(dirname(__DIR__)))) . '/Forum/';
        
chdir($dir);
        echo 
"including" . include 'global.php';
        
print_r($arr $vbulletin->userinfo);
        
$userid = isset($arr['userid']) && $arr['userid'] != $arr['userid'] : -1;
        echo 
"userid = " $arr['userid'];
        echo 
"username = " $arr['username']; 

and got an empty username and id again.

kh99 09-06-2012 01:45 PM

Hmm...well, at least it didn't break the forum. :) So are you seeing *any* info in $vbulletin->userinfo? (edit: I see now in your first post you say you are). You could try using something like Firefox with Firebug (the net tab) and see if the cookies are being sent (I still think it might be a cookie problem).

Also, maybe try include "./global.php" (with the ./ in front). Looking at your code I think you know php much better than I do, and I don't know why it should make any difference, but I seem to remember someone else having an issue before that was fixed by adding the ./ (Edit: but now that I see where you said you *are* getting some info in $vbulletin, it must be included correctly so probably that's not it).

Edit: is the code you posted inside a function? That's another thing that doesn't work.

ohadpartuck 09-06-2012 02:41 PM

no, it's empty,
I taught it was the xcache.var_size,
so I changed it from 0M to 2M (restart apache) and tried again (no luck)..

change it to ./global.php - also nothing.

the $vbulletin->userinfo is empty.

It was in a function -->I took it out from it and now the $vbulletin->userinfo is not empty but i get
userid = 0
and
username = not registered


All times are GMT. The time now is 02:45 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.01251 seconds
  • Memory Usage 1,757KB
  • 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
  • (3)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)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