![]() |
|
Tutorial Making your own Sig Randomizer - Printable Version +- Sinisterly (https://sinister.li) +-- Forum: Coding (https://sinister.li/Forum-Coding) +--- Forum: Coding (https://sinister.li/Forum-Coding--71) +--- Thread: Tutorial Making your own Sig Randomizer (/Thread-Tutorial-Making-your-own-Sig-Randomizer) Pages:
1
2
|
Making your own Sig Randomizer - Dean Winchester - 12-15-2013 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 [IMG] tag which links to your random.jpg directory. An example is below. Code: [img]http://yourhost.com/random.jpg[/img]RE: Making your own Sig Randomizer - Suicide - 12-15-2013 This is a very nice and detailed guide. I am sure it will help alot of people. RE: Making your own Sig Randomizer - BeastlyHobos - 12-16-2013 Very cool guide maybe I would use it if I wasn't so in depth haha RE: Making your own Sig Randomizer - Hey - 12-19-2013 This is a pretty sick guide, interested in making this. RE: Making your own Sig Randomizer - Dean Winchester - 12-19-2013 Thanks for the comments guys. It's an easy method indeed. RE: Making your own Sig Randomizer - Aces - 12-21-2013 Nice, I'll play around with it a little tomorrow. RE: Making your own Sig Randomizer - Shift - 12-21-2013 Thanks for the tutorial Jimmy. RE: Making your own Sig Randomizer - Fallen - 12-21-2013 I was actually looking at one today. They were about $8 per license. RE: Making your own Sig Randomizer - Feat - 12-21-2013 I wish that some sites still used the actually avatar/signature randomizer plugin. I still see it on TTG all the time. RE: Making your own Sig Randomizer - sprremix - 01-20-2014 That's a really neat trick. You could make an awesome 50/50 (http://www.reddit.com/r/fiftyfifty) script with this. Nice, I already setted everything up. Thanks mate. |