<?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"
	>

<channel>
	<title>bradym.net</title>
	<atom:link href="http://bradym.net/feed" rel="self" type="application/rss+xml" />
	<link>http://bradym.net</link>
	<description>Random thoughts of a Code Monkey</description>
	<pubDate>Tue, 29 Apr 2008 06:53:40 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
			<item>
		<title>Making the Windows Command Prompt Usable</title>
		<link>http://bradym.net/windows/making-the-windows-command-prompt-usable</link>
		<comments>http://bradym.net/windows/making-the-windows-command-prompt-usable#comments</comments>
		<pubDate>Tue, 29 Apr 2008 06:53:40 +0000</pubDate>
		<dc:creator>bradym</dc:creator>
		
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://bradym.net/?p=11</guid>
		<description><![CDATA[If you&#8217;ve used an interactive shell on Linux or OS X you know what a good command prompt is like. To go from that to the command prompt in Windows XP is painful, since I&#8217;m stuck on Windows at work, I had to do something about the command prompt to make it more bearable.
Install Console
Console [...]<script type="text/javascript">SHARETHIS.addEntry({ title: "Making the Windows Command Prompt Usable", url: "http://bradym.net/windows/making-the-windows-command-prompt-usable" });</script>]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve used an interactive shell on Linux or OS X you know what a good command prompt is like. To go from that to the command prompt in Windows XP is painful, since I&#8217;m stuck on Windows at work, I had to do something about the command prompt to make it more bearable.</p>
<h2><strong>Install Console</strong></h2>
<p><a href="http://sourceforge.net/projects/console" title="Console" onclick="javascript:pageTracker._trackPageview ('/outbound/sourceforge.net');">Console</a> is an <a href="http://www.opensource.org/" onclick="javascript:pageTracker._trackPageview ('/outbound/www.opensource.org');">Open Source</a> command prompt window enhancement. If you&#8217;re familiar with <a href="http://konsole.kde.org/" onclick="javascript:pageTracker._trackPageview ('/outbound/konsole.kde.org');">Konsole</a> from <a href="http://kde.org" onclick="javascript:pageTracker._trackPageview ('/outbound/kde.org');">Kde</a>, Console has a similar feature set.</p>
<p>Console allows you much greater control over the display and setup of the command prompt including resizing the console, specifying background and font colors, specifying a startup directory, using tabs, etc.</p>
<p>There&#8217;s no installer with Console, just extract the zip file and run console.exe. I&#8217;ve created shortcuts in my taskbar and on the desktop for easy access. Once you&#8217;ve launched Consoe, be sure to spend some time playing around with the settings, that&#8217;s where all the power is!<strong><br />
</strong></p>
<h2><strong>Install Cygwin or GNUWin32</strong></h2>
<p>Now that we have a decent console, it&#8217;s time to get some *nix goodness! There are two great options for getting ports of *nix tools working on Windows: <a href="http://www.cygwin.com" onclick="javascript:pageTracker._trackPageview ('/outbound/www.cygwin.com');">Cygwin</a> and <a href="http://gnuwin32.sourceforge.net/" onclick="javascript:pageTracker._trackPageview ('/outbound/gnuwin32.sourceforge.net');">GnuWin32</a>.</p>
<p>Cygwin provides a more *nix like environment, as well as a larger number of tools overall. Cygwin includes a batch file to launch a command prompt with bash as the interpreter. With Cygwin you can also install an X server and run programs that require an X server, though if you&#8217;re trying to do that it&#8217;d be much easier to install <a href="http://www.virtualbox.org/" onclick="javascript:pageTracker._trackPageview ('/outbound/www.virtualbox.org');">VirtualBox</a> or <a href="http://www.vmware.com/products/player/" onclick="javascript:pageTracker._trackPageview ('/outbound/www.vmware.com');">VMWare Player</a> and run a virtual instance of your favorite *nix distro.</p>
<p>GnuWin provides Windows ports of many *nix tools, but does not try to imitate the *nix filesystem like Cygwin does. If you&#8217;re only looking for specific tools it may be easier to get them from GnuWin32.</p>
<p>I&#8217;m currently using Cygwin as it&#8217;s a standard at work.</p>
<h2>Using *nix Tools from the Windows Command Line</h2>
<p>Now that we have our command line and our *nix tools, all that&#8217;s left is to connect the two by adding the folder with the binaries to your Windows path. For Cygwin this is c:\cygwin\bin by default.</p>
<ol>
<li>Right click on &#8220;My Computer&#8221; on your desktop (or in windows explorer)</li>
<li>Select &#8220;Properties&#8221;</li>
<li>Click the &#8220;Advanced&#8221; tab</li>
<li>Click on &#8220;Environment Variables&#8221;</li>
<li>Look at the top list of variables,
<ul>
<li>If there is not a variable named &#8220;Path&#8221;
<ol>
<li>Click on &#8220;New&#8221;</li>
<li>Enter &#8220;Path&#8221; in the &#8220;Variable name&#8221; field</li>
<li>Enter &#8220;C:\cygwin\bin&#8221; in the &#8220;Variable value&#8221; field</li>
</ol>
</li>
<li>If there is a variable named &#8220;Path&#8221;
<ol>
<li>Click &#8220;Edit&#8221;</li>
<li>Click in the &#8220;Variable value&#8221; box and go to the end of the field</li>
<li>Add a semi-colon ( ; )</li>
<li>Enter &#8220;C:\cygwin\bin&#8221;</li>
</ol>
</li>
</ul>
</li>
<li>Click OK 3 times and you should be ready to go</li>
</ol>
<p>Open Console and enjoy your much improved windows command prompt experience!</p>
<p><a href="http://sharethis.com/item?&wp=2.5.1&amp;publisher=2d8bfca9-8364-44f0-bf85-c07beb6ae964&amp;title=Making+the+Windows+Command+Prompt+Usable&amp;url=http%3A%2F%2Fbradym.net%2Fwindows%2Fmaking-the-windows-command-prompt-usable">ShareThis</a></p>]]></content:encoded>
			<wfw:commentRss>http://bradym.net/windows/making-the-windows-command-prompt-usable/feed</wfw:commentRss>
		</item>
		<item>
		<title>Opera friendly PHP redirect</title>
		<link>http://bradym.net/php/opera-friendly-php-redirect</link>
		<comments>http://bradym.net/php/opera-friendly-php-redirect#comments</comments>
		<pubDate>Thu, 03 Jan 2008 03:23:09 +0000</pubDate>
		<dc:creator>bradym</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[Opera]]></category>

		<guid isPermaLink="false">http://bradym.net/php/opera-friendly-php-redirect</guid>
		<description><![CDATA[Opera can&#8217;t handle a redirect to a URL that ends in an anchor. I found this out trying to use the PHP header() function.
From what little I was able to find using Google on the topic, it appears that Opera won&#8217;t redirect a user to the page they just came from, it must be a [...]<script type="text/javascript">SHARETHIS.addEntry({ title: "Opera friendly PHP redirect", url: "http://bradym.net/php/opera-friendly-php-redirect" });</script>]]></description>
			<content:encoded><![CDATA[<p>Opera can&#8217;t handle a redirect to a URL that ends in an anchor. I found this out trying to use the PHP header() function.</p>
<p>From what little I was able to find using Google on the topic, it appears that Opera won&#8217;t redirect a user to the page they just came from, it must be a different URI.</p>
<p>To get around this in php, here&#8217;s what I did:</p>

<div class="wp_syntax"><div class="code"><pre class="php"><span style="color: #000066;">header</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'Location: file.php?value1=12&amp;amp;value2=43&amp;amp;r='</span><span style="color: #66cc66;">.</span><span style="color: #000066;">rand</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">.</span><span style="color: #ff0000;">'#anchorName'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span></pre></div></div>

<p>Having the random number from rand() makes the page unique, and the redirect works as expected.</p>
<p><a href="http://sharethis.com/item?&wp=2.5.1&amp;publisher=2d8bfca9-8364-44f0-bf85-c07beb6ae964&amp;title=Opera+friendly+PHP+redirect&amp;url=http%3A%2F%2Fbradym.net%2Fphp%2Fopera-friendly-php-redirect">ShareThis</a></p>]]></content:encoded>
			<wfw:commentRss>http://bradym.net/php/opera-friendly-php-redirect/feed</wfw:commentRss>
		</item>
		<item>
		<title>Can&#8217;t get JCalendar to select a specific date when opening</title>
		<link>http://bradym.net/javascript/cant-get-jcalendar-to-select-a-specific-date-when-opening</link>
		<comments>http://bradym.net/javascript/cant-get-jcalendar-to-select-a-specific-date-when-opening#comments</comments>
		<pubDate>Thu, 03 Jan 2008 03:22:34 +0000</pubDate>
		<dc:creator>bradym</dc:creator>
		
		<category><![CDATA[JavaScript]]></category>

		<category><![CDATA[Jcalendar]]></category>

		<guid isPermaLink="false">http://bradym.net/javascript/cant-get-jcalendar-to-select-a-specific-date-when-opening</guid>
		<description><![CDATA[There is an error in calendar-setup.js that prevents the setting of an initial date for the calendar. Go to line 159 and replace the code:

if &#40;dateEl&#41; params.date = Date.parseDate&#40;dateEl.value &#124;&#124; dateEl.innerHTML, dateFmt&#41;;

with:

if &#40;dateEl &#38;amp;&#38;amp; &#40;dateEl.value &#124;&#124; dateEl.innerHTML&#41;&#41; params.date = Date.parseDate&#40;dateEl.value &#124;&#124; dateEl.innerHTML, dateFmt&#41;;

<script type="text/javascript">SHARETHIS.addEntry({ title: "Can&#8217;t get JCalendar to select a specific date when opening", url: "http://bradym.net/javascript/cant-get-jcalendar-to-select-a-specific-date-when-opening" });</script>]]></description>
			<content:encoded><![CDATA[<p>There is an error in calendar-setup.js that prevents the setting of an initial date for the calendar. Go to line 159 and replace the code:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript"><span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>dateEl<span style="color: #66cc66;">&#41;</span> params.<span style="color: #006600;">date</span> = Date.<span style="color: #006600;">parseDate</span><span style="color: #66cc66;">&#40;</span>dateEl.<span style="color: #006600;">value</span> <span style="color: #66cc66;">||</span> dateEl.<span style="color: #006600;">innerHTML</span>, dateFmt<span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>with:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript"><span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>dateEl <span style="color: #66cc66;">&amp;</span>amp;<span style="color: #66cc66;">&amp;</span>amp; <span style="color: #66cc66;">&#40;</span>dateEl.<span style="color: #006600;">value</span> <span style="color: #66cc66;">||</span> dateEl.<span style="color: #006600;">innerHTML</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> params.<span style="color: #006600;">date</span> = Date.<span style="color: #006600;">parseDate</span><span style="color: #66cc66;">&#40;</span>dateEl.<span style="color: #006600;">value</span> <span style="color: #66cc66;">||</span> dateEl.<span style="color: #006600;">innerHTML</span>, dateFmt<span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p><a href="http://sharethis.com/item?&wp=2.5.1&amp;publisher=2d8bfca9-8364-44f0-bf85-c07beb6ae964&amp;title=Can%26%238217%3Bt+get+JCalendar+to+select+a+specific+date+when+opening&amp;url=http%3A%2F%2Fbradym.net%2Fjavascript%2Fcant-get-jcalendar-to-select-a-specific-date-when-opening">ShareThis</a></p>]]></content:encoded>
			<wfw:commentRss>http://bradym.net/javascript/cant-get-jcalendar-to-select-a-specific-date-when-opening/feed</wfw:commentRss>
		</item>
		<item>
		<title>Display HTML code without having it parsed</title>
		<link>http://bradym.net/html/display-html-code-without-having-it-parsed</link>
		<comments>http://bradym.net/html/display-html-code-without-having-it-parsed#comments</comments>
		<pubDate>Thu, 03 Jan 2008 03:21:24 +0000</pubDate>
		<dc:creator>bradym</dc:creator>
		
		<category><![CDATA[HTML]]></category>

		<guid isPermaLink="false">http://bradym.net/html/display-html-code-without-having-it-parsed</guid>
		<description><![CDATA[Sometimes it is nice to display html code with out it being parsed as html, for example if you are writing a tutorial and want to show how to do something.
To display code, you will need to use a code to display a &#60; or &#62; to prevent the browser from treating it like actual [...]<script type="text/javascript">SHARETHIS.addEntry({ title: "Display HTML code without having it parsed", url: "http://bradym.net/html/display-html-code-without-having-it-parsed" });</script>]]></description>
			<content:encoded><![CDATA[<p>Sometimes it is nice to display html code with out it being parsed as html, for example if you are writing a tutorial and want to show how to do something.</p>
<p>To display code, you will need to use a code to display a &lt; or &gt; to prevent the browser from treating it like actual code.</p>
<p>The code to display a &lt; is &lt; while &gt; is &gt;</p>
<p>Displaying codes like I have just done can be a little more tricky.  To display the above codes, I had to use the codes to display the &amp; and the ;  so that it wouldn&#8217;t just show you the &lt; and &gt;.</p>
<p>Confused yet?  Basically to show you the code:  &lt; I actually had to type in &lt;.</p>
<p>Take a look at <a href="http://htmlhelp.com/reference/charset/" onclick="javascript:pageTracker._trackPageview ('/outbound/htmlhelp.com');">http://htmlhelp.com/reference/charset/</a> for a list of codes.</p>
<p><a href="http://sharethis.com/item?&wp=2.5.1&amp;publisher=2d8bfca9-8364-44f0-bf85-c07beb6ae964&amp;title=Display+HTML+code+without+having+it+parsed&amp;url=http%3A%2F%2Fbradym.net%2Fhtml%2Fdisplay-html-code-without-having-it-parsed">ShareThis</a></p>]]></content:encoded>
			<wfw:commentRss>http://bradym.net/html/display-html-code-without-having-it-parsed/feed</wfw:commentRss>
		</item>
		<item>
		<title>Setting up Wireless with DSL</title>
		<link>http://bradym.net/misc/setting-up-wireless-with-dsl</link>
		<comments>http://bradym.net/misc/setting-up-wireless-with-dsl#comments</comments>
		<pubDate>Thu, 03 Jan 2008 03:19:54 +0000</pubDate>
		<dc:creator>bradym</dc:creator>
		
		<category><![CDATA[Misc]]></category>

		<category><![CDATA[Cisco 678]]></category>

		<category><![CDATA[DSL]]></category>

		<category><![CDATA[Linksys WRT54G]]></category>

		<category><![CDATA[Wireless]]></category>

		<guid isPermaLink="false">http://bradym.net/uncategorized/setting-up-wireless-with-dsl</guid>
		<description><![CDATA[It turns out that setting up wireless with DSL is a bit different than with cable modem, here&#8217;s how I got it to work.
In order to get it working I used a Cisco 678 DSL Modem, Linksys WRT54G Wireless Router and a Basic 5 port hub.
Here&#8217;s the process that I went through to get it [...]<script type="text/javascript">SHARETHIS.addEntry({ title: "Setting up Wireless with DSL", url: "http://bradym.net/misc/setting-up-wireless-with-dsl" });</script>]]></description>
			<content:encoded><![CDATA[<p>It turns out that setting up wireless with DSL is a bit different than with cable modem, here&#8217;s how I got it to work.</p>
<p>In order to get it working I used a Cisco 678 DSL Modem, Linksys WRT54G Wireless Router and a Basic 5 port hub.</p>
<p>Here&#8217;s the process that I went through to get it working.</p>
<p><strong>Step 1: Configure Cisco 678</strong></p>
<p>The first thing I did was to enable the DHCP Server on the Cisco 678. Be sure to set the starting IP address and DNS servers on the Cisco, or it won&#8217;t work properly.</p>
<p>DSL Modem Setup:</p>
<p>IP Address: 192.168.1.1</p>
<p>Subnet Mask: 255.255.255.0</p>
<p>Starting IP Address: 192.168.1.100</p>
<p><strong>Step 2: Configure Linksys WRT54G</strong></p>
<p>Here&#8217;s the part that I had to call tech support for help with. The wireless router must be on a different subnet than the Cisco, or it will not work properly.</p>
<p>Wireless Router Setup:</p>
<p>IP Address: 192.168.2.1</p>
<p>Subnet Mask: 255.255.255.128</p>
<p>Starting IP Address: 192.168.2.100</p>
<p>The wireless router should be setup to get an IP address automatically, which is the default setting on the Linksys.</p>
<p>I also set the DNS servers on the Linksys to make sure that they would be set properly on client computers. It may work without this, but setting it here avoids possible problems.</p>
<p><strong>Step 3: Hook it all together</strong></p>
<p>Run a cable from the Cisco 678 to the uplink port in the hub. Then plug the wireless router into the hub as well, and you should be good to go.</p>
<p><strong>Additional Notes:</strong></p>
<ul>
<li>Computers plugged into the hub will be in the 192.168.1 subnet.</li>
<li>Computers plugged into the Linksys will be in the 192.168.2 subnet.</li>
</ul>
<p>If you plan to use your network for gaming or other network applications, it is important to have all of the computers on the same subnet. This would mean plugging any computers without wireless cards into the Linksys.</p>
<p><a href="http://sharethis.com/item?&wp=2.5.1&amp;publisher=2d8bfca9-8364-44f0-bf85-c07beb6ae964&amp;title=Setting+up+Wireless+with+DSL&amp;url=http%3A%2F%2Fbradym.net%2Fmisc%2Fsetting-up-wireless-with-dsl">ShareThis</a></p>]]></content:encoded>
			<wfw:commentRss>http://bradym.net/misc/setting-up-wireless-with-dsl/feed</wfw:commentRss>
		</item>
		<item>
		<title>Choosing a Domain Registrar</title>
		<link>http://bradym.net/misc/choosing-a-domain-registrar</link>
		<comments>http://bradym.net/misc/choosing-a-domain-registrar#comments</comments>
		<pubDate>Thu, 03 Jan 2008 03:17:54 +0000</pubDate>
		<dc:creator>bradym</dc:creator>
		
		<category><![CDATA[Misc]]></category>

		<category><![CDATA[Domain]]></category>

		<category><![CDATA[Registrar]]></category>

		<guid isPermaLink="false">http://bradym.net/misc/choosing-a-domain-registrar</guid>
		<description><![CDATA[At one point between work and personal sites, I managed close to 10 different domain names. A couple years ago I decided it was time move all of the domain names I manage to one account to make my life easier.
Two of the domains I had registered before this time were with Namesecure, and it [...]<script type="text/javascript">SHARETHIS.addEntry({ title: "Choosing a Domain Registrar", url: "http://bradym.net/misc/choosing-a-domain-registrar" });</script>]]></description>
			<content:encoded><![CDATA[<p>At one point between work and personal sites, I managed close to 10 different domain names. A couple years ago I decided it was time move all of the domain names I manage to one account to make my life easier.</p>
<p>Two of the domains I had registered before this time were with Namesecure, and it quickly became apparent that choosing them was a mistake.</p>
<p>One domain was transferred without problems, but getting the other domain transferred took nearly a year. Through the process of getting this domain transferred, I learned two very important lessons.</p>
<p><strong>Never do business with a company that doesn&#8217;t provide phone support</strong></p>
<p>When I originally registered my domain names I didn&#8217;t care that Namesecure didn&#8217;t have phone support because I figured I could take care of most things myself, and e-mail is easier to deal with anyways.</p>
<p>But when a problem came along, I learned the value of phone support. Had I been able to call at the first sign of a problem and speak with someone in a support department it would have probably been resolved within a week or so.</p>
<p><strong>Make sure the registrar offers all of the services you want</strong></p>
<p>Is it important to you to be able to manage your DNS entries yourself? Do you need e-mail forwarding? Will you need to change/add subdomains on a frequent basis or on a whim?</p>
<p>Make sure the company you choose will allow you to do what you need to do! Had I originally chosen a company that provided all of the features I now want to use I wouldn&#8217;t have had to transfer my domains in the first place.</p>
<p><strong>My recommendation</strong></p>
<p>I highly recommend <a href="http://domainsite.com" target="_blank" onclick="javascript:pageTracker._trackPageview ('/outbound/domainsite.com');">Domainsite</a> as a registrar. They give you complete access to your domain name and DNS entries though their website that works well and is easy to use. They also have very good prices for domain name registration.</p>
<p>When you have a problem or question, they have great support. <a href="http://domainsite.com" target="_blank" onclick="javascript:pageTracker._trackPageview ('/outbound/domainsite.com');">Domainsite</a> has their mailing address, phone number, and support e-mail address right on the top of every page on their website.</p>
<p>Just a note: I am not an employee of <a href="http://domainsite.com" target="_blank" onclick="javascript:pageTracker._trackPageview ('/outbound/domainsite.com');">Domainsite</a>, just a satisfied customer.</p>
<p><a href="http://sharethis.com/item?&wp=2.5.1&amp;publisher=2d8bfca9-8364-44f0-bf85-c07beb6ae964&amp;title=Choosing+a+Domain+Registrar&amp;url=http%3A%2F%2Fbradym.net%2Fmisc%2Fchoosing-a-domain-registrar">ShareThis</a></p>]]></content:encoded>
			<wfw:commentRss>http://bradym.net/misc/choosing-a-domain-registrar/feed</wfw:commentRss>
		</item>
		<item>
		<title>Creating iCalendar (ics) files with PHP</title>
		<link>http://bradym.net/php/creating-icalendar-ics-files-with-php</link>
		<comments>http://bradym.net/php/creating-icalendar-ics-files-with-php#comments</comments>
		<pubDate>Thu, 03 Jan 2008 02:56:59 +0000</pubDate>
		<dc:creator>bradym</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[iCalendar]]></category>

		<category><![CDATA[ics]]></category>

		<guid isPermaLink="false">http://bradym.net/php/creating-icalendar-ics-files-with-php</guid>
		<description><![CDATA[For a past project, I needed to create iCalendar files from event data stored in a database. There is an iCalendar class on phpclasses.org, but there is very little documentation and you need to understand some of the quirks of the iCalendar specification for it to be useful.
Since I got stumped on trying to get [...]<script type="text/javascript">SHARETHIS.addEntry({ title: "Creating iCalendar (ics) files with PHP", url: "http://bradym.net/php/creating-icalendar-ics-files-with-php" });</script>]]></description>
			<content:encoded><![CDATA[<p>For a past project, I needed to create iCalendar files from event data stored in a database. There is an <a href="http://www.phpclasses.org/browse/package/873.html" onclick="javascript:pageTracker._trackPageview ('/outbound/www.phpclasses.org');">iCalendar class on phpclasses.org</a>, but there is very little documentation and you need to understand some of the quirks of the iCalendar specification for it to be useful.</p>
<p>Since I got stumped on trying to get the class working, I went to the specs and figured out how to do it without using the class. Here are some links that I found helpful:</p>
<ul>
<li><a href="http://www.prism.gatech.edu/~gte267v/iCalendarFormat.html" onclick="javascript:pageTracker._trackPageview ('/outbound/www.prism.gatech.edu');">Breakdown and explanation of a simple iCalendar file</a></li>
<li><a href="http://www.kanzaki.com/docs/ical/" onclick="javascript:pageTracker._trackPageview ('/outbound/www.kanzaki.com');">iCalendar Specification Excerpts</a></li>
<li><a href="http://rfc.net/rfc2445.html" onclick="javascript:pageTracker._trackPageview ('/outbound/rfc.net');">Entire iCalendar Specification</a></li>
</ul>
<p>An iCalendar file is just a text file, so creating it is not difficult - it&#8217;s figuring out the quirks of the specification and understanding what the different properties mean that is frustrating. Of course the other frustrating thing is that there seem to be differences in how calendar applications parse ics files, and which fields they consider to be required.</p>
<p>Here&#8217;s the MySQL Table Schema that I&#8217;m using for my calendar table:</p>

<div class="wp_syntax"><div class="code"><pre class="mysql"><span style="color: #993333; font-weight: bold;">CREATE TABLE</span> calendar
<span style="color: #66cc66;">&#40;</span>
     id <span style="color: #aa9933; font-weight: bold;">INT</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">11</span><span style="color: #66cc66;">&#41;</span> <span style="color: #aa3399; font-weight: bold;">NOT NULL</span> <span style="color: #aa3399; font-weight: bold;">AUTO_INCREMENT</span>,
     title <span style="color: #aa9933; font-weight: bold;">TINYTEXT</span>,
     description <span style="color: #aa9933; font-weight: bold;">TEXT</span>,
     startDate <span style="color: #aa9933; font-weight: bold;">DATE</span> <span style="color: #aa3399; font-weight: bold;">NOT NULL</span> <span style="color: #aa3399; font-weight: bold;">DEFAULT</span> <span style="color: #ff0000;">'0000-00-00'</span>,
     endDate <span style="color: #aa9933; font-weight: bold;">DATE</span> <span style="color: #aa3399; font-weight: bold;">NOT NULL</span> <span style="color: #aa3399; font-weight: bold;">DEFAULT</span> <span style="color: #ff0000;">'0000-00-00'</span>,
     <span style="color: #993333; font-weight: bold;">PRIMARY KEY</span> <span style="color: #66cc66;">&#40;</span>id<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>And here&#8217;s the PHP that I used. Note that this code currently does not export ics files that can be used by Mozilla Sunbird. It works with MS Outlook 2003, which is my current target client.</p>

<div class="wp_syntax"><div class="code"><pre class="php"><span style="color: #808080; font-style: italic;">// database connection</span>
<span style="color: #b1b100;">include_once</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'db.php'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
<span style="color: #808080; font-style: italic;">// Dates must be in the format YYYYMMDD</span>
<span style="color: #ff0000">$events</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000">$conn</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">execute</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;SELECT id, title, DATE_FORMAT(startDate,'%Y%m%d') AS start, DATE_FORMAT(DATE_ADD(endDate, INTERVAL 1 DAY),'%Y%m%d') AS end, startDate, endDate, description FROM calendar&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
<span style="color: #808080; font-style: italic;">// Define the file as an iCalendar file</span>
<span style="color: #000066;">header</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Content-Type: text/Calendar&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
<span style="color: #808080; font-style: italic;">// Give the file a name and force download</span>
<span style="color: #000066;">header</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Content-Disposition: inline; filename=calendar.ics&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
<span style="color: #808080; font-style: italic;">// Header of ics file</span>
<span style="color: #000066;">echo</span> <span style="color: #ff0000;">&quot;BEGIN:VCALENDAR<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #66cc66;">;</span>
<span style="color: #000066;">echo</span> <span style="color: #ff0000;">&quot;VERSION:2.0<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #66cc66;">;</span>
<span style="color: #000066;">echo</span> <span style="color: #ff0000;">&quot;PRODID:PHP<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #66cc66;">;</span>
<span style="color: #000066;">echo</span> <span style="color: #ff0000;">&quot;METHOD:REQUEST<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #66cc66;">;</span>
<span style="color: #808080; font-style: italic;">// Loop through database results and create an event for each item</span>
<span style="color: #b1b100;">while</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">!</span><span style="color: #ff0000">$events</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">EOF</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
    <span style="color: #000066;">echo</span> <span style="color: #ff0000;">&quot;BEGIN:VEVENT<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #66cc66;">;</span>
    <span style="color: #808080; font-style: italic;">// The end date of an event is non-inclusive, so if the event is an all day event or one with no specific start and stop</span>
    <span style="color: #808080; font-style: italic;">// times, the end date would be the next day.  This script is used with a calendar that does not deal with times, just dates,</span>
    <span style="color: #808080; font-style: italic;">// so the time for all events is set to 000000.</span>
    <span style="color: #000066;">echo</span> <span style="color: #ff0000;">&quot;DTSTART:&quot;</span><span style="color: #66cc66;">.</span><span style="color: #ff0000">$events</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">fields</span><span style="color: #66cc66;">&#91;</span>start<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #ff0000;">&quot;T000000<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #66cc66;">;</span>
    <span style="color: #000066;">echo</span> <span style="color: #ff0000;">&quot;DTEND:&quot;</span><span style="color: #66cc66;">.</span><span style="color: #ff0000">$events</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">fields</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'end'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #ff0000;">&quot;T000000<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #66cc66;">;</span>
    <span style="color: #808080; font-style: italic;">// Only create Description field if there is a description</span>
    <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #000066;">isset</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$events</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">fields</span><span style="color: #66cc66;">&#91;</span>description<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&amp;</span>amp<span style="color: #66cc66;">;</span> <span style="color: #ff0000">$events</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">fields</span><span style="color: #66cc66;">&#91;</span>description<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">!=</span> <span style="color: #ff0000;">''</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#123;</span>
            <span style="color: #000066;">echo</span> <span style="color: #ff0000;">&quot;DESCRIPTION:&quot;</span><span style="color: #66cc66;">;</span>
            <span style="color: #808080; font-style: italic;">// Remove all linebreaks from description stored in database</span>
            <span style="color: #ff0000">$description</span> <span style="color: #66cc66;">=</span> <span style="color: #000066;">str_replace</span><span style="color: #66cc66;">&#40;</span><span style="color: #000066;">chr</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">13</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">.</span><span style="color: #000066;">chr</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><span style="color: #ff0000;">&quot;  &quot;</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000">$events</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">fields</span><span style="color: #66cc66;">&#91;</span>description<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
            <span style="color: #000066;">echo</span> <span style="color: #ff0000">$description</span><span style="color: #66cc66;">.</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #66cc66;">;</span>
    <span style="color: #66cc66;">&#125;</span>
    <span style="color: #000066;">echo</span> <span style="color: #ff0000;">&quot;SUMMARY:{$events-&gt;fields[title]}<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #66cc66;">;</span>
    <span style="color: #000066;">echo</span> <span style="color: #ff0000;">&quot;UID:{$events-&gt;fields[id]}<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #66cc66;">;</span>
    <span style="color: #000066;">echo</span> <span style="color: #ff0000;">&quot;SEQUENCE:0<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #66cc66;">;</span>
    <span style="color: #000066;">echo</span> <span style="color: #ff0000;">&quot;DTSTAMP:&quot;</span><span style="color: #66cc66;">.</span><span style="color: #000066;">date</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'Ymd'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">.</span><span style="color: #ff0000;">'T'</span><span style="color: #66cc66;">.</span><span style="color: #000066;">date</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'His'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">.</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #66cc66;">;</span>
    <span style="color: #000066;">echo</span> <span style="color: #ff0000;">&quot;END:VEVENT<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #66cc66;">;</span>
    <span style="color: #ff0000">$events</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">MoveNext</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
<span style="color: #66cc66;">&#125;</span>
<span style="color: #000066;">echo</span> <span style="color: #ff0000;">&quot;END:VCALENDAR<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #66cc66;">;</span></pre></div></div>

<p><a href="http://sharethis.com/item?&wp=2.5.1&amp;publisher=2d8bfca9-8364-44f0-bf85-c07beb6ae964&amp;title=Creating+iCalendar+%28ics%29+files+with+PHP&amp;url=http%3A%2F%2Fbradym.net%2Fphp%2Fcreating-icalendar-ics-files-with-php">ShareThis</a></p>]]></content:encoded>
			<wfw:commentRss>http://bradym.net/php/creating-icalendar-ics-files-with-php/feed</wfw:commentRss>
		</item>
		<item>
		<title>New Blog</title>
		<link>http://bradym.net/news/hello-world</link>
		<comments>http://bradym.net/news/hello-world#comments</comments>
		<pubDate>Tue, 01 Jan 2008 12:01:52 +0000</pubDate>
		<dc:creator>bradym</dc:creator>
		
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://bradym.net/?p=1</guid>
		<description><![CDATA[As you can see I&#8217;ve just setup WordPress to run my new blog. I&#8217;ll post more soon.
<script type="text/javascript">SHARETHIS.addEntry({ title: "New Blog", url: "http://bradym.net/news/hello-world" });</script>]]></description>
			<content:encoded><![CDATA[<p>As you can see I&#8217;ve just setup WordPress to run my new blog. I&#8217;ll post more soon.</p>
<p><a href="http://sharethis.com/item?&wp=2.5.1&amp;publisher=2d8bfca9-8364-44f0-bf85-c07beb6ae964&amp;title=New+Blog&amp;url=http%3A%2F%2Fbradym.net%2Fnews%2Fhello-world">ShareThis</a></p>]]></content:encoded>
			<wfw:commentRss>http://bradym.net/news/hello-world/feed</wfw:commentRss>
		</item>
	</channel>
</rss>
