Reply
Old February 28th, 2005 Top | #1

OSNN Subscriber  
SPeedY_B's Avatar
I may actually be insane.
Joined: March 2002
Location: Midlands, England
Posts: 16,127
Reputation: 2877
Power: 286

Default Guide: Dynamic Signatures.

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 Code:
<?php
ob_start
'ob_gzhandler' );
srandtime() );
$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:

[img]http://speedyb.co.uk/is/the/best/site/ever/sigs/sig.php[/img]

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 Code:
<?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
    
srandtime() );

    
$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.
SPeedY_B is offline   Reply With Quote
Old February 28th, 2005 Top | #2

OSNN Folding Team  
Moonwraith's Avatar
OSNN Veteran Addict
Joined: October 2004
Location: UK
Posts: 1,130
Reputation: 320
Power: 80

Default Re: Guide: Dynamic Signatures.

Thanks Speedy, was wondering where the original went excellent, ta


Intel Core 2 Duo E8600 -- Asus Rampage Formula

BFG GeForce 280 GTX OCX -- 4GB Corsair XMS2 Dominator
Moonwraith is offline   Reply With Quote
Old February 28th, 2005 Top | #3
 
vivid_vibe's Avatar
OSNN Senior Addict
Joined: December 2002
Posts: 410
Reputation: 250
Power: 95

Post Re: Guide: Dynamic Signatures.

Very nice post, Speedy.
vivid_vibe is offline   Reply With Quote
Old May 31st, 2006 Top | #4
 
Volomon's Avatar
OSNN Junior Addict
Joined: May 2006
Posts: 4
Reputation: 0
Power: 0

Default Re: Guide: Dynamic Signatures.

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.

Volomon is offline   Reply With Quote
Old May 31st, 2006 Top | #5

OSNN Subscriber
OSNN Folding Team  
kcnychief's Avatar
█▄█ ▀█▄ █
Joined: April 2005
Location: Massachusetts
Posts: 16,973
Reputation: 4941
Power: 279

Default Re: Guide: Dynamic Signatures.

I'm pretty sure that www.1and1.com does allow it.

XBOX Live Gamertag: kcnychief
kcnychief is offline   Reply With Quote
Old May 31st, 2006 Top | #6

OSNN Subscriber  
SPeedY_B's Avatar
I may actually be insane.
Joined: March 2002
Location: Midlands, England
Posts: 16,127
Reputation: 2877
Power: 286

Default Re: Guide: Dynamic Signatures.

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 ?
SPeedY_B is offline   Reply With Quote
Old June 1st, 2006 Top | #7
 
Volomon's Avatar
OSNN Junior Addict
Joined: May 2006
Posts: 4
Reputation: 0
Power: 0

Default Re: Guide: Dynamic Signatures.

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.

Volomon is offline   Reply With Quote
Old June 1st, 2006 Top | #8

OSNN Subscriber
OSNN Folding Team  
kcnychief's Avatar
█▄█ ▀█▄ █
Joined: April 2005
Location: Massachusetts
Posts: 16,973
Reputation: 4941
Power: 279

Default Re: Guide: Dynamic Signatures.

That being said, 1and1 has very competetive and cheap prices, as well as great support

XBOX Live Gamertag: kcnychief
kcnychief is offline   Reply With Quote
Old November 7th, 2007 Top | #9
 
robry's Avatar
OSNN Junior Addict
Joined: September 2007
Posts: 10
Reputation: 0
Power: 31

Default Re: Guide: Dynamic Signatures.

this is gonna help so much. thanks speedy.

alienware
intel quad core (extreme when it comes out with a board)
intel board 975x
nvidia geforce 8800gts cross fire
2048gb memory, 4x512mb
29" flat panel widescreen monitor
19" flat panel monitor
40gb hard disk (nothing on it except os and steam, ownage fast)
2tb secondary hard disk
robry is offline   Reply With Quote

Reply

Bookmarks

Thread Tools

Posting Rules

Similar Threads
Thread Thread Starter Forum Replies Last Post
php: Dynamic Titles... penguin Web Design & Coding 3 August 4th, 2005 8:19pm
Guide : Dynamic Signatures SPeedY_B Graphic Design 22 May 29th, 2004 9:29am
Buyers Guide: My guide to 64 bit patrick General Hardware 4 April 20th, 2004 5:47am
Dynamic IP server A.T Windows Desktop Systems 3 October 11th, 2002 10:42pm
Dynamic Disk??? bheagle General Hardware 10 April 7th, 2002 2:46pm