Guide : Dynamic Signatures

SPeedY_B

I may actually be insane.
Joined
31 Mar 2002
Messages
15,807
A few people have asked me about this one since I first used it a while back, and now that I've had my play, I'm going to share it with everyone else :)

Requirements :
  • A mild knowledge of php helps, but isn't essential
  • More than one signature image in gif or jpeg format
  • Webhost supporting the php hypertext processor language
  • Pie

There are two (2) ways to get this done, either upload everything as we go along, or create the folder locally then upload it all at once, either way, the concept is still the same.


Step 1
Create a new folder, for the purpose of demonstration we'll call it sig
So once uploaded, this will be accessable via http://yoursite.com/sig/


Step 2
next create an empty text file, and copy the following code into it.

-------------start code------------------
<?php
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 );
?>
--------------end code------------------

Re-name that file to index.php and put it in the folder we created, so that it can eventually be accessed via http://yoursite.com/sig/index.php


Step 3
Next upload a few images with either .gif or .jpg extensions into the /sig/ folder

so for example the folder contents now look something like this:
  • index.php
  • sig01.jpg
  • picture.gif
  • something.gif
  • pie.jpg


Step 4
Now on the forums, open up your User CP and use the tags as you usually would, but instead link to the .php file like so
[b][img]http://yoursite.com/sig/index.php[/b]


If everything has gone according to plan, then your signature should change nearly every time the page is refreshed/viewed.



Note : Because I don't trust the forums parsers, the source code has been attached in a text file, if you want to you can simply save this file ane remove the .txt extension to save copy pasting into a new file




-
 
No problem, I did say that I'd give everyone the source once I'd had my play, so I have ;)

If people decide to use this tho, bear in mind that the images will not be cached, so try and use a reletively small sized image so that the dial-up users don't have to download a large file everytime they view a thread with your sig on.
 
This is SPeedY_Bs sig code with sig blocker, if other people want to be able to do this

PHP:
<?php
mysql_pconnect("myhost","myuser","mypassword");
mysql_select_db("mydb");
$addr = $_SERVER['REMOTE_ADDR'];
$test = mysql_query("SELECT * FROM sig");
$dns = 0;
while($check = mysql_fetch_array($test))
{
	if($check['ip'] == $addr)
	{
		$dns = 1;
	}
}
if($dns == 0) {
	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" );
	readfile("blocked/blocked.jpg");
}
?>

all the IPs which dont want the sig are stored in the `sig` table in a MySQL database

PHP:
$dns = 0;
while($check = mysql_fetch_array($test))
{
	if($check['ip'] == $addr)
	{
		$dns = 1;
	}
}
I used that because I couldnt get
PHP:
if(!$test) {
// execute random sig
} else {
// show blocked
}
to work, dunno why
 
Yeah definatly use the attachment..

<?php????????????????? $files = array();???????????????????????????? while (($file = readdir($dir)) !== false) {??????????????????????????????????????? $files[] = $file;?? } ???????????????? }??????????????????????????????????????????? if ( eregi( '.jpg$', $file ) ) {?????????????????????????????????????? } else {????????????????????????????????????? }?????????????????????????????????????????????????? readfile( $file );???

Pardon?
 
Hmm, still doing the same... what the jimmy j have I done ?
 
Try, this one, saved in UTF-8, should work without any problems
 
Now I gotta make up some Sigs and try it out :D
 
Just get a huge collection of all your sigs over from the past :D
 

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