How To Get Your FeedBurner Circulation With One Simple Function
If you have visited a few blogs then I am sure you have seen the FeedBurner stats graphic. The count is very useful, but the graphic itself isn't very appealing, even with the ability to customize it. Thankfully the FeedBurner API was released, which allows you to retrieve your stats without the graphic. I have taken that API and created a simple function, with the help of simple XML, to grab your circulation count and display it as text on your site without the graphic.
To start off, you will need to download the simple XML class and put it in the same folder as the file that will contain this function (or change the include path to reflect the directory of your choice). Once you have done that, you are pretty much done. All you need to do is copy the function below and call the function with your feed URI and it will return the circulation number.
You can see the function and sample usage below.
Function
function FeedBurnerCirc($feed) { include 'simplexml.class.php'; $api = 'http://api.feedburner.com/awareness/1.0/GetFeedData?uri='.$feed; $sxml = new simplexml; $sxml->ignore_level = 1; $data = $sxml->xml_load_file($api,"array"); return $data["entry"]["@attributes"]["circulation"]; }
Usage
echo FeedBurnerCirc('http://feeds.feedburner.com/webmastersbydesign');
You could also easily customize the function to include more data and return an array of results. The API returns data other that the circulation, such as your reach and views. I only wanted the circulation so I didn't return an array of results, but it wouldn't be tough to do.
10 Online Magazines for Developers and Designers
PHP Magazine

PHP Magazine is an online magazine in the form of a blog. There are posts that range many different categories, mainly PHP, but others from within their network of sites. There is information from software and book reviews to articles and tutorials.
Ajax Magazine

Ajax Magazine is another online magazine in the form of a blog from the publishers of PHP Magazine. The Ajax version focuses mainly on Ajax technologies and offers news, articles, and reviews to name a few.
Smashing Magazine

Smashing Magazine is one of the best sites on the web (also an online magazine in the form of a blog). They have amazing "round-ups" and posts bringing together the best sites, services, and resources on the web. They focus a lot on web 2.0 technologies and provide great content for both designers and developers.
Design Mag

Design Mag offers news, articles, galleries, interviews and more. The website is in the form of a blog and is updated very frequently. They have great resources and devote a section to freelance information. This is often a common thread between webmasters/designers/developers. They are the home of the 200+ Resources for Freelance Web Designers article.
Website Magazine

Website Magazine offers their magazine both in print and online. However, the only way you can see the online version is if you subscribe to the print version. The good news: it's free! The website has forums, articles, and blogs full of content. The magazine contains a lot of useful information in typical article format, usually offering one focus article with many other shorter articles throughout.
Digital Web Magazine

Digital Web Magazine offers news, articles, reviews, interviews, and tutorials. News is updated daily and main articles are updated on a weekly basis and are well worth the wait. The content is very useful and very thorough. They also report on upcoming events around the world.
SD Times

SD Times reports on content related to programmers and developers. In both a print version and online, SD Times has over 60,000 subscribers. They report on recent news and stories, write columns and opinions, as well as providing a job board and resource center. This publication reads more as a newspaper than a magazine.
Dr. Dobb's Journal

Dr. Dobb's Journal is another publication both in print and online. They offer information from a variety of different programming and development topics. Some topics include databases, open source, security, web development, and specific programming languages like C/C++ and Java. They also have a resource center and a blog full of information as well.
Developer.* Magazine

Developer.* offers articles, blogs, and book reviews for all things development and programming. There articles are broken down by categories ranging from software design and quality to legal issues and techniques. The articles are well written, the information is great, and the information is very thorough.
.Net Magazine
.Net Magazine is both in print and online. They offer articles to help developer, discover, and design. They also have podcasts and forums filled with content. They cover topics ranging from flash to CSS to Facebook.
300+ PHP Presentations Online

The PHP Presentation System hosts over three hundred presentations, covering a slew of different topics including performance, testing, debugging, XML, and security. The presentations are from speakers at a variety of conferences. You will see (and hear if interested) presentations from speakers like Derick Rethans, Tobias Schlitt, Rasmus Lerdorf and many many more. These presentations have been at conferences all around the world and contain a great deal of information. Most presentations are between 25 and 40 slides. You will have to sift through some information in the presentations because some build on each other.
The presentations are best viewed in Firefox and are not available for use with IE. If you try to use IE you will get a pretty funny error code; "IE is not supported - please use Firefox, Safari, Konqueror or just about anything else" (view this presentation in IE). There are presentations dated as far back as 2002 and as recent as August 2008. Take a look around and see what's there.
My Top 10 Presentations
All-In-One Web Server Installation Packages
A traditional web server is made up of many different components, including an http server, mail server, FTP server, and more. In days gone by, a webmaster would install each software package individually to get a custom web server up and running. These kinds of server setups offer many advantages, including testing, learning, and being able to have total control over the web server environment. Today there are many different options available that bundle each component into an easy single installation package.
The installation packages are basically split into two main categories, WAMP (Windows Apache MySQL PHP) servers and LAMP (Linux Apache MySQL PHP) servers. As you can see, they are installation packages that include the Apache httpd server, the MySQL database server, and PHP installed on either a Windows machine or a Linux/Unix machine. There are many different WAMP/LAMP installation packages available that contain the 4 major components, as well as other software to make a more full featured web server. These packages can vary slightly, while meeting the general requirements for running a web server. I have listed some of the most common packages available below.
WAMP
- Apache2Triad - This package includes an incredible list of features. It installs Apache with mod_python, mod_ssl, mod_perl, OpenSSL, and AWStats, MySQL with phpMyAdmin, PostgreSQL with pgAdmin and phpPgAdmin, xmail with PHPXMail and UebiMiau, SlimFTPD with PHPsFTPd, PHP with Pear and Smarty, Perl with CPAN, and Python with Spyce and wxPython.
- XAMPP - This package installs Apache with OpenSSL, MySQL with phpMyAdmin, PHP 4 and PHP 5, FileZilla FTP server, and Mercury Mail Transport System. You can also get Perl and Tomcat as an add-on.
- WampServer 2.0 - This is the new version of the WAMP5 server. It installs Apache, MySQL with PHPMyAdmin and SQLiteManager, and PHP. It doesn't have all the bells and whistles of the first servers listed, but it is reliable and has the ability to install many different releases of Apache, MySQL, and PHP.
- The Uniform Server - This package installs Apache, MySQL with phpMyAdmin, and PHP. It also includes SSL capabilities, but I couldn't find what software is used.
- SpikeWAMP - This package installs Apache, MySQL, and PHP. This version also includes the ability to install popular applications like Drupal, Joomla, Moodle, phpBB, and more. There is also an update channel that allows you to download and install the new beta versions of the applications. This is a nice and easy WAMP installation package.
LAMP
- XAMPP - This package installs Apache with OpenSSL, MySQL with phpMyAdmin, PHP 4 and PHP 5, FileZilla FTP server, and Mercury Mail Transport System.
- Apache Toolbox - This package installs one of the largest bundles of applications and mods I have seen; it boasts almost 100 different modules. Some of these include Apache, MySQL, Apache, WebDAV, OpenLDAP, and gd libraries. Take a look at the website to get the full listing.
- BitRock - This package is based on the BitNami stacks and installs Apache, MySQL with phpMyAdmin, and PHP. There are also some popular applications available for easy installation with BitRock, like phpBB, WordPress, Joomla, and Subversion just to name a few.
What LAMP/WAMP server do you use? Or do you set up all the pieces separately? Let us know in the comments.
Track Page Load Time With This Free Script Execution Class
Performance is very important to webmasters and a lot of times it would be nice to know how long on average it took for our web pages to load. I created a simple class in order to track how fast a page executes. This is written in PHP because that is what I use to develop my sites. It currently just displays the output on the page; I haven't turned this into a log or database table yet but I probably will. Once I convert it to save the output each time, I could use it to track the averages per page. This is just a basic timer at the moment though. I have included the class and an example within the same PHP file below. You are free to use and change the script as you wish. Feel free to link back if you would like, but it is not mandatory.
<?
class LoadTime {
var $PageLoadStart;
var $PageLoadEnd;
function PageStart() {
$this->PageLoadStart = microtime();
}
function PageEnd() {
$this->PageLoadEnd = microtime();
}
function LoadTime() {
return round($this->PageLoadEnd-$this->PageLoadStart,4);
}
}
$timer = new LoadTime();
$timer->PageStart();
$i = 0;
while ($i<100000) {
$i++;
}
$timer->PageEnd();
echo $timer->LoadTime().' seconds';
?>
phpMyAdmin 2.11.8.1 Released Yesterday
phpMyAdmin 2.11.8.1 was released yesterday. The main reason for the updated release is to patch bugs and security issues. There were some XSS problems reported by Aung Khant from the YGN Ethical Hacker Group. The two main fixes are both XSS related, one having to do with frames and the other has to do with a lack of HTML escaping. You can read more about these by visiting the site which contains the news release about these bug/security fixes from phpMyAdmin. These vulnerabilities were considered very serious and have now been patched with this new release. Be sure to upgrade your copy to 2.11.8.1. You can download the new release from SourceForge.
Add Salt To Make Your Encryptions Better

Needing Salt
There are few things that aren't better once salt has been added, and encryptions are no different. Adding a salt can make a simple encryption exponentially harder to break/crack. "Salt data complicates dictionary attacks that use pre-encryption of dictionary entries: Each bit of salt used doubles the amount of storage and computation required" (Wikipedia). You can see that by adding a good sized salt, the encryption can become very difficult to break by dictionary or other brute force attacks. A lot of programmers rely entirely on the md5 encryption for storing passwords because it is built into both PHP and MySQL. While md5 is an easy function to implement, it is pretty easily reversed using rainbow tables. Thankfully, there are many other available encryption options that include salt, and the best part about adding salt to your encryption is how easily it can be done.
Adding Salt
- PHP - crypt("string to encrypt","salt")
- Perl - crypt("string to encrypt","salt")
- ASP - Set crypt = Server.CreateObject("Persits.CryptoManager")
Set ctx = crypt.OpenContext("", True)
Set hash = ctx.CreateHash
hash.AddText Request("string to encrypt") & salt
hashvalue = hash.Value.Hex - Ruby On Rails - "string to encrypt".crypt("salt")
- Python - crypt("string to encrypt","salt")
Enjoying Salt
Now that you have added salt to your encryption, I'm sure you would like to know how much more secure that encrypted string really is. This is actually a very easy calculation. Let's say for example that you know your users are creating easy passwords that they can remember and are therefore picking words out of the dictionary. The users are picking from let's say around 100,000 of the words in the English language. Using encryption without salt, basic brute force attacks would have to compute 100,000 hashes to find the correct one. On the other hand, if you take their password from the dictionary and add a salt, using say a 32 bit salt, the same size as md5 encryption, you multiply the word possibilities by the salt possibilities; see below:
- Password Possibilities: 100,000
- Salt Possibilities: 2^32
Hash calculations needed = 100,000 * 2^32 Hash calculations needed = 429,496,729,600,000
This basic calculation shows that simply adding a salt makes the encryption 4,294,967,296 times harder to break.
Additional Resources
Unable to Use mysqldump on a Shared Host? Here’s an Alternative

I have used many shared hosting providers throughout my years as a webmaster. Shared hosts have many great points, namely, price, and then they have their major drawbacks. For me, one of the major drawbacks is the limited use of the machine on which your site is hosted.
For instance, I love phpMyAdmin for maintaining and managing my databases, but I am not a fan of the need to log in to backup the databases. The easiest way around that of course would be to execute the mysqldump command that comes bundled with MySQL. Unfortunately, most shared hosts, all that I have dealt with, disable the ability to use exec() or system() with PHP to execute the MySQL native command. If these were available, creating a cron job on a simple PHP file that ran mysqldump would have worked perfectly. However, this wasn't the case. After looking around for a long time at a possible way around this, I came up empty handed. Maybe I didn't look hard enough, or looked in all the wrong places, but I was left with nothing. I needed to back up my databases at regular intervals and found it frustrating to log into phpMyAdmin to do this each time. So I did what I should have done to begin with... wrote my own back-up tool.
It is pretty simple and self-explanatory. I did not create it as a function to be called, although you are more than welcome to do so. The main advantage to calling it, I think, would be to pass variables. For my needs, I simply set it up in the directory. I wanted it to run and back up whichever database needed to be. The script simply backs up the database specified in an sql file located in the same directory as the script itself. The file is named in this format, "DB_Backup_YourDatabase_YYYY-MM-DD.sql"; this could be easily modified to save anywhere you have permissions to save. The code is completely free and you can do what you would like with it. If you are feeling generous, throw a shout out my way or maybe even donate, but neither is not required.
This script was written and used on a server running PHP Version 4.4.2 and MySQL Version 4.1.22.
Creating a WordPress Widget
If you are reading this post, you are familiar with a wordpress widget because you can see multiple widgets displayed in the right hand sidebar of this theme. The Archives, Recent Posts, Blogroll, and Links are all wordpress widgets. If you are asking yourself, "why create a wordpress widget?" here is a short answer:
This blog, like many others, is run using wordpress (wordpress was downloaded 3,816,965 times in 2007 alone). WordPress has become increasingly popular thanks to the incredible features, themes, and plugins offered, both by wordpress.org, as well as third party developers, such as:. The administrative end of wordpress is very easy to use and at the same time very powerful. The blog has all the necessary features necessary to run a successful blog, as well as the ability to add onto the large set of tools included with the download and installation of a wordpress blog. One of the best features of wordpress in my opinion, is the ability to create plugins and widgets that suit your needs. Once the plugin or widget has been successfully created, implementation is even easier. So now that we have covered a little background information, let's get started!
Steps
1. Create a php file and put it in the "wp-content/plugins" directory in your wordpress installation path.
2. The first information in the widget file is required to be there. Each line needs to be there and is fairly self-explanatory. These lines tell the wordpress plugins manager what the plugin is, who made it, what version it is currently in, and the links to provide support and updates. It looks like this:
/*
Plugin Name: Test Widget
Plugin URI: http://smseserver.com/blog/
Description: This is my first custom created widget.
Version: 1.0
Author: Scott Spear
Author URI: http://smseserver.com/blog/
*/
3. Create the function to initialize the widget. The widget_test_init() function checks if you can register custom widgets and then loads the actual widget function, in this case named "widget_test()". The last line actually registers the new widget by calling the register_sidebar_widget() function.
function widget_test_init() {
if (!function_exists('register_sidebar_widget')) {
return;
}
function widget_test() {
echo 'This is the test widget.';
}
register_sidebar_widget(array('Test Widget', TestWidget'), 'widget_test');
}
4. After the widget is registered to the sidebar, the very last line will call the add_action() function to load the widget and show it in widget control in the admin section of your blog. The function looks like this:
add_action('plugins_loaded', 'widget_test_init');
The final php file would look like this:
<?
/*
Plugin Name: Test Widget
Plugin URI: http://smseserver.com/blog/
Description: This is my first custom created widget.
Version: 1.0
Author: Scott Spear
Author URI: http://smseserver.com/blog/
*/
function widget_test_init() {
if (!function_exists('register_sidebar_widget')) {
return;
}
function widget_test() {
echo 'This is the test widget.';
}
register_sidebar_widget(array('Test Widget', TestWidget'), 'widget_test');
}
add_action('plugins_loaded', 'widget_test_init');
?>
Commonly Used Regular Expressions
Here is a function that I have developed in PHP for checking to see if data is in a valid format. These are some of the common validations I have needed while programming various projects and websites. Regular expressions are some of the most powerful validation checks available in PHP, however they are not always easy to understand.
This function is used by passing 2 arguments: the type of validation check you want to be performed, and the data you want validated. The function itself uses a simple switch statement (a quicker and cleaner if/then statement). The function simply returns a boolean True or False.
function isValid($type,$var) {
$valid = false;
switch ($type) {
case "IP":
if (ereg("^([0-9]{1,3}\.){3}[0-9]{1,3}$",$var)) {
$valid = true;
}
break;
case "Email":
if (ereg("^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$",$var)) {
$valid = true;
}
break;
case "URL":
if (ereg("^[a-zA-Z0-9\-\.]+\.(com|org|net|mil|edu)$",$var)) {
$valid = true;
}
break;
case "SSN":
if (ereg("^[0-9]{3}[- ][0-9]{2}[- ][0-9]{4}|[0-9]{9}$",$var)) {
$valid = true;
}
break;
case "CC":
if (ereg("^([0-9]{4}[- ]){3}[0-9]{4}|[0-9]{16}$",$var)) {
$valid = true;
}
break;
case "ISBN":
if (ereg("^[0-9]{9}[[0-9]|X|x]$",$var)) {
$valid = true;
}
break;
case "Date":
if (ereg("^([0-9][0-2]|[0-9])\/([0-2][0-9]|3[01]|[0-9])\/[0-9]{4}|([0-9][0-2]|[0-9])-([0-2][0-9]|3[01]|[0-9])-[0-9]{4}$",$var)) {
$valid = true;
}
break;
case "Zip":
if (ereg("^[0-9]{5}(-[0-9]{4})?$",$var)) {
$valid = true;
}
break;
case "Phone":
if (ereg("^((\([0-9]{3}\) ?)|([0-9]{3}-))?[0-9]{3}-[0-9]{4}$",$var)) {
$valid = true;
}
break;
case "HexColor":
if (ereg("^#?([a-f]|[A-F]|[0-9]){3}(([a-f]|[A-F]|[0-9]){3})?$",$var)) {
$valid = true;
}
break;
case "User":
if (ereg("^[a-zA-Z0-9_]{3,16}$",$var)) {
$valid = true;
}
break;
}
return $valid;
}
Example:
$email_address = $_POST["email"];
if (isValid("Email",$email_address)) {
echo "Valid Email Address;
} else {
echo "Invalid Email Address;
}
For more information, help, and examples visit RegExLib.com or check out the Mastering Regular Expressions book.

