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

Reply
 
Thread Tools Display Modes
  #1  
Old 05-10-2007, 03:54 AM
Joshva Joshva is offline
 
Join Date: Nov 2005
Posts: 58
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default php include in global_start plugin = no cookies!

Hi,

I have the following global_start plugin hook:

ob_start();
require_once('http://www.joshandfriends.com.au:45317/dancemusic/faces/ExternalPlugin.jsp');
$included_file = ob_get_contents();
ob_end_clean();


In the ExternalPlugin.jsp when i look for the cookies of my website it returns nothing at all!!!

When i place:

http://www.joshandfriends.com.au:453...rnalPlugin.jsp

in a browser i can see all cookies logged.

I had this on my old site as well.


Any ideas why i would be receiving no cookies?
Reply With Quote
  #2  
Old 05-10-2007, 06:03 PM
Zero Tolerance's Avatar
Zero Tolerance Zero Tolerance is offline
 
Join Date: Feb 2004
Location: England
Posts: 813
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The file 'ExternalPlugin.jsp' is being executed by your server, and the contents returned and being saved into "$included_file". The problem exists because it is your server pulling the contents of this file.

Perhaps pass along some variables?

PHP Code:
function build_cookie_string()
{
    global 
$cookies;

    
$string = array();

    if (!empty(
$cookies))
    {
        foreach (
$cookies as $cookie)
        {
            if (isset(
$_COOKIES[$cookie]))
            {
                
$string[] = $cookie '=' $_COOKIES[$cookie];
            }
        }
    }

    return 
implode('&'$string);
}

$cookies = array(
    
'cookie1',
    
'cookie2',
    
'cookie3',
);

ob_start();
require_once(
'http://www.joshandfriends.com.au:45317/dancemusic/faces/ExternalPlugin.jsp?' build_cookie_string());
$included_file ob_get_contents();
ob_end_clean(); 
I haven't tested it, but if you could change that script to use http variables then you could do it that way, just change the cookie array for the cookies you want passing through

- Zero Tolerance
Reply With Quote
  #3  
Old 05-10-2007, 10:30 PM
Joshva Joshva is offline
 
Join Date: Nov 2005
Posts: 58
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Would it make a difference if i gave a relative url for example

require_once("../ExternalPlugin.jsp");

Would it then be passed the cookies in a normal request fashion?

btw thanks for the reply. I will try your code this weekend see if it works for what i need
Reply With Quote
  #4  
Old 05-11-2007, 11:11 AM
Zero Tolerance's Avatar
Zero Tolerance Zero Tolerance is offline
 
Join Date: Feb 2004
Location: England
Posts: 813
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Depends really, some setups will allow you to use require_once with the variables too, some won't, should it fail you can use:

PHP Code:
$file implode(''file('http://www.joshandfriends.com.au:45317/dancemusic/faces/ExternalPlugin.jsp?' build_cookie_string())); 
With this you don't need to use ob_* functions

- Zero Tolerance
Reply With Quote
  #5  
Old 05-13-2007, 05:00 AM
Joshva Joshva is offline
 
Join Date: Nov 2005
Posts: 58
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

OK tried them both. Firstly the suggestion of passing cookies as request parameters.

Their are NO request parameters of any sort received by my jsp.

The request is BLANK!

This is very odd as of course the cookies are empty too.

This suggests that the request is somehow getting totally cleared at some point.

The 2nd suggestion refused to render entirely. I imagine it was a php error.

Any suggestions of where the request would be getting cleared?
Reply With Quote
  #6  
Old 05-19-2007, 07:54 AM
Joshva Joshva is offline
 
Join Date: Nov 2005
Posts: 58
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Any other advice?

This happens on both Tomcat appserver and also Glassfish app server.

Very stuck on this one
Reply With Quote
  #7  
Old 05-19-2007, 09:21 AM
Paul M's Avatar
Paul M Paul M is offline
 
Join Date: Sep 2004
Location: Nottingham, UK
Posts: 23,748
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Joshva View Post
Any ideas why i would be receiving no cookies?
Because your webserver is requesting the page, not you. Webservers don't send cookies with their requests, and even if they did, they wouldn't be yours.
Reply With Quote
  #8  
Old 05-19-2007, 02:24 PM
Joshva Joshva is offline
 
Join Date: Nov 2005
Posts: 58
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok everyone we are a little further along!


a) Parameters can be passed to the jsp

b) Within the plugin return "count=" . count($_COOKIES); RETURNS 0


So basically even with in the vBulletin plugin i can not access any cookies at all!!!

Any ideas? Is their a particular vbulletin function i need to call to retrieve the cookies

THis doesn't return anything either:

$bbuserinfo['username'];

even though i am logged in.

THis is all in the global start hook

STOP PRESS!!!

I got it working with:




function build_cookie_string()
{
return "bbsessionhash=" . $_COOKIE['bbsessionhash'];
}

ob_start();
require_once('http://www.joshandfriends.com.au/dancemusic/faces/ExternalPlugin.jsp?' . build_cookie_string());

$included_file = ob_get_contents();
ob_end_clean();





Thanks to everyone who helped!

Josh
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 04:32 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.11887 seconds
  • Memory Usage 2,243KB
  • Queries Executed 13 (?)
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
  • (2)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (8)post_thanks_box
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)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_postinfo_query
  • fetch_postinfo
  • 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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete