• Welcome to ForumKorner!
    Join today and become a part of the community.

Making your Signature Randomizer

Jimmy

Ex-Staff Member
Reputation
0
Making your Signature Randomizer

Step 1: Get your own web host

For this step you need an actual webhosting service that supports the use of the PHP language. If you already have your website set up then you can skip this step.

Once you've set up your site (it shouldn't take too long, you normally just have to provide a username, password, website name and a contact email address for yourself. Personal details are sometimes required, but you can sometimes skip that part.) you can move on to step number 2.

Step 2: Create your directory

Once your site is set up and is running, you can create a new directory (folder) on the root of your site and call it "random.jpg." Actually you can call it whatever you like but remember to change the referenced names at the end. And yes you can create directories which have dots in them followed by extensions.

Upload all of the images which you want to be in your rotator to the "random.jpg" directory.

Also, make sure that the files which you upload are only files with the following extensions:

.jpg
.jpeg
.png
.gif

Step 4: Make the index.php file

Open up notepad or an equivalent plain text editor, it doesn't really matter which. Then copy and paste the following code into your document. For easy copy and pasting, Ctrl + Click in the white box, then press Ctrl + C.

Code:
<?php
// This script randomly selects and displays images from the current directory
// It is a stripped-down version of the Automatic Image Rotator script by Dan P. Benjamin.

// Set image filename extensions
$extList = array();
$extList['gif'] = 'image/gif';
$extList['jpg'] = 'image/jpg';
$extList['jpeg'] = 'image/jpeg';
$extList['png'] = 'image/png';

// Get contents of current directory
$fileList = array();
$handle = opendir("./");
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 = $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);
}
}

?>

Save this file as index.php and upload it into the "random.jpg" directory which you created in step 2.

Step 5: Save your rotator

Create an tag which links to your random.jpg directory. An example is below.

[code][img]http://yourhost.com/random.jpg[/code]

 

Testicle

Active Member
Reputation
0
I got stuck on the first step
 

Testicle

Active Member
Reputation
0
Hopefully theres an easier way. Theres no way I can do this.
 

Sanctuary

User is banned.
Reputation
0
Ocean made a thread with a similar (or same) script. If it's what I'm thinking it is, at least.
http://www.forumkorner.org/thread-35035.html

Some of you may find his tutorial easier.

I'm currently using this script with my avatar.
Here's another example of what it looks like:
new


Every time you refresh, the image changes into something else. :p Pretty cool.

Either way, good tutorial Jimmy.

If anybody wants me to do it for them so they can use it, let me know. :p

Catholic‍ said:
Now everyone can copy off of Awkward Penguin, quality tut Jim.

No, you're mistaken. Penguin Paul's script is entirely different.
 
Top