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-02-2005, 03:04 AM
kyouens's Avatar
kyouens kyouens is offline
 
Join Date: Apr 2005
Posts: 35
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Headers already sent by . . .Snag with integration with Amazon Shop -- SOLVED

Hi everybody,

I have a quick question. I'm working on an integration of Ghostscripter's Amazon Store with my vBulletin installation, and I've come across a problem. I've got the script fairly well integrated into my site, with the header and footer "sandwiching" the Amazon Store code. Here's the code I add to the beginning of the Amazon Store php files to make most of it work:

PHP Code:
<?php
error_reporting
(E_ALL & ~E_NOTICE);
define('NO_REGISTER_GLOBALS'1);
define('THIS_SCRIPT''bookstore'); //Change to match file name
chdir('/var/www/html/vbulletin/');  //Change to server path of yoru forums
$globaltemplates = array(
    
'footer',
    
'header',
    
'navbar',
);
if (
$_REQUEST['page'])
{
    
$globaltemplates array_merge($globaltemplates);
}
require_once(
'./global.php');
globalize($_REQUEST, array('page' => STR,));

eval(
'$nakedheader = "' fetch_template('nakedheader') . '";');
eval(
'$footer = "' fetch_template('footer') . '";');
eval(
'$navbar = "' fetch_template('navbar') . '";');

$headinclude str_replace(array('"clientscript''url(images/gradients'), array("\"$vboptions[bburl]/clientscript""url($vboptions[bburl]/images/gradients"), $headinclude);
$footer str_replace('"cron.php'"\"$vboptions[bburl]/cron.php"$footer);

if (
$shownewpm AND $vboptions['showpm'])
{
    eval(
'$pmscript = "' fetch_template('pm_popup_script') . '";');
    
$footer .= str_replace('"private.php'"\"$vboptions[bburl]/private.php"$pmscript);
}
//-------- End call to VBulletin header and footer -------//
chdir("/var/www/html/amazon/");
After I do this, I have no problem with echoing my header and footer to the Amazon Store pages. The problem is when I try to access the cart.php to add items, etc. The urls when an item is to be added look like this:

HTML Code:
http://myserver.com/amazon/cart.php?cmd=add&asin=0345391802
When I try to do this, I get the following error, and no I don't have whitespaces before or after my php tags:
Quote:
Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/amazon/cart.php:35) in /cart.php on line 116
I know that this error is occurring because global.php sends header / cookie information and the cart.php file also sends header information. I guess something must be getting printed or echoed in between. Here's an example of the code from cart.php that's altering the header (would post more but this code is proprietary):
PHP Code:
case'clear':
    unset(
$_SESSION['cart']['items']);
    
header("Location: cart.php");
    break;
case 
'remove':
    unset(
$_SESSION['cart']['items'][$_GET['asin']]);
    
header("Location: cart.php");
    break; 
Does anyone know of 1) a way to put all the output of global.php into a variable or something like that, then echo it in the cart.php file? 2) some other brilliant thing I haven't thought of yet?

I know people doing integrations of external scripts have come across this problem and I was wondering if anyone had a clue.

Thanks,
Kenny
Reply With Quote
  #2  
Old 05-02-2005, 04:10 AM
Reeve of shinra's Avatar
Reeve of shinra Reeve of shinra is offline
 
Join Date: Oct 2001
Location: NYC
Posts: 1,896
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try using this:
https://vborg.vbsupport.ru/showthrea...threadid=66084
Reply With Quote
  #3  
Old 05-02-2005, 09:23 PM
kyouens's Avatar
kyouens kyouens is offline
 
Join Date: Apr 2005
Posts: 35
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Reeve of shinra
Thanks for the link--that is a cool hack--but unfortunately it doesn't work for dynamic php pages, only for static ones. Anyone got any other ideas?
Reply With Quote
  #4  
Old 05-02-2005, 09:36 PM
Guy G Guy G is offline
 
Join Date: Nov 2004
Posts: 250
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That sometimes happens if you have a space between the ending for the page and the ending of the script.

delete all that is between the ?> and the end.
Reply With Quote
  #5  
Old 05-02-2005, 09:47 PM
kyouens's Avatar
kyouens kyouens is offline
 
Join Date: Apr 2005
Posts: 35
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Guy G
That sometimes happens if you have a space between the ending for the page and the ending of the script.

delete all that is between the ?> and the end.
There's not any space there in my file. I checked after I came across that as a solution in my first round of forum searching for an answer Thanks.

I was able to resolve this issue, and I think the solution I found could be useful for integration of other complex scripts that send their own cookies, change headers, etc.

What I did was this: Made a seperate php file called headerinclude.php like this:


ob_start();
--include global php
--output the header only
(This is shown in several other forum posts.)
$header=ob_get_contents();
ob_clean();


Then I included headerinclude.php and encompassed the rest of the contents of my external file (except the php tags, obviously) (in my case cart.php) in another set of output buffer.


-include headerinclude.php
ob_start();
--EXTERNAL PHP file goes here
(This is shown in several other forum posts.)
$content=ob_get_contents();
ob_clean();


Then I echo this:

echo $header;
echo $content;

and it works, with all cookies, etc. apparently intact, and without that header already sent error.
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 08:26 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.03878 seconds
  • Memory Usage 2,225KB
  • 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
  • (1)bbcode_html
  • (2)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (5)post_thanks_box
  • (5)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (5)post_thanks_postbit_info
  • (5)postbit
  • (5)postbit_onlinestatus
  • (5)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