<?php
$folder = './';
$extList = array();
$extList['gif'] = 'image/gif';
$extList['jpg'] = 'image/jpeg';
$extList['jpeg'] = 'image/jpeg';
$extList['png'] = 'image/png';
$img = null;
if (substr($folder,-1) != '/') {
$folder = $folder.'/';
}
if (isset($_GET['img'])) {
$imageInfo = pathinfo($_GET['img']);
if (
isset( $extList[ strtolower( $imageInfo['extension'] ) ] ) &&
file_exists( $folder.$imageInfo['basename'] )
) {
$img = $folder.$imageInfo['basename'];
}
} else {
$fileList = array();
$handle = opendir($folder);
while ( false !== ( $file = readdir($handle) ) ) {
$file_info = pathinfo($file);
if (
isset( $extList[ strtolower( $file_info['extension'] ) ] )
) {
$fileList[] = $file;
}
}
closedir($handle);
if (count($fileList) > 0) {
$imageNumber = time() % count($fileList);
$img = $folder.$fileList[$imageNumber];
}
}
if ($img!=null) {
$imageInfo = pathinfo($img);
$contentType = 'Content-type: '.$extList[ $imageInfo['extension'] ];
header ($contentType);
readfile($img);
} else {
if ( function_exists('imagecreate') ) {
header ("Content-type: image/png");
$im = @imagecreate (100, 100)
or die ("Cannot initialize new GD image stream");
$background_color = imagecolorallocate ($im, 255, 255, 255);
$text_color = imagecolorallocate ($im, 0,0,0);
imagestring ($im, 2, 5, 5, "IMAGE ERROR", $text_color);
imagepng ($im);
imagedestroy($im);
}
}
?>
Is it possible to add a different set of rotating banners to different nodes? I have been creating children styles of my default style with a different banner set in the ad_above_top_breadcrumb template of each one and then assigning that style to the node the banners are for, but we have like 30 boards and I can't even get it so save anymore. I tried adding a conditional but I couldn't get it to work.
So say I had 3 boards with 2 banners in each one, is it possible to show those banners, in their respective nodes only, with all of the code in the same template/style? I actually have about 25 in my main board area and there are like 5 other boards that get 3 or 4 each. Maybe this would be a good suggestion for an add-on.
<xen:comment>DEFINE AND RANDOMIZE YOUR BANNERS</xen:comment>
<xen:if is="{$forumId} == 2">
<xen:set var="$banners.1">banner one for forumId 2</xen:set>
<xen:set var="$banners.2">banner two for forumId 2</xen:set>
<xen:set var="$banners.3">banner three for forumId 2</xen:set>
<xen:set var="$banners.4">banner four for forumId 2</xen:set>
<xen:elseif is="{$forumId} == 4" />
<xen:set var="$banners.1">banner one for forumId 4</xen:set>
<xen:set var="$banners.2">banner two for forumId 4</xen:set>
<xen:set var="$banners.3">banner three for forumId 4</xen:set>
<xen:set var="$banners.4">banner four for forumId 4</xen:set>
<xen:set var="$banners.5">banner five for forumId 4</xen:set>
<xen:else />
<xen:set var="$banners.1">banner one for all other forums and pages</xen:set>
<xen:set var="$banners.2">banner two for all other forums and pages</xen:set>
<xen:set var="$banners.3">banner three for all other forums and pages</xen:set>
</xen:if>
<xen:foreach loop="$banners" value="$curBanner" i="$i" count="$count">
<xen:if is="!{$rand}">
<xen:set var="$rand">{xen:calc '({$serverTime} % {$count}) + 1'}</xen:set>
</xen:if>
<xen:if is="{$i} == {$rand}">
{xen:raw '$banners.{$rand}'}
</xen:if>
</xen:foreach>
<xen:container var="$forumId">{$forum.node_id}</xen:container>
Thank you so much, this is just what I needed. We really appreciate the support you guys offer.Here is code for you. Note that with this code I have generalized the banner selection in the foreach loop. This allows you to specify different numbers of banners for each forum, and you no longer have to specify the total number of banners for the rand calculation:
Edit: got it to work through a different route. Still annoyed that users can copy my banner though, is there a way to void the link that allows them to save the image?
There is no way to prevent it. No matter what method you use, the image must still be downloaded by the client which allows a user to save it.
Where it says banner one, banner two etc
Can I put a google adsense or chitika javascript ad code for each space?
Here is code for you. Note that with this code I have generalized the banner selection in the foreach loop. This allows you to specify different numbers of banners for each forum, and you no longer have to specify the total number of banners for the rand calculation:
Rich (BB code):<xen:comment>DEFINE AND RANDOMIZE YOUR BANNERS</xen:comment> <xen:if is="{$forumId} == 2"> <xen:set var="$banners.1">banner one for forumId 2</xen:set> <xen:set var="$banners.2">banner two for forumId 2</xen:set> <xen:set var="$banners.3">banner three for forumId 2</xen:set> <xen:set var="$banners.4">banner four for forumId 2</xen:set> <xen:elseif is="{$forumId} == 4" /> <xen:set var="$banners.1">banner one for forumId 4</xen:set> <xen:set var="$banners.2">banner two for forumId 4</xen:set> <xen:set var="$banners.3">banner three for forumId 4</xen:set> <xen:set var="$banners.4">banner four for forumId 4</xen:set> <xen:set var="$banners.5">banner five for forumId 4</xen:set> <xen:else /> <xen:set var="$banners.1">banner one for all other forums and pages</xen:set> <xen:set var="$banners.2">banner two for all other forums and pages</xen:set> <xen:set var="$banners.3">banner three for all other forums and pages</xen:set> </xen:if> <xen:foreach loop="$banners" value="$curBanner" i="$i" count="$count"> <xen:if is="!{$rand}"> <xen:set var="$rand">{xen:calc '({$serverTime} % {$count}) + 1'}</xen:set> </xen:if> <xen:if is="{$i} == {$rand}"> {xen:raw '$banners.{$rand}'} </xen:if> </xen:foreach>
Add more elseif's to check more forumIds.
But before this will work you need to pass the node_id using xen:container. Edit these two templates:
Admin CP -> Appearance -> Templates
> forum_view
> thread_view
Add this line to the top of each template:
Code:<xen:container var="$forumId">{$forum.node_id}</xen:container>
<xen:comment>DEFINE AND RANDOMIZE YOUR BANNERS</xen:comment>
<xen:if is="{$forum.node_id} == 2">
<xen:set var="$banners.1">banner one for forumId 2</xen:set>
<xen:set var="$banners.2">banner two for forumId 2</xen:set>
<xen:set var="$banners.3">banner three for forumId 2</xen:set>
<xen:set var="$banners.4">banner four for forumId 2</xen:set>
<xen:elseif is="{$forum.node_id} == 4" />
<xen:set var="$banners.1">banner one for forumId 4</xen:set>
<xen:set var="$banners.2">banner two for forumId 4</xen:set>
<xen:set var="$banners.3">banner three for forumId 4</xen:set>
<xen:set var="$banners.4">banner four for forumId 4</xen:set>
<xen:set var="$banners.5">banner five for forumId 4</xen:set>
<xen:else />
<xen:set var="$banners.1">banner one for all other forums and pages</xen:set>
<xen:set var="$banners.2">banner two for all other forums and pages</xen:set>
<xen:set var="$banners.3">banner three for all other forums and pages</xen:set>
</xen:if>
<xen:foreach loop="$banners" value="$curBanner" i="$i" count="$count">
<xen:if is="!{$rand}">
<xen:set var="$rand">{xen:calc '({$serverTime} % {$count}) + 1'}</xen:set>
</xen:if>
<xen:if is="{$i} == {$rand}">
{xen:raw '$banners.{$rand}'}
</xen:if>
</xen:foreach>
<xen:set var="$banners.1">http://www.xxxxxxxxx/logo1.png</xen:set>
<xen:set var="$banners.2">http://www.xxxxxxxxx/logo2.png</xen:set>
<xen:set var="$banners.3">http://www.xxxxxxxxx/logo3.gif</xen:set>
<div id="logoBlock">
<div class="pageWidth">
<div class="pageContent">
<xen:include template="ad_header" />
<xen:hook name="header_logo">
<div id="logo"><a href="{$logoLink}">
<span><xen:comment>This span fixes IE vertical positioning</xen:comment></span>
<img src="{xen:raw '$banners.{xen:calc '({$serverTime} % 3) + 1'}'}" alt="{$xenOptions.boardTitle}" />
</a></div>
</xen:hook>
<span class="helper"></span>
</div>
</div>
</div>
<xen:comment>DEFINE AND RANDOMIZE YOUR BANNERS</xen:comment>
<xen:set var="$banners.1"><a href="http://www.simonrevill.com/wedding-workflow-and-processing-1-to-1-photographer-training"><img src="http://www.ippn.co.uk/DFPpartners/ADbanner1.png" /></xen:set>
<xen:set var="$banners.2"><a href="http://www.simonrevill.com/wedding-workflow-and-processing-1-to-1-photographer-training"><img src="http://www.ippn.co.uk/DFPpartners/ADbanner1.png" /></xen:set>
<xen:set var="$banners.3"><a href="http://www.simonrevill.com/wedding-workflow-and-processing-1-to-1-photographer-training"><img src="http://www.ippn.co.uk/DFPpartners/ADbanner1.png" /></xen:set>
<xen:set var="$rand">{xen:calc '({$serverTime} % 3) + 1'}</xen:set>
{$banners.{$rand}}
I'm trying to add banners at the top right of the forum to be displayed all the time - whatever node people are looking at
Now I also want the banner to be clickable to go to a different site address
I thought I needed to edit ad_header
with this code
Code:<xen:comment>DEFINE AND RANDOMIZE YOUR BANNERS</xen:comment> <xen:set var="$banners.1"><a href="http://www.simonrevill.com/wedding-workflow-and-processing-1-to-1-photographer-training"><img src="http://www.ippn.co.uk/DFPpartners/ADbanner1.png" /></xen:set> <xen:set var="$banners.2"><a href="http://www.simonrevill.com/wedding-workflow-and-processing-1-to-1-photographer-training"><img src="http://www.ippn.co.uk/DFPpartners/ADbanner1.png" /></xen:set> <xen:set var="$banners.3"><a href="http://www.simonrevill.com/wedding-workflow-and-processing-1-to-1-photographer-training"><img src="http://www.ippn.co.uk/DFPpartners/ADbanner1.png" /></xen:set> <xen:set var="$rand">{xen:calc '({$serverTime} % 3) + 1'}</xen:set> {$banners.{$rand}}
But all I'm getting is a line of code <a to /> displayed above my forum logo on the left hand side ?
<xen:hook name="ad_header" />
<xen:comment>DEFINE AND RANDOMIZE YOUR BANNERS</xen:comment>
<xen:set var="$banners.1"><a href="http://www.simonrevill.com/wedding-workflow-and-processing-1-to-1-photographer-training"><img src="http://www.ippn.co.uk/DFPpartners/ADbanner1.png" /></a></xen:set>
<xen:set var="$banners.2"><a href="http://www.simonrevill.com/wedding-workflow-and-processing-1-to-1-photographer-training"><img src="http://www.ippn.co.uk/DFPpartners/ADbanner1.png" /></a></xen:set>
<xen:set var="$banners.3"><a href="http://www.simonrevill.com/wedding-workflow-and-processing-1-to-1-photographer-training"><img src="http://www.ippn.co.uk/DFPpartners/ADbanner1.png" /></a></xen:set>
{xen:raw '$banners.{xen:calc '({$serverTime} % 3) + 1'}'}
How do I get it to sit at the right hand side not in the middle
<div style="float: right;">
</div>
We use essential cookies to make this site work, and optional cookies to enhance your experience.