Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
  #1  
Old 04-08-2006, 04:31 PM
makaiguy's Avatar
makaiguy makaiguy is offline
 
Join Date: May 2004
Location: Aiken, SC, USA
Posts: 150
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Help with Insert PHP file hack

I'm using this hack: Insert HTML or (pre-processed!) PHP file above specific forum. Installed it in 3.0.7, and it worked fine in 3.5.4. Then I moved to a new server, which apparently is configured differently.

Don't know if this is germain to the problem I'm asking about, but just in case...
When going into an affected forum, I got these errors on the new server:

Quote:
Warning: file_get_contents(): URL file-access is disabled in the server configuration in /forumdisplay.php on line [whatever]

Warning: file_get_contents(http://www.mydomain.com/forums/filename.php): failed to open stream: no suitable wrapper could be found in /forumdisplay.php on line [whatever]
I found it would import my files if I changed it to not address the file via http:
PHP Code:
$mycustomheader file_get_contents("http://www.mydomain.com/forums/filename.php"):

Changed to

$mycustomheader file_get_contents("filename.php"): 
Now the problem I'm asking about:

Most of the import files are straight html display and they work fine. But for one forum I input a php file that displays a calculated future date as part of the displayed text. When I run the php file by going to it directly in the browser, it displays properly, but when it is imported via file_get_contents() the php is not interpreted at the server, but is passed thru to the downloaded html code. What the browser then does with it varies with the browser used (MSIE really messed up the page, Firefox just ignored the php).

Here's the imported page code:
PHP Code:
  <div class="smallfont" style="text-align:center;">
  [Top line of text]<Br /> 
<?php
  
print ('Last acceptable start date: ' date("M d, Y",strtotime("+45 days")));
?>
  </div>
Again, this all worked fine on the previous server. I suspect my problem is caused by the file not being imported via http (??). Is there some way around my problem? If it's a matter of server configuration, what should I tell them to reconfigure?

Apache v1.3.33 (cgi)
PHP 4.4.2

[Adding to this saga in case it helps somebody else]

My host (DreamHost) has the PHP option allow_url_fopen disabled, thus preventing accessing the file via http (above). One of their suggested workarounds is as I tried above, accessing the file via get_file_contents directly, rather than via http.

Where the RESULTS from the imported page are desired, they suggest using their installed cURL library in place of get_file_contents(). The following code is now working for me:
PHP Code:
Replace:

$mycustomheader file_get_contents("http://www.mydomain.com/forums/filename.php"):

With

   
$ch curl_init();
   
$timeout 5// set to zero for no timeout
   
curl_setopt ($chCURLOPT_URL'http://www.mydomain.com/forums/filename.php');
   
curl_setopt ($chCURLOPT_RETURNTRANSFER1);
   
curl_setopt ($chCURLOPT_CONNECTTIMEOUT$timeout);
   
$mycustomheader curl_exec($ch);
   
curl_close($ch); 
Check with your host as to whether they have the cURL library available.
Reply With Quote
Reply

Thread Tools
Display Modes

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 03:17 AM.


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.04016 seconds
  • Memory Usage 2,170KB
  • 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
  • (3)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)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