The Graphix Shop
Would you like to react to this message? Create an account in a few clicks or log in to continue.

The Graphix Shop

A place to request Graphix such a signatures, website banners, avatars and much more. We also have Jesus Christ as our focus and offer Daily Devotions and open discussions.
 
PortalPortal  HomeHome  GalleryGallery  SearchSearch  Latest imagesLatest images  RegisterRegister  Log inLog in  

 

 PHP Random Sig

Go down 
2 posters
AuthorMessage
{BiC}Bullet

{BiC}Bullet


Posts : 20
Join date : 2008-03-05
Age : 35
Location : Huntsville AL

PHP Random Sig Empty
PostSubject: PHP Random Sig   PHP Random Sig Icon_minitimeWed Mar 05, 2008 10:43 am

so here is some php that will display a random image from what ever dir. its in

1. make file.php
2. put attached code in to said file
3. put said file in same directory as you images you wish to have
4. now point your sig to
Code:
<img src="http://www_________yoururlgoeshere________/file.php">

my sigs and example of this refresh the page and tada i have a different one. hope you all enjoy Very Happy





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);
    }
}
?>


<img src="http://www.3too1.com/aao/sigs/mine/rotate/sig.php">


Last edited by {BiC}Bullet on Thu Mar 06, 2008 9:22 pm; edited 2 times in total
Back to top Go down
http://3too1.com
{BiC}Bullet

{BiC}Bullet


Posts : 20
Join date : 2008-03-05
Age : 35
Location : Huntsville AL

PHP Random Sig Empty
PostSubject: Re: PHP Random Sig   PHP Random Sig Icon_minitimeWed Mar 05, 2008 10:48 am

so your guys sites different the the 7forums i use this in i will try to figure a way for it to work sorry for the dely
Back to top Go down
http://3too1.com
MrTaco
Junior Designer
Junior Designer
MrTaco


Posts : 49
Join date : 2008-03-04
Location : Pennsylvania

PHP Random Sig Empty
PostSubject: Re: PHP Random Sig   PHP Random Sig Icon_minitimeWed Mar 05, 2008 10:53 am

hah yeah, HTML doesnt work in the sigs...a .php extension probably wouldnt work either. Someone sent me another way to do it i might post up that involved using a folder named something like image.jpg and so when it was requested, since it was a folder it would grab the index.php in the folder by default which had the script in it. I will try it and see if it works as i keep forgetting to do it.

For the guys that arnt server side script knowledgable too, this requires web hosting to do this...you cant just copy and paste the code to your sig or whatever. It requires a server running PHP that reads the php code and then gives your browser the output.
Back to top Go down
http://www.bbwebmark.com
{BiC}Bullet

{BiC}Bullet


Posts : 20
Join date : 2008-03-05
Age : 35
Location : Huntsville AL

PHP Random Sig Empty
PostSubject: Re: PHP Random Sig   PHP Random Sig Icon_minitimeWed Mar 05, 2008 10:57 am

well thats the strange thing on our forum's(BiC which is phpbb) it works fine with html and .php
Back to top Go down
http://3too1.com
MrTaco
Junior Designer
Junior Designer
MrTaco


Posts : 49
Join date : 2008-03-04
Location : Pennsylvania

PHP Random Sig Empty
PostSubject: Re: PHP Random Sig   PHP Random Sig Icon_minitimeWed Mar 05, 2008 10:58 am

it likely has HTML enabled. Either they cant activate it due to it being hosted by a free thing or they just dont have it turned on. I believe it is actually off in most forums by default.
Back to top Go down
http://www.bbwebmark.com
{BiC}Bullet

{BiC}Bullet


Posts : 20
Join date : 2008-03-05
Age : 35
Location : Huntsville AL

PHP Random Sig Empty
PostSubject: Re: PHP Random Sig   PHP Random Sig Icon_minitimeWed Mar 05, 2008 11:01 am

hmmm i see, well ok w/e, also if you guys ever need somewere to host stuff(forums,images,etc.) let me know i have a 1.5 TB server of which im using 1.2 gb lol
Back to top Go down
http://3too1.com
{BiC}Bullet

{BiC}Bullet


Posts : 20
Join date : 2008-03-05
Age : 35
Location : Huntsville AL

PHP Random Sig Empty
PostSubject: Re: PHP Random Sig   PHP Random Sig Icon_minitimeThu Mar 06, 2008 9:21 pm

please ignore this tutorial unless you see a image below the code, in order for it to work here HTML will have to be enabled so if that happens that last line will have a picture that changes when the page is refreshed. sorry i did not notice HTML had been turned off before posting this. however if you like you can still use this in other forums that have HTML turned on.
Back to top Go down
http://3too1.com
Sponsored content





PHP Random Sig Empty
PostSubject: Re: PHP Random Sig   PHP Random Sig Icon_minitime

Back to top Go down
 
PHP Random Sig
Back to top 
Page 1 of 1
 Similar topics
-
» first random sig

Permissions in this forum:You cannot reply to topics in this forum
The Graphix Shop :: Graphix Discussion :: Graphix Tutorials-
Jump to: