NineChime forum

Furry stuff, oekaki stuff, and other stuff.

You are not logged in.

#1 03-29-2008 12:46:05

AlkseeyaKC
Member

random banner background image.

I have been using this site that makes images random for you so you can have one URL for all of them. Example would be http://www.tektek.org/account/signup.vex

But they have not been completely reliable. So I'm trying to work a Java Script in so I don't need to go threw them. But I don't really know what I am doing. XD
I'm trying to use the scripting from http://javascript.internet.com/miscella … image.html

Here is where I'm trying to use it:
http://i6.photobucket.com/albums/y212/AlkseeyaKC/Picture7.png
This is in my template.

http://i6.photobucket.com/albums/y212/AlkseeyaKC/Picture8.png

the image needs to go in the background be hind the logo.

I could just make make the logo part of the background image. to be easy. But I really wanted it centered on all browsers.

Offline

#2 03-29-2008 13:51:59

Trunksi
Member

Re: random banner background image.

I always used this one:
http://ma.tt/scripts/randomimage/

I'm not sure if the code is a good one (I hope it's trustworthy... lol) ... but it worked for me tongue
and the best: you don't have to name every picture
just put it in that folder is enough


So I saved this as a php-file and putting a simple <img>-code in the banner-box big_smile

Last edited by Trunksi (03-29-2008 13:57:20)

Offline

#3 03-29-2008 23:40:51

AlkseeyaKC
Member

Re: random banner background image.

LOL there instructions are not user friendly. I don't understand if I should be or were I should be changing stuff or where it goes! X_x;;

I made a BG.php file:
http://i6.photobucket.com/albums/y212/AlkseeyaKC/Picture7-1.png

and I added this to my template:
http://i6.photobucket.com/albums/y212/AlkseeyaKC/Picture5.png

What am I doing wrong! >_<;;;?

EDIT: I don't know how or why, But I have a java button were the banner should be. O_o
I'm going to keep messing with it, I think I'm getting closer some how. XD

Edit: nope not working. I realized that I think I need the .php in the same folder. So I put it in with the BGs.  But I still don't know why its not working. =/

Last edited by AlkseeyaKC (03-30-2008 00:02:23)

Offline

#4 03-30-2008 03:47:32

Waccoon
Administrator

Re: random banner background image.

The bug is in this line:

Code:

if ('http://oekamie.divagate.com/BGs/' == $folder) $folder = './';

This line will compare the hard-coded path to $folder, and find them to be identical, so it sets the folder path to ./ instead of what we want, which is ./BGs/.  The reason why you get a Java button is because the script is serving the image files from the root folder, instead of the ./BGs/ folder.

Here's the full script (with a few tweaks).  It's easier to use relative paths, anyway:

Code:

<?php
/*
    By Matt Mullenweg > http://ma.tt
    Tweaked a bit by Waccoon
    Inspired by Dan Benjamin > http://hiveware.com/imagerotator.php
    Latest version always at:
    http://ma.tt/scripts/randomimage/
*/


// -- CONFIG --

// Make this the relative path to the images, like "../img" or "random/images/".
// If the images are in the same directory, leave it blank.
$folder = './BGs/';

// Array of extensions, all lower case.
// You probably won't have to change this.
$exts = array('jpg', 'jpeg', 'png', 'gif');



// -- DO NOT CHANGE ANYTHING BELOW THIS LINE --

// Verify config
if (!isset($folder) || empty($folder)) {
    $folder = './';
}
if (!isset($exts) || empty($exts)) {
    $exts = array('jpg', 'jpeg', 'png', 'gif');
}

// Open the directory
$files = array();
$handle = opendir($folder);
while (false !== ($file = readdir($handle))) {
    foreach($exts as $ext) {
        // for each extension, check the extension
        if (strpos(strtolower($file), '.'.$ext) !== false) {
            $files[] = $file; // it's good
        }
    }
}
closedir($handle); // We're not using it anymore

$i = count($files);
if ($i > 0) {
    mt_srand( (double) microtime() * 1000000); // seed for PHP < 4.2
    $rand = mt_rand(0, count($files));

    header('Location: '.$folder.$files[$rand]); // Voila!
}
exit();

?>

Offline

#5 03-30-2008 11:40:24

AlkseeyaKC
Member

Re: random banner background image.

IT WORKS NOW!!! Thank you soooo much Trunksi and Waccoon! <3

Offline

Board footer

Yep, still running PunBB
© Copyright 2002–2008 PunBB