Quantcast

Jump to content

» «
Photo

How to make a rotating signature

4 replies to this topic
Josh
  • Josh

    I wasn't born so much as I fell out

  • The Connection
  • Joined: 10 Oct 2010
  • None

#1

Posted 23 December 2010 - 10:28 PM

MAKE YOUR OWN ROTATING SIGNATURE!


Since the collapse of the rotating signature site Clintonio.com there have been a few bemused members asking how they can get their rotating signatures online. Well you could always use another host, but that would still be relying on other people. Your images will still be subject to various potential problems such as hacking attacks, site closedowns etc. So I thought that I'd compile an easy to follow guide, below are the 5 steps which you can follow to get your own rotating signature.

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. Some free webhosts are available in the WD&P Mega Topic which is pinned at the top of this forum. However these sites need to have support for PHP. I'll post a few sites which definitely support PHP in the second post.

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 "rotate.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.

Step 3: Upload your files

Upload all of the images which you want to be in your rotator to the "rotate.jpg" directory. Make sure that they all adhere to the signature size rules, you will have to make sure that they are all a maximum of 150x500 pixels in size, and that none of them exceed the filesize limit which stands at 80kb at the moment. If your signature is disabled, then that is why.

Also, make sure that the files which you upload are only files with the following extensions:
      • .jpg
      • .jpeg
      • .png
      • .gif
The script won't be able to read any other filetypes.

Now you can move on to the meaty part, the coding itself.

Step 4: Make the index.php file

Open up notepad, wordpad 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 "rotate.jpg" directory which you created in step 2.

Step 5: Get your rotator

Create an [IMG] tag which links to your rotate.jpg directory. An example is below.
CODE
[img]http://goatse.110mb.com/rotate.jpg[/img]

Add that to your sig to see a very boring rotator signature which I knocked up in my spare time a week or so ago. You will get a message which states that GTAF couldn't check the filesize of your images because you are using a rotator, but as long as you don't click the back button on your browser your sig will be saved and it will be updated.

So there you have it, your very own rotating signature! Assorted links which you may need are provided in the next post.

Josh
  • Josh

    I wasn't born so much as I fell out

  • The Connection
  • Joined: 10 Oct 2010
  • None

#2

Posted 23 December 2010 - 10:35 PM

ASSORTED LINKS

Free PHP webhosts:
Rotating signature hosts:

I only know of one, located at kzemo.com. The signup process is easy, just enter a username, and confirm a password. Then add the links to your images and make your own rotator. A direct link is provided and you have the option to edit or delete your rotators at a later date.

Image hosts:

If you want to use kzemo.com's option then you'll need an image hosting site. Some excellent ones are linked to in the WD&P Mega Topic.

fred
  • fred

  • Moderator
  • Joined: 20 Jul 2002
  • None

#3

Posted 24 December 2010 - 03:20 PM

It's probably widely accepted enough to not be a problem but the proper mime type for .jpg images is still image/jpeg, not image/jpg.

Also, if you're rotating it every second, it may as well be random. It might be worth slowing that down or trying cookie based rotation.

GTArv
  • GTArv

    #

  • Members
  • Joined: 29 Feb 2008

#4

Posted 24 December 2010 - 04:27 PM

Terrific script. I like the way how its automated, allowing the user to add or remove images to the rotator by simply adding/removing files.

It may not work well with free webhosts though - they may have directory reading disabled and the gd library not installed, apart from capping CPU and memory usage. In such cases it would be better to store the images with an image host and make a redirect to their locations.
CODE
$images = array(
'http://i43.tinypic.com/blah.png',
'http://i39.tinypic.com/sssfssf.gif',
'http://im2s.imageshack.us/fwljwy.jpg'
);

$idx = rand(0, count($images)-1);
header('Location: '.$images[$idx]);

This would mean a trade-off by manual editing of the file every time an image needs to be added or removed from the rotator.



Josh
  • Josh

    I wasn't born so much as I fell out

  • The Connection
  • Joined: 10 Oct 2010
  • None

#5

Posted 29 December 2010 - 05:51 PM

I didn't really consider that GTArv, thanks. There are some good PHP webhsts out there for very little money which don't limit all of the points which you mentioned. And if I were to make it like that then it wouldn't be as easy for the user to make their rotator work. However in cases of free webhosts that is almost certianly a more advantageous routeto go down.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users