Firefox Download Counter for websites

It is fun to see how the Firefox initiative is growing. Years back, I had done a small hack which will bring the download counter status from the SpreadFirefox website.

I just checked that code again today. Surprisingly, it still works.

Want the code? Here it is.

PHP Code:
<code><code>/* * admin [at] pchelp.in Display number of FireFox downloads graphically. * */// It is a png image - not HTML
header("Content-type: image/png");
$buf = file("http://feeds.spreadfirefox.com/downloads/firefox.xml?ff=1");

//Whats in between?
$replace = Array("<description>","</description>");
$my_count = trim(str_replace($replace,'',$buf[9]));

//Put this font in the same directory. I am using Arial-Rounded
$font = "ARLRDBD.TTF";

//Base image. Get it from http://pchelp.in/images/misc/3.png
//and use it to create the image.
$im = imagecreatefrompng('images/misc/3.png');

//Change to any color you want.
$grey = imagecolorallocate($im, 66,66,66);
imagettftext($im, 10, 0, 44, 22, $grey, $font,$my_count." Downloads");
imagepng($im);
imagedestroy($im);

You can use your own font and base image. Let me know how you are using this 

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>