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

Reply
 
Thread Tools Display Modes
  #1  
Old 09-03-2012, 03:01 PM
ohadpartuck ohadpartuck is offline
 
Join Date: Mar 2012
Posts: 138
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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?
Reply With Quote
  #2  
Old 09-03-2012, 03:08 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #3  
Old 09-03-2012, 03:08 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You need to actually activate a session. Are you seen in the session table at all?
Reply With Quote
  #4  
Old 09-06-2012, 09:39 AM
ohadpartuck ohadpartuck is offline
 
Join Date: Mar 2012
Posts: 138
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
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!
Reply With Quote
  #5  
Old 09-06-2012, 09:57 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by ohadpartuck View Post
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.
Reply With Quote
  #6  
Old 09-06-2012, 10:17 AM
ohadpartuck ohadpartuck is offline
 
Join Date: Mar 2012
Posts: 138
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
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..)
Reply With Quote
  #7  
Old 09-06-2012, 11:04 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #8  
Old 09-06-2012, 01:27 PM
ohadpartuck ohadpartuck is offline
 
Join Date: Mar 2012
Posts: 138
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #9  
Old 09-06-2012, 01:45 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #10  
Old 09-06-2012, 02:41 PM
ohadpartuck ohadpartuck is offline
 
Join Date: Mar 2012
Posts: 138
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
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 01:39 AM.


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.04368 seconds
  • Memory Usage 2,277KB
  • Queries Executed 11 (?)
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
  • (3)bbcode_php
  • (3)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
  • (2)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_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