|
|
|
|
![]() ![]() |
Sep 8 2005, 11:34 PM
Post
#1
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 339 Joined: 2-December 04 From: Atlanta, GA Member No.: 2,516 |
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 trap17, 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
Necessary stuff - 1. Host supporting PHP (required) ,.htaccess,(optional) and CHMOD (optional) (Trap17 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. CODE <?php /* AUTOMATIC IMAGE ROTATOR Version 2.2 - December 4, 2003 Copyright (c) 2002-2003 Dan P. Benjamin, Automatic, Ltd. All Rights Reserved. http://www.hiveware.com/imagerotator.php http://www.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... ![]() 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. ![]() 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://www.yoursite.com/sig.png. (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 - CODE [IMG]http://www.yoursite.com/sig.png[/IMG] Advanced Features/Suggestions If you'd like for only a certian signature to be shown in that directory, query it the following way... CODE 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 - 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 - 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? - Mr. Panda |
|
|
|
Sep 9 2005, 07:29 AM
Post
#2
|
|
|
Advanced Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 119 Joined: 6-September 05 From: in the dark days of mine Member No.: 11,562 |
great.. this tutorial is more detail. the previous tutorial is not as detail as this one
|
|
|
|
Sep 9 2005, 07:36 AM
Post
#3
|
|
|
$p4m 0n j00 $h4m3 m3 0nc3 $p4m 0n m3 $h4m3 m3 7\/\/1c3 ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: [HOSTED] Posts: 6,308 Joined: 21-September 04 From: 9r33|\| 399$ 4|\|D 5P4/\/\ Member No.: 1,218 ![]() |
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.
|
|
|
|
Sep 9 2005, 12:31 PM
Post
#4
|
|
|
Mankie ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 761 Joined: 22-July 05 From: New Delhi, India Member No.: 9,746 |
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 below take care |
|
|
|
Sep 9 2005, 07:22 PM
Post
#5
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 339 Joined: 2-December 04 From: Atlanta, GA Member No.: 2,516 |
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 |
|
|
|
Aug 25 2006, 11:45 AM
Post
#6
|
|
|
Premium Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 183 Joined: 24-July 06 From: Cape Town Member No.: 27,194 |
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 |
|
|
|
Aug 26 2006, 04:28 PM
Post
#7
|
|
|
Newbie ![]() Group: Members Posts: 9 Joined: 26-August 06 Member No.: 28,967 |
Amazing! I love the tutorial, it made my life easier.
|
|
|
|
Sep 12 2006, 02:24 AM
Post
#8
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 400 Joined: 21-June 05 From: Callifornia Member No.: 8,519 |
sweet just did this thanks for the great sig rotator
Btw 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... |