Author Topic: Random gallery banner 2006  (Read 6267 times)

0 Members and 1 Guest are viewing this topic.

Offline Flo2005

  • Full Member
  • ***
  • Posts: 237
  • Copy & Paste Profi :)
    • View Profile
    • snuup.de! - Bilder - Sounds - Videos - fun4FREE!
Random gallery banner 2006
« on: February 25, 2006, 09:57:32 PM »
I have found a script which can be very usefull for your website.

The following MOD looks like "random-image" on your gallery but it works with your gallery-banner

Each refresh on your page loads new banner with different urls -> you can try this here http://www.snuup.de/lite

1. Create a new file e.g. banner_2006.php and paste this code into it -> save it in root of 4images gallery

1b. Define the path of $base_dir & $img_url

Code: [Select]
<?php

/* Banner Simple, Version 1.0
 * by Dan Kaplan <dan@abledesign.com>
 * Last Modified: January 10, 2003
 * --------------------------------------------------------------------
 *
 * USE THIS LIBRARY AT YOUR OWN RISK; no warranties are expressed or
 * implied. You may modify the file however you see fit, so long as
 * you retain this header information and any credits to other sources
 * throughout the file.  If you make any modifications or improvements,
 * please send them via email to Dan Kaplan <dan@abledesign.com>.
 * --------------------------------------------------------------------
*/

$base_dir '/path/to/www/';
$img_url 'http://www.mysite.com/4images/templates/default/images/banner';

// add any banner sizes (width x height) that you will use:
// IAB Standards & Guidelines:  http://www.iab.net/standards/adunits.asp
$banner_sizes = array ("468x60""100x60""405x60""100x38""300x250""250x250""240x400""336x280""180x150""234x60""88x31""120x90""120x60""120x240""125x125""160x600""120x600");

$srand_called FALSE;
$last_file '';
$array '';

function 
get_banner($size='') {
global $base_dir$img_url$banner_sizes$srand_called$last_file$array;

if (empty($size) || !in_array($size$banner_sizes)) {
$size "468x60";
}

$size_split explode("x"$size);
$width $size_split[0];
$height $size_split[1];

if (empty($last_file) || ($size != $last_file) || !is_array($array)) {
// if calling muliple banners on one page, no need to read in the same file repeatedly.  so,
// if the last banner file read in is the next one called, pull the $array array from memory.

$file $base_dir."/templates/default/images/banner/banner_".$size.".txt";
if (!file_exists($file)) {
// could not load the banner file, so create a default blank image and exit
$banner "<img src=\"\" width=\"$width\" height=\"$height\" border=\"0\" alt=\"broken image\">";
return $banner;
}
$array file($file); // read $file into an array
$last_file $size; // save the last read-in file into memory
}

if (!$srand_called) {
// slightly less random without this; srand() should only be called once for multiple banners
mt_srand ((double) microtime() * 1000000);
$srand_called TRUE;
}

$rand mt_rand(1count($array)-1); // start at 1 to ignore comment line
$line chop($array[$rand]);

# URL | target="_blank" (1/0) | off-site image (1/0) | image | Alt text
$banner_split explode("|"$line);
$URL $banner_split[0];
$blank $banner_split[1];
$off_site $banner_split[2];
$image $banner_split[3];
$alt $banner_split[4];

if ($blank == 1) {
$target "target=\"_blank\"";
} else {
$target "";
}

if ($off_site == 1) {
$image $image;
} else {
$image "$img_url/$image";
}

$banner "<a href=\"$URL\" $target><img src=\"$image\" width=\"$width\" height=\"$height\" border=\"0\" alt=\"$alt\"></a>";
return $banner;
}

?>

2. Create a new folder templates/default/images/banner

3. Create a new txt file called banner_405x60.txt and paste this line into it
Code: [Select]
# URL | target="_blank" (1 = Yes, 0 = No) | off-site image (1 = Yes, 0 = No) | image | Alt text
4. Now you can add your banner and define url, target, image,... (off-site image 1 -> image is remote linked)
Code: [Select]
# URL | target="_blank" (1 = Yes, 0 = No) | off-site image (1 = Yes, 0 = No) | image | Alt text
http://www.mysite.com/4images/index.php|0|0|gallery_home.gif|Welcome to our gallery

5. Edit the following files:

categories.php
details.php
guestbook.php*
index.php
lightbox.php
member.php
memberlist.php*
pm.php*
postcards.php
register.php
search.php
top.php

*when you have installed this mod

Note: If you have installed other MODs - you have also edit these "TopLevel PHP" files!

Search in every file which is listed above:

Code: [Select]
require(ROOT_PATH.'includes/sessions.php');
Add below:

Code: [Select]
include(ROOT_PATH.'banner_2006.php');
6. Open your templates/default/

categories.html
details.html
guestbook.html*
home.html
lightbox.html
member.html
memberlist.html*
pm.html*
postcards.html
register.html
search.html
top.html

Find:
Code: [Select]
<img src="{template_url}/images/header_logo.gif" width="405" height="60" alt="" />
Replace:
Code: [Select]
<?php
echo 
get_banner("405x60");
?>

If you have installed a Template from Bali-Webdesign you have only edit header.html

*when you have installed this mod

The positive effect of this script is that you can call banner with different sizes with the same banner_2006.php

e.g.
Code: [Select]
<?php
echo 
get_banner("88x31");
?>

Now I hope I´ve nothing forget to explain! Good luck! :wink:

Project offline

Offline $tony

  • Pre-Newbie
  • Posts: 9
    • View Profile
Re: Random gallery banner 2006
« Reply #1 on: April 27, 2006, 03:25:57 PM »
hi also ich glaube genau das was du hier geschildert hast brauche ich also einen banner auf der index seite und evtl bei neugeladener seite ein anderer kommt.

nun ist es so das mien englisch extremm mies ist könntest du mir das mal in deutsch erklären?????

wäre dir sehr dankbar.

MFG
$tony

Offline Flo2005

  • Full Member
  • ***
  • Posts: 237
  • Copy & Paste Profi :)
    • View Profile
    • snuup.de! - Bilder - Sounds - Videos - fun4FREE!
Re: Random gallery banner 2006
« Reply #2 on: October 02, 2006, 10:59:49 AM »
Sorry, war lange nicht mehr aktiv im Forum, hat es denn mittlerweile geklappt bei Dir?

Project offline