<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>nicholaspier.com</title>
	<atom:link href="http://nicholaspier.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://nicholaspier.com</link>
	<description></description>
	<lastBuildDate>Thu, 17 Mar 2011 09:47:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Kibibyte or Kilobyte?</title>
		<link>http://nicholaspier.com/2011/03/kibibyte-v-kilobyte/</link>
		<comments>http://nicholaspier.com/2011/03/kibibyte-v-kilobyte/#comments</comments>
		<pubDate>Thu, 17 Mar 2011 09:39:17 +0000</pubDate>
		<dc:creator>Nicholas Pier</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://nicholaspier.com/?p=172</guid>
		<description><![CDATA[Ever purchase a 1TB hard drive and find yourself disappointed when it showed up under &#8216;My Computer&#8217; as 931GiB? If so, you may not have really understood why and felt cheated by the manufacturer. However, there is a simple and &#8230; <a href="http://nicholaspier.com/2011/03/kibibyte-v-kilobyte/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Ever purchase a 1TB hard drive and find yourself disappointed when it showed up under &#8216;My Computer&#8217; as 931GiB? If so, you may not have really understood why and felt cheated by the manufacturer. However, there is a simple and innocent reason for this. Computers evaluate numbers on a different base than humans.</p>
<p><a href="http://nicholaspier.com/2011/03/kibibyte-v-kilobyte/hdd/" rel="attachment wp-att-173"><img src="http://nicholaspier.com/wp-content/uploads/2011/03/hdd-300x200.jpg" alt="" title="hdd" width="300" height="200" class="alignright size-medium wp-image-173" /></a></p>
<p>As human beings, we generally perceive numbers and mathematics on a 10-base number system. Why? The simplest answer is probably that we have 10 fingers and toes. Thus, 10 is a number which is easy for us to make sense of.  This is not the case with computers. Most people are aware that computers perceive data in binary form, or 2-base numbering. There&#8217;s always only 2 possibilities. A circuit is either <em>on</em> or <em>off</em>.</p>
<p><strong>How does this relate to the hard drive?</strong></p>
<p><span id="more-172"></span></p>
<p>When a manufacturer places memory on the magnetic disks of your hard drive, it does so using SI or metric unit values which increment by the 1000s (1GB = 1000MB = 1000000KB&#8230;). As such, with the earlier 1TB, you&#8217;re really purchasing 1(1000^4) bytes of data.</p>
<p>Now, when a computer goes to measure this disk space it does so differently. You still have 1(1000^4) bytes. However, the conversion between units is different. Unit values are instead converted as powers of 1024 instead of 1000. The reason? 1024 is the power of 2 that was chosen at some point. Perhaps because it&#8217;s 2^10 and someone thought that would be easier for humans to make sense of (I can only speculate). This means that 1TB to a computer, is really 1024GB</p>
<p>To make up for this confusion, the IEC standardized a unit system for computer memory which uses units such as the <a href="http://en.wikipedia.org/wiki/Kibibyte">Kibibyte</a> in place of the kilobyte. Hopefully this system will take over and alleviate the confusion from earlier.</p>
<p>But why did I decided to write an article on 10-base and 2-base number systems? The simplest answer would be that I was bored out of my mind but I also wanted to provide a good preface of information for using a little java applet I wrote for fun (I&#8217;m odd and code for fun) that converts these units for a user. You&#8217;ll find it on the <a href="/memory-converter/">Memory Unit Converter</a> page of this website. I have a statistics application which I&#8217;ll be posting soon too.</p>
]]></content:encoded>
			<wfw:commentRss>http://nicholaspier.com/2011/03/kibibyte-v-kilobyte/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>MySQL DB Backup Script</title>
		<link>http://nicholaspier.com/2010/10/mysql-backup-script/</link>
		<comments>http://nicholaspier.com/2010/10/mysql-backup-script/#comments</comments>
		<pubDate>Sat, 16 Oct 2010 06:53:13 +0000</pubDate>
		<dc:creator>Nicholas Pier</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[Professional]]></category>

		<guid isPermaLink="false">http://nicholaspier.com/?p=133</guid>
		<description><![CDATA[The following is a bash shell script which I wrote to backup all databases on a MySQL server. It&#8217;s fairly simple to implement. First step is to fill in the necessary arguments in the commented region of the header. You &#8230; <a href="http://nicholaspier.com/2010/10/mysql-backup-script/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The following is a bash shell script which I wrote to backup all databases on a MySQL server. It&#8217;s fairly simple to implement. First step is to fill in the necessary arguments in the commented region of the header. You will need:</p>
<ul>
<li>The name of a MySQL user account with sufficient privileges to perform a backup. &#8216;root&#8217;, will likely suffice.</li>
<li>The password of the previously mentioned user.</li>
<li>The directory and file where you&#8217;d like the backup saved to. By default, backups are made to a /root/backup directory and files are named by *date*_db_backup.sql. If this directory does not exist, you&#8217;ll have to create it.</li>
<li>The specific database you&#8217;d like to backup.</li>
</ul>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #666666; font-style: italic;">#######ARGUMENTS#############</span>
<span style="color: #666666; font-style: italic;">#	MySQL user to execute dump</span>
	<span style="color: #007800;">db_backup_user</span>=<span style="color: #ff0000;">&quot;root&quot;</span>;
<span style="color: #666666; font-style: italic;">#	Password of MySQL user</span>
	<span style="color: #007800;">db_backup_password</span>=<span style="color: #ff0000;">&quot;***&quot;</span>;
<span style="color: #666666; font-style: italic;">#	Directory to place the updates</span>
	<span style="color: #007800;">db_backup_dir</span>=<span style="color: #ff0000;">&quot;/root/backup/<span style="color: #007800;">$(date +%m_%d_%y)</span>_db_backup.sql&quot;</span>;
<span style="color: #666666; font-style: italic;">#	Specific database to backup. Removing this line and its usage in the mysqldump string will backup ALL databases with the added: --all-databases parameter.</span>
	<span style="color: #007800;">db_backup_db</span>=<span style="color: #ff0000;">&quot;test&quot;</span>;
<span style="color: #666666; font-style: italic;">##############################</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'BEGINNING MySQL DUMP. PLACING DATABASES IN &quot;/root/backup&quot; DIR'</span>;
mysqldump -u<span style="color: #007800;">$db_backup_user</span> -p<span style="color: #007800;">$db_backup_password</span> <span style="color: #007800;">$db_backup_db</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #007800;">$db_backup_dir</span> ;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'END OF &quot;dbbackup.sh&quot; NOW CLOSING'</span>;
<span style="color: #7a0874; font-weight: bold;">exit</span>;</pre></div></div>

<p>Next, name the file with a .sh file extension and place it in a secure directory on your server. I recommend the root user directory (/root). This is a precaution since the file must be configured with the MySQL a user&#8217;s password in order to run properly.</p>
<p>Your next question may not be how to run it. You can manually run backups by executing the shell file within the shell (make sure it has execute permissions). An alternative is to automate database backups using <a href="http://en.wikipedia.org/wiki/Cron">crontab</a>. Crontab is the better option for preventing catastrophic data loss since individuals may get lazy or genuinely forget to perform timely updates.</p>
<p>Please note, that there are many additional steps which may be taken to ensure the best integrity of backups. This tutorial merely shows a method for accessing the database files.</p>
]]></content:encoded>
			<wfw:commentRss>http://nicholaspier.com/2010/10/mysql-backup-script/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Java Normal Probability Approximation Method</title>
		<link>http://nicholaspier.com/2010/10/java-normal-probability-aproximation-method/</link>
		<comments>http://nicholaspier.com/2010/10/java-normal-probability-aproximation-method/#comments</comments>
		<pubDate>Sun, 10 Oct 2010 19:05:42 +0000</pubDate>
		<dc:creator>Nicholas Pier</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://nicholaspier.com/?p=129</guid>
		<description><![CDATA[Recently, I&#8217;ve decided that I want to write my own statistics package in Java (I&#8217;m too bored for my own good). Originally, I wanted to write my own classes to handle the probability calculations under curves. However, this became a &#8230; <a href="http://nicholaspier.com/2010/10/java-normal-probability-aproximation-method/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Recently, I&#8217;ve decided that I want to write my own statistics package in Java (I&#8217;m too bored for my own good). Originally, I wanted to write my own classes to handle the probability calculations under curves. However, this became a bit much when it came time to do f and student-T distributions. As such, I gave up and am now using a Java class provided by CERN laboratories under the GNU license.</p>
<p>Before I gave up, I wrote a simple method for calculating the area under normal distribution curves based on Z statistics (the result of a statistical <a href="http://en.wikipedia.org/wiki/Z_test">Z-Test</a>). It uses the <a href="http://en.wikipedia.org/wiki/Error_function">Error Function</a> to approximate left-tail probability (-infinity  -&gt; Z-statistic).<span id="more-129"></span></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">        <span style="color: #666666; font-style: italic;">/*
	 * Normal probability method
         * @author Nicholas Pier
	 */</span>
	<span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">double</span> getCDF<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">double</span> x<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">double</span> p <span style="color: #339933;">=</span> .5 <span style="color: #339933;">*</span> <span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span> <span style="color: #339933;">+</span> getERF<span style="color: #009900;">&#40;</span> x <span style="color: #339933;">/</span> <span style="color: #003399;">Math</span>.<span style="color: #006633;">sqrt</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">return</span> p<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
        <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">double</span> getERF<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">double</span> x<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">double</span> a <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">8</span> <span style="color: #339933;">*</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Math</span>.<span style="color: #006633;">PI</span> <span style="color: #339933;">-</span> <span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">3</span> <span style="color: #339933;">*</span> <span style="color: #003399;">Math</span>.<span style="color: #006633;">PI</span> <span style="color: #339933;">*</span> <span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">4</span><span style="color: #339933;">-</span> <span style="color: #003399;">Math</span>.<span style="color: #006633;">PI</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">double</span> erf <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>x <span style="color: #339933;">/</span> <span style="color: #003399;">Math</span>.<span style="color: #006633;">abs</span><span style="color: #009900;">&#40;</span>x<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #003399;">Math</span>.<span style="color: #006633;">sqrt</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span> <span style="color: #339933;">-</span> <span style="color: #003399;">Math</span>.<span style="color: #006633;">exp</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span><span style="color: #003399;">Math</span>.<span style="color: #006633;">pow</span><span style="color: #009900;">&#40;</span>x, <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">4</span><span style="color: #339933;">/</span><span style="color: #003399;">Math</span>.<span style="color: #006633;">PI</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>a <span style="color: #339933;">*</span> <span style="color: #003399;">Math</span>.<span style="color: #006633;">pow</span><span style="color: #009900;">&#40;</span>x, <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>a <span style="color: #339933;">*</span> <span style="color: #003399;">Math</span>.<span style="color: #006633;">pow</span><span style="color: #009900;">&#40;</span>x, <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">return</span> erf<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://nicholaspier.com/2010/10/java-normal-probability-aproximation-method/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Subnet Calculator and NetTrain.com</title>
		<link>http://nicholaspier.com/2010/10/subnet-calculator-and-nettrain-com/</link>
		<comments>http://nicholaspier.com/2010/10/subnet-calculator-and-nettrain-com/#comments</comments>
		<pubDate>Sun, 03 Oct 2010 23:30:34 +0000</pubDate>
		<dc:creator>Nicholas Pier</dc:creator>
				<category><![CDATA[Professional]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://nicholaspier.com/?p=125</guid>
		<description><![CDATA[I was recently contacted by the owner the website, NetTrain.com, and asked to further develop my Subnet Calculator (mentioned in previous posts) from a WordPress template page to a full-blown plugin. NetTrain provides technical training to individuals seeking to acquire various &#8230; <a href="http://nicholaspier.com/2010/10/subnet-calculator-and-nettrain-com/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I was recently contacted by the owner the website, <a href="http://nettrain.com">NetTrain.com</a>, and asked to further develop my Subnet Calculator (mentioned in previous posts) from a WordPress template page to a full-blown plugin. NetTrain provides technical training to individuals seeking to acquire various Cisco Certifications. Thanks to their funding, I was able to allot time and convert the php code into a WordPress plugin, making several improvements along the way.</p>
<p>Much to my delight, not only is my work being paid for and used on another website, but the owner of NetTrain has allowed me to keep all the source-code open and free. As such, you may now download the new plugin via the following link: <a href="http://nicholaspier.com/files/subnetcalc-plugin.rar">download</a></p>
<p>Also, if you&#8217;d like a working example of the code, please visit the <a href="http://nicholaspier.com/subnet-calculator/">Subnet Calculator Page</a> on my website or the implementation of <a href="http://www.nettrain.com/?page_id=370">NetTrain.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://nicholaspier.com/2010/10/subnet-calculator-and-nettrain-com/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Securing phpMyAdmin on Ubuntu 10.04</title>
		<link>http://nicholaspier.com/2010/07/securing-phpmyadmin-on-ubuntu-10-04/</link>
		<comments>http://nicholaspier.com/2010/07/securing-phpmyadmin-on-ubuntu-10-04/#comments</comments>
		<pubDate>Tue, 13 Jul 2010 07:59:07 +0000</pubDate>
		<dc:creator>Nicholas Pier</dc:creator>
				<category><![CDATA[Professional]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://nicholaspier.com/?p=90</guid>
		<description><![CDATA[This will be the first in a number of tutorials which I plan to post regarding IT topics and solutions to problems which I run into both in a business environment and personal tinkering. I currently run a Linux home &#8230; <a href="http://nicholaspier.com/2010/07/securing-phpmyadmin-on-ubuntu-10-04/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This will be the first in a number of tutorials which I plan to post regarding IT topics and solutions to problems which I run into both in a business environment and personal tinkering.</p>
<p>I currently run a Linux home server for the purpose of website development and testing prior to making content available online. However, it occurred to me following installation that the ‘www.hostname.tld/phpMyAdmin’ directory, while requiring authentication, is open to the internet and likewise, subject to brute force attacks. This tutorial will attempt to offer a number of solutions to securing such an installation.<span id="more-90"></span></p>
<p><strong>Installation and Securing Mysql</strong></p>
<p>The tutorial assumes a default Ubuntu 10.04 Installation with both apache and mysql installed (phpMyAdmin is a front-end for mysql).<br />
The very first task in securing both phpMyAdmin and mysql should be to change the mysql root password. By default, Ubuntu uses no password for the root user. This is absolutely insecure. So, how does one set the mysql password? It’s actually fairly simple. Reach a shell and enter the following commands. The string of x’s following password can be supplemented with a password of your choice. Obviously, the complexity of one’s password will dictate how affective this procedure has been.</p>
<pre>mysql -u root
set password for root@localhost = password('xxxxxxx');
flush privileges;
quit;</pre>
<p>Now that mysql is secure, install the phpMyAdmin front-end. The installation is fairly simple. Once again, shell access will be required. Assuming your server installation has internet access, issue the following command. The ‘sudo’ at the beginning of the command provides the user with temporary root privileges and will ask for the current user’s password (assuming this user is included in sudoers, beyond the scope of my tutorial).</p>
<pre>sudo apt-get install phpmyadmin</pre>
<p>To complete the installation, one must have access to their mysql root password and the ip address or hostname of the mysql server (local loopbacks like localhost or 127.0.0.1 will generally suffice). Once the installation is complete, the phpMyAdmin interface should be accessible through a web browser. A screenshot of how this may appear is provided.</p>
<p><strong> Securing phpMyAdmin</strong></p>
<p><a href="http://nicholaspier.com/wp-content/uploads/2010/07/phpmyadmin.png"><img class="alignright size-medium wp-image-92" title="phpmyadmin" src="http://nicholaspier.com/wp-content/uploads/2010/07/phpmyadmin-300x275.png" alt="" width="300" height="275" /></a>Now that phpMyAdmin is installed, it should be apparent that the www.hostname.tld/phpMyAdmin website directory is not something which should be visible to the general public. This tutorial will show two methods for securing the directory and making it inaccessible to unwanted hosts. The first denies or allows hosts based on IP address or hostname. The second, employs apache’s built-in user authentication.</p>
<p>To begin, all configuration changes should be made to the file: /etc/phpmyadmin/apache.conf</p>
<p>Simply open this file with root privileges using a text-editor of your choice and find the &lt;Directory&gt;  …  &lt;/Directory&gt; tags. All edits will go within this area.</p>
<p><strong>Host-based Security</strong></p>
<p><strong></strong>To enable host-based security, or rather the denial or allowing of hosts based on IP / hostname, one line must be added between the aforementioned  tags.</p>
<pre>Order Allow, Deny</pre>
<p>This command establishes the default behavior of the security. If allow comes before deny, apache will deny all traffic by default while making exceptions for Allow commands. The converse of this, ‘Deny, Allow’, will allow all traffic by default and only deny hosts for which a Deny command exists. Now, an explanation of both Allow and Deny commands.<br />
A specific host may be allowed using the following command:</p>
<pre>Allow from 192.168.1.4</pre>
<p>Or, an entire subnet may be allowed using either of the following:</p>
<pre>Allow from 192.168.1.0/24
Allow from 192.168.1.0/255.255.255.0</pre>
<p>To make these statements Deny hosts, simply replace the Allow with Deny. Also, hostnames may be used instead of ip addresses, however this is not recommended as the system must perform a lookup every time the page is accessed. Below, is an example of my  section in the apache.conf file.</p>
<pre># phpMyAdmin default Apache configuration
Alias /phpmyadmin /usr/share/phpmyadmin

Options FollowSymLinks
DirectoryIndex index.php

# Deny all hosts unless an implicit Allow command is included.
# In this case, Allow from 192.168.1.0/24.

Order Allow,Deny
Allow from 192.168.1.0/24

AddType application/x-httpd-php .php
php_flag magic_quotes_gpc Off
php_flag track_vars On
php_flag register_globals Off
php_value include_path .</pre>
<p>Finally, once any changes are made to the apache.conf file, apache must be restarted to enable the changes. From a command shell, enter the following to verify and enable your changes.</p>
<pre>sudo apache2ctl configtest
sudo apache2ctl restart</pre>
<p><strong>User-based Security</strong></p>
<p><strong></strong><a href="http://nicholaspier.com/wp-content/uploads/2010/07/phpmyadmin-auth.png"><img class="size-medium wp-image-93 alignright" title="phpmyadmin-auth" src="http://nicholaspier.com/wp-content/uploads/2010/07/phpmyadmin-auth-300x278.png" alt="" width="144" height="133" /></a>The second option for securing the phpMyAdmin directory is to password-protect the directory with a username and password. This may seem silly since phpMyAdmin already requires a password, but it’s an additional level of defense to keep users away from your databases.</p>
<p>The configuration begins as follows and should be placed between the aforementioned &lt;Directory&gt; tags in /etc/phpmyadmin/apache.conf :</p>
<pre>AuthType Basic
AuthName "phpMyAdmin Authentication"
AuthUserFile /etc/phpmyadmin/passwords
Require user admin</pre>
<p>This command is fairly simple. AuthType enables password protection and AuthName provides a name for the particular instance. AuthUserFile specifies the file which holds usernames and passwords. The final line, Require user … specifies which user has access to this directory. Next, we must make this passwords file and create a user with a password. Open a shell and issue the following:</p>
<pre>sudo htpasswd –c /etc/phpmyadmin/passwords admin</pre>
<p>Following the entering of this command, the system will prompt you for a password for the specified user. The –c parameter creates the /etc/phpmyadmin/passwords file, it is not necessary if the file already exists. Further, the admin username can be supplemented with a username of your choice. For example, I might enter: htpasswd –c /etc/phpmyadmin/passwords npier</p>
<p>Finally, once any changes are made to the apache.conf file, apache must be restarted to enable the changes. From a command shell, enter the following to verify and enable your changes.</p>
<pre>sudo apache2ctl configtest
sudo apache2ctl restart</pre>
<p><strong>Further Thoughts</strong><br />
SSL encryption would also provide additional security as all passwords submitted in this tutorial are sent in clear text and are capable of being ‘sniffed’ with a network analyzer. This is sometimes referred to as “the man in the middle.” I’m including a link to an excellent documentation for enabling this on Ubuntu server: <a href="https://help.ubuntu.com/8.04/serverguide/C/httpd.html#https-configuration">https://help.ubuntu.com/8.04/serverguide/C/httpd.html#https-configuration</a></p>
<p>Please feel free to provide any feedback regarding this post. It is my wish that these instructions will pose little issue for many users.</p>
]]></content:encoded>
			<wfw:commentRss>http://nicholaspier.com/2010/07/securing-phpmyadmin-on-ubuntu-10-04/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Subnet Calculator</title>
		<link>http://nicholaspier.com/2010/06/subnet-calculator/</link>
		<comments>http://nicholaspier.com/2010/06/subnet-calculator/#comments</comments>
		<pubDate>Fri, 18 Jun 2010 02:56:54 +0000</pubDate>
		<dc:creator>Nicholas Pier</dc:creator>
				<category><![CDATA[Professional]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://nicholaspier.com/?p=57</guid>
		<description><![CDATA[Recently, I&#8217;ve decided to begin working toward the CCNP certification and have required significant review of CCNA material. As such, in order to review some of the subnet math, I decided to write a subnet calculator in PHP. I&#8217;ve spent &#8230; <a href="http://nicholaspier.com/2010/06/subnet-calculator/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Recently, I&#8217;ve decided to begin working toward the CCNP certification and have required significant review of CCNA material. As such, in order to review some of the subnet math, I decided to write a subnet calculator in PHP.</p>
<p>I&#8217;ve spent most of today working on it and hopefully it works well in all cases. However, the form handler may still allow some improper values. As long as proper input is provided, the calculator should produce accurate results. To view the calculator, visit the &#8216;<a href="http://nicholaspier.com/?page_id=54">Subnet Calculator</a>&#8216; via the link provided above.</p>
<p>As always, I&#8217;m providing the source to my program. It&#8217;s currently set up to be used as a page template. Paste the code into a .php file and place it in the directory of a WordPress template to use it. Click <a href="http://nicholaspier.com/files/template-subnet.rar">here</a> to download the source or &#8216;Continue Reading&#8217; to view the source.<span id="more-57"></span></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">/*
Template Name: Subnet Page
*/</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> get_header<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
    &lt;div id=&quot;content&quot;&gt;
&nbsp;
        &lt;div id=&quot;main&quot;&gt;
&nbsp;
            &lt;div class=&quot;box1 clearfix&quot;&gt;
                    &lt;div class=&quot;post clearfix&quot;&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">//Shows Input form until the subnet button is clicked.</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'submit'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
		&lt;h2 class=&quot;hd-page&quot;&gt;Subnet Calculator&lt;/h2&gt;
				&lt;form name=&quot;subnet-calculator&quot; action=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> get_permalink<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; method=&quot;post&quot;&gt;
					&lt;table width=&quot;100%&quot;&gt;
						&lt;tr&gt;
							&lt;td width=&quot;40%&quot; align=&quot;left&quot;&gt;&lt;p&gt;IP Address&lt;/p&gt;&lt;p&gt;&lt;input type=&quot;text&quot; size=&quot;3&quot; name=&quot;subOctet1&quot;&gt;.&lt;input type=&quot;text&quot; size=&quot;3&quot; name=&quot;subOctet2&quot;&gt;.&lt;input type=&quot;text&quot; size=&quot;3&quot; name=&quot;subOctet3&quot;&gt;.&lt;input type=&quot;text&quot; size=&quot;3&quot; name=&quot;subOctet4&quot;&gt;&lt;/p&gt;&lt;/td&gt;
							&lt;td width=&quot;30%&quot; align=&quot;left&quot;&gt;&lt;p&gt;/ Mask&lt;/p&gt; &lt;p&gt;/ &lt;input type=&quot;text&quot; size=&quot;2&quot; name=&quot;bits&quot;&gt;&lt;/p&gt;&lt;/td&gt;
							&lt;td width=&quot;30&quot; valign=&quot;middle&quot;&gt;&lt;br /&gt;&lt;p&gt;&lt;button type=&quot;submit&quot; name=&quot;submit&quot;&gt;Results&lt;/button&gt;&lt;/p&gt;&lt;/td&gt;
						&lt;/tr&gt;
					&lt;/table&gt;
				&lt;/form&gt;
		<span style="color: #000000; font-weight: bold;">&lt;?php</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #666666; font-style: italic;">//Variables</span>
				<span style="color: #000088;">$subArray</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'subOctet1'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'subOctet2'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'subOctet3'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'subOctet4'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #000088;">$bits</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'bits'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
					<span style="color: #000000; font-weight: bold;">function</span> formCheck<span style="color: #009900;">&#40;</span><span style="color: #000088;">$subArray</span><span style="color: #339933;">,</span> <span style="color: #000088;">$bits</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
						<span style="color: #666666; font-style: italic;">//FORM CHECK Subnet</span>
						<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$subArray</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
							<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$subArray</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$subArray</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">255</span> <span style="color: #339933;">||</span> <span style="color: #000088;">$subArray</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
								<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;h3&gt;You have entered an incorrect value. Subnet octet values must be between 0 and 255.&lt;/h3&gt;'</span><span style="color: #339933;">;</span>
								<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
							<span style="color: #009900;">&#125;</span>
						<span style="color: #009900;">&#125;</span>
						<span style="color: #666666; font-style: italic;">//FORM CHECK bits</span>
						<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$bits</span> <span style="color: #339933;">!=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$bits</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">30</span> <span style="color: #339933;">||</span> <span style="color: #000088;">$bits</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
							<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;h3&gt;You have entered an incorrect value. Subnet bits must be less than 30 and greater than 0 &lt;/h3&gt;'</span><span style="color: #339933;">;</span>
							<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
						<span style="color: #009900;">&#125;</span>
						<span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
					<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
				<span style="color: #666666; font-style: italic;">//Functions for calculation of subnet information.</span>
					<span style="color: #666666; font-style: italic;">//Returns Subnet Mask as String</span>
					<span style="color: #000000; font-weight: bold;">function</span> getSubnetMask<span style="color: #009900;">&#40;</span><span style="color: #000088;">$bits</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
						<span style="color: #000088;">$subnetMask</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">4</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
							<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$bits</span> <span style="color: #339933;">&gt;=</span> <span style="color: #cc66cc;">8</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
								<span style="color: #000088;">$subnetMask</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">255</span><span style="color: #339933;">;</span>
								<span style="color: #000088;">$bits</span> <span style="color: #339933;">-=</span> <span style="color: #cc66cc;">8</span><span style="color: #339933;">;</span>
							<span style="color: #009900;">&#125;</span>
							<span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span>
								<span style="color: #000088;">$subnetMask</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>string<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">256</span> <span style="color: #339933;">-</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">pow</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">8</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$bits</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
								<span style="color: #000088;">$bits</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
							<span style="color: #009900;">&#125;</span>
						<span style="color: #009900;">&#125;</span>
						<span style="color: #b1b100;">return</span> <span style="color: #990000;">implode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'.'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$subnetMask</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
					<span style="color: #666666; font-style: italic;">//Returns Wildcard Mask as String</span>
					<span style="color: #000000; font-weight: bold;">function</span> getWildCardMask<span style="color: #009900;">&#40;</span><span style="color: #000088;">$bits</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
						<span style="color: #000088;">$wildcardMask</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
						<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">4</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
							<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$bits</span> <span style="color: #339933;">&gt;=</span> <span style="color: #cc66cc;">8</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
								<span style="color: #000088;">$wildcardMask</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
								<span style="color: #000088;">$bits</span> <span style="color: #339933;">-=</span> <span style="color: #cc66cc;">8</span><span style="color: #339933;">;</span>
							<span style="color: #009900;">&#125;</span>
							<span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span>
								<span style="color: #000088;">$wildcardMask</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>string<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">pow</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">8</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$bits</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
								<span style="color: #000088;">$bits</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
							<span style="color: #009900;">&#125;</span>
						<span style="color: #009900;">&#125;</span>
						<span style="color: #b1b100;">return</span> <span style="color: #990000;">implode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'.'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$wildcardMask</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
					<span style="color: #666666; font-style: italic;">//Returns Class of IP Address/Subnet as String based on first octet.</span>
					<span style="color: #000000; font-weight: bold;">function</span> getSubnetClass<span style="color: #009900;">&#40;</span><span style="color: #000088;">$subArray</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
					<span style="color: #000088;">$subclass</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
						<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$subArray</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$subArray</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">128</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
							<span style="color: #000088;">$subClass</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'A'</span><span style="color: #339933;">;</span>
						<span style="color: #009900;">&#125;</span>
						<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$subArray</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">127</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$subArray</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">192</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
							<span style="color: #000088;">$subClass</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'B'</span><span style="color: #339933;">;</span>
						<span style="color: #009900;">&#125;</span>
						<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$subArray</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">191</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$subArray</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">224</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
							<span style="color: #000088;">$subClass</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'C'</span><span style="color: #339933;">;</span>
						<span style="color: #009900;">&#125;</span>
						<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$subArray</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">223</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
							<span style="color: #000088;">$subClass</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'D (multicast)'</span><span style="color: #339933;">;</span>
						<span style="color: #009900;">&#125;</span>
						<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$subArray</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">239</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
							<span style="color: #000088;">$subClass</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'E (reserved)'</span><span style="color: #339933;">;</span>
						<span style="color: #009900;">&#125;</span>
						<span style="color: #b1b100;">return</span> <span style="color: #000088;">$subClass</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
					<span style="color: #666666; font-style: italic;">//Gets number of subnets ignoring class rules (Subnet/Hosts). Returns Integer as String.</span>
					<span style="color: #000000; font-weight: bold;">function</span> getClasslessSubnets<span style="color: #009900;">&#40;</span><span style="color: #000088;">$bits</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
						<span style="color: #b1b100;">return</span> <span style="color: #990000;">pow</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span><span style="color: #000088;">$bits</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
					<span style="color: #666666; font-style: italic;">//Gets number of subnets using class rules (Class/Subnet/Hosts). Returns Integer as String.</span>
					<span style="color: #000000; font-weight: bold;">function</span> getClassfulSubnets<span style="color: #009900;">&#40;</span><span style="color: #000088;">$bits</span><span style="color: #339933;">,</span> <span style="color: #000088;">$subArray</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
						<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>getSubnetClass<span style="color: #009900;">&#40;</span><span style="color: #000088;">$subArray</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;A&quot;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$bits</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">7</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
							<span style="color: #000088;">$bits</span> <span style="color: #339933;">-=</span> <span style="color: #cc66cc;">8</span><span style="color: #339933;">;</span>
							<span style="color: #b1b100;">return</span> <span style="color: #990000;">pow</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span><span style="color: #000088;">$bits</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						<span style="color: #009900;">&#125;</span>
						<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>getSubnetClass<span style="color: #009900;">&#40;</span><span style="color: #000088;">$subArray</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;B&quot;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$bits</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">15</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
							<span style="color: #000088;">$bits</span> <span style="color: #339933;">-=</span> <span style="color: #cc66cc;">16</span><span style="color: #339933;">;</span>
							<span style="color: #b1b100;">return</span> <span style="color: #990000;">pow</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span><span style="color: #000088;">$bits</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						<span style="color: #009900;">&#125;</span>
						<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>getSubnetClass<span style="color: #009900;">&#40;</span><span style="color: #000088;">$subArray</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;C&quot;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$bits</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">23</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
							<span style="color: #000088;">$bits</span> <span style="color: #339933;">-=</span> <span style="color: #cc66cc;">24</span><span style="color: #339933;">;</span>
							<span style="color: #b1b100;">return</span> <span style="color: #990000;">pow</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span><span style="color: #000088;">$bits</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						<span style="color: #009900;">&#125;</span>
						<span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span>
							<span style="color: #b1b100;">return</span> <span style="color: #0000ff;">'Classful rules may not be applied to this subnet.'</span><span style="color: #339933;">;</span>
						<span style="color: #009900;">&#125;</span>
					<span style="color: #009900;">&#125;</span>
					<span style="color: #666666; font-style: italic;">//Gets number of hosts using bits after prefix length. Returns Integer as String.</span>
					<span style="color: #000000; font-weight: bold;">function</span> getHosts<span style="color: #009900;">&#40;</span><span style="color: #000088;">$bits</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
						<span style="color: #b1b100;">return</span> <span style="color: #990000;">pow</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">32</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$bits</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
					<span style="color: #666666; font-style: italic;">//Returns the subnet which contains the input IP as String.</span>
					<span style="color: #000000; font-weight: bold;">function</span> getSubnet<span style="color: #009900;">&#40;</span><span style="color: #000088;">$mask</span><span style="color: #339933;">,</span> <span style="color: #000088;">$subArray</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
						<span style="color: #000088;">$subnetMask</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'.'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$mask</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						<span style="color: #000088;">$subnet</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">4</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
							<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$subnetMask</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">255</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
								<span style="color: #000088;">$subnet</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$subArray</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
							<span style="color: #009900;">&#125;</span>
							<span style="color: #b1b100;">elseif</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$subnetMask</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
								<span style="color: #000088;">$subnet</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
							<span style="color: #009900;">&#125;</span>
							<span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span>
								<span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$subArray</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">&gt;=</span> <span style="color: #000088;">$subnet</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
									<span style="color: #000088;">$subnet</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+=</span> <span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">255</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$subnetMask</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
								<span style="color: #009900;">&#125;</span>
								<span style="color: #000088;">$subnet</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">-=</span> <span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">255</span><span style="color: #339933;">-</span> <span style="color: #000088;">$subnetMask</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
							<span style="color: #009900;">&#125;</span>
						<span style="color: #009900;">&#125;</span>
						<span style="color: #b1b100;">return</span> <span style="color: #990000;">implode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'.'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$subnet</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
					<span style="color: #666666; font-style: italic;">//Returns the broadcast address of subnet which contains the input IP as String.</span>
					<span style="color: #000000; font-weight: bold;">function</span> getBroadcast<span style="color: #009900;">&#40;</span><span style="color: #000088;">$mask</span><span style="color: #339933;">,</span> <span style="color: #000088;">$subArray</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
						<span style="color: #000088;">$subnetMask</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'.'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$mask</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						<span style="color: #000088;">$broadcast</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">4</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
							<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$subnetMask</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">255</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
								<span style="color: #000088;">$broadcast</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$subArray</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
							<span style="color: #009900;">&#125;</span>
							<span style="color: #b1b100;">elseif</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$subnetMask</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
								<span style="color: #000088;">$broadcast</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">255</span><span style="color: #339933;">;</span>
							<span style="color: #009900;">&#125;</span>
							<span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span>
								<span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$subArray</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">&gt;=</span> <span style="color: #000088;">$broadcast</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
									<span style="color: #000088;">$broadcast</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+=</span> <span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">255</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$subnetMask</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
								<span style="color: #009900;">&#125;</span>
							<span style="color: #009900;">&#125;</span>
						<span style="color: #009900;">&#125;</span>
						<span style="color: #b1b100;">return</span> <span style="color: #990000;">implode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'.'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$broadcast</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
					<span style="color: #666666; font-style: italic;">//Returns the first usable host in subnet as String.</span>
					<span style="color: #000000; font-weight: bold;">function</span> getLowRange<span style="color: #009900;">&#40;</span><span style="color: #000088;">$subnet</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
						<span style="color: #000088;">$lowRange</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'.'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$subnet</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						<span style="color: #000088;">$lowRange</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">++;</span>
						<span style="color: #b1b100;">return</span> <span style="color: #990000;">implode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'.'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$lowRange</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
					<span style="color: #666666; font-style: italic;">//Returns the last usable host in subnet as String.</span>
					<span style="color: #000000; font-weight: bold;">function</span> getHighRange<span style="color: #009900;">&#40;</span><span style="color: #000088;">$broadcast</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
						<span style="color: #000088;">$highRange</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'.'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$broadcast</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						<span style="color: #000088;">$highRange</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">--;</span>
						<span style="color: #b1b100;">return</span> <span style="color: #990000;">implode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'.'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$highRange</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
<span style="color: #666666; font-style: italic;">//If the formc check returns true. Display results.</span>
				<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>formCheck<span style="color: #009900;">&#40;</span><span style="color: #000088;">$subArray</span><span style="color: #339933;">,</span> <span style="color: #000088;">$bits</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				<span style="color: #000000; font-weight: bold;">?&gt;</span>
						&lt;table width=&quot;100%&quot;&gt;
							&lt;tr&gt;
								&lt;td width=&quot;50%&quot; valign=&quot;top&quot;&gt;
									&lt;h3&gt;Subnet Information&lt;/h3&gt;
									&lt;p&gt;
										Class: &lt;strong class=&quot;value&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> getSubnetClass<span style="color: #009900;">&#40;</span><span style="color: #000088;">$subArray</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/strong&gt;&lt;br /&gt;
										Subnet: &lt;strong class=&quot;value&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> getSubnet<span style="color: #009900;">&#40;</span>getSubnetMask<span style="color: #009900;">&#40;</span><span style="color: #000088;">$bits</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$subArray</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/strong&gt;&lt;br /&gt;
										Host-range: &lt;strong class=&quot;value&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> getLowRange<span style="color: #009900;">&#40;</span>getSubnet<span style="color: #009900;">&#40;</span>getSubnetMask<span style="color: #009900;">&#40;</span><span style="color: #000088;">$bits</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$subArray</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">' - '</span> <span style="color: #339933;">.</span> getHighRange<span style="color: #009900;">&#40;</span>getBroadcast<span style="color: #009900;">&#40;</span>getSubnetMask<span style="color: #009900;">&#40;</span><span style="color: #000088;">$bits</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$subArray</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/strong&gt;&lt;br /&gt;
										Broadcast-address: &lt;strong class=&quot;value&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> getBroadcast<span style="color: #009900;">&#40;</span>getSubnetMask<span style="color: #009900;">&#40;</span><span style="color: #000088;">$bits</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$subArray</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/strong&gt;&lt;br /&gt;
										Classful-subnets: &lt;strong class=&quot;value&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> getClassfulSubnets<span style="color: #009900;">&#40;</span><span style="color: #000088;">$bits</span><span style="color: #339933;">,</span> <span style="color: #000088;">$subArray</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/strong&gt;
									&lt;/p&gt;
								&lt;/td&gt;
&nbsp;
								&lt;td width=&quot;50%&quot; valign=&quot;top&quot;&gt;
									&lt;h3&gt;Prefix Information&lt;/h3&gt;
									&lt;p&gt;
										Prefix-length: &lt;strong class=&quot;value&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;/&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$bits</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/strong&gt;&lt;br /&gt;
										Subnet-mask: &lt;strong class=&quot;value&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> getSubnetMask<span style="color: #009900;">&#40;</span><span style="color: #000088;">$bits</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/strong&gt;&lt;br /&gt;
										Wildcard-mask: &lt;strong class=&quot;value&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> getWildCardMask<span style="color: #009900;">&#40;</span><span style="color: #000088;">$bits</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/strong&gt;&lt;br /&gt;
										Hosts-per-subnet: &lt;strong class=&quot;value&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> getHosts<span style="color: #009900;">&#40;</span><span style="color: #000088;">$bits</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/strong&gt;&lt;br /&gt;
										Classless-subnets: &lt;strong class=&quot;value&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> getClasslessSubnets<span style="color: #009900;">&#40;</span><span style="color: #000088;">$bits</span><span style="color: #339933;">,</span> <span style="color: #000088;">$subArray</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/strong&gt;
									&lt;/p&gt;
								&lt;/td&gt;
							&lt;/tr&gt;
						&lt;/table&gt;
&nbsp;
&nbsp;
            <span style="color: #000000; font-weight: bold;">&lt;?php</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
					edit_post_link<span style="color: #009900;">&#40;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Edit this entry.'</span><span style="color: #339933;">,</span>woothemes<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;p&gt;'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;/p&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000000; font-weight: bold;">?&gt;</span>
                &lt;/div&gt;
            &lt;/div&gt;
&nbsp;
        &lt;/div&gt;&lt;!-- / #main --&gt;
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> get_sidebar<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
	&lt;/div&gt;&lt;!-- / #content --&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> get_footer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://nicholaspier.com/2010/06/subnet-calculator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Steam XML Parser</title>
		<link>http://nicholaspier.com/2010/01/steam-xml-parser/</link>
		<comments>http://nicholaspier.com/2010/01/steam-xml-parser/#comments</comments>
		<pubDate>Tue, 19 Jan 2010 05:42:22 +0000</pubDate>
		<dc:creator>Nicholas Pier</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[community]]></category>
		<category><![CDATA[counter-strike source]]></category>
		<category><![CDATA[parser]]></category>
		<category><![CDATA[steam]]></category>
		<category><![CDATA[widget]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://nicholaspier.com/?p=41</guid>
		<description><![CDATA[As mentioned in a previous post, I&#8217;ve developed a WordPress plug-in to display a user&#8217;s Steam Stats as a widget. It&#8217;s available for download here. However, this does no good to anyone without a WordPress-based-site and I wanted to make &#8230; <a href="http://nicholaspier.com/2010/01/steam-xml-parser/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>As mentioned in a previous post, I&#8217;ve developed a WordPress plug-in to display a user&#8217;s Steam Stats as a widget. It&#8217;s available for download <a title="Steam XML Parser for WordPress" href="http://nicholaspier.com/?p=32">here</a>.  However, this does no good to anyone without a WordPress-based-site and I wanted to make the source freely available. As such, I&#8217;ve included it below. Valve provides Steam profiles as an XML feed which can be parsed and formatted according to a developer&#8217;s needs. To personalize the script, simply edit the URL following the &#8220;$profileURL&#8221; variable.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">/* Steam Community Widget
*/</span>	
&nbsp;
	<span style="color: #666666; font-style: italic;">//Variables. Edit Profile URL to match the link to your personal Steam Community Page.</span>
		<span style="color: #000088;">$ProfileURL</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'http://steamcommunity.com/profiles/76561197970479548/'</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$xml</span> <span style="color: #339933;">=</span> <span style="color: #990000;">simplexml_load_file</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ProfileURL</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'?xml=1'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #666666; font-style: italic;">//Begin Widget Content</span>
					<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;p&gt;&lt;strong&gt;SteamID:&lt;/strong&gt; '</span><span style="color: #339933;">;</span>
					<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">steamID</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;br /&gt;&lt;strong&gt;Member since:&lt;/strong&gt; '</span><span style="color: #339933;">;</span>
					<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">memberSince</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;br /&gt;&lt;strong&gt;Steam Rating:&lt;/strong&gt; '</span><span style="color: #339933;">;</span>
					<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">steamRating</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;br /&gt;&lt;strong&gt;Playing time:&lt;/strong&gt; '</span><span style="color: #339933;">;</span>
					<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">hoursPlayed2Wk</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot; hrs past 2 weeks&lt;/p&gt;&quot;</span><span style="color: #339933;">;</span>
					<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">4</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
						<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">mostPlayedGames</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">mostPlayedGame</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">gameLink</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
							<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;p&gt;&lt;a href=&quot;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">mostPlayedGames</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">mostPlayedGame</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">gameLink</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot;&gt;&lt;img src=&quot;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">mostPlayedGames</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">mostPlayedGame</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">gameIcon</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot; /&gt;&lt;/a&gt; '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">mostPlayedGames</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">mostPlayedGame</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">gameName</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">' '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">mostPlayedGames</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">mostPlayedGame</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">hoursPlayed</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">' hrs&lt;/p&gt;'</span><span style="color: #339933;">;</span>
						<span style="color: #009900;">&#125;</span>
					<span style="color: #009900;">&#125;</span>
				<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;p&gt;&lt;a href=&quot;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$ProfileURL</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'games&quot;&gt;View all games&lt;/a&gt;&lt;/p&gt;&lt;p align=&quot;center&quot;&gt;&lt;em&gt;&amp;copy '</span> <span style="color: #339933;">.</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span>Y<span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">' &lt;a href=&quot;http://nicholaspier.com&quot;&gt;nicholaspier.com&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;'</span><span style="color: #339933;">;</span>
			<span style="color: #666666; font-style: italic;">//End Widget Content</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://nicholaspier.com/2010/01/steam-xml-parser/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Steam WordPress Plugin / Widget</title>
		<link>http://nicholaspier.com/2009/12/steam-wordpress-plugin-widget/</link>
		<comments>http://nicholaspier.com/2009/12/steam-wordpress-plugin-widget/#comments</comments>
		<pubDate>Mon, 07 Dec 2009 21:18:15 +0000</pubDate>
		<dc:creator>Nicholas Pier</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://nicholaspier.com/?p=32</guid>
		<description><![CDATA[Today I completed my very first WordPress Plugin to display a user&#8217;s Steam Gameplay Stats. To those unfamiliar with Steam, steam is a windows community application for video gaming. It allows users to store and purchase titles from many different &#8230; <a href="http://nicholaspier.com/2009/12/steam-wordpress-plugin-widget/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Today I completed my very first WordPress Plugin to display a user&#8217;s Steam Gameplay Stats. To those unfamiliar with Steam, steam is a windows community application for video gaming. It allows users to store and purchase titles from many different publishers online and also offers an excellent community element to chat, browse the web and compare stats with friends. More information is available here: <a title="Steam" href="http://www.steampowered.com" target="_blank">www.steampowered.com</a> Steam is likely the future of pc gaming as it allows a much more secure and economical publishing method for many game studios.</p>
<p>I&#8217;ll likely be posting the widget for free distribution on WordPress&#8217;s site soon. I&#8217;m in the process of making the widget more accessible to normal users as it currently requires the manual input of a user&#8217;s steam account URL into a text file.</p>
<p>Update: I&#8217;ve release version 1.01 of my <a title="View Official WordPress Page for widget." href="http://wordpress.org/extend/plugins/steam-community-gamestats-widget/">Steam Community Gamestats Widget</a>. I&#8217;ve been sick recently and had a lot of time to revise the code and better adapt it to WordPress&#8217;  Widget Class implemented in WordPress 2.8. </p>
]]></content:encoded>
			<wfw:commentRss>http://nicholaspier.com/2009/12/steam-wordpress-plugin-widget/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Cisco CCNA Certified</title>
		<link>http://nicholaspier.com/2009/10/cisco-ccna-certified/</link>
		<comments>http://nicholaspier.com/2009/10/cisco-ccna-certified/#comments</comments>
		<pubDate>Tue, 27 Oct 2009 00:00:10 +0000</pubDate>
		<dc:creator>Nicholas Pier</dc:creator>
				<category><![CDATA[Professional]]></category>

		<guid isPermaLink="false">http://nicholaspier.com/?p=18</guid>
		<description><![CDATA[Today I passed my Cisco CCNA exam with a score of 917 / 1000 which has left me incredibly content! The whole Cisco course has really taught me a lot about networking and I am pleased to have accepted it &#8230; <a href="http://nicholaspier.com/2009/10/cisco-ccna-certified/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://nicholaspier.com/wp-content/uploads/2009/10/ccna_med.gif"><img class="alignleft size-full wp-image-120" title="CCNA" src="http://nicholaspier.com/wp-content/uploads/2009/10/ccna_med.gif" alt="" width="150" height="150" /></a>Today I passed my Cisco CCNA exam with a score of 917 / 1000 which has left me incredibly content! The whole Cisco course has really taught me a lot about networking and I am pleased to have accepted it as a challenge. Furthermore, I did all of this a month before my goal of Thanksgiving and only a month after my last certification. One could say that I&#8217;m really on a roll. I hope I can continue to excel in college while getting my technical education on the side with these certifications.</p>
]]></content:encoded>
			<wfw:commentRss>http://nicholaspier.com/2009/10/cisco-ccna-certified/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cisco CCENT Certified</title>
		<link>http://nicholaspier.com/2009/09/cisco-ccent-certified/</link>
		<comments>http://nicholaspier.com/2009/09/cisco-ccent-certified/#comments</comments>
		<pubDate>Sat, 26 Sep 2009 07:52:43 +0000</pubDate>
		<dc:creator>Nicholas Pier</dc:creator>
				<category><![CDATA[Professional]]></category>

		<guid isPermaLink="false">http://nicholaspier.com/?p=15</guid>
		<description><![CDATA[I&#8217;m pleased to post that yesterday I passed the Cisco ICND1 exam with a score of 916 / 1000 ! This places me closer to my short term goal of obtaining the CCNA certification by Thanksgiving and in the meantime &#8230; <a href="http://nicholaspier.com/2009/09/cisco-ccent-certified/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://nicholaspier.com/wp-content/uploads/2009/09/The-complete-Cisco-CCNA-Certification-Guide1.jpg"><img class="size-thumbnail wp-image-122 alignleft" title="CCENT" src="http://nicholaspier.com/wp-content/uploads/2009/09/The-complete-Cisco-CCNA-Certification-Guide1-150x150.jpg" alt="" width="150" height="150" /></a>I&#8217;m pleased to post that yesterday I passed the Cisco ICND1 exam with a score of 916 / 1000 ! This places me closer to my short term goal of obtaining the CCNA certification by Thanksgiving and in the meantime attributes me with the Cisco CCENT certification.</p>
]]></content:encoded>
			<wfw:commentRss>http://nicholaspier.com/2009/09/cisco-ccent-certified/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

