Reply
Old April 30th, 2003 Top | #1
 
SPeedY_B's Avatar
I may actually be insane.
Joined: March 2002
Location: Midlands, England
Posts: 15,800
Reputation: 2877
Power: 307

Default Guide : Dynamic Signatures

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 [img] tags as you usually would, but instead link to the .php file like so
[img]http://yoursite.com/sig/index.php[/img]


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 is offline   Reply With Quote
Old April 30th, 2003 Top | #2

OSNN Folding Team  
NetRyder's Avatar
Tech Junkie
Joined: April 2002
Location: New York City
Posts: 13,256
Reputation: 4260
Power: 294

Default

Excellent! Thanks SpeedY
NetRyder is offline   Reply With Quote
Old April 30th, 2003 Top | #3
 
SPeedY_B's Avatar
I may actually be insane.
Joined: March 2002
Location: Midlands, England
Posts: 15,800
Reputation: 2877
Power: 307

Default

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.
SPeedY_B is offline   Reply With Quote
Old May 4th, 2003 Top | #4

OSNN Folding Team  
Geffy's Avatar
OSNN Veteran Addict
Joined: March 2002
Location: United Kingdom
Posts: 7,805
Reputation: 1490
Power: 213

Default

This is SPeedY_Bs sig code with sig blocker, if other people want to be able to do this

PHP Code:
<?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) {
    
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" );
    
readfile("blocked/blocked.jpg");
}
?>
all the IPs which dont want the sig are stored in the `sig` table in a MySQL database

PHP Code:
$dns 0;
while(
$check mysql_fetch_array($test))
{
    if(
$check['ip'] == $addr)
    {
        
$dns 1;
    }

I used that because I couldnt get
PHP Code:
if(!$test) {
// execute random sig
} else {
// show blocked

to work, dunno why


blogtumbloglastfmflickr#rubyonrails@twitter
"I could be replaced with a very small shell script"
Geffy is offline   Reply With Quote
Old May 5th, 2003 Top | #5

OSNN Folding Team  
NetRyder's Avatar
Tech Junkie
Joined: April 2002
Location: New York City
Posts: 13,256
Reputation: 4260
Power: 294

Default

Someone sticky this thread
NetRyder is offline   Reply With Quote
Old May 5th, 2003 Top | #6
 
SPeedY_B's Avatar
I may actually be insane.
Joined: March 2002
Location: Midlands, England
Posts: 15,800
Reputation: 2877
Power: 307

Thumbs up

Done.
SPeedY_B is offline   Reply With Quote
Old May 22nd, 2003 Top | #7
 
X-Istence's Avatar
*
Joined: December 2001
Location: USA
Posts: 6,490
Reputation: 2808
Power: 217

Default

Really nice tutorial.
X-Istence is offline   Reply With Quote
Old May 23rd, 2003 Top | #8

OSNN Folding Team  
xsivforce's Avatar
Prodigal Son
Joined: February 2002
Location: Texas, USA
Posts: 8,542
Reputation: 1410
Power: 221

Default

Originally posted by X-Istence
Really nice tutorial.
I beleive it was originaly @ x-istence.com
xsivforce is offline   Reply With Quote
Old May 23rd, 2003 Top | #9
 
SPeedY_B's Avatar
I may actually be insane.
Joined: March 2002
Location: Midlands, England
Posts: 15,800
Reputation: 2877
Power: 307

Default

It was?
SPeedY_B is offline   Reply With Quote
Old June 1st, 2003 Top | #10

OSNN Folding Team  
Electronic Punk's Avatar
The Last High
Joined: December 2001
Location: London
Posts: 18,506
Blog Entries: 51
Reputation: 3652
Power: 346

Default

Yeah definatly use the attachment..

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

Electronic Punk is offline   Reply With Quote
Old June 1st, 2003 Top | #11

OSNN Folding Team  
Electronic Punk's Avatar
The Last High
Joined: December 2001
Location: London
Posts: 18,506
Blog Entries: 51
Reputation: 3652
Power: 346

Default

Hmm, still doing the same... what the jimmy j have I done ?

Electronic Punk is offline   Reply With Quote
Old June 1st, 2003 Top | #12
 
SPeedY_B's Avatar
I may actually be insane.
Joined: March 2002
Location: Midlands, England
Posts: 15,800
Reputation: 2877
Power: 307

Default

You've broke it all

It's working fine here
SPeedY_B is offline   Reply With Quote
Old June 1st, 2003 Top | #13
 
SPeedY_B's Avatar
I may actually be insane.
Joined: March 2002
Location: Midlands, England
Posts: 15,800
Reputation: 2877
Power: 307

Default

Try, this one, saved in UTF-8, should work without any problems
SPeedY_B is offline   Reply With Quote
Old June 1st, 2003 Top | #14
 
X-Istence's Avatar
*
Joined: December 2001
Location: USA
Posts: 6,490
Reputation: 2808
Power: 217

Default

Originally posted by xsivforce
I beleive it was originaly @ x-istence.com
Not that i know off. Speedy_B only asked if there was some way he could improve it. Which there isnt.
X-Istence is offline   Reply With Quote
Old August 26th, 2003 Top | #15
 
wadada's Avatar
OSNN Senior Addict
Joined: November 2002
Location: netherlands
Posts: 707
Reputation: 180
Power: 121

Default . . .

kewl lol im so newbie with this php code

wadada is offline   Reply With Quote
Old August 26th, 2003 Top | #16
 
Glaanieboy's Avatar
OSNN Veteran Addict
Joined: March 2002
Location: The Netherlands
Posts: 2,626
Reputation: 270
Power: 150

Default Re: . . .

Originally posted by wadada
kewl lol im so newbie with this php code
You shall learn, my son. It's quite fun to do.
Glaanieboy is offline   Reply With Quote
Old August 27th, 2003 Top | #17

OSNN Folding Team  
gonaads's Avatar
Beware the G-Man
Joined: March 2002
Location: XP-erience, NTFS, OSNN, Bay Area, California
Posts: 18,474
Reputation: 4070
Power: 345

Default

Now I gotta make up some Sigs and try it out

"I play violent video games, I could snap at any second."
gonaads is offline   Reply With Quote
Old August 27th, 2003 Top | #18
 
SPeedY_B's Avatar
I may actually be insane.
Joined: March 2002
Location: Midlands, England
Posts: 15,800
Reputation: 2877
Power: 307

Default

Just get a huge collection of all your sigs over from the past
SPeedY_B is offline   Reply With Quote
Old August 27th, 2003 Top | #19

OSNN Folding Team  
gonaads's Avatar
Beware the G-Man
Joined: March 2002
Location: XP-erience, NTFS, OSNN, Bay Area, California
Posts: 18,474
Reputation: 4070
Power: 345

Default

That is alot

"I play violent video games, I could snap at any second."
gonaads is offline   Reply With Quote
Old September 16th, 2003 Top | #20

OSNN Folding Team  
Grandmaster's Avatar
Electronica Addict
Joined: February 2002
Location: Santa Clara, CA
Posts: 10,574
Reputation: 2960
Power: 257

Default

cool tutorial


Grandmaster is offline   Reply With Quote

Reply

Bookmarks

Thread Tools

Posting Rules

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