Guide: Dynamic Signatures.

SPeedY_B

I may actually be insane.
#1
Only smurfs know where the original thread went, so here it is again just for reference sake.

To get yourself a dynamic signature, first you need a proper host which supports both PHP and hotlinking. Most free hosts do not offer this and won't work at all, check with your host before trying to use this script, else you may end up wasting your time.

Create a folder on your host called 'sigs' (or whatever you want really) then pop the following code into your favourite text editor and save the file as 'sig.php' or any other name you like.
PHP:
<?php
ob_start( 'ob_gzhandler' );
srand( time() );
$files = array();
if ($dir = @opendir(".")) {
while (($file = readdir($dir)) !== false) {
if ( eregi( '.(jpg|gif|png)$', $file ) ) {
$files[] = $file;
}
}
closedir($dir);
}
$file = $files[rand() % sizeof( $files )];
if ( eregi( '.jpg$', $file ) ) { header( "Content-Type: image/jpeg" ); }
elseif ( eregi( '.gif$', $file ) )  { header( "Content-Type: image/gif" ); }
else { header( "Content-Type: image/png" ); }
header( "Content-Length: " . filesize( $file ) );
readfile( $file );
?>
upload this to your host in the folder we just created, fill the folder with the images of your choice (being jpeg, gif or png files) and then hotlink the file in your signature using the following code:



substituting the domain for your own, of course.

Couresy of Geffy we also have a dynamic signature with IP blocking so certain IP's can be prevented/saved from viewing the images which is handy for those on dial-up, and also for those who view the forums at work and don't wish to see risque images.

PHP:
<?php
/**
 * MySQL Table Definition
 * 
 * CREATE TABLE `sig` (
 *     `id` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
 *     `ip` VARCHAR( 16 ) NOT NULL ,
 *     PRIMARY KEY ( `id` ) ,
 *     UNIQUE (
 *         `ip`
 *     )
 * );
 *
 * Script first checks to see if the IP address has been added to
 * a list of addresses which have requested not the see a random image.
 * If they have then the blocked image is shown, if not then the
 * contents of the folder which this file is in is read and an image
 * is randomly selected, the proper headers sent and then the image
 * data.
 */
mysql_pconnect("localhost","username","password");
mysql_select_db("database");

$addr = $_SERVER['REMOTE_ADDR'];
$query = mysql_query("SELECT `id` FROM sig WHERE `ip`='{$addr}'");
$rows = mysql_num_rows($query);

if($rows != 0) {
    // No rows, ip address has not requested blocking
    srand( time() );

    $files = array();
    if ($dir = @opendir(".")) {
        
        while (($file = readdir($dir)) !== false) {
            if ( eregi( '.(jpg|gif)$', $file ) ) {
                $files[] = $file;
            }
        }
        
        closedir($dir);
    }

    $file = $files[rand() % sizeof( $files )];

    if ( eregi( '.jpg$', $file ) ) {
        header( "Content-Type: image/jpeg" );
    } else {
        header( "Content-Type: image/gif" );
    }

    header( "Content-Length: " . filesize( $file ) );

    readfile( $file );
} else {
    header( "Content-Type: image/jpeg" );
    header( "Content-Length: " . filesize("blocked.jpg"));
    readfile( "blocked.jpg" );
}
?>
As with the previous code, simply save the file and upload it into a folder full of images, hotlink it, and you're set.

Enjoy.
 

Volomon

OSNN Newbie
#4
Does anyone know any PHP hosts that will allow hotlinking? Its driving me crazy looking for a host becuase 90% of the time they don't say whether you can hotlink or not so I gotta go through the whole process of registering and testing it out over and over.

I would EXTREMELY appreciate it if someone could help me out here.
 

SPeedY_B

I may actually be insane.
#6
Free hosts usually don't allow hotlinking, I don't think that I've ever heard of a paid host not allowing it though.

Which hosts have you been using ?
 

Volomon

OSNN Newbie
#7
I've been just looking for a free one, if I paid for it I would definately be a bit disappointed if they didn't let me hotlink.
 

Members online

No members online now.

Latest posts

Latest profile posts

Perris Calderon wrote on Electronic Punk's profile.
Ep, glad to see you come back and tidy up...did want to ask a one day favor, I want to enhance my resume , was hoping you could make me administrator for a day, if so, take me right off since I won't be here to do anything, and don't know the slightest about the board, but it would be nice putting "served administrator osnn", if can do, THANKS

Been running around Quora lately, luv it there https://tinyurl.com/ycpxl
Electronic Punk wrote on Perris Calderon's profile.
All good still mate?
Hello, is there anybody in there? Just nod if you can hear me ...
Xie
What a long strange trip it's been. =)

Forum statistics

Threads
61,969
Messages
673,295
Members
89,015
Latest member
arrangel