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
  #22  
Old 12-28-2004, 08:12 AM
Spinball's Avatar
Spinball Spinball is offline
 
Join Date: Feb 2002
Location: Telford, England
Posts: 705
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I have used my hack to display banners above and below threads.
Edit showthread.php and find
*********************************************
// ################################################## ###########################
// output page
eval('print_output("' . fetch_template('SHOWTHREAD') . '");');
*********************************************
and add this code before it:
*********************************************
$headerbanner = "<P ALIGN=\"CENTER\" CLASS=\"smallfont\">" . file_get_contents("http://www.url_of_your_script.php?forumid=$forumid&type=h eader") . "</P>";
$footerbanner = "<P ALIGN=\"CENTER\" CLASS=\"smallfont\">" . file_get_contents("http://www.url_of_your_script.php?forumid=$forumid&type=f ooter") . "</P>";
*********************************************
Then in the SHOWTHREAD template, find
*********************************************
$navbar
*********************************************
and after it, put
*********************************************
<if condition="$headerbanner">$headerbanner</if>
*********************************************
and find
*********************************************
<if condition="$bbuserinfo[field11] == 'Yes'">$quickreply</if>
*********************************************
and above it add
*********************************************
<if condition="$footerbanner">$footerbanner</if>
*********************************************

Then write your php script to output banners depending on what forumid is passed and whether it's the header or footer:

PHP Code:
$forumid $_REQUEST['forumid'];
$type $_REQUEST['type'];

switch (
$forumid) {
 case 
36:                                 // for your forum number 36 only...
   
if ($type == "header") {
      
$banners = array (
      
"banner_1.gif|banner_1.pl|The alt text|0|468|60",
      
"banner_2.gif|banner_2.pl|The alt text|0|468|60"
      
);
   } elseif (
$type == "footer") {
      
$banners = array (
      
"banner_3.gif|banner_3.pl|The alt text|0|468|60",
      
"banner_4.gif|banner_4.pl|The alt text|0|468|60"
      
);
   }
   break;
 case 
37:                                 // for your forum number 37 only...
   
if ($type == "header") {
      
$banners = array (
      
"banner_5.gif|banner_5.pl|The alt text|0|468|60",
      
"banner_6.gif|banner_6.pl|The alt text|0|468|60"
      
);
   } elseif (
$type == "footer") {
      
$banners = array (
      
"banner_7.gif|banner_7.pl|The alt text|0|468|60",
      
"banner_8.gif|banner_8.pl|The alt text|0|468|60"
      
);
   }
   break;
}
$banner $banners[mt_rand(0,sizeof($banners) - 1)];
list(
$imgsrc,$myurl,$alttext,$border,$width,$height) = explode ('|',$banner);
echo (
"<A HREF='http://www.your_domain.com/cgi-bin/$myurl' TARGET='_blank'><IMG src='http://www.your_domain/path_to_your/banners/$imgsrc?" mt_rand(1,9999) . "' border='$border' width='$width' height='$height' alt='$alttext'></A>"); 
I'm actually working on a complete vBulletin banner solution which enables you to display (rotating) banners above the forum list and also above and below every thread (and anywhere else you want). But it's work-in-progress.

Re your specific code request, I recommend you learn some PHP.
PHP Code:
if ($forumid==76 or $forumid==78 or $forumid==81
or if you have lots of forums, use the 'switch' command as per my example above.

Re displaying banners for whole categories, you might be able to do it, but I don't have time to look into it this year
Reply With Quote
  #23  
Old 01-08-2005, 04:17 PM
keithsl keithsl is offline
 
Join Date: Jan 2005
Location: St. Louis
Posts: 29
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

How would you do this if you want to include something on top of every page of the forum?
Reply With Quote
  #24  
Old 01-08-2005, 04:42 PM
Spinball's Avatar
Spinball Spinball is offline
 
Join Date: Feb 2002
Location: Telford, England
Posts: 705
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You wouldn't need to use this hack - use the phpinclude_start template instead.
Reply With Quote
  #25  
Old 01-08-2005, 06:05 PM
YLP1 YLP1 is offline
 
Join Date: Aug 2004
Posts: 417
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Spinball
You wouldn't need to use this hack - use the phpinclude_start template instead.
Are there instructions for the php newbie to use this start tempate? Thanks in advance.
Reply With Quote
  #26  
Old 01-08-2005, 06:09 PM
Spinball's Avatar
Spinball Spinball is offline
 
Join Date: Feb 2002
Location: Telford, England
Posts: 705
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Do a search on vbulletin.com for phpinclude
Reply With Quote
  #27  
Old 01-09-2005, 12:10 PM
H@K@N H@K@N is offline
 
Join Date: Dec 2004
Location: Dortmund
Posts: 75
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi,

i am going to try, to use the shoutcast status Box, which is availible for vba-portal, on my Forumhome.

When i try to include the shoutcast.php below the $navbar it says :

Code:
Fatal error: Call to undefined function: fetch_template() in /srv/www/htdocs/web1/html/shoutcast.php on line 68
On the Line 68 i have following :

Code:
eval('$home[$mods[\'modid\']][\'content\'] .= "' . fetch_template('adv_portal_shoutcast') . '";');
what should i change to have that script running ?

th@nks
Reply With Quote
  #28  
Old 01-09-2005, 12:18 PM
sabret00the's Avatar
sabret00the sabret00the is offline
 
Join Date: Jan 2003
Location: London
Posts: 5,268
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

try this, you're eval is a mess as is
PHP Code:
        eval("\$home['content'] .= \"" fetch_template("adv_portal_shoutcast") . "\";"); 
Reply With Quote
  #29  
Old 01-09-2005, 03:12 PM
H@K@N H@K@N is offline
 
Join Date: Dec 2004
Location: Dortmund
Posts: 75
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

th@nks 4 reply, but i have still this error :

Code:
Fatal error: Call to undefined function: fetch_template() in /srv/www/htdocs/web1/html/shoutcast.php on line 68


here i paste the whole script :

PHP Code:
<?php
// Shoutcast Server Stats
// Parses shoutcasts xml to make an effective stats thing for any website

//Configuration
$scdef "TEst FM";   // Default station name
$scip "myipadress";       // ip or url of shoutcast server
$scport "8000";       // port of shoutcast server
$scpass "yourpass";  // password to shoutcast server
$maxusers "32"//max users for your server
//End configuration

$scfp = @fsockopen($scip$scport, &$errno, &$errstr3);

if(!
$scfp) {
eval(
"\$home['content'] .= \"" fetch_template("adv_portal_shoutcast_off") . "\";"); 
}else{
if(
$scsuccs!=1){
fputs($scfp,"GET /admin.cgi?pass=$scpass&mode=viewxml HTTP/1.0\r\nUser-Agent: SHOUTcast Song Status (Mozilla Compatible)\r\n\r\n");
while(!
feof($scfp)) {
  
$page .= fgets($scfp1000);
}
}

//define  xml elements

$loop = array("STREAMSTATUS""BITRATE""SERVERTITLE""CURRENTLISTENERS");
$y=0;
while(
$loop[$y]!=''){
  
$pageed ereg_replace(".*<$loop[$y]>"""$page);
  
$scphp strtolower($loop[$y]);
  $
$scphp ereg_replace("</$loop[$y]>.*"""$pageed);
  if(
$loop[$y]==SERVERGENRE || $loop[$y]==SERVERTITLE || $loop[$y]==SONGTITLE || $loop[$y]==SERVERTITLE)
   $
$scphp urldecode($$scphp);

// uncomment the next line to see all variables
//echo'$'.$scphp.' = '.$$scphp.'<br>';
  
$y++;
}
//end intro xml elements

//get song info and history
$pageed ereg_replace(".*<SONGHISTORY>"""$page);
$pageed ereg_replace("<SONGHISTORY>.*"""$pageed);
$songatime explode("<SONG>"$pageed);
$r=1;
while(
$songatime[$r]!=""){
  
$t=$r-1;
  
$playedat[$t] = ereg_replace(".*<PLAYEDAT>"""$songatime[$r]);
  
$playedat[$t] = ereg_replace("</PLAYEDAT>.*"""$playedat[$t]);
  
$song[$t] = ereg_replace(".*<TITLE>"""$songatime[$r]);
  
$song[$t] = ereg_replace("</TITLE>.*"""$song[$t]);
  
$song[$t] = urldecode($song[$t]);
  
$dj[$t] = ereg_replace(".*<SERVERTITLE>"""$page);
  
$dj[$t] = ereg_replace("</SERVERTITLE>.*"""$pageed);
$r++;
}
//end song info

fclose($scfp);
}

//display stats
if($scfp) {
if(
$streamstatus == "1"){
//you may edit the html below, make sure to keep variable intact
eval("\$home['content'] .= \"" fetch_template("adv_portal_shoutcast") . "\";"); 
} else {
eval(
"\$home['content'] .= \"" fetch_template("adv_portal_shoutcast_off") . "\";"); 
}
}
?>

i hade the eval twice, so i have tried also to change the eval below the server settings, but still not working.


gr33tz
Reply With Quote
  #30  
Old 01-09-2005, 03:52 PM
sabret00the's Avatar
sabret00the sabret00the is offline
 
Join Date: Jan 2003
Location: London
Posts: 5,268
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

you need to include the global.php
Reply With Quote
  #31  
Old 01-09-2005, 05:21 PM
H@K@N H@K@N is offline
 
Join Date: Dec 2004
Location: Dortmund
Posts: 75
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by sabret00the
you need to include the global.php

Th@nks 4 help but i can't include that.

if i use :

require_once('./global.php');

into the Header of the php,Forumhome is going to open the shoutcast.php himself on the Index, and i cannot login anymore.

gr33tz
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 10:56 AM.


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.06774 seconds
  • Memory Usage 2,364KB
  • 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
  • (3)bbcode_code
  • (4)bbcode_php
  • (2)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
  • (4)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