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

Reply
 
Thread Tools Display Modes
  #1  
Old 01-14-2013, 05:27 PM
manuel.fho manuel.fho is offline
 
Join Date: Jan 2011
Posts: 9
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default problem in get $vbulletin into external class

This works
PHP Code:
<?php
chdir
('/home/x/public_html/forum/');
require_once(
'./global.php');
return 
$vbulletin->userinfo;
This Dont Work D:
PHP Code:
<?php
class myCMS{
    function 
getVBInfo(){
        
chdir('/home/x/public_html/forum/');
        require_once(
'./global.php');
        return 
$vbulletin->userinfo;
    }
}

$test = new myCMS();
print_r($test->getVBInfo());
Help in third party portal please.
Reply With Quote
  #2  
Old 01-14-2013, 05:32 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It doesn't work because the code is written to expect some variables to be global, but if you do the include in a function, they're not. You can get around that by declaring the variables as global before you do the include. I know $vbulletin is one, I think $bootstrap is another, but unfortuantely I don't have the complete list (if you worked it out and posted it here, that would be great).
Reply With Quote
  #3  
Old 01-14-2013, 05:38 PM
manuel.fho manuel.fho is offline
 
Join Date: Jan 2011
Posts: 9
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Sorry, this work:
global $vbulletin;

but other problem:
http://elsilencio.cl/portal/brigde.php [works]
http://www.elsilencio.cl/portal/brigde.php [dont work]

PHP Code:
<?php

function userVB(){
    
    
$fnCwd getcwd();
    
chdir('/home/x/public_html/foro/');
    global 
$vbulletin;
    include(
'global.php');
    
chdir($fnCwd);
    
    return 
$vbulletin->userinfo;
}

$vb userVB();
print_r($vb);
:-/ iam configured forum cookies to .elsilencio.cl and whitelist of redirects www.elsilencio.cl and elsilencio.cl but dont work.


forum: http://foro.elsilencio.cl/
Reply With Quote
  #4  
Old 01-14-2013, 05:45 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hmm...the only thing I can think of right now is, did you change the cookie domain setting after finding that it didn't work? You might have to clear all cookies from your browser and try again.
Reply With Quote
  #5  
Old 01-14-2013, 05:46 PM
manuel.fho manuel.fho is offline
 
Join Date: Jan 2011
Posts: 9
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

clean cookies, history, passwords, test in other browser... ff, chrome, safary, etc and same problem.
Register in forum and test the public script please.

User ID 999:
>>> console.log(document.location + ' ::: ' + document.cookie)
http://elsilencio.cl/portal/brigde.php ::: CF_ORACLE=PRECACHED; __cfduid=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaa; __utma=1915749.1000392128.1358186771.1358186771.13 58186771.1; __utmb=1915749.27.10.1358186771; __utmc=1915749; __utmz=1915749.1358186771.1.1.utmcsr=(direct)|utmc cn=(direct)|utmcmd=(none); bb_lastvisit=1358189348; bb_lastactivity=0

User ID 0:
>>> console.log(document.location + ' ::: ' + document.cookie)
http://www.elsilencio.cl/portal/brigde.php ::: __cfduid=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaa; __utma=1915749.1000392128.1358186771.1358186771.13 58186771.1; __utmb=1915749.27.10.1358186771; __utmc=1915749; __utmz=1915749.1358186771.1.1.utmcsr=(direct)|utmc cn=(direct)|utmcmd=(none); bb_lastvisit=1358189348; bb_lastactivity=0
Reply With Quote
  #6  
Old 01-14-2013, 05:54 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Seems to be working for me. On either page I see:
Code:
Array ( [userid] => 17057 [temp] => [field1] => ...

if I'm logged in, and
Code:
Array ( [userid] => 0 [usergroupid] => 1 [username] => No registrado

when I log out.
Reply With Quote
  #7  
Old 01-14-2013, 06:00 PM
manuel.fho manuel.fho is offline
 
Join Date: Jan 2011
Posts: 9
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

test with www and without www logged in
Reply With Quote
  #8  
Old 01-14-2013, 06:03 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by manuel.fho View Post
test with www and without www logged in
This is what I did. But I just found out, if I choose "Guardar?" when I log in, it works. But if I don't check guardar then go to the bridge.php page, I see userid=0, and I get logged out from the site.
Reply With Quote
  #9  
Old 01-14-2013, 06:06 PM
manuel.fho manuel.fho is offline
 
Join Date: Jan 2011
Posts: 9
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

you're right.
how to fix? this is a bug in vbulletin.

--------------- Added [DATE]1358191183[/DATE] at [TIME]1358191183[/TIME] ---------------

my temporal solution:
Code:
$('#cb_cookieuser_navbar').hide().prop('checked', true);
All users login in with session forever.
Reply With Quote
  #10  
Old 01-14-2013, 06:20 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try adding $bootstrap to your globals, like:
Code:
    global $vbulletin, $bootstrap;
    include('global.php');

I don't know why that would cause this problem, but other people have asked about doing the same kind of thing and ended up needing to put in $bootstrap.
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 05:45 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.12178 seconds
  • Memory Usage 2,261KB
  • 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
  • (4)bbcode_code
  • (3)bbcode_php
  • (1)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_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