Register for free, and make this box disappear!

Welcome to the BF Forums! Register Now, It's Free!


Welcome to the BF Forums; your source for the latest video game news, strategies, discussions, and resources. Join over 66,000 like-minded gamers to chat about your interests in our community.

You are currently viewing the forums as a guest user, which limits your access to certain content, contests, downloads, and more. By joining our free community, you will be able to respond in discussions/articles, contact members privately (PM), participate in regular-scheduled contests, see less advertisements, and have access to many other features. Registration is quick, easy, and completely free.



Have your questions answered. Share your thoughts about a topic. Take 2 minutes, Register Now!
BattleForums.com Forums > Other Interests > The Artist Outlet > Graphic Design

We're Half-Way There!! - BF Lotto: $50 Ebay or Amazon Gift Card - A Single Click is All It Takes...

Reply
 
Thread Tools Display Modes
Old 01-15-2006, 09:03 PM   #1 (permalink)
Respected Member
 
Trojan's Avatar
 
Join Date: Jun 2004
Location: OG From '02
Age: 18
Posts: 3,550
The Answer...

The answer to every noob and guru's question of 'How do I get my signature to go all random like?'.

Just copy and paste this code into notepad and change the line that says "enter prefix here" to whatever you want and make every image you want to include in the rotation have the same prefix such as, trojan1, trojan2, trojan3 etc... After that save it as a .php file and upload that and the images in the same folder and paste the .php location on your host to the forums in [img] tags. I hope I answered a bunch of people's questions.

Code:
<?php



// Set variables

$image_dir = './';

$image_prefix = 'enter prefix here';

$imageArray = array();



// Set image types

if(function_exists("imagegif")){

	$image_types = array( 'gif', 'jpg' );

} else {

	$image_types = array( 'jpg' );

}



// Get all sig images

$dir = dir( $image_dir );

while ( false !== ( $image_name = $dir->read() ) ) { 



	$image_info = pathinfo( $image_name );

	// If it's an iamge and it starts with the correct prefix

	if( in_array( @$image_info[ 'extension' ], $image_types ) && substr( $image_name, 0, strlen( $image_prefix ) ) == $image_prefix ){

		array_push( $imageArray, array( 'name' => $image_name, 'type'=> $image_info['extension'] ) );

	}



} 

$dir->close(); 



// Did it find any?

if( count($imageArray) ){



	// Yes

	// Choose a random one

	$image = $imageArray[ rand( 0, count( $imageArray )-1 ) ];



	switch( $image[ 'type' ] ){



		// Create a gif image		

		case('gif'):{

			if($load_image = @ImageCreatefromgif( $image_dir . $image[ 'name' ] )){

				header("Content-Type: image/gif");

				Imagegif($load_image);

			} else {

				createErrorImage( 'Error creating gif' );

			}

			break;	

		}



		// Create a jpeg image		

		case('jpg'):{

			if($load_image = @ImageCreatefromjpeg( $image_dir . $image[ 'name' ] )){

				header("Content-Type: image/jpeg");

				Imagejpeg($load_image);

			} else {

				createErrorImage( 'Error creating jpeg' );

			}

			break;	

		}



	} // END switch( $image[ 'type' ] )



} else {



		// No

		// Create an error image

		createErrorImage( 'No images found' );



}



// Create an error image

function createErrorImage( $error ) {



	$load_image = imagecreate (300, 50);

	$background= imagecolorallocate ($load_image, 255, 255, 255); 

	$text_colour = imagecolorallocate ($load_image, 0, 0, 0); 

	imagefilledrectangle ($load_image, 0, 0, 150, 30, $background); 

	imagestring ($load_image, 1, 5, 5, "Error: $error", $text_colour); 

	header("Content-Type: image/jpeg");

	Imagejpeg($load_image);



} // END function createErrorImage()



?>
Trojan is offline   Reply With Quote
Beitrag Sponsored Links

__________________
Ads suck! Take 2 minutes to register for your free account, and GET RID OF THESE ADS!
Reply

Get rid of all these ads! Take 30 seconds to register.

« Avatar, sig change | diff spawn sig that i just got right now »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


All times are GMT +1. The time now is 08:02 PM.



Powered by vBulletin® Version 3.7.2 | Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0