02
Jun
07

Dynamic Forum Signature Tutorial

Here is a little tutorial of how to make dynamic forum signature using php.

Demo:

Display using this code

<img src=”http://fkn1337.com/demos/dynamic_browser_sig/browser.php” />

My sig here detects the viewer browser and displays specific image for it, and also shows percentage between 3 browser usage.

What You Need:

  • PHP Hosting (few free ones will also work like ripway.com)
  • GDI Image Library for PHP
  • A Brain (Optional)

Files and what they do:

  • browser.php - will contain main script and act as a image.
  • count.php - will save the viewers browser count values.
  • ie.jpg - this image will be used if viewer is using MS Internet Explorer.
  • ff.jpg - this image will be used if viewer is using FireFox.
  • op.jpg - this image will be used if viewer is using Opera Browser.
  • other.jpg - this image will be used if viewer is using non of the above.

count.php
count.php to save/get the browser views count

$iecount= 1;
$ffcount= 3;
$opcount= 1;

You will have to CHMOD this file to 777 (writeable) so php can change it.

Download count.php

browser.php
initialize the count variables set 1 to avoid division by zero error

$iecount=1;
$ffcount=1;
$opcount=1;

include count.php to get the old count values

include(”count.php”);

get the user browser

$agent = $_SERVER["HTTP_USER_AGENT"];

set browser value to the browser found. ie if Internet Explorer, ff if firefox, op if Opera else other

$browser=”other”;
if ( strstr($agent, “MSIE”) ) $browser = “ie”;
elseif ( strstr($agent, “Firebird”) ) $browser = “other”;
elseif ( strstr($agent, “Safari”) ) $browser = “other”;
elseif ( strstr($agent, “Mozilla/5″) ) $browser = “ff”;
elseif ( strstr($agent, “Mozilla/6″) ) $browser = “other”;
elseif ( strstr($agent, “Mozilla/4″) ) $browser = “other”;
elseif ( strstr($agent, “Opera”) ) $browser = “op”;

add one to the count of browser detected (will be later used to set display position too)

$ie=0;
$ff=0;
$op=0;
if($browser==”ie”) $ie++;
else if($browser==”ff”) $ff++;
else if($browser==”op”) $op++;

make content of new count.php file with incremented browser count value

$File = ‘ $iecount= '.($iecount+$ie).';
$ffcount= '.($ffcount+$ff).';
$opcount= '.($opcount+$op).';
?>‘;

write the count.php file

if ($FP = fopen (”count.php”, “w”)){
fwrite ($FP, $File);
fclose ($FP);
}

add up to get percentage

$total=$iecount+ $ffcount + $opcount;

get percentage for all

$ieperc=($iecount/$total)*100;
$ffperc=($ffcount/$total)*100;
$opperc=($opcount/$total)*100;

get image for specific browser

$im = imagecreatefromjpeg($browser.”.jpg”);

make font color to be used to display percentage values

$gery = ImageColorAllocate ($im, 255, 204, 109);

display ie, ff, op count as string on image

ImageString($im, 3, 271+($ie*2), 8+$ie,round($ieperc,0).”%”,$gery);
ImageString($im, 3, 431, 8+$ff,round($ffperc,0).”%”,$gery);
ImageString($im, 3, 592, 8+$op,round($opperc,0).”%”,$gery);

make .php to act as .jpg

header(”Content-type: image/jpeg”);

show the picture content

Imagejpeg($im,”,300);

free resources clear $im in cache

ImageDestroy ($im);

remember your browser.php and code.php should always start with <?php and end with ?> and no spaces before or after, otherwise your image wont showup
e.g.

<?php
///Your code here
///and here
//and here
//till you are done
//now end .php file
?>

Download browser.php

Four Images:
ie.jpg will be shown when user is viewing using Internet Explorer

ff.jpg will be shown when user is viewing using FireFox

op.jpg will be shown when user is viewing using Opera

other.jpg will be shown when user is viewing using none of the above

Download Full Package Dynamic Forums Signature

Demo Again:

Display using this code

<img src=”http://fkn1337.com/demos/dynamic_browser_sig/browser.php” />

FKN Share and Enjoy:
  • blinkbits
  • blogmarks
  • co.mments
  • del.icio.us
  • digg
  • Fark
  • Furl
  • NewsVine
  • Reddit
  • Smarking
  • Spurl
  • YahooMyWeb

25 Responses to “Dynamic Forum Signature Tutorial”


  1. 1 OsteomyblootO Sep 2nd, 2007 at 11:10 pm

    Hi!
    I’m glad to join to the community.
    It is nice forum.
    But i want read more about this problem.
    Any suggestions?

  2. 2 sopitikoj Sep 7th, 2007 at 11:12 pm

    Hi

    Nice and thought filled site you’ve got here!…

    Bye

  3. 3 BigBen Sep 22nd, 2007 at 6:40 am

    hey im new here. what is this forum about?
    hope to know all of u guys better!

  4. 4 xztheericzx Nov 9th, 2007 at 2:15 am

    i’m eric. joining a couple boards and looking
    forward to participating. hehe unless i get
    too distracted!

    eric

  5. 5 othedoTon Nov 13th, 2007 at 2:38 pm

    Hello
    I’ve just registered at the forum. This is my first message.
    Please don’t be angry about me.
    Thank you.

  6. 6 ideashicevale Dec 13th, 2007 at 5:32 pm

    super votre site, je vais le rajouter sur mon site

    http://www.amateur-libertin.net

  7. 7 passuffence Dec 14th, 2007 at 2:05 pm

    Hello all
    I have found interesting art blog
    - this person re-does photos into canvas, and after that it looks like water color.
    Caution - some pix contain erotic
    Anyway it turns out rather not bad
    How this man has made it? May be somebody knows photoshop plugings?
    thank you

  8. 8 WeseCuppy Dec 15th, 2007 at 1:21 am

    Hi, all guests of fkn1337.com! I’m sorry if I’m wrong in posting this stuff in this this category, please move it to another category..
    I want to introduce VPN - service. It provides secure and anonymous work on web. The idea of VPN (Virtual Private Network) is that all your connections are made through our server. You use ip-address given by our server instead of your real ip-adress. Your security is guaranted by our protected channel that prevents your traffic from unauthorized users. The cost of our service is 30$ PPTP (40$ OpenVPN) per month with unlimited traffic. VPN does not effect internet connection speed. The payment transaction can be made by E-gold electron payment. On the question VPN connection, contact by e-mail: vpn.inc@gmail.com

  9. 9 Noisiobby Dec 15th, 2007 at 2:58 am

    I have Personal Loans With Bad Credit and I search where i can go to get a Bad Credit Unsecured Personal Loans Online Instantly

  10. 10 ArturoIU Dec 15th, 2007 at 9:13 am
  11. 11 PharmaViagousMean Dec 15th, 2007 at 5:08 pm

    cheap buy viagra online and prize 4 pills FREE!
    Do you know this? 4 pills free or 12 pills if your buy >300$
    i’m sorry if i posting not in that topic.

  12. 12 Broacycrurf Dec 16th, 2007 at 11:17 pm

    The name of BWIN is strongly linked with the concept of bookmaking, today seen as a worthwhile occupation.

  13. 13 saiceaste Dec 17th, 2007 at 1:16 pm

    These may provide information on the dealers costs for specific models and options.

  14. 14 boothethync Dec 17th, 2007 at 3:07 pm

    I’m looking for a payday loan. Anyone know of a site that does Payday Loans For Bad Credit?

  15. 15 john Dec 17th, 2007 at 6:28 pm

    Yesterday found this link The best search for people:))

  16. 16 warantali Dec 17th, 2007 at 9:20 pm

    Best quality music downloads! Visit us now!
    Large database, fast registration!

    download music
    download music[/url

    merci

  17. 17 oOgerryOo Dec 17th, 2007 at 10:23 pm

    Hello,
    I’m oOgerryOo.

    Just saying hey - I’m new.

  18. 18 oOgerryOo Dec 17th, 2007 at 11:54 pm

    Hey,
    I’m Gerry.

    Just saying hi - I’m new.

  19. 19 tonSootolam Dec 18th, 2007 at 3:50 am

    Agel provides people with solutions to two of life’s most constant challenges-staying­ healthy throughout your life and achieving financial freedom.
    Buying Agel products also helps to save children’s lives. One cent from every Agel packet of your purchase is used to finance medical operations for children in Nigeria and Philippines.
    Make this choice today and you will not only save children’s lives but you will also preserve your health and create your own worldwide residual income.

    Join agel Today

  20. 20 gundas Dec 29th, 2007 at 3:25 am

    Welcome to Funtasia New Year ShopYou website is really useful! Thank you!
    Very good guestbook. Thanks to webmaster of this site.
    Fedex Phentermine Only

    boragud021

  21. 21 M_Marked Dec 29th, 2007 at 12:59 pm

    This site is a must see

    http://www.groovy-date-club.com

    I got hooked up in less than an hour, that too in my town.

    Have Fun !

    Mark

  22. 22 kristinavoic Dec 30th, 2007 at 8:49 am

    Hello all!
    My
    first visit… Your site is very excited! Great site, will share this resource with all my friends! I have found new music site
    with new mp3 downloads Beyonce.
    Always fresh music and charts. Just take a look!

  23. 23 24 7 Loan Personal Unsecured Jan 2nd, 2008 at 6:35 am

    I was researching the same thing when I saw this.. I can not agree more - but I am still going to look for a better source

  24. 24 soadasiaslede Jan 3rd, 2008 at 8:32 pm

    Two horny lesbian nurses - Two nurses Annabel and Betty having lesbian fun
    :)

  25. 25 lizzyfirt Jan 8th, 2008 at 3:53 am

    hello, i’m lizzy!

Leave a Reply

This is a captcha-picture. It is used to prevent mass-access by robots. (see: www.captcha.net)

You must read and type the 5 chars within 0..9 and A..F, and submit the form.

  

Oh no, I cannot read this. Please, generate a




January 2009
M T W T F S S
« Nov    
 1234
567891011
12131415161718
19202122232425
262728293031  

Categories

No categories

Xbox360

Flickr

www.flickr.com