Jump to content
xisto Community
thablkpanda

Yet Another Signature Rotator (Easier, and more Efficient)

Recommended Posts

Hey Trap, It's Mr. Panda, and I'm introducing a signature rotator script I came across several months ago. Unlike most other signature rotators on Xisto, this one does DOES NOT require the configuration process, and a new signature can be added, simply by uploading it to the proper directory. Seeing as this requires so much less configuration, I do hope it will be implemented by some of you 'Sig Masters' out there :), that have to add another line of code to your rotator file each time you want to add a new sig. This simplifies the process greatly. Enough chit-chat. Let's get this one-time install over with :) -

Necessary stuff -
1. Host supporting PHP (required) ,.htaccess,(optional) and CHMOD (optional) (Xisto does)
2. More than one signature file to rotate
3. Plain-Text editor, or specialized PHP Editor (PHP Designer 2005, Notepad, etc.)
4. FTP Client

Procedure -

Step 1
Create a new .php file, named 'index.php' (no quotes). Copy and Paste the following code into that PHP file, and save and close.
 



<?php/* AUTOMATIC IMAGE ROTATOR Version 2.2 - December 4, 2003 Copyright (c) 2002-2003 Dan P. Benjamin, Automatic, Ltd. All Rights Reserved. hiveware.com/imagerotator.php automaticlabs.com/ DISCLAIMER Automatic, Ltd. makes no representations or warranties about the suitability of the software, either express or implied, including but not limited to the implied warranties of merchantability, fitness for a particular purpose, or non-infringement. Dan P. Benjamin and Automatic, Ltd. shall not be liable for any damages suffered by licensee as a result of using, modifying or distributing this software or its derivatives. ABOUT This PHP script will randomly select an image file from a folder of images on your webserver.  You can then link to it as you would any standard image file and you'll see a random image each time you reload. When you want to add or remove images from the rotation-pool, just add or remove them from the image rotation folder. VERSION CHANGES Version 1.0  - Release version Version 1.5  - Tweaked a few boring bugs Version 2.0  - Complete rewrite from the ground-up  - Made it clearer where to make modifications  - Made it easier to specify/change the rotation-folder  - Made it easier to specify/change supported image types  - Wrote better instructions and info (you're them reading now)  - Significant speed improvements  - More error checking  - Cleaner code (albeit more PHP-specific)  - Better/faster random number generation and file-type parsing  - Added a feature where the image to display can be specified  - Added a cool feature where, if an error occurs (such as no    images being found in the specified folder) *and* you're    lucky enough to have the GD libraries compiled into PHP on    your webserver, we generate a replacement "error image" on    the fly.    Version 2.1        - Updated a potential security flaw when value-matching          filenames    Version 2.2        - Updated a few more potential security issues        - Optimized the code a bit.        - Expanded the doc for adding new mime/image types.        Thanks to faithful ALA reader Justin Greer for        lots of good tips and solid code contribution!*//* ------------------------- ----------------------- Set $folder to the full path to the location of your images. For example: $folder = '/user/me/example.com/images/'; If the rotate.php file will be in the same folder as your images then you should leave it set to $folder = '.';*/ $folder = '.';/*    If you'd like to enable additional image types other than gif, jpg, and png, add a duplicate line to the section below for the new image type. Add the new file-type, single-quoted, inside brackets. Add the mime-type to be sent to the browser, also single-quoted, after the equal sign. For example: PDF Files:  $extList['pdf'] = 'application/pdf';    CSS Files:        $extList['css'] = 'text/css';    You can even serve up random HTML files:     $extList['html'] = 'text/html';     $extList['htm'] = 'text/html';    Just be sure your mime-type definition is correct!*/    $extList = array(); $extList['gif'] = 'image/gif'; $extList['jpg'] = 'image/jpeg'; $extList['jpeg'] = 'image/jpeg'; $extList['png'] = 'image/png';// You don't need to edit anything after this point.// --------------------- END CONFIGURATION -----------------------$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); }}?>

Make sure you saved, and closed :)..

Step 2

Open a FTP Client, I'm using FlashFXP, and login to your FTP site...
404.png
In the public_html directory, create a new folder called "sig.png" (without quotes). Into this folder, upload the index.php file, along with more than one signature you want to rotate.

404.png
The Index.php file is highlighted.. the rest are my signatures, and a .htaccess file that will be described later

Finally, open your favorite browser (Should be Firefox) and visit http://forums.xisto.com/no_longer_exists/. (where yoursite.com is the root directory for wherever you're hosted).

You should see one of your signatures, if not, check the Troubleshooting section. Refresh the page, and you should see another one of your sigs. Again, if not, see the Troubleshooting Section..

Of course, you'll replace your current signature with this by adding the following string into your signature block -
 



yoursite.com/sig.png;

Advanced Features/Suggestions

If you'd like for only a certian signature to be shown in that directory, query it the following way...




http://example.com/rotate.php?img=mikescreation.jpg

Where 'mikescreation.jpg' is the signature's filename in the sig.png directory that you wish to show specifically.

---

Wish to randomly select OTHER types of files, opposed to just images?

Open up index.php and look for this block of code -
 



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

To that list you'll add the MIME types of the other filetypes you wish to randomize in that folder. Save and upload, and you can randomize any other files you want. There are simplified instructions for that configuration above that block of code, courtesy of Dan P. Benjamin, the script's writer.

Troubleshooting

Question : Instead of getting my signature, when I visit my sig.png directory, I see a list of those signatures in that directory.

Answer : Upload the following file, named '.htaccess' to your sig.png directory. The problem is a result of a indexing error, which is fixable by this line of code -
 



DirectoryIndex index.php

Save and close that file, as '.htaccess'. Nothing more. And upload it to the proper directory. Your signatures will randomize now.

Closing

In conclusion, any further questions will be answered promptly in this thread, I HAVE turned on E-mail notification.

Also, This script was NOT written by me, It was created by Dan P. Benjamin, whose contact information you will find at the top of the index.php file. To reiterate, I did NOT write this script, I wrote the tutorial.

Thanks for reading, happy Sigging (sp? :D)

- Mr. Panda



Share this post


Link to post
Share on other sites

well the thing with that scripts its going ot cost you alot of webspace to use unlike the other ones but this owuld be good for the people that don't have that many sigs like some of our season siggers.

Share this post


Link to post
Share on other sites

Hey thanks a lot for the script...I've just applied it!I was planning to do it but was thinking of having more sigs....but then I thought that it will be better to apply the script even if I have only 4 sigs :)i think you'll be able to see the result down belowtake care

Share this post


Link to post
Share on other sites

Mike, I'm confused with your response. This will support as many, if not more signatures than the other rotators.To use the rest of the rotator scripts out there, you must add a line of code for each new signature.This one automatically searches the folder for the correct type of file, and randomly select one to display.More efficient, time-wise. Please help me better understand the issue Mike, it could be something I can edit and fix...Panda

Share this post


Link to post
Share on other sites

Finally a rotator that actually has the authors name on it! Hopefully this one works without me changing it because I'm becoming very frustrated over it. <_<Thanks thablkpanda, the signature rotater is awesome! Thanks a lot, I've been wanting one for such a long time. Check out my avatar, it should change with every reload :P .

Notice from electriic ink:
Merged double post...

Share this post


Link to post
Share on other sites

sweet just did this thanks for the great sig rotatorBtw ill host peoples rotators if they need to just pm me and ill talk to you about it there limit to 10 sigs i think not sure yet ill give you ftp to a folder in otherwords...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.