vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Issue with vBulletin php include on non vb page (https://vborg.vbsupport.ru/showthread.php?t=192803)

noppid 10-08-2008 04:00 PM

Then you need something like in vBa CMPS that does a search and replace I guess.

Dismounted 10-09-2008 01:49 AM

Quote:

Originally Posted by DandD (Post 1640236)
Hi Dismounted,

Thanks for the thoughts. Admittedly I am a novice, so please bear with me. It seems the problem is due to relative paths in all the files. The site home page (the page in question) is in the root folder. The calendar.php file is in the /forum/ folder. If I understand your suggestion correctly, I can copy the calendar.php code into the home page rather than using an include. I tried this and modified the paths on all the includes for that file accordingly. But we then have the same problem with the first file called down the line - in this case my modified code can now find /forum/global.php but returns an error because /includes/init.php can't be found. I would then need to modify the path in global.php and so on back to who knows where. That seems more than a little convoluted, not to mention opening the door to other issues.

Hopefully I am missing something simple. As you can tell I could really use some guidance.

Thanks for any help.
David
:eek:

As Marco has said - you can use chdir(). This will change the working directory to whatever you want.

DandD 10-09-2008 05:42 AM

Quote:

Originally Posted by Dismounted (Post 1640816)
As Marco has said - you can use chdir(). This will change the working directory to whatever you want.

Hi Dismounted,

I really appreciate your help. This has been quite strange. I was repeatedly getting error codes when trying to use the chdir but now I'm not and everything seems to be working with the exact same code I tried before. I mean exactly. There is one other problem now: I have additional html on the page after the php tags which simply does not show up now, not on the page, not on the page source code. Is there a trick I'm missing?

Edit: I spoke too soon. Before I would get the errors in Firefox immediately and eventually in Safari. Tonight all seemed well in Safari, even after clearing the cache. In Firefox, I again get the error message:

Unable to add cookies, header already sent.
File: /home/xxxx/public_html/index-test.php
Line: 2

Here is the entire code I'm trying now:

<base href="forum/" />
<?php chdir('forum/'); ?>
<?php include ("calendar.php"); ?>

(If I don't use the base href the css does not work. I even tried a link href for the .css file instead but it does not work.)

This is the page: http://www.lahabraevents.com/index-test.php

I feel like I am going crazy. Obviously, I could use any help you could offer. Much thanks.
David

Dismounted 10-09-2008 06:04 AM

Add your base element in the headinclude template, and use an absolute URL (http://www.site.com/forum). Use absolute paths (i.e. /home/user/public_html) for chdir().

DandD 10-09-2008 07:51 AM

Quote:

Originally Posted by Dismounted (Post 1640892)
Add your base element in the headinclude template, and use an absolute URL (http://www.site.com/forum). Use absolute paths (i.e. /home/user/public_html) for chdir().

Dismounted,

I feel like I should apologize for taking your time. You have been most gracious. I would like to think we are making progress. I added the base element to the headinclude template using the absolute URL as suggested. I added to the index-test.php page:

chdir('/home/xxxx/public_html/forum')

The CSS worked in Safari but not Firefox on the index page. I added a link href to the .css file in the index page and now that works (I had to use the absolute URL, relative did not work).

I no longer get error messages and my html footer now displays again. Unfortunately, the original issue remains. The user login status and the calendar view links do not display correctly. I am wondering if this is related to the include itself. If I use a relative path, the page does not work, I only get error codes. The code now is:

include ("http://www.lahabraevents.com/forum/calendar.php");

If you have a magic wand to make this work, I would be most appreciative.

Thanks again,
David

Dismounted 10-09-2008 08:15 AM

And the errors are?...

DandD 10-09-2008 03:58 PM

Quote:

Originally Posted by Dismounted (Post 1640945)
And the errors are?...

With this current code, no errors but still the original issues:

headinclude
base href="http://www.lahabraevents.com/forum/"

index-test.php
chdir('/home/xxxx/public_html/forum')

link href="http://www.lahabraevents.com/forum/clientscript/vbulletin_css/style-b391d83b-00002.css" rel="stylesheet" type="text/css"

include ("http://www.lahabraevents.com/forum/calendar.php");

Error
If I change the include to a relative path, I get the same errors I have been fighting.

include ("calendar.php");

Error:
Unable to add cookies, header already sent.
File: /home/xxxx/public_html/index-test.php
Line: 7

Hopefully I am missing something simple.

Thanks again,
David

Lynne 10-09-2008 04:18 PM

It is very hard to tell what you have done since you are not using the php or html tags to quote exactly what you code is. One thing I have noticed it your chdir is not ending in a slash and then your include is not starting with a slash. Perhaps that is a problem? I would try:

PHP Code:

chdir('/home/xxxx/public_html/forum');
include (
"./calendar.php"); 


DandD 10-09-2008 05:12 PM

Quote:

Originally Posted by Lynne (Post 1641247)
It is very hard to tell what you have done since you are not using the php or html tags to quote exactly what you code is. One thing I have noticed it your chdir is not ending in a slash and then your include is not starting with a slash. Perhaps that is a problem? I would try:

PHP Code:

chdir('/home/xxxx/public_html/forum');
include (
"./calendar.php"); 


Hi Lynne,

Thanks for the suggestion. I have tried so many variations I have ended up going in circles. The above gives the same error code. If I add a slash to the end of the chdir path and use any relative path variation for the include, same error. If I add a slash to the chdir path and use the absolute path for the include, no error but the original issue exists. Examples:

1
PHP Code:

chdir('/home/xxxx/public_html/forum'); 

PHP Code:

include ("calendar.php"); 

Error
Unable to add cookies, header already sent.
File: /home/xxxx/public_html/index-test.php
Line: 7

2
PHP Code:

chdir('/home/xxxx/public_html/forum'); 

PHP Code:

include ("/calendar.php"); 

Error
Warning: main(/calendar.php) [function.main]: failed to open stream: No such file or directory in /home/xxxx/public_html/index-test.php on line 8

Warning: main(/calendar.php) [function.main]: failed to open stream: No such file or directory in /home/xxxx/public_html/index-test.php on line 8

Warning: main() [function.include]: Failed opening '/calendar.php' for inclusion (include_path='.:/usr/lib/php') in /home/xxxx/public_html/index-test.php on line 8

3
PHP Code:

chdir('/home/xxxx/public_html/forum'

;
PHP Code:

include ("./calendar.php"); 

Error
Unable to add cookies, header already sent.
File: /home/xxxx/public_html/index-test.php
Line: 7

4
PHP Code:

chdir('/home/xxxx/public_html/forum'); 

PHP Code:

include ("/home/xxxx/public_html/forum/calendar.php"); 

Error
Unable to add cookies, header already sent.
File: /home/xxxx/public_html/index-test.php
Line: 7

5
PHP Code:

chdir('/home/xxxx/public_html/forum'); 

PHP Code:

include ("http://www.lahabraevents.com/forum/calendar.php"); 

Page displays, no errors, but original issues unresolved.

thanks,
David

Lynne 10-09-2008 07:59 PM

But, what is your entire code? Unable to add cookies usually means you have it doing 'header-type' stuff twice. Once you start to write your page, you can't go back and try to set a cookie again. So, it could be that you are doing things out-of-order in your page. You may have to try rearranging your php.


All times are GMT. The time now is 01:48 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.01916 seconds
  • Memory Usage 1,767KB
  • 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
  • (12)bbcode_php_printable
  • (5)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)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