GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   EZ Image Rotation Script! (https://gfy.com/showthread.php?t=606566)

DeanCapture 05-06-2006 10:41 AM

EZ Image Rotation Script!
 
I'm looking for an EZ to install image rotation script for my site. I want a new pic to show each time someone refreshes the page or visits the site. Got a script you can refer me to?

MrIzzz 05-06-2006 10:43 AM

i'm interested in something like this as well :wetkiss

grumpy 05-06-2006 11:03 AM

simple java will do that. Need it in java?

grumpy 05-06-2006 11:10 AM

PHP Code:

function show_random_image(){
  
max_pics 30;
  
pic_base ="<img src='pics/";
  
pic_ext  =".jpg'>";
  var 
ran_unrounded=Math.random()* max_pics;
  var 
ran_number=Math.floor(ran_unrounded);
  
document.write(pic_base+ran_number+pic_ext);


some where on the page

PHP Code:

<script>show_random_image()</script> 


shows pic between 0-30

SmokeyTheBear 05-06-2006 11:56 AM

ok make a folder called "rimg"

lets say your domain is example.com

so make a ew folder example.com/rimg/

then save the following as index.php

Code:

<?php





        $folder = '.';


        $extList = array();
        $extList['gif'] = 'image/gif';
        $extList['jpg'] = '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 !hahahaha ( $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);
        }
}
?>

then simply upload all your images to that directory

and call the random image like this <img src=http://yoursite.com/rimg/>

SmokeyTheBear 05-06-2006 11:58 AM

fucking gfy fucks with the code hold on ill repost

SmokeyTheBear 05-06-2006 12:00 PM

Code:

<?php





        $folder = '.';


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

ok that should work better

The benefit to using php instead of java is you dont have to manually write down every image name

grumpy 05-06-2006 12:12 PM

with my solution just make sure your pics are numbered.
No php needed
browser does the work, not your server.

But im not saying its better, just diffrent :winkwink:

SmokeyTheBear 05-06-2006 12:17 PM

Quote:

Originally Posted by grumpy
with my solution just make sure your pics are numbered.
No php needed
browser does the work, not your server.

But im not saying its better, just diffrent :winkwink:

the server doesnt have to do much work for the php version , infact it saves you from having to hand write all the images into the script

There are times when you would want to use jave ( like if you had 3 banners to rotate through ) but if your doing a random "porn" pic , your prob going to want to add lots of pics making it cumbersome to use java. :winkwink:

OG LennyT 05-06-2006 12:31 PM

fucking-around-and-business-discussion/606545-script-rotate-images.html

last post for java version. works well for banner rotation

grumpy 05-06-2006 01:48 PM

Quote:

Originally Posted by SmokeyTheBear
the server doesnt have to do much work for the php version , infact it saves you from having to hand write all the images into the script

There are times when you would want to use jave ( like if you had 3 banners to rotate through ) but if your doing a random "porn" pic , your prob going to want to add lots of pics making it cumbersome to use java. :winkwink:

as i said, the only thing you have to do is to number the pics in the dir like pic1.jpg upto how many you have, In the script you only have to set the max number pics var.


All times are GMT -7. The time now is 06:41 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123