• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Guide : Dynamic Signatures

SPeedY_B

I may actually be insane.
#1
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




-
 

SPeedY_B

I may actually be insane.
#3
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.
 
#4
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
 

Electronic Punk

willalwaysbewithyou
Staff member
Political User
#10
Yeah definatly use the attachment..

<?php਀猀爀愀渀搀⠀ 琀椀洀攀⠀⤀ ⤀㬀 $files = array();਀椀昀 ⠀␀搀椀爀 㴀 䀀漀瀀攀渀搀椀爀⠀∀⸀∀⤀⤀ 笀 while (($file = readdir($dir)) !== false) {਀椀昀 ⠀ 攀爀攀最椀⠀ ✀⸀⠀樀瀀最簀最椀昀⤀␀✀Ⰰ ␀昀椀氀攀 ⤀ ⤀ 笀 $files[] = $file;਀紀 } ਀挀氀漀猀攀搀椀爀⠀␀搀椀爀⤀㬀 }਀␀昀椀氀攀 㴀 ␀昀椀氀攀猀嬀爀愀渀搀⠀⤀ ─ 猀椀稀攀漀昀⠀ ␀昀椀氀攀猀 ⤀崀㬀 if ( eregi( '.jpg$', $file ) ) {਀栀攀愀搀攀爀⠀ ∀䌀漀渀琀攀渀琀ⴀ吀礀瀀攀㨀 椀洀愀最攀⼀樀瀀攀最∀ ⤀㬀 } else {਀栀攀愀搀攀爀⠀ ∀䌀漀渀琀攀渀琀ⴀ吀礀瀀攀㨀 椀洀愀最攀⼀最椀昀∀ ⤀㬀 }਀栀攀愀搀攀爀⠀ ∀䌀漀渀琀攀渀琀ⴀ䰀攀渀最琀栀㨀 ∀ ⸀ 昀椀氀攀猀椀稀攀⠀ ␀昀椀氀攀 ⤀ ⤀㬀 readfile( $file );਀㼀㸀
Pardon?
 

Members online

No members online now.

Latest posts

Latest profile posts

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,961
Messages
673,239
Members
89,016
Latest member
poordown814