vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   problem in get $vbulletin into external class (https://vborg.vbsupport.ru/showthread.php?t=293925)

manuel.fho 01-14-2013 05:27 PM

problem in get $vbulletin into external class
 
This works :D
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.

kh99 01-14-2013 05:32 PM

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).

manuel.fho 01-14-2013 05:38 PM

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.
http://elsilencio.cl/portal/cookies.png

forum: http://foro.elsilencio.cl/

kh99 01-14-2013 05:45 PM

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.

manuel.fho 01-14-2013 05:46 PM

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

kh99 01-14-2013 05:54 PM

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.

manuel.fho 01-14-2013 06:00 PM

test with www and without www logged in

kh99 01-14-2013 06:03 PM

Quote:

Originally Posted by manuel.fho (Post 2396837)
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.

manuel.fho 01-14-2013 06:06 PM

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.

kh99 01-14-2013 06:20 PM

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.


All times are GMT. The time now is 10:33 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.01086 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
  • (4)bbcode_code_printable
  • (3)bbcode_php_printable
  • (1)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