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