Previous Thread
Next Thread
Print Thread
Rate Thread
Joined: Sep 2003
Posts: 488
Code Monkey
Code Monkey
Joined: Sep 2003
Posts: 488
Mod Name / Version: Multiple Random Banners v1.1 (No Duplicates)

Description: This updated script will allow you to display multiple random images or banners on your site without ever showing duplicates, and it is also more user friendly now.

It is tailored to be used for UBBThreads via the generic or forum headers, although it can easily be used on any PHP page as well. (it looks like footer includes need to be added to the send_footer() function in ubbt.inc.php instead, or else it won't work - not sure why that is).

Instructions
============

1) Download and save the script (banners.inc.php) to your UBBThreads includes folder.

2) Then configure the script by filling in the HTML for each banner listed. If you ever want to change/delete banners in the future you can easily edit the HTML code here.

3) Configure how many banners you wish to display on the page (0 to 12) from the entire pool of available ones.

4) Then simply include this code in your header/footer...
Adjust the path as necessary if you are using it on a non-threads page.

<? include "$thispath/includes/banners.inc.php"; ?>


DEMO -
http://www.mameworld.info/ubbthreads/demo.php


Working Under: UBB.Threads 6.0-6.5

Mod Status: Finished

Any pre-requisites:

Author(s): Twisty

Date: 10/21/04

Credits:

Files Altered:

New Files:

Database Altered:

Info/Instructions: (see attachment)

Disclaimer: Please backup every file that you intend to modify.
If the modification modifies the database, it's a good idea to backup your database before doing so.

Note: If you modify your UBB.Threads code, you may be giving up your right for "official" support from Infopop.If you need official support, you'll need to restore unmodified files.
Attachments
121715-banners.inc.zip (0 Bytes, 42 downloads)

Sponsored Links
Joined: Nov 2002
Posts: 554
Code Monkey
Code Monkey
Offline
Joined: Nov 2002
Posts: 554
If I were to put this part
Code
<br />// This section can be called via an include if you wish <br /><br />$image_html = array();<br /><br />// Insert the HTML code below for each image or banner in the pool (don't forget the \ before the ")<br />// You can also add individual ALT and TITLE tags if you wish<br /><br />$image_html[0] = "<a href=\"http://www.example1.com\"><img src=\"images/1.gif\" border=\"0\"></a>";<br />$image_html[1] = "<a href=\"http://www.example2.com\"><img src=\"images/2.jpg\" border=\"0\"></a>";<br />$image_html[2] = "<a href=\"http://www.example3.com\"><img src=\"images/3.png\" border=\"0\"></a>";<br />$image_html[3] = "<a href=\"http://www.example4.com\"><img src=\"images/4.gif\" border=\"0\"></a>";<br />$image_html[4] = "<a href=\"http://www.example5.com\"><img src=\"images/5.jpg\" border=\"0\"></a>";<br />$image_html[5] = "<a href=\"http://www.example6.com\"><img src=\"images/6.png\" border=\"0\"></a>";<br /><br />// Configure the number of unique images or banners to be displayed on the page<br />// It can be any number from 0-6 in the example given<br /><br />$number_of_images = 3; // <-- Configure<br /><br />$random = array_rand($image_html, $number_of_images);<br />?> <br />

into a file named banner.inc.php

where would I put the following line of code?Or am I going about this wrong?
require ("includes/banner.inc.php");


This I have placed in my Generic Header
Code
 <center><br /><br /><?php echo $image_html[$random[0]]; ?><br /><?php echo $image_html[$random[1]]; ?><br /><?php echo $image_html[$random[2]]; ?><br /><?php echo $image_html[$random[3]]; ?><br /><?php echo $image_html[$random[4]]; ?><br /><?php echo $image_html[$random[5]]; ?><br /></center> 

Joined: Sep 2003
Posts: 488
Code Monkey
Code Monkey
Joined: Sep 2003
Posts: 488
You could place it in several locations.

1) In the actual ubbt_header.tmpl file right after this...

<? //UBBTREMARK

2) Paste the code somewhere in ubbt.inc.php

3) Save it as an include like you mentioned, and then paste this into ubbt.inc.php...

include ("$thispath/includes/banner.inc.php");

...right underneath the others listed...

include("$configdir/config.inc.php");
include("$thispath/mysql.inc.php");
include("$thispath/theme.inc.php");

I would personally use the 3rd method just to keep everything orderly, and allow easier editing of the html code.


Joined: Nov 2002
Posts: 554
Code Monkey
Code Monkey
Offline
Joined: Nov 2002
Posts: 554
do you mean these?

require_once("$configdir/config.inc.php");
require_once("$thispath/mysql.inc.php");
require_once("$thispath/includes/theme.inc.php");
require_once("$thispath/includes/configpal.inc.php");

Joined: Sep 2003
Posts: 488
Code Monkey
Code Monkey
Joined: Sep 2003
Posts: 488
Yes, I'm using 6.3 which is a li'l different. Although still use the same line I mentioned though.

I recommend using include() over require_once() since it is a non-critical file.

The former will merely give a warning upon failure while the latter will give a fatal error, which would be more understandable for the other listed includes.

Sponsored Links
Joined: Nov 2002
Posts: 554
Code Monkey
Code Monkey
Offline
Joined: Nov 2002
Posts: 554
// This section can be called via an include if you wish $image_html = array(); // Insert the HTML code below for each image or banner in the pool (don't forget the \ before the ") // You can also add individual ALT and TITLE tags if you wish $image_html[0] = ""; $image_html[1] = ""; $image_html[2] = ""; $image_html[3] = ""; $image_html[4] = ""; $image_html[5] = ""; // Configure the number of unique images or banners to be displayed on the page // It can be any number from 0-6 in the example given $number_of_images = 6; // <-- Configure $random = array_rand($image_html, $number_of_images); ?>
Warning: Cannot modify header information - headers already sent by (output started at /usr/www/efs/ubbthreads/includes/banner.inc.php:10) in /usr/www/efs/ubbthreads/ubbt.inc.php on line 328

What did I do wrong here? That is showing where I would like my banners? I placed the code in my header insert

Joined: Sep 2003
Posts: 488
Code Monkey
Code Monkey
Joined: Sep 2003
Posts: 488
Ok I think this can be fixed using output buffering. Try adding this to your banner include...

At the begining of the code put this line:

//begin buffering
ob_start();


and at the end of the code put this line:


//end buffering
ob_end_flush();


Lemme know how it works.

Joined: Nov 2002
Posts: 554
Code Monkey
Code Monkey
Offline
Joined: Nov 2002
Posts: 554
well one thing I forgot was this at the top of my banner.inc.php
<?php
It must be pretty important




so now I am getting just this

Warning: Cannot modify header information - headers already sent by (output started at /usr/www/efs/ubbthreads/includes/banner.inc.php:24) in /usr/www/efs/ubbthreads/ubbt.inc.php on line 328

I will try the the buffering now-
*edit-still getting that last error even after inserting the buffer code*

Last edited by ChAoS; 10/25/2004 7:13 PM.
Joined: Sep 2003
Posts: 488
Code Monkey
Code Monkey
Joined: Sep 2003
Posts: 488
Ugh, if using an include like that, I know there's a way to do it with buffering but I'd have to play around with it a bit and test some things.

For now just include all the code in the header template and it should work a-ok.

EDIT: See my post below for an example

Joined: Sep 2003
Posts: 488
Code Monkey
Code Monkey
Joined: Sep 2003
Posts: 488
Something else to try if going the include route...

Do the same thing I mentioned above with the output buffering but add those beginning and ending lines to ubbt.inc.php instead of the banner include. That *might* work.

Sponsored Links
Joined: Sep 2003
Posts: 488
Code Monkey
Code Monkey
Joined: Sep 2003
Posts: 488
Here's a follow-up to what you'll need to do if including everything in the header template (a little extra code req'd)...

Example (displaying 3 images from a pool of 3 possible):

<? //UBBTREMARK

$image_html = array();

// Insert the HTML code below for each image or banner in the pool (don't forget the \ before the ")
// You can also add individual ALT and TITLE tags if you wish

$image_html[0] = "<a href="http://www.example1.com"><img src="images/1.gif" border="0"></a>";
$image_html[1] = "<a href="http://www.example2.com"><img src="images/2.jpg" border="0"></a>";
$image_html[2] = "<a href="http://www.example3.com"><img src="images/3.png" border="0"></a>";

// Configure the number of unique images or banners to be displayed on the page
// It can be any number from 0-6 in the example given

$number_of_images = 3; // <-- Configure

$random = array_rand($image_html, $number_of_images);

[:"red"]$image1 = $image_html[$random[0]];
$image2 = $image_html[$random[1]];
$image3 = $image_html[$random[2]];[/]


echo <<<UBBTPRINT
<!-- START OF header.tmpl TEMPLATE -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html dir="{$ubbt_lang['READ_DIRECTION']}">
<head>
$headerinsert
$refresh
<meta http-equiv="Content-Type" content="text/html; charset={$ubbt_lang['CHARSET']}" />
<link rel="stylesheet" href="$stylesheet" type="text/css" />
<link rel="shortcut icon" href="{$config['images']}/loonyicon.ico" />
$javascript
<title>{$config['title']}: $inputTitle</title>
</head>
<body>
[:"red"]<center>
$image1
$image2
$image3
</center> [/]
<!-- END OF header.tmpl TEMPLATE -->
UBBTPRINT
/* UBBTREMARK */ ?>


Now notice the parts in red.

The first red section is *new code* you'll need, which converts the randomized array into single variables. It's pretty straight-forward.

The second red section is what will actually display the images now with the variables we just created above.

I think it's pretty easy to understand eh? That will now absolutely make everything work using this method!

Joined: Nov 2002
Posts: 554
Code Monkey
Code Monkey
Offline
Joined: Nov 2002
Posts: 554
ok I placed it in the ubbt_header.tmpl and it displays the images but does not do it randomly

If I assign this value
$number_of_images = 3; // <-- Configure
I get the same three images upon refreshing (the first three on the list I believe)

If I assign a value of
$number_of_images = 1; // <-- Configure
then nothing displays


Here is my ubbt_header.tmpl
Code
 <!-- <? //UBBTREMARK --><br />// File Version 6.5<br />[:"green"]<br />$image_html = array();<br /><br />// Insert the HTML code below for each image or banner in the pool (don't forget the \ before the ")<br />// You can also add individual ALT and TITLE tags if you wish<br /><br />$image_html[0] = "<a href=\"http://www.bajema.com\"><img src=\"/ubbthreads/images/banners/bajbnr.jpg\" border=\"0\"></a>";<br />$image_html[1] = "<a href=\"http://melancholic.net\"><img src=\"/ubbthreads/images/banners/melancholicban.jpg\" border=\"0\"></a>";<br />$image_html[2] = "<a href=\"http://www.decayingmadness.com\"><img src=\"/ubbthreads/images/banners/decayingmadness.gif\" border=\"0\"></a>";<br />$image_html[3] = "<a href=\"http://www.vixenshop.com\"><img src=\"/ubbthreads/images/banners/vixshop.gif\" border=\"0\"></a>";<br />$image_html[4] = "<a href=\"http://www.giger.com/mainflash.htm\"><img src=\"/ubbthreads/images/banners/giger.jpg\" border=\"0\"></a>";<br />$image_html[5] = "<a href=\"http://www.pitchfork.de/page_en.php?\"><img src=\"/ubbthreads/images/banners/projectpitchfork.jpg\" border=\"0\"></a>";<br />$image_html[6] = "<a href=\"http://emeraldforestseattle.com\"><img src=\"/ubbthreads/images/happyhalloween.gif\" border=\"0\"></a>";<br /><br />// Configure the number of unique images or banners to be displayed on the page<br />// It can be any number from 0-6 in the example given<br /><br />$number_of_images = 1; // <-- Configure<br /><br />$random = array_rand($image_html, $number_of_images);<br /><br />[/]<br /><!-- echo <<<UBBTPRINT --><br /><!-- START OF header.tmpl TEMPLATE --><br /><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><br /><html dir="{$ubbt_lang['READ_DIRECTION']}"><br /><head><br />$headerinsert<br />$refresh<br /><meta http-equiv="Content-Type" content="text/html; charset={$ubbt_lang['CHARSET']}" /><br /><link rel="stylesheet" href="$stylesheet" type="text/css" /><br /><link rel="shortcut icon" href="{$config['images']}/favicon.ico" /><br />$javascript<br /><title>{$config['title']}: $inputTitle</title><br /></head><br /><body><br /><!-- END OF header.tmpl TEMPLATE --><br /><!-- UBBTPRINT --><br /><!-- /* UBBTREMARK */ ?> --><br /> 



And here is my generic header
Code
 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><br /><br /><title>Emerald Forest Seattle </title><br /><br /><br /><br /><body bgcolor="#7b9b74"><br /><br /><br /><center><p><br /><table border="0" cellspacing="0" cellpadding="0" width="100%"><tr><br /><td width="80%" align="center" valign="middle"><br /><img src="/efsbanner.gif"><br /><br /><br /><br><br /><br><br /></td><br /></tr><br /></table><br /><br /><table border="0" cellspacing="1" cellpadding="2" width="95%"bgcolor="#000000"><tr bgcolor="#7C8F79"><td align="center" width="20%" background="/attachments/64861-grad-02.gif"><br /><br /><b><a href="/faq.html" target="_new">Rules</a></b></td><br /><br /><td align="center" width="20%" background="/attachments/64861-grad-02.gif"><b><a href="http://efs.stats.nuclearfallout.net"target="_new">Statistics</a></b></td><br /><br /><td align="center" width="20%" background="/attachments/64861-grad-02.gif"><b><a href="http://216.254.1.196/~chaos/live1.6.html" target="_new">LiveStatus</a></b></td><br /><br /><td align="center" width="20%" background="/attachments/64861-grad-02.gif"><b><a href="/efclan/staff.html" target="_new">Staff</a></b></td><br /><br /><td align="center" width="20%" background="http://emeraldforestseattle.nuclearfallout.net/attachments/64861-grad-02.gif"><b><a href="/Links.html" target="_new">Links</a></b></td></tr><br /></table><br /><br /><br /><br /><br /><!--THIS PART GOES INTO THE GENERIC HEADER--><div align="center"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td align="center" valign="top"><br /><br /><br />        <table border="0" cellspacing="1" cellpadding="2" width="95%" bgcolor="#000000"><br />          <tr><br />          <td width="20%" class="welcome"><br />            <form action="https://www.paypal.com/cgi-bin/webscr" method="post"><br />            <input type="hidden" name="cmd" value="_xclick"><br />            <input type="hidden" name="business" value="[email protected]"><br />            <input type="image" src="http://emeraldforestseattle.nuclearfallout.net/ubbthreads/images/x-click-but04.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!"><br />            </form><br />            <b>Send Money!</b><br />          </td><br /><br />	  <td width="60%" td bgcolor="#92A88E"><br /><br></ br><br /><center>Welcome To The Forest</center><br /><center><br />[:"green"]<br /></center><center><br /><?php echo $image_html[$random[0]]; ?><br /><?php echo $image_html[$random[1]]; ?><br /><?php echo $image_html[$random[2]]; ?><br /><?php echo $image_html[$random[3]]; ?><br /><?php echo $image_html[$random[4]]; ?><br /><?php echo $image_html[$random[5]]; ?><br /><?php echo $image_html[$random[6]]; ?><br /></center><br />[/]<br />                 </td><br /><td width="20%" align="right" class="welcome"><br />  <form action="https://www.paypal.com/cgi-bin/webscr" method="post"><br /><input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but20.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!"><br /><input type="hidden" name="cmd" value="_xclick-subscriptions"><br /><input type="hidden" name="business" value="[email protected]"><br /><input type="hidden" name="item_name" value="Emerald Forest Seattle"><br /><input type="hidden" name="item_number" value="EFS Subscription"><br /><input type="hidden" name="no_note" value="1"><br /><input type="hidden" name="currency_code" value="USD"><br /><input type="hidden" name="a3" value="5.00"><br /><input type="hidden" name="p3" value="1"><br /><input type="hidden" name="t3" value="M"><br /><input type="hidden" name="src" value="1"><br /><input type="hidden" name="sra" value="1"><br />            </form><br />            <b>Hurry!</b><br />          <br /><br /> </tr><br /></td><br /> </table> <br /><br><br /></ br><br /><br /> 

Joined: Nov 2002
Posts: 554
Code Monkey
Code Monkey
Offline
Joined: Nov 2002
Posts: 554
argh I posted that before I got to read your post.

Problem is I want to have the images displaying in the default header in the html include section so I have the first part in the ubbt_header.tmpl and this
</center><center>
<?php echo $image_html[$random[0]]; ?>
<?php echo $image_html[$random[1]]; ?>
<?php echo $image_html[$random[2]]; ?>
<?php echo $image_html[$random[3]]; ?>
<?php echo $image_html[$random[4]]; ?>
<?php echo $image_html[$random[5]]; ?>
<?php echo $image_html[$random[6]]; ?>
</center>
in the default header

:will that not work?

Joined: Nov 2002
Posts: 554
Code Monkey
Code Monkey
Offline
Joined: Nov 2002
Posts: 554
I put the code in exactly like you decribed and it is not working. I have 6 banners and I want only one to display at a time.

When setting the variable to one nothing displays

Joined: Sep 2003
Posts: 488
Code Monkey
Code Monkey
Joined: Sep 2003
Posts: 488
Like I mentioned above, you need to convert the array into variables if posting into a template as opposed to echoing in a PHP script

So in your case it would look like this (I also gave a commented example in both sections for how to display 2 images instead of one in order to scale it up if needed)...

Code
 <!-- <? //UBBTREMARK --> <br />// File Version 6.5 <br />[:"green"] <br />$image_html = array(); <br /> <br />// Insert the HTML code below for each image or banner in the pool (don't forget the \ before the ") <br />// You can also add individual ALT and TITLE tags if you wish <br /> <br />$image_html[0] = "<a href=\"http://www.bajema.com\"><img src=\"/ubbthreads/images/banners/bajbnr.jpg\" border=\"0\"></a>"; <br />$image_html[1] = "<a href=\"http://melancholic.net\"><img src=\"/ubbthreads/images/banners/melancholicban.jpg\" border=\"0\"></a>"; <br />$image_html[2] = "<a href=\"http://www.decayingmadness.com\"><img src=\"/ubbthreads/images/banners/decayingmadness.gif\" border=\"0\"></a>"; <br />$image_html[3] = "<a href=\"http://www.vixenshop.com\"><img src=\"/ubbthreads/images/banners/vixshop.gif\" border=\"0\"></a>"; <br />$image_html[4] = "<a href=\"http://www.giger.com/mainflash.htm\"><img src=\"/ubbthreads/images/banners/giger.jpg\" border=\"0\"></a>"; <br />$image_html[5] = "<a href=\"http://www.pitchfork.de/page_en.php?\"><img src=\"/ubbthreads/images/banners/projectpitchfork.jpg\" border=\"0\"></a>"; <br />$image_html[6] = "<a href=\"http://emeraldforestseattle.com\"><img src=\"/ubbthreads/images/happyhalloween.gif\" border=\"0\"></a>"; <br /> <br />// Configure the number of unique images or banners to be displayed on the page <br />// It can be any number from 0-6 in the example given <br /> <br />$number_of_images = 1; // <-- Configure <br /> <br />$random = array_rand($image_html, $number_of_images); <br /> <br />// Convert the array into variables for posting in a template <br />// The number of lines below is the *same number* specified by $number_of_images, in this case 1 <br />$image1 = $image_html[$random[0]]; <br />// $image2 = $image_html[$random[1]]; <-- This is how it would look if using 2 images in $number_of_images, and so on <br />[/] <br /><!-- echo <<<UBBTPRINT --> <br /><!-- START OF header.tmpl TEMPLATE --> <br /><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <br /><html dir="{$ubbt_lang['READ_DIRECTION']}"> <br /><head> <br />$headerinsert <br />$refresh <br /><meta http-equiv="Content-Type" content="text/html; charset={$ubbt_lang['CHARSET']}" /> <br /><link rel="stylesheet" href="$stylesheet" type="text/css" /> <br /><link rel="shortcut icon" href="{$config['images']}/favicon.ico" /> <br />$javascript <br /><title>{$config['title']}: $inputTitle</title> <br /></head> <br /><body> <br /><!-- END OF header.tmpl TEMPLATE --> <br /><!-- UBBTPRINT --> <br /><!-- /* UBBTREMARK */ ?> --> <br /> 



And here is my generic header
Code
 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <br /> <br /><title>Emerald Forest Seattle </title> <br /> <br /> <br /> <br /><body bgcolor="#7b9b74"> <br /> <br /> <br /><center><p> <br /><table border="0" cellspacing="0" cellpadding="0" width="100%"><tr> <br /><td width="80%" align="center" valign="middle"> <br /><img src="/efsbanner.gif"> <br /> <br /> <br /><br> <br /><br> <br /></td> <br /></tr> <br /></table> <br /> <br /><table border="0" cellspacing="1" cellpadding="2" width="95%"bgcolor="#000000"><tr bgcolor="#7C8F79"><td align="center" width="20%" background="/attachments/64861-grad-02.gif"> <br /> <br /><b><a href="/faq.html" target="_new">Rules</a></b></td> <br /> <br /><td align="center" width="20%" background="/attachments/64861-grad-02.gif"><b><a href="http://efs.stats.nuclearfallout.net"target="_new">Statistics</a></b></td> <br /> <br /><td align="center" width="20%" background="/attachments/64861-grad-02.gif"><b><a href="http://216.254.1.196/~chaos/live1.6.html" target="_new">LiveStatus</a></b></td> <br /> <br /><td align="center" width="20%" background="/attachments/64861-grad-02.gif"><b><a href="/efclan/staff.html" target="_new">Staff</a></b></td> <br /> <br /><td align="center" width="20%" background="http://emeraldforestseattle.nuclearfallout.net/attachments/64861-grad-02.gif"><b><a href="/Links.html" target="_new">Links</a></b></td></tr> <br /></table> <br /> <br /><br /> <br /> <br /><!--THIS PART GOES INTO THE GENERIC HEADER--><div align="center"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td align="center" valign="top"> <br /> <br /> <br />        <table border="0" cellspacing="1" cellpadding="2" width="95%" bgcolor="#000000"> <br />          <tr> <br />          <td width="20%" class="welcome"> <br />            <form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <br />            <input type="hidden" name="cmd" value="_xclick"> <br />            <input type="hidden" name="business" value="[email protected]"> <br />            <input type="image" src="http://emeraldforestseattle.nuclearfallout.net/ubbthreads/images/x-click-but04.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!"> <br />            </form> <br />            <b>Send Money!</b> <br />          </td> <br /> <br />	  <td width="60%" td bgcolor="#92A88E"> <br /><br></ br> <br /><center>Welcome To The Forest</center> <br /><center> <br />[:"green"] <br /></center><center> <br />$image1 <br /><!-- $image2 --> <br /><!-- the 2nd image variable would go above if we were including 2 images --> <br /></center> <br />[/] <br />                 </td> <br /><td width="20%" align="right" class="welcome"> <br />  <form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <br /><input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but20.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!"> <br /><input type="hidden" name="cmd" value="_xclick-subscriptions"> <br /><input type="hidden" name="business" value="[email protected]"> <br /><input type="hidden" name="item_name" value="Emerald Forest Seattle"> <br /><input type="hidden" name="item_number" value="EFS Subscription"> <br /><input type="hidden" name="no_note" value="1"> <br /><input type="hidden" name="currency_code" value="USD"> <br /><input type="hidden" name="a3" value="5.00"> <br /><input type="hidden" name="p3" value="1"> <br /><input type="hidden" name="t3" value="M"> <br /><input type="hidden" name="src" value="1"> <br /><input type="hidden" name="sra" value="1"> <br />            </form> <br />            <b>Hurry!</b> <br /> <br /> <br /> </tr> <br /></td> <br /> </table> <br /><br> <br /></ br> <br /> <br /> 
[/]

Joined: Sep 2003
Posts: 488
Code Monkey
Code Monkey
Joined: Sep 2003
Posts: 488
[]ChAoS said:
I put the code in exactly like you decribed and it is not working. I have 6 banners and I want only one to display at a time.

When setting the variable to one nothing displays [/]

Just hold on a couple minutes, lemme test.

Joined: Nov 2002
Posts: 554
Code Monkey
Code Monkey
Offline
Joined: Nov 2002
Posts: 554
Copied exactly as above produces this

Welcome To The Forest
Happy Halloween<-this is a .gif that is hardcoded in and a banner should display below it
$image1

Joined: Sep 2003
Posts: 488
Code Monkey
Code Monkey
Joined: Sep 2003
Posts: 488
Yeah I think you're gonna need to use an include for this because the ubbt_template.tmpl file and the generic header file aren't related to one another.

I'll keep plugging away at to see if I can come up some kind of with a workable solution, and if so, I will post in this thread.

Joined: Nov 2002
Posts: 554
Code Monkey
Code Monkey
Offline
Joined: Nov 2002
Posts: 554
Thanks Twisty-I dont mind being the Guinea Pig hehe

Joined: Sep 2003
Posts: 488
Code Monkey
Code Monkey
Joined: Sep 2003
Posts: 488
It's time for another labotomy Chaos. Right then, forget everything else posted in this thread. This is a new approach, which is verified to work.

So here's what's involved...2 steps:

(see attachment, text file used so as to preserve the code spacing).
Attachments
122039-random_banners_for_chaos.txt (0 Bytes, 39 downloads)

Joined: Nov 2002
Posts: 554
Code Monkey
Code Monkey
Offline
Joined: Nov 2002
Posts: 554
Doing all of that did something funky to the table rows and bonked the layout of the page,didn't see a banner either. Its late so I will try again tomorrow-Thanks for the hard work Twisty

Joined: Sep 2003
Posts: 488
Code Monkey
Code Monkey
Joined: Sep 2003
Posts: 488
I found the mistake, all fixed now (redownload the attachment). I personally tested it on my site

The new method is even simpler, you no longer have to
edit ubbt.inc.php

Joined: Nov 2002
Posts: 554
Code Monkey
Code Monkey
Offline
Joined: Nov 2002
Posts: 554
wow Twisty thats great,thanks for the hard work on that

*edit* This is working great Twisty-Thanks again!! *edit*

I know how much time you spent on it

Last edited by ChAoS; 10/26/2004 12:37 PM.
Joined: Sep 2003
Posts: 488
Code Monkey
Code Monkey
Joined: Sep 2003
Posts: 488
Ok good to hear

Joined: Nov 2002
Posts: 554
Code Monkey
Code Monkey
Offline
Joined: Nov 2002
Posts: 554
Would it be hard to add in a variable that would rotate them without refreshing the page?
Maybe something similar to this?


<?php // DynAds: Display an ad per period
$StartDate = "15 January 2004" ;
$PeriodHours = 24 ;
$AdGroup = "NameOfTheAdGroup" ;
$DispPosName = "NameForThisAdDisplayPosition" ;
$ScriptUrl = "http://YourDomain/DynAdsInstallPath/ad.pl" ;
// No editing beyond this line
$PerCount = (int)((time() - strtotime($StartDate)) / ($PeriodHours*60*60)) ;
$url = $ScriptUrl . "?pos=" . urlencode($DispPosName) . "&agn=" . urlencode($AdGroup) . "&dsp=html&sel=seq&ano=" . $PerCount ;
@include($url) ;
?>
<<<<gets ready to duck and run


$ScriptUrl = "http://YourDomain/DynAdsInstallPath/ad.pl" ;

could be taken out and replaced with banners.inc.php (I think)

maybe like so

<?php // DynAds: Display an ad per period
$StartDate = "15 January 2004" ;
$PeriodHours = 24 ;
$AdGroup = "Test" ;
$DispPosName = "Test" ;
$ScriptUrl = "http://emeraldforestseattle.nuclearfallout.net/ubbthreadss/includes/banners.inc.php" ;
// No editing beyond this line
$PerCount = (int)((time() - strtotime($StartDate)) / ($PeriodHours*1*1)) ;
$url = $ScriptUrl . "?pos=" . urlencode($DispPosName) . "&agn=" . urlencode($AdGroup) . "&dsp=html&sel=seq&ano=" . $PerCount ;
@include($url) ;
?>

and it would rotate every minute

or is this over killl and I should just use Meta Refresh?

Last edited by ChAoS; 10/26/2004 1:15 PM.
Joined: Sep 2003
Posts: 488
Code Monkey
Code Monkey
Joined: Sep 2003
Posts: 488
[]ChAoS said:
Would it be hard to add in a variable that would rotate them without refreshing the page?
Maybe something similar to this?


<?php // DynAds: Display an ad per period
$StartDate = "15 January 2004" ;
$PeriodHours = 24 ;
$AdGroup = "NameOfTheAdGroup" ;
$DispPosName = "NameForThisAdDisplayPosition" ;
$ScriptUrl = "http://YourDomain/DynAdsInstallPath/ad.pl" ;
// No editing beyond this line
$PerCount = (int)((time() - strtotime($StartDate)) / ($PeriodHours*60*60)) ;
$url = $ScriptUrl . "?pos=" . urlencode($DispPosName) . "&agn=" . urlencode($AdGroup) . "&dsp=html&sel=seq&ano=" . $PerCount ;
@include($url) ;
?>
<<<<gets ready to duck and run
[/]

Ewww.

What you'll want to do is use client-side scripting for this task ie. Javascript as opposed to server-side scripting ie. PHP

So try this instead then. Add the following code to your generic template where the PHP include line is from my original mod which won't be needed anymore...

Code
 <script language="JavaScript"> <br /> <!-- <br /> function adArray() { <br />  for (i=0; i*2<adArray.arguments.length; i++) { <br />   this[i] = new Object(); <br />   this[i].src = adArray.arguments[i*2]; <br />   this[i].href = adArray.arguments[i*2+1]; <br />  } <br />  this.length = i; <br /> } <br /> function getAdNum() { <br />  dat = new Date(); <br />  dat = (dat.getTime()+"").charAt(8); <br />  if (dat.length == 1) <br />   ad_num  = Math.floor(Math.random() * ads.length); <br />  else <br />   ad_num = 0; <br />  return ad_num; <br /> } <br /> var ads = new adArray( <br /> <br /> "/ubbthreads/images/banners/bajbnr.jpg","http://www.bajema.com", <br /> "/ubbthreads/images/banners/melancholicban.jpg","http://melancholic.net", <br /> "/ubbthreads/images/banners/decayingmadness.gif","http://www.decayingmadness.com", <br /> "/ubbthreads/images/banners/vixshop.gif","http://www.vixenshop.com", <br /> "/ubbthreads/images/banners/giger.jpg","http://www.giger.com/mainflash.htm", <br /> "/ubbthreads/images/banners/projectpitchfork.jpg","http://www.pitchfork.de/page_en.php?", <br /> "/ubbthreads/images/happyhalloween.gif","http://emeraldforestseattle.com"); <br /> <br /> var ad_num = getAdNum(); <br /> document.write('<CENTER><TABLE CELLPADDING=0 CELLSPACING=1 BORDER=0><TR><TD ' <br /> +'ALIGN=CENTER>'+'</TD><TR></TR><TD><A HREF="'+ads[ad_num].href+'"><IMG SRC="'+ads[ad_num].src+'" ' <br /> +'WIDTH="468" HEIGHT="60" BORDER=0 name=js_ad></A></TD></TR></TABLE></CENTER>'); <br /> link_num = document.links.length-1; <br /> function rotateSponsor() { <br />  if (document.images) { <br />   ad_num = (ad_num+1)%ads.length; <br />   document.js_ad.src = ads[ad_num].src; <br />   document.links[link_num].href = ads[ad_num].href; <br />   setTimeout("rotateSponsor()",60000); <br />  } <br /> } <br /> setTimeout("rotateSponsor()",60000); <br /> // --> <br /> </script>  

Joined: Nov 2002
Posts: 554
Code Monkey
Code Monkey
Offline
Joined: Nov 2002
Posts: 554
So what do you think of the latter? Would it be usefull or just a matter of preference?

Joined: Sep 2003
Posts: 488
Code Monkey
Code Monkey
Joined: Sep 2003
Posts: 488
[]ChAoS said:
So what do you think of the latter? Would it be usefull or just a matter of preference? [/]

Well it's just not the best way to go about it even if you could get it running perfectly. More inefficient compared to doing it client-side which is designed for this kind of thing :-)

PS - I added a tweak to the Javascript so that it no longer always starts cycling on the 1st image after a refresh, but rather chooses one randomly now and then cycles in order from there. This helps to ensure better coverage of the group.


Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
Zarzal
Zarzal
Berlin, Germany
Posts: 808
Joined: July 2001
Forum Statistics
Forums63
Topics37,575
Posts293,932
Members13,824
Most Online6,139
Sep 21st, 2024
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,835
Greg Hard 4,625
Top Posters(30 Days)
Gizmo 1
Top Likes Received
isaac 82
Gizmo 20
Brett 7
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2025 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.1
(Snapshot build 20240918)