Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.0 > vBulletin 3.0 Full Releases
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Insert HTML or (pre-processed!) PHP file above specific forum Details »»
Insert HTML or (pre-processed!) PHP file above specific forum
Version: 1.00, by Spinball Spinball is offline
Developer Last Online: Oct 2023 Show Printable Version Email this Page

Version: 3.0.3 Rating:
Released: 08-02-2004 Last Update: Never Installs: 24
Supported
 

This is a very simple but very powerful hack for VB 3 which I've not been able to find elsewhere so decided to write.

It inserts a named external file (or files) above a specific forum (or forums). I use it to insert some HTML from HTML AND PHP (!) files above specific forums.
It works perfectly on my forums with over 28,000 members.

It requires editing one file and one template.

The amazing thing I discovered is that if the php function used (file_get_contents) is used on a php file, the php is processed BEFORE the file contents are read into the string.

The first attached image shows this hack 'including' a php file which dynamically builds a list from a database on a different server into a drop-down list box.

The second image shows the inclusion of a banner and beneath it a HTML file showing latest news (which is created automatically).

* Updated August 7 2004. Altered the text file to include instructions on how to insert the file at the top of your forum list *.
Please note that the forum list instructions are untested. If someone uses it, please let me know if it works ok.
One question, though. This hack is so simple but so powerful, howcome nobody has done it before? Or have they already?

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #32  
Old 01-10-2005, 09:31 AM
Spinball's Avatar
Spinball Spinball is offline
 
Join Date: Feb 2002
Location: Telford, England
Posts: 705
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Sorry but is this relevant to the hack?
Reply With Quote
  #33  
Old 03-24-2005, 02:43 PM
Julio Julio is offline
 
Join Date: Oct 2002
Posts: 87
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Also, where do I input the code to center the banners on the forum home page? Do I just use this code: <div style="text-align:center;">
<a href......>banner</a>
</div> ???

PLEASE let me know as well!
Reply With Quote
  #34  
Old 03-24-2005, 03:00 PM
Spinball's Avatar
Spinball Spinball is offline
 
Join Date: Feb 2002
Location: Telford, England
Posts: 705
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well I use the phpinclude_start template:
Code:
ob_start();
require("/home/sites/avforums/public_html/page_top.php");
$forum_heading = ob_get_contents();
ob_end_clean();
and then right at the top of the header template:
Code:
$forum_heading
And the page_top.php file I call some banner serving software.
Reply With Quote
  #35  
Old 04-21-2005, 09:00 PM
Julio Julio is offline
 
Join Date: Oct 2002
Posts: 87
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

After a couple of weeks of using this mod, and everything working OK, Today I logged to my forums, and I am getting the following error message at the top of FORUMHOME.

Warning: file_get_contents(): URL file-access is disabled in the server configuration in /index.php on line 59

Warning: file_get_contents(http://www.mydomain.com/forums/banners.php): failed to open stream: no suitable wrapper could be found in /index.php on line 59
Reply With Quote
  #36  
Old 04-22-2005, 09:51 AM
Spinball's Avatar
Spinball Spinball is offline
 
Join Date: Feb 2002
Location: Telford, England
Posts: 705
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Sounds like there has been some kind of configuration change.
If you access the URL in your browser rather than in the file_get_contents, does it work?
Reply With Quote
  #37  
Old 04-22-2005, 05:02 PM
Julio Julio is offline
 
Join Date: Oct 2002
Posts: 87
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes, it works.
Reply With Quote
  #38  
Old 04-22-2005, 06:34 PM
Spinball's Avatar
Spinball Spinball is offline
 
Join Date: Feb 2002
Location: Telford, England
Posts: 705
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The message
Quote:
URL file-access is disabled in the server configuration
might offer you a clue.
If it worked previously, check (with your hosts) whether the configuration of the server has changed in some way.
Reply With Quote
  #39  
Old 04-08-2006, 04:10 PM
makaiguy's Avatar
makaiguy makaiguy is offline
 
Join Date: May 2004
Location: Aiken, SC, USA
Posts: 150
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Julio
After a couple of weeks of using this mod, and everything working OK, Today I logged to my forums, and I am getting the following error message at the top of FORUMHOME.

Warning: file_get_contents(): URL file-access is disabled in the server configuration in /index.php on line 59

Warning: file_get_contents(http://www.mydomain.com/forums/banners.php): failed to open stream: no suitable wrapper could be found in /index.php on line 59
I had this same problem when I moved a working 3.5.4 installation to a new server, which apparently was configured differently. I found it worked if I changed it to not address the file via http:
PHP Code:
$mycustomheader file_get_contents("filename.php"): 
Reply With Quote
  #40  
Old 04-12-2006, 12:16 AM
makaiguy's Avatar
makaiguy makaiguy is offline
 
Join Date: May 2004
Location: Aiken, SC, USA
Posts: 150
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Adding to my post, above, re URL file-access is disabled in the server configuration:

I found this is because my server has the PHP option allow_url_fopen disabled, thus preventing accessing the file via http. For importing static html, the solution in the above post was fine.

But one of my import files was a php file that generated some variable text depending on the date. When accessing this directly instead of as an http import, all I got was the static php code, not the RESULT of running the php code.

The support folks at the server suggested using their installed cURL library in place of get_file_contents(). The following modification to this hack in forumdisplay.php 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); 
If you're having the same problem, check with your host as to whether they have the cURL library available.
Reply With Quote
  #41  
Old 04-20-2006, 07:24 PM
Oleks Oleks is offline
 
Join Date: Apr 2004
Posts: 32
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Spinball
The amazing thing I discovered is that if the php function used (file_get_contents) is used on a php file, the php is processed BEFORE the file contents are read into the string.
Hi,
It seams, this is not the case for my server.
I see the text of the .php file, not the results of execution.

What I should ask my host to change?
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: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.06492 seconds
  • Memory Usage 2,317KB
  • Queries Executed 25 (?)
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
  • (2)bbcode_code
  • (2)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)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_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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete