Page 1 of 2 12 LastLast
Results 1 to 10 of 12
  1. #1
    Join Date
    Mar 2008
    Location
    Swindon, UK
    Posts
    1,274
    Tokens
    187
    Habbo
    :Ltd

    Latest Awards:

    Default Sig image changer, with links [P-H-PEH]

    PHP Code:
    <?php
    session_start 
    ();

    /**
     * @website     InterStudios.co.uk
     * @author         James Rozee 
     */
     

    switch ( $_GET 'cmd' ] )
    {
        case 
    'link':
            if ( 
    $_SESSION 'url' ] === '' )
            {
                
    header'Location: http://google.co.uk' );
            }
            else
            {
                
    header'Location: http://' $_SESSION'url' ] . '/' );
            }
        break;
        
        default:
            if( !
    function_exists'exif_imagetype' ) )
            {
                function 
    exif_imagetype$filename )
                {
                    if( ( list(
    $width$height$type$attr) = getimagesize$filename ) ) !== false )
                    {
                        return 
    $type;
                    }
                return 
    false;
                }
            }
            
    /* PHP.net *above* */
            
            // Add images to the array below, you can have as many as you want. Btw its ur job 2 do the size enit fosho
            
    $images = array( array ( 'img.jpg''url2site.com' ),
                             array ( 
    'img2.jpg''url2site2.com' ),
                             array ( 
    'img3.jpg''url2sitex.com' )
                                );
            
            
    // Choose image to display!
            
    $image $images array_rand $images ) ];
            
            
    $image_source $image ]; // url 2 img
            
    $image_url $image ]; // url 2 link
            
    $image_type exif_imagetype $image_source );
            
            if( 
    $image_type == )
            {
                
    header('content-type: image/gif');
                
    $img imagecreatefromgif $image_source );
                
    imagegif $img );
                
    imagedestroy $img );
            }
            elseif ( 
    $image_type == )
            {
                
    header('content-type: image/jpeg');
                
    $img imagecreatefromjpeg $image_source );
                
    imagejpeg $img );
                
    imagedestroy $img );
            }
            elseif( 
    $image_type == )
            {
                
    header('content-type: image/png');
                
    $img imagecreatefrompng $image_source );
                
    imagepng $img );
                
    imagedestroy $img );
            }
            else
            {
                
    // if it comes to this, your a noob. I swear 2 god
            
    }
            
            
    $_SESSION 'url' ] = $image_url;
    }
    ?>
    Probably not the best coding, but get over it.

    How to use it?
    Link the image, (eg call that php file index.php)
    so in HTML it be like

    HTML Code:
    <img src="index.php">
    and to make it link to the website you requested like this
    HTML Code:
    <a href="index.php?cmd=link">
     <img src="index.php">
    </a>
    or in BB CODE
    HTML Code:
    [url="http://kg-hosting.co.uk/sig/index.php?cmd=link"]
    [IMG]http://kg-hosting.co.uk/sig/index.php[/IMG]
    [/url]
    Last edited by Protege; 05-07-2008 at 01:25 PM.
    Hi, names James. I am a web developer.

  2. #2
    Join Date
    Jun 2007
    Location
    Kent
    Posts
    4,101
    Tokens
    981

    Latest Awards:

    Default

    PHP Code:
    array ( 'img.jpg''url2site.com' ),
                                     array ( 
    'img2.jpg''url2site2.com' ),
                                     array ( 
    'img3.jpg''url2sitex.com' 
    So i need to change that bit for the image and link yeh?

  3. #3
    Join Date
    Mar 2008
    Location
    Swindon, UK
    Posts
    1,274
    Tokens
    187
    Habbo
    :Ltd

    Latest Awards:

    Default

    Correct, add as many as you like. jpeg,gif,png
    Hi, names James. I am a web developer.

  4. #4
    Join Date
    Jun 2007
    Location
    Kent
    Posts
    4,101
    Tokens
    981

    Latest Awards:

    Default

    Fantastic +Rep.

    And i put you to my owed rep list so i can rep you again when i can.

  5. #5
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    Just an idea, to save a lot of coding, as you have matched each file type and used an imagecreatefrom[format] approach.

    An easier way would be getting the contents of a file, either using file_get_contents or fopen() to read it.

    Then using imagecreatefromstring() which doesn't require you have all that code, then you can output it

  6. #6
    Join Date
    Mar 2008
    Location
    Swindon, UK
    Posts
    1,274
    Tokens
    187
    Habbo
    :Ltd

    Latest Awards:

    Default

    I don't amend the code I publish, that's for the other people to do. ]

    I'm probs gunna get knifed by ifuse for hosting an image exchange, if this counts as one
    Last edited by Protege; 05-07-2008 at 01:34 PM.
    Hi, names James. I am a web developer.

  7. #7
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    Well as long as you have the bandwith, I don't think they will say anything.

  8. #8
    Join Date
    Mar 2008
    Location
    Swindon, UK
    Posts
    1,274
    Tokens
    187
    Habbo
    :Ltd

    Latest Awards:

    Default

    In their TOS, it says they don't allow a banner exchange (I basically revised it after some-what-****-of-a-josh put **** on his acc) I also think the "random" is not that random, seems always to hit number #1
    Hi, names James. I am a web developer.

  9. #9
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    Hmm, well.. maybe they won't notice

  10. #10
    Join Date
    Mar 2008
    Location
    Swindon, UK
    Posts
    1,274
    Tokens
    187
    Habbo
    :Ltd

    Latest Awards:

    Default

    maybe not, ontopic posts only now, I think i'll edit mine to check if its last one was the one its just randomized, then choose another.
    Last edited by Protege; 05-07-2008 at 01:45 PM.
    Hi, names James. I am a web developer.

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •