gaggu007 0 Report post Posted July 11, 2006 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
wappy 0 Report post Posted July 12, 2006 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
electron 0 Report post Posted July 16, 2006 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
juice 0 Report post Posted August 4, 2006 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
HotBlade 0 Report post Posted August 4, 2006 Dont forget,u need to add your images in the folder image.gif lol 4 those who didnt know... Share this post Link to post Share on other sites
Chatz 0 Report post Posted August 4, 2006 I got a script like that some where on my computer.It's almost something like random text or quote.But anyway thanx for showing us the code. Share this post Link to post Share on other sites
wappy 0 Report post Posted August 7, 2006 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
Chatz 0 Report post Posted August 7, 2006 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