Guide: Dynamic Signatures.

SPeedY_B

I may actually be insane.
Joined
31 Mar 2002
Messages
15,807
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:

sig.php


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.
 
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.
 
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 ?
 
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.
 
That being said, 1and1 has very competetive and cheap prices, as well as great support :)
 

Members online

No members online now.

Latest profile posts

Also Hi EP and people. I found this place again while looking through a oooollllllldddd backup. I have filled over 10TB and was looking at my collection of antiques. Any bids on the 500Mhz Win 95 fix?
Any of the SP crew still out there?
Xie wrote on Electronic Punk's profile.
Impressed you have kept this alive this long EP! So many sites have come and gone. :(

Just did some crude math and I apparently joined almost 18yrs ago, how is that possible???
hello peeps... is been some time since i last came here.
Electronic Punk wrote on Sazar's profile.
Rest in peace my friend, been trying to find you and finally did in the worst way imaginable.

Forum statistics

Threads
62,015
Messages
673,494
Members
5,621
Latest member
naeemsafi
Back