Jump to content
xisto Community
Sign in to follow this  
gaggu007

A Wap Php Script.

Recommended Posts

RANDOM IMAGE SCRIPT

 

 

First create a folder called image.gif and upload your images to it.

When you have done that, make a file in that folder called index.php and add this code

<?php	$folder = '.';	$extList = array();	$extList['gif'] = 'image/gif';	$extList['jpg'] = 'image/jpeg';	$extList['jpeg'] = 'image/jpeg';	$extList['png'] = 'image/png';	$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);	}}?>

Now by linking to yoursite.com/image.gif (image.gif being the folder) the index file will automatically run and random images will be displayed. That means you can display random images in forums like these.

 

Cool eh?!

Share this post


Link to post
Share on other sites

Hey im very impressed with this! I can think of many uses for it! And yes will be great for random images in sig's. Where did you get this code or did you write it yourself?

Share this post


Link to post
Share on other sites

Hey even my sig uses that.However I have added a little Twist to it.It can reveal your OS and also you "The User" can write 10 different Texts that would be randomly selected with the mt_rand function and displayed.If you have someway to Optimze my Sig let me know.

Share this post


Link to post
Share on other sites

Nice script, will come in handy but I've seen in more places than one. I guess its one of those scripts that travel along the internet like dust in the wind :)

Share this post


Link to post
Share on other sites

Dont forget,u need to add your images in the folder image.gif lol 4 those who didnt know...

o hello hotblade, i take it you can see why i don't help people on wap now? As they are rude and ungratefull eh. So... / the fact you have to upload images to the folder was CLEARLY STATED at the begining of the post :)

Share this post


Link to post
Share on other sites

o hello hotblade, i take it you can see why i don't help people on wap now? As they are rude and ungratefull eh. So... / the fact you have to upload images to the folder was CLEARLY STATED at the begining of the post :)

Wappy I wouldn't use the term "they",like that you making web people think wap is all that bad.Not everyone's bad in wap,maybe 2/5 are bad.But we as wap coders got a responsabilltiy to make wap a better place don't you agree? Anyway let's not talk about bad wap here,thanx for the code once again.

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
Sign in to follow this  

×
×
  • 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.