vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   php include in global_start plugin = no cookies! (https://vborg.vbsupport.ru/showthread.php?t=146892)

Joshva 05-10-2007 03:54 AM

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?

Zero Tolerance 05-10-2007 06:03 PM

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

Joshva 05-10-2007 10:30 PM

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

Zero Tolerance 05-11-2007 11:11 AM

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

Joshva 05-13-2007 05:00 AM

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?

Joshva 05-19-2007 07:54 AM

Any other advice?

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

Very stuck on this one

Paul M 05-19-2007 09:21 AM

Quote:

Originally Posted by Joshva (Post 1244769)
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.

Joshva 05-19-2007 02:24 PM

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


All times are GMT. The time now is 10:03 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.01229 seconds
  • Memory Usage 1,740KB
  • 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
  • (2)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete