<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0">
  <channel>
    <title>CodeAngel.org</title>
    <link>http://www.codeangel.org/</link>
    <description>Faith in Knowledge</description>
    <language>en-US</language>
    <webMaster>admin@codeangel.org (Chad Emrys Minick)</webMaster>
        <image>
            <url>http://www.codeangel.org/public/img/ca_logo.png</url>
            <title>RSS: CodeAngel.org - Faith in Knowledge</title>
            <link>http://www.codeangel.org/</link>
        </image>
    <item>
  <title>Stemming in Zend Search Lucene</title>
  <link>http://www.codeangel.org/article/stemming-in-zend-search-lucene</link>
  <description>
  <![CDATA[
    <div class="intro"> 
<p>One of the most difficult parts of making a search engine, whether it is a small search for a single website or something as large as a web search engine, is tweaking the ability to get as much relevant results from a user's query as possible.  The best way to tweak this with Lucene and Zend_Search_Lucene is the  correct use of analyzers for both indexing and querying an index.</p>

<p>Analyzers prepare and normalize text to be indexed and are also used to parse queries. For example, unless you want your search engine to be case sensitive  you would want your analyzer to have a filter that lowercases everything as it goes into the index; that same analyzer needs to be used against the query to lowercase any terms in order for it to match the terms in the index. That way a search for "query" will match "Query, qUery, query, etc..", and a search for "Query" will match the same.</p>

<p>Now we come to the subject of Stemming.  Stemming is the act of getting related words to "stem" to the same word.  For example "nationalize, nationalization, nations" should all stem to "nation".  Why is this important? say for example you are searching for Ipods, if you aren't making use of stemming, your search engine will match only "ipods", but not the singular "ipod".  By making use of stemming you will get more relevant results.  Stemming doesn't actually have to return a term that is spelled correctly. For example "ponies" and "pony" both stem to poni.  The important thing is that all related words stem to the same thing, spelled right or not.</p>
</div>
<p>Stemming algorithms differ from language to language.  A English stemmer will NOT work for German or any other language.  The most used stemming algorithm for English is the Porter Stemmer, made by Martin Porter. You can read about the Martin Porter Stemmer <a href="http://tartarus.org/martin/PorterStemmer/">here</a>.  I have ported the Porter Stemmer from the <a href="http://lucene.apache.org/java/">Java Lucene Project</a> for use with Zend Search Lucene.  You can download it from my <a href="/downloads">downloads</a> section or directly <a href="/public/downloads/CodeAngel_PorterStemmer-1.0.tar.gz">here</a>. This is pretty much a direct port, so If you can find some optimizations, feel free, and let me have some patches so I can update the package.</p>

<p>And now some super simple example code of the stemming filter in action:</p> 

<pre class="code" style="color: navy;">&#160;
<span style="color: darkred;">&#60;?php</span>
<span style="color: darkred;">class</span> Search <span style="color: olive;">&#123;</span>
&#160;
  <span style="color: darkred;">private</span> <span style="color: #0000ff;">$_index</span>;
&#160;
  <span style="color: darkred;">public</span> <span style="color: darkred;">function</span> __construct<span style="color: olive;">&#40;</span><span style="color: olive;">&#41;</span><span style="color: olive;">&#123;</span>
    <span style="color: #0000ff;">$this</span>-&#62;_index = Zend_Search_Lucene::<span style="color: #006600;">open</span><span style="color: olive;">&#40;</span><span style="color: #ff0000;">'/path/to/index'</span><span style="color: olive;">&#41;</span>;
    <span style="color: #0000ff;">$analyzer</span> = <span style="color: darkred;">new</span> Zend_Search_Lucene_Analysis_Analyzer_Common_Text_CaseInsensitive<span style="color: olive;">&#40;</span><span style="color: olive;">&#41;</span>;
    <span style="color: #0000ff;">$analyzer</span>-&#62;<span style="color: #006600;">addFilter</span><span style="color: olive;">&#40;</span><span style="color: darkred;">new</span> CodeAngel_PorterStemmerFilter<span style="color: olive;">&#40;</span><span style="color: olive;">&#41;</span><span style="color: olive;">&#41;</span>;        
    Zend_Search_Lucene_Analysis_Analyzer::<span style="color: #006600;">setDefault</span><span style="color: olive;">&#40;</span><span style="color: #0000ff;">$analyzer</span><span style="color: olive;">&#41;</span>;
  <span style="color: olive;">&#125;</span>
&#160;
  <span style="color: darkred;">public</span> <span style="color: darkred;">function</span> find<span style="color: olive;">&#40;</span><span style="color: #0000ff;">$query</span><span style="color: olive;">&#41;</span><span style="color: olive;">&#123;</span>
    <span style="color: teal;">return</span> <span style="color: #0000ff;">$this</span>-&#62;_index-&#62;<span style="color: #006600;">find</span><span style="color: olive;">&#40;</span><span style="color: #0000ff;">$query</span><span style="color: olive;">&#41;</span>;
  <span style="color: olive;">&#125;</span>
&#160;
  <span style="color: darkred;">public</span> <span style="color: darkred;">function</span> addDocument<span style="color: olive;">&#40;</span><span style="color: #0000ff;">$link</span>, <span style="color: #0000ff;">$content</span><span style="color: olive;">&#41;</span><span style="color: olive;">&#123;</span>
    <span style="color: #0000ff;">$doc</span> = <span style="color: darkred;">new</span> Zend_Search_Lucene_Document<span style="color: olive;">&#40;</span><span style="color: olive;">&#41;</span>;
    <span style="color: #0000ff;">$doc</span>-&#62;<span style="color: #006600;">addField</span><span style="color: olive;">&#40;</span>Zend_Search_Lucene_Field::<span style="color: #006600;">Keyword</span><span style="color: olive;">&#40;</span><span style="color: #ff0000;">'link'</span>, <span style="color: #0000ff;">$link</span><span style="color: olive;">&#41;</span><span style="color: olive;">&#41;</span>;
    <span style="color: #0000ff;">$doc</span>-&#62;<span style="color: #006600;">addField</span><span style="color: olive;">&#40;</span>Zend_Search_Lucene_Field::<span style="color: #006600;">Unstored</span><span style="color: olive;">&#40;</span><span style="color: #ff0000;">'contents'</span>, <span style="color: #0000ff;">$content</span><span style="color: olive;">&#41;</span><span style="color: olive;">&#41;</span>;
    <span style="color: #0000ff;">$this</span>-&#62;_index-&#62;<span style="color: #006600;">addDocument</span><span style="color: olive;">&#40;</span><span style="color: #0000ff;">$doc</span><span style="color: olive;">&#41;</span>;
    <span style="color: #0000ff;">$this</span>-&#62;_index-&#62;<span style="color: #006600;">commit</span><span style="color: olive;">&#40;</span><span style="color: olive;">&#41;</span>;
  <span style="color: olive;">&#125;</span>
<span style="color: olive;">&#125;</span>
<span style="color: darkred;">?&#62;</span>
&#160;</pre>
<p>Using this class is as easy as 1-2-3:</p>
<pre class="code" style="color: navy;">&#160;
<span style="color: darkred;">&#60;?php</span>
  <span style="color: #0000ff;">$searcher</span> = <span style="color: darkred;">new</span> Search<span style="color: olive;">&#40;</span><span style="color: olive;">&#41;</span>;
&#160;
  <span style="color: orange;">//index a document</span>
  <span style="color: #0000ff;">$searcher</span>-&#62;<span style="color: #006600;">addDocument</span><span style="color: olive;">&#40;</span><span style="color: #ff0000;">'some.html'</span>, <span style="color: #ff0000;">'Hello, how about some ipods and some nationalization'</span><span style="color: olive;">&#41;</span>;
&#160;
  <span style="color: orange;">//search</span>
  <span style="color: #0000ff;">$hits</span> = <span style="color: #0000ff;">$searcher</span>-&#62;<span style="color: #006600;">find</span><span style="color: olive;">&#40;</span><span style="color: #ff0000;">'Ipod'</span><span style="color: olive;">&#41;</span>;
<span style="color: darkred;">?&#62;</span>
&#160;</pre>  ]]>
  </description>
  <author>admin@codeangel.org (Chad Emrys Minick)</author>
  <pubDate>Tue, 19 Feb 2008 21:48:21 CST</pubDate>
      <category>PHP</category>
    <category>Zend Framework</category>
    <category>Lucene</category>
    <guid>http://www.codeangel.org/article/stemming-in-zend-search-lucene</guid>
</item>
<item>
  <title>Codeangel 0.5</title>
  <link>http://www.codeangel.org/article/codeangel-0-5</link>
  <description>
  <![CDATA[
    <p>Well it's been a long time since I've done an update.  Mostly because my interests have drifted to video game making, AI, and guitars.  I'll probably have posts soon relating to those.  For now though I finally finished a bit update!</p>

<p>Codeangel 0.5 has the following new features:</p>
<ul>
<li>Trackback and Pingback support (both recieve and sending).</li>
<li>Feeds are reimplemented, Also notice the syndication symbol under each article links to this comment feed</li>
<li>Reimplementation of the Search Engine.  Articles are searched with better granularity, Comments are now indexed as well.  Also I made a Porter Stemmer so one should get more relevant full results. I'll post more about this Porter Stemmer and release it soon.</li>
</ul>

<p>Probably won't notice much on my next planned release: Splitting my admin and the main part of the site into modules.  Also going to make a better article manager.  Then I'm going to add published/unpublished article support.  After I get done with that I will implement Skin support and implement skins with Zend_Layout.  The big thing you'll notice is a new look for codeangel.org!</p>  ]]>
  </description>
  <author>admin@codeangel.org (Chad Emrys Minick)</author>
  <pubDate>Sun, 10 Feb 2008 22:58:43 CST</pubDate>
      <category>CodeAngel</category>
    <category>Zend Framework</category>
    <guid>http://www.codeangel.org/article/codeangel-0-5</guid>
</item>
<item>
  <title>Codeangel 0.4</title>
  <link>http://www.codeangel.org/article/codeangel-0-4</link>
  <description>
  <![CDATA[
    <p>Codeangel is now running on version 0.4!</p>
<ul>
<li>Now Powered By Zend Framework 1.0.1!</li>
<li>Improved Security Auditing and logging</li>
<li>404 and 500 error pages</li>
<li>Cacheing, Front Page now twice as fast!</li>
<li>Other Refactor using more features of Zend Framework, and code cleanup for faster execution.</li>
</ul>

<p>Codeangel 0.5 the user will finally notice some feature updates, including linkback support, comment subscription, and a better searching experience.</p>   ]]>
  </description>
  <author>admin@codeangel.org (Chad Emrys Minick)</author>
  <pubDate>Sat, 25 Aug 2007 19:07:51 CST</pubDate>
      <category>CodeAngel</category>
    <guid>http://www.codeangel.org/article/codeangel-0-4</guid>
</item>
<item>
  <title>Custom Zend Log Format: Security Logging</title>
  <link>http://www.codeangel.org/article/custom-zend-log-format-security-logging</link>
  <description>
  <![CDATA[
    <div class="intro">
<p>
The default file logging format for Zend_Log File Writer is as folows:</p>
<pre>
%timestamp% %priorityName% (%priority%): %message%
</pre>
<p>
Which is fine for error logging. For other sorts of logging like security auditing, We need more, like an IP of the visitor and a hostname.  Other sorts of logging you might want to log things like the request where the error occurred.  This is very easy to do with Zend_Log, however this really isn't documented and I've found people doing weird things like extending Zend_Log to achieve this.  Let's look how to do this right.
</p>
</div>
<pre class="code" style="color: navy;">&#160;
<span style="color: orange;">//first we create a file writer</span>
<span style="color: #0000ff;">$stream</span> = <span style="color: darkred;">new</span> Zend_Log_Writer_Stream<span style="color: olive;">&#40;</span><span style="color: #ff0000;">'./path/to/logs/sec.log'</span><span style="color: olive;">&#41;</span>;
<span style="color: orange;">//then we create a log formatter, note that we changed the default</span>
<span style="color: orange;">//fields to add the user ip and the user host of the request.</span>
<span style="color: #0000ff;">$formatter</span> = <span style="color: darkred;">new</span> Zend_Log_Formatter_Simple<span style="color: olive;">&#40;</span><span style="color: #ff0000;">'%userip% - %userhost% - [%timestamp%] %priorityName%: %message%'</span> . PHP_EOL<span style="color: olive;">&#41;</span>;
<span style="color: orange;">//now we add the new formatter to the writer</span>
<span style="color: #0000ff;">$stream</span>-&#62;<span style="color: #006600;">setFormatter</span><span style="color: olive;">&#40;</span><span style="color: #0000ff;">$formatter</span><span style="color: olive;">&#41;</span>;
<span style="color: orange;">//then we add the writer to create a new logging instance</span>
<span style="color: #0000ff;">$logger</span> = <span style="color: darkred;">new</span> Zend_Log<span style="color: olive;">&#40;</span><span style="color: #0000ff;">$stream</span><span style="color: olive;">&#41;</span>;
<span style="color: orange;">//now we give meaning to the newly added fields.</span>
<span style="color: orange;">//I also changed the default format of the timestamp</span>
<span style="color: #0000ff;">$logger</span>-&#62;<span style="color: #006600;">setEventItem</span><span style="color: olive;">&#40;</span><span style="color: #ff0000;">'userip'</span>,<span style="color: #0000ff;">$_SERVER</span><span style="color: olive;">&#91;</span><span style="color: #ff0000;">'REMOTE_ADDR'</span><span style="color: olive;">&#93;</span><span style="color: olive;">&#41;</span>;
<span style="color: #0000ff;">$logger</span>-&#62;<span style="color: #006600;">setEventItem</span><span style="color: olive;">&#40;</span><span style="color: #ff0000;">'userhost'</span>,<a href="http://www.php.net/gethostbyaddr"><span style="color: #666666;">gethostbyaddr</span></a><span style="color: olive;">&#40;</span><span style="color: #0000ff;">$_SERVER</span><span style="color: olive;">&#91;</span><span style="color: #ff0000;">'REMOTE_ADDR'</span><span style="color: olive;">&#93;</span><span style="color: olive;">&#41;</span><span style="color: olive;">&#41;</span>;
<span style="color: #0000ff;">$logger</span>-&#62;<span style="color: #006600;">setEventItem</span><span style="color: olive;">&#40;</span><span style="color: #ff0000;">'timestamp'</span>, <a href="http://www.php.net/date"><span style="color: #666666;">date</span></a><span style="color: olive;">&#40;</span><span style="color: #ff0000;">'m-d-Y H:i:s'</span>, <a href="http://www.php.net/time"><span style="color: #666666;">time</span></a><span style="color: olive;">&#40;</span><span style="color: olive;">&#41;</span><span style="color: olive;">&#41;</span><span style="color: olive;">&#41;</span>;
&#160;
<span style="color: orange;">//now in our code we can log away</span>
<span style="color: #0000ff;">$logger</span>-&#62;<span style="color: #006600;">emerg</span><span style="color: olive;">&#40;</span><span style="color: #ff0000;">&#34;User Failed Login&#34;</span><span style="color: olive;">&#41;</span>;
&#160;</pre>

<p>In our log we'll get nice messages with IP and Host:</p>
<pre>
127.0.0.1 - localhost - [08-22-2007 21:54:30] EMERG: User Failed Login
</pre>  ]]>
  </description>
  <author>admin@codeangel.org (Chad Emrys Minick)</author>
  <pubDate>Sat, 25 Aug 2007 18:10:10 CST</pubDate>
      <category>PHP</category>
    <category>Security</category>
    <category>Zend Framework</category>
    <guid>http://www.codeangel.org/article/custom-zend-log-format-security-logging</guid>
</item>
<item>
  <title>Misconceptions about Exceptions</title>
  <link>http://www.codeangel.org/article/misconceptions-about-exceptions</link>
  <description>
  <![CDATA[
    <div class="intro">
<p>
I was surprised the other day when someone came into ##php on freenode wanted a strange feature when he hit a wall designing his app with exceptions.  He wanted something like the following:
</p>
<pre class="code" style="color: navy;">
<span style="color: orange;">//NOTE THIS IS NOT POSSIBLE, IT'S BULLCRAP!!</span>
try <span style="color: olive;">&#123;</span>
  throw <span style="color: darkred;">new</span> Exception<span style="color: olive;">&#40;</span><span style="color: #ff0000;">&#34;throw an exception&#34;</span><span style="color: olive;">&#41;</span>;
<span style="color: olive;">&#125;</span> catch <span style="color: olive;">&#40;</span>Exception <span style="color: #0000ff;">$e</span><span style="color: olive;">&#41;</span> <span style="color: olive;">&#123;</span>
  <span style="color: orange;">//do something with a thrown exception.</span>
<span style="color: olive;">&#125;</span> <span style="color: teal;">else</span> <span style="color: olive;">&#123;</span>
  <span style="color: orange;">//do something if there wasn't an exception thrown.</span>
<span style="color: olive;">&#125;</span>
</pre>
<p>That's right, he wanted an 'else' for a try/catch block.  My mind was blown, surely he was using exceptions wrongly.  After I did some inquiring on why he wanted such a ridiculous feature, I found out he was indeed misusing exceptions.  He was using exceptions to control his code execution flow.  Using them to drive his application by recoverable errors. He was quite defensive about it too!  I decided if there weren't enough blog articles about correct exception usage, there needed to be one more...
</p>
</div>
<p>
This tutorial isn't specific to PHP, It applies to all languages that support exceptions.  Error checking is very important in any language. You should be checking for any possible place where an error can occur. </p>
<pre class="code" style="color: navy;">&#160;
<span style="color: #0000ff;">$db</span> = <span style="color: darkred;">new</span> my_db<span style="color: olive;">&#40;</span><span style="color: #ff0000;">'host'</span>,<span style="color: #ff0000;">'user'</span>,<span style="color: #ff0000;">'pass'</span>,<span style="color: #ff0000;">'db'</span><span style="color: olive;">&#41;</span>;
<span style="color: teal;">if</span><span style="color: olive;">&#40;</span><span style="color: #0000ff;">$db</span>-&#62;<span style="color: #006600;">connect_error</span><span style="color: olive;">&#40;</span><span style="color: olive;">&#41;</span><span style="color: olive;">&#41;</span><span style="color: olive;">&#123;</span>
  <a href="http://www.php.net/die"><span style="color: #666666;">die</span></a><span style="color: olive;">&#40;</span><span style="color: #ff0000;">&#34;Error Connected to the Database&#34;</span><span style="color: olive;">&#41;</span>;
<span style="color: olive;">&#125;</span>
<span style="color: #0000ff;">$stmt</span> = <span style="color: #0000ff;">$db</span>-&#62;<span style="color: #006600;">prepare</span><span style="color: olive;">&#40;</span><span style="color: #ff0000;">&#34;SELECT * FROM table WHERE field = ?&#34;</span><span style="color: olive;">&#41;</span>;
<span style="color: teal;">if</span><span style="color: olive;">&#40;</span><span style="color: #0000ff;">$db</span>-&#62;<span style="color: #006600;">error</span><span style="color: olive;">&#40;</span><span style="color: olive;">&#41;</span><span style="color: olive;">&#41;</span><span style="color: olive;">&#123;</span>
  <a href="http://www.php.net/die"><span style="color: #666666;">die</span></a><span style="color: olive;">&#40;</span><span style="color: #ff0000;">&#34;Could not prepare query&#34;</span><span style="color: olive;">&#41;</span>;
<span style="color: olive;">&#125;</span>
<span style="color: #0000ff;">$stmt</span>-&#62;<span style="color: #006600;">bind_param</span><span style="color: olive;">&#40;</span><span style="color: #cc66cc;">1</span>,<span style="color: #ff0000;">'value'</span><span style="color: olive;">&#41;</span>;
<span style="color: #0000ff;">$stmt</span>-&#62;<span style="color: #006600;">execute</span><span style="color: olive;">&#40;</span><span style="color: olive;">&#41;</span>;
<span style="color: teal;">if</span><span style="color: olive;">&#40;</span><span style="color: #0000ff;">$db</span>-&#62;<span style="color: #006600;">error</span><span style="color: olive;">&#40;</span><span style="color: olive;">&#41;</span><span style="color: olive;">&#41;</span><span style="color: olive;">&#123;</span>
  <a href="http://www.php.net/die"><span style="color: #666666;">die</span></a><span style="color: olive;">&#40;</span><span style="color: #ff0000;">&#34;Could not execute query&#34;</span><span style="color: olive;">&#41;</span>;
<span style="color: olive;">&#125;</span>
&#160;</pre>
<p>With exceptions this becomes a lot cleaner. The error checking can all be moved to one place.</p>
<pre class="code" style="color: navy;">&#160;
try <span style="color: olive;">&#123;</span>
  <span style="color: #0000ff;">$db</span> = <span style="color: darkred;">new</span> my_db<span style="color: olive;">&#40;</span><span style="color: #ff0000;">'host'</span>,<span style="color: #ff0000;">'user'</span>,<span style="color: #ff0000;">'pass'</span>,<span style="color: #ff0000;">'db'</span><span style="color: olive;">&#41;</span>;
  <span style="color: #0000ff;">$stmt</span> = <span style="color: #0000ff;">$db</span>-&#62;<span style="color: #006600;">prepare</span><span style="color: olive;">&#40;</span><span style="color: #ff0000;">&#34;SELECT * FROM table WHERE field = ?&#34;</span><span style="color: olive;">&#41;</span>;
  <span style="color: #0000ff;">$stmt</span>-&#62;<span style="color: #006600;">bind_param</span><span style="color: olive;">&#40;</span><span style="color: #cc66cc;">1</span>,<span style="color: #ff0000;">'value'</span><span style="color: olive;">&#41;</span>;
  <span style="color: #0000ff;">$stmt</span>-&#62;<span style="color: #006600;">execute</span><span style="color: olive;">&#40;</span><span style="color: olive;">&#41;</span>;
<span style="color: olive;">&#125;</span> catch <span style="color: olive;">&#40;</span>Exception <span style="color: #0000ff;">$e</span><span style="color: olive;">&#41;</span> <span style="color: olive;">&#123;</span>
  <a href="http://www.php.net/die"><span style="color: #666666;">die</span></a><span style="color: olive;">&#40;</span><span style="color: #0000ff;">$e</span>-&#62;<span style="color: #006600;">getMessage</span><span style="color: olive;">&#40;</span><span style="color: olive;">&#41;</span><span style="color: olive;">&#41;</span>;
<span style="color: olive;">&#125;</span>
&#160;</pre>
<p>Exceptions are great.  But they're meant to track one kind of error only: Exceptional Errors.  Exceptional errors are non-recoverable.  Exceptional errors are things that are unexpected. Exceptional errors should not have happened in any normal sense. If you remove all Exception handling in your code, the code should still run (that is if nothing exceptional happened.)</p>
<p>Here are some examples where an exception is not warranted:</p>
<ul>
<li>User enters an incorrect password, you should expect this</li>
<li>A user enters alpha characters in a phone number field that should only contain digits, WRONG, but you should expect this behavior</li>
<li>Checking that a file exists that you have no idea if it should exist or not.</li>
<li>A Search returns no results.</li>
</ul>
<p>Examples of where exceptions may be warranted:</p>
<ul>
<li>A database connection fails that should be able to connect.</li>
<li>A SQL query cannot execute because it is malformed.</li>
<li>Checking that a file exists that should be there.</li>
<li>A Parser cannot parse because the data is malformed.</li>
<li>Checking for existence of required properties in a class that should have been set before a method was run.</li>
</ul>

<p>Why this distinction of when to use exceptions?  The biggest reason is that exceptions moves the code execution to a catch statement much like goto moves code execution to a different part of the program, and can create spaghetti code if used incorrectly.  A normal day to day catch statement should show a friendly error to the user, log or show the exception, and halt the execution flow.</p>

<p>I hope this article helps readers understand when to use exceptions, and if it can prevent just one person from designing their code like the user in the first paragraph, it did it's job.</p>

<p>
References:<br />
Hunt, Andrew and Thomas, David <i>The Pragmatic Programmer</i> Addison-Wesley, Feb 2006.
</p>  ]]>
  </description>
  <author>admin@codeangel.org (Chad Emrys Minick)</author>
  <pubDate>Thu, 02 Aug 2007 23:09:00 CST</pubDate>
      <category>PHP</category>
    <category>Programming</category>
    <guid>http://www.codeangel.org/article/misconceptions-about-exceptions</guid>
</item>
<item>
  <title>Codeangel 0.3</title>
  <link>http://www.codeangel.org/article/codeangel-0-3</link>
  <description>
  <![CDATA[
    <p>Well this was a fast release! I promise 0.4 will be a lot longer wait, and probably the experience will inspire me to write more regular articles.  Changes for 0.3 include:</p>
<ul>
<li>Added links for digg, furl, stumbleupon, del.icio.us, technorati, etc... on each article page.</li>
<li>Changed code highlighting class from Pear Text::Highlight to <a href="http://qbnz.com/highlighter/index.php">GeSHi</a></li>
<li>Refactored the models a little bit with better error reporting.  Not completely the way I want them yet, mostly due to the limitations of the older Zend Framework I'm working on.</li>
<li>Fixed various small bugs</li>
</ul>
<p>0.4 well be a big change, upgrading to Zend Framework 1.0. Because of the large differences between 1.0 and 0.8, there will be alot of code refactored (for the better).</p>  ]]>
  </description>
  <author>admin@codeangel.org (Chad Emrys Minick)</author>
  <pubDate>Sat, 21 Jul 2007 00:25:41 CST</pubDate>
      <category>CodeAngel</category>
    <guid>http://www.codeangel.org/article/codeangel-0-3</guid>
</item>
<item>
  <title>Codeangel 0.2</title>
  <link>http://www.codeangel.org/article/codeangel-0-2</link>
  <description>
  <![CDATA[
    <p>I am calling this release 0.2, It's mainly bug fixes and a few features additions I have been putting off.  Changes can be summerized:</p>
<ul>
<li>Changed homegrown js to the <a href="http://jquery.com/">jquery</a> library</li>
<li>fixed a bug with md5 files on the download page(thanks to David for pointing it out)</li>
<li>Completely changed my article linking method, the old way was a failed experiment.</li>
<li>Made warnings to check when my posts weren't valid XML.</li>
<li>truncated lists of tags and archives in the sidebar.</li>
</ul>
<p>plans for 0.3 include adding links for dig this, technorati, delicious and what not for the articles and replacing the code highlighting lib with <a href="http://qbnz.com/highlighter/index.php">GeSHi</a>. In 0.5 I plan on refactoring the app to work with Zend Framework 1.0 and to include things like cacheing and logging. Also I hope to replace some of my home-grown components with Zend Framework's components.</p>  ]]>
  </description>
  <author>admin@codeangel.org (Chad Emrys Minick)</author>
  <pubDate>Sat, 14 Jul 2007 15:22:56 CST</pubDate>
      <category>CodeAngel</category>
    <guid>http://www.codeangel.org/article/codeangel-0-2</guid>
</item>
<item>
  <title>Zend Framework 1.0 is released</title>
  <link>http://www.codeangel.org/article/zend-framework-1-0-is-released</link>
  <description>
  <![CDATA[
    <div class="intro">
<p>
<img style="float: left" alt="Zend Framework" src="/public/img/var/zf_logo.gif" /> The Zend Framework 1.0 has  been released!  I have been keeping an eye on/involved in this project since I first heard about it almost 2 years ago.  My involvement started out learning the framework and providing feedback.  Lately I have joined in the cause to help out with documentation and will continue to do so from now on.
</p>
<p>This very blog has been written in Zend Framework. It's 0.8 and I need to upgrade it and refactor it, and I don't have time with my current projects. It will happen soon though!</p>

<p>If your a web application developer, you really have to try Zend Framework out, it has many libraries for fast application development, but allows for much more degree of control than most other frameworks, making it more enterprise family.</p>

<p>The Zend Framework is more a collection of libraries ready for your use, It also gives plenty of abstract classes and interfaces to add on or change the framework to meet your needs.  The most notable components of the Zend Framework are  it's MVC implementation, a PHP port of Lucene, and a stand alone PDF class.  And that's not all!</p>

<p> So give the Zend Framework a look and try it out for your next project!  A word before you judge to early, one of the missing components that we couldn't get in to the 1.0 release was a partial view renderer, If you see this as a loss, don't worry it'll most likely be out by the next realease.</p>
</div>  ]]>
  </description>
  <author>admin@codeangel.org (Chad Emrys Minick)</author>
  <pubDate>Mon, 02 Jul 2007 12:47:44 CST</pubDate>
      <category>PHP</category>
    <category>Zend Framework</category>
    <guid>http://www.codeangel.org/article/zend-framework-1-0-is-released</guid>
</item>
<item>
  <title>Custom Zend Framework Router</title>
  <link>http://www.codeangel.org/article/custom_zend_framework_router</link>
  <description>
  <![CDATA[
    <div class="intro">
<p>
<img style="float: left;" alt="Zend Framework" src="/public/img/var/zf_logo.gif" />
One could tweak Zend Framework's Router_Route to meet almost all your routing needs.  But what if you want something beyond what that package can offer?  You can make your routing dreams come true with making your own custom router, all you need to do is implement <i>Zend_Controller_Router_Route_Interface</i> (that's a mouth full).
</p>
<p>Case example, I needed a website that could have an arbitrary amount of hierarchal categories.  I wanted my URI path to reflect the full path to that category.  For example:</p>
<pre>
http://www.example.org/category/clothing/hats/dress/fedora
</pre>
<p>This URL would represent the category controller. Each category is a child of the category to the left of it, clothing being the top most parent.</p>
</div>
<p>For this particular router I ignored the action component.  The category controller will only have an index action, for all that is needed is to view the contents of the category.  Administration of the categories happen in a completely different app, so I really don't need the usual scaffolding behavior. I just need the Route to route to the correct controller and then put the rest of the URL into a flat array that I can retrieve with <i>_getParam()</i>.  Looking at the example below however, it would be very easy to figure out how to make action routing work right :)</p>

<p><i>Zend_Controller_Router_Route_Interface</i> requires to implement three methods: <i>match()</i>, <i>assemble()</i>, and <i>getInstance()</i>.  The <i>match()</i> method is what does all the magic, it parses the url, decides if it's the right router for this url, and then passes an array of info to the dispatcher.  The <i>assemble()</i> method is used to reconstruct an URL given an array of data.  This is mainly used by some helpers like <i>Zend_View_Helper_Url</i>.  I won't show how to implement this method since it's slightly beyond the scope of this article. The <i>assemble()</i> is not necessary for the Router to work. Since the Interface requires it, I'll put it in the class as a dummy method.  You can play with Url Helper on your own to get <i>assemble()</i> to return what is needed for this Helper. The <i>getInstance()</i> method is simply a factory method to create instances of itself from <i>Zend_Config.</i></p>
<pre class="code" style="color: navy;">&#160;
<span style="color: darkred;">&#60;?php</span>
<span style="color: darkred;">class</span> MyApp_CatRoute implements Zend_Controller_Router_Route_Interface
<span style="color: olive;">&#123;</span>
	<span style="color: darkred;">public</span> <span style="color: #0000ff;">$defaults</span> = <a href="http://www.php.net/array"><span style="color: #666666;">array</span></a><span style="color: olive;">&#40;</span><span style="color: olive;">&#41;</span>;
        <span style="color: darkred;">public</span> <span style="color: #0000ff;">$name</span> = <span style="color: darkred;">null</span>;
&#160;
        <span style="color: orange;">//this class sets the defaults and the name of the controller</span>
        <span style="color: darkred;">public</span> <span style="color: darkred;">function</span> __construct<span style="color: olive;">&#40;</span><span style="color: #0000ff;">$name</span>, <span style="color: #0000ff;">$default</span> = <a href="http://www.php.net/array"><span style="color: #666666;">array</span></a><span style="color: olive;">&#40;</span><span style="color: olive;">&#41;</span><span style="color: olive;">&#41;</span>
        <span style="color: olive;">&#123;</span>
            	<span style="color: teal;">if</span><span style="color: olive;">&#40;</span>!<a href="http://www.php.net/empty"><span style="color: #666666;">empty</span></a><span style="color: olive;">&#40;</span><span style="color: #0000ff;">$default</span><span style="color: olive;">&#41;</span><span style="color: olive;">&#41;</span><span style="color: olive;">&#123;</span>
            		<span style="color: #0000ff;">$this</span>-&#62;<span style="color: #006600;">defaults</span> = <span style="color: #0000ff;">$default</span>;
            	<span style="color: olive;">&#125;</span> <span style="color: teal;">else</span> <span style="color: olive;">&#123;</span>
            		<span style="color: #0000ff;">$this</span>-&#62;<span style="color: #006600;">defaults</span> = <a href="http://www.php.net/array"><span style="color: #666666;">array</span></a><span style="color: olive;">&#40;</span>
                        <span style="color: #ff0000;">'controller'</span> =&#62; <span style="color: #ff0000;">'category'</span>,
                        <span style="color: #ff0000;">'action'</span> =&#62; <span style="color: #ff0000;">'index'</span>
                    <span style="color: olive;">&#41;</span>;
            	<span style="color: olive;">&#125;</span>
                <span style="color: #0000ff;">$this</span>-&#62;<span style="color: #006600;">name</span> = <span style="color: #0000ff;">$name</span>;
        <span style="color: olive;">&#125;</span>
&#160;
        <span style="color: darkred;">public</span> <span style="color: darkred;">function</span> match<span style="color: olive;">&#40;</span><span style="color: #0000ff;">$path</span><span style="color: olive;">&#41;</span>
        <span style="color: olive;">&#123;</span>
            <span style="color: orange;">//splits the URL into an array</span>
            <span style="color: teal;">if</span> <span style="color: olive;">&#40;</span><a href="http://www.php.net/preg_match_all"><span style="color: #666666;">preg_match_all</span></a><span style="color: olive;">&#40;</span><span style="color: #ff0000;">'#/([^/]*)#'</span>, <span style="color: #0000ff;">$path</span>, <span style="color: #0000ff;">$matches</span><span style="color: olive;">&#41;</span><span style="color: olive;">&#41;</span> <span style="color: olive;">&#123;</span>
                <span style="color: orange;">//gets the array from the preg_match</span>
                <span style="color: #0000ff;">$segments</span> = <span style="color: #0000ff;">$matches</span><span style="color: olive;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: olive;">&#93;</span>;
                <span style="color: orange;">/*pops off the first element and checks if 
                 *this is the right router, if not, return   
                 *false, Zend framework will continue looking 
                 *for the right router
                 */</span>
                <span style="color: #0000ff;">$category</span> = <a href="http://www.php.net/array_shift"><span style="color: #666666;">array_shift</span></a><span style="color: olive;">&#40;</span><span style="color: #0000ff;">$segments</span><span style="color: olive;">&#41;</span>;
                <span style="color: teal;">if</span> <span style="color: olive;">&#40;</span><span style="color: #0000ff;">$category</span> != <span style="color: #0000ff;">$this</span>-&#62;<span style="color: #006600;">defaults</span><span style="color: olive;">&#91;</span><span style="color: #ff0000;">'controller'</span><span style="color: olive;">&#93;</span><span style="color: olive;">&#41;</span><span style="color: olive;">&#123;</span>
                	<span style="color: teal;">return</span> <span style="color: darkred;">false</span>;
                <span style="color: olive;">&#125;</span>
                <span style="color: orange;">//creates an array, the array with all the categories are indexed by 'cats'</span>
                <span style="color: #0000ff;">$return</span> = <a href="http://www.php.net/array"><span style="color: #666666;">array</span></a><span style="color: olive;">&#40;</span>
                    <span style="color: #ff0000;">'category'</span> =&#62; <span style="color: #0000ff;">$category</span>,
                    <span style="color: #ff0000;">'cats'</span> =&#62; <span style="color: #0000ff;">$segments</span> 
                <span style="color: olive;">&#41;</span>;
                <span style="color: orange;">//merges the array above with the defaults and returns it.</span>
                <span style="color: #0000ff;">$return</span> = <a href="http://www.php.net/array_merge"><span style="color: #666666;">array_merge</span></a><span style="color: olive;">&#40;</span><span style="color: #0000ff;">$return</span>,<span style="color: #0000ff;">$this</span>-&#62;<span style="color: #006600;">defaults</span><span style="color: olive;">&#41;</span>;
                <span style="color: teal;">return</span> <span style="color: #0000ff;">$return</span>;
            <span style="color: olive;">&#125;</span>
            <span style="color: teal;">return</span> <span style="color: darkred;">false</span>;
        <span style="color: olive;">&#125;</span>
&#160;
        <span style="color: darkred;">public</span> <span style="color: darkred;">function</span> assemble<span style="color: olive;">&#40;</span><span style="color: #0000ff;">$data</span> = <a href="http://www.php.net/array"><span style="color: #666666;">array</span></a><span style="color: olive;">&#40;</span><span style="color: olive;">&#41;</span><span style="color: olive;">&#41;</span>
        <span style="color: olive;">&#123;</span>
            <span style="color: teal;">return</span> <span style="color: #0000ff;">$route</span>;
        <span style="color: olive;">&#125;</span>
&#160;
        <span style="color: darkred;">public</span> <a href="http://www.php.net/static"><span style="color: #666666;">static</span></a> <span style="color: darkred;">function</span> getInstance<span style="color: olive;">&#40;</span>Zend_Config <span style="color: #0000ff;">$config</span><span style="color: olive;">&#41;</span><span style="color: olive;">&#123;</span>
            <span style="color: #0000ff;">$defs</span> = <span style="color: olive;">&#40;</span><span style="color: #0000ff;">$config</span>-&#62;<span style="color: #006600;">defaults</span> instanceof Zend_Config<span style="color: olive;">&#41;</span> ? <span style="color: #0000ff;">$config</span>-&#62;<span style="color: #006600;">defaults</span>-&#62;<span style="color: #006600;">toArray</span><span style="color: olive;">&#40;</span><span style="color: olive;">&#41;</span> : <a href="http://www.php.net/array"><span style="color: #666666;">array</span></a><span style="color: olive;">&#40;</span><span style="color: olive;">&#41;</span>;
            <span style="color: teal;">return</span> <span style="color: darkred;">new</span> self<span style="color: olive;">&#40;</span><span style="color: #0000ff;">$config</span>-&#62;<span style="color: #006600;">route</span>, <span style="color: #0000ff;">$defs</span><span style="color: olive;">&#41;</span>;
        <span style="color: olive;">&#125;</span>
<span style="color: olive;">&#125;</span>
<span style="color: darkred;">?&#62;</span>
&#160;
&#160;</pre>
<p>Basically the idea is to have <i>match()</i> return an array with atleast the 'controller' and 'action' indexes set.  If your using a modular layout you would also need a 'module' index in the array.  Any other index you can set is completely up to you, and those indexes are accessible with <i>_getParam()</i> in the controller.  Here is how I set up this Route in the bootstrap:</p>
<pre class="code" style="color: navy;">&#160;
<span style="color: teal;">require_once</span><span style="color: olive;">&#40;</span><span style="color: #ff0000;">'MyApp/CatRoute.php'</span><span style="color: olive;">&#41;</span>;
<span style="color: #0000ff;">$rwRouter</span>-&#62;<span style="color: #006600;">addRoute</span><span style="color: olive;">&#40;</span><span style="color: #ff0000;">'cat'</span>, <span style="color: darkred;">new</span> MyApp_CatRoute<span style="color: olive;">&#40;</span><span style="color: #ff0000;">'category'</span>,<a href="http://www.php.net/array"><span style="color: #666666;">array</span></a><span style="color: olive;">&#40;</span><span style="color: #ff0000;">'controller'</span> =&#62; <span style="color: #ff0000;">'category'</span>, <span style="color: #ff0000;">'action'</span> =&#62; <span style="color: #ff0000;">'index'</span><span style="color: olive;">&#41;</span><span style="color: olive;">&#41;</span><span style="color: olive;">&#41;</span>;
&#160;</pre>

<p>Finally one can grab the array of categories easily in your action:</p>
<pre class="code" style="color: navy;">&#160;
<span style="color: #0000ff;">$cats</span> = <span style="color: #0000ff;">$this</span>-&#62;_getParam<span style="color: olive;">&#40;</span><span style="color: #ff0000;">'cats'</span>, <a href="http://www.php.net/array"><span style="color: #666666;">array</span></a><span style="color: olive;">&#40;</span><span style="color: olive;">&#41;</span><span style="color: olive;">&#41;</span>;
&#160;</pre>
<p>If you have any questions you can find me on irc on freenode.com in #zftalk.  You can also find me on the ZF General Mailing list. Have Fun!</p>  ]]>
  </description>
  <author>admin@codeangel.org (Chad Emrys Minick)</author>
  <pubDate>Sat, 30 Jun 2007 20:37:35 CST</pubDate>
      <category>PHP</category>
    <category>Tutorial</category>
    <category>Zend Framework</category>
    <guid>http://www.codeangel.org/article/custom_zend_framework_router</guid>
</item>
<item>
  <title>Adding APR support for Tomcat 6</title>
  <link>http://www.codeangel.org/article/adding_apr_support_for_tomcat_6</link>
  <description>
  <![CDATA[
    <div class="intro">
<p><img style="float: left;" src="/public/img/var/tomcat.gif" alt="tomcat logo" />Tomcat 6 has some neat new features. The one feature I am eyeballing the most is it's advanced IO features like the Comet Servlet Interface.  In an upcoming article I'll be explaining the Comet Servlet Interface some more, Plus a neat proof of concept!</p>

<p>In order to get these advanced IO features, one has to enable APR listener support.  APR is Apache's portable runtime that gives developers an API which behavior is consistent across many platforms. This runtime is the magic that makes the latest versions of Apache's httpd so darn portable. It's also needed for some advanced features in Tomcat!</p>
</div>

<p>I am assuming you have tomcat 6 installed at this point and are trying to figure out how to get APR working.  I am also assuming you are running Linux (If not you better!). To install APR support you need JNI headers, OpenSSL, and of course the APR lib.  If you have a Java JDK 1.4+ installed on your system, the JNI headers should already be there.  If you don't have this, go to the Java web site, grab the latest JDK, install it, and point your JAVA_HOME environment variable at it.  Depending on your distribution, you may have to do some other voodoo to get your default Java switched over.  For me all I had to do was move a symlink.  Most likely you already have OpenSSL libs installed on your Linux Distribution, you might need to grab the headers so that you can compile against the libraries, usually these are in a package named such as libssl-dev.  You'll also need  the APR library and headers.  Some distributions already have APR available through packages.  Go check your package repos and install libapr and libapr-dev packages.  For me, I had to install APR from the source packages <a href="http://apr.apache.org/download.cgi">here</a>. You  Should only have to do the familiar ./configure &amp;&amp; make &amp;&amp; make install, to install APR from source.</p>

<p>Now that we got the deps out of the way, time to get APR working in Tomcat.  First thing we need to do is compile the  JNI wrappers. The source for this comes with Tomcat, cd into your Tomcat $CATALINA_BASE/bin/ directory, and do the following: (paths may vary)</p>
<pre>
tar -xvzf tomcat-native.tar.gz
cd tomcat-native-1.1.10-src/jni/native
./configure --with-apr=/usr --with-java-home=/usr/lib/java --with-ssl=yes
make
sudo make install
</pre>
<p>After the make install it should give the path where the wrappers were installed, for me they were in /usr/local/apr/lib/. Now the hard part was getting Java to find these wrappers, since they are not in the usual java.library.path. To get them in the java.library.path, set the LD_LIBRARY_PATH environment variable on server startup. Edit tomcat's startup.sh script and add a line near the beginning (I did mine after the uname case stuff).</p>
<pre>
export LD_LIBRARY_PATH=/usr/local/apr/lib
</pre>
<p>Restart Tomcat and enjoy! You will be able to tell that APR support is installed by going to your /manager/status webapp, there should be a new section called 'OS' that gives OS memory and CPU information.</p>  ]]>
  </description>
  <author>admin@codeangel.org (Chad Emrys Minick)</author>
  <pubDate>Wed, 27 Jun 2007 22:31:16 CST</pubDate>
      <category>Linux</category>
    <category>Java</category>
    <category>Apache</category>
    <category>Tomcat</category>
    <guid>http://www.codeangel.org/article/adding_apr_support_for_tomcat_6</guid>
</item>
<item>
  <title>Mathematica 6 is released</title>
  <link>http://www.codeangel.org/article/mathematica_6_is_released</link>
  <description>
  <![CDATA[
    <div class="intro">
<p><img style="float: left;" src="/public/img/var/spikey.gif" alt="Wolfram Logo" /><a href="http://www.wolfram.com/products/mathematica/">Mathematica 6.0</a> has been released today!  Mathematica 6 has gone in a different direction than any of it's predecessors.  It allows users to create dynamic interfaces quickly and easily. It also allows interactivity beyond what any previous version offered.</p>

<p>Mathematica is a highly interactive functional programming language that allows almost anyone to produce mathematical models and simple code with little knowledge of computer science.  With Mathematica 6 it allows users to create interactive dynamic interfaces in a few lines of code that would take a traditional programming language thousands of lines to produce. Mathematica has the ability to connect to the internet and databases, parse xml, has regular expression functionality, and anything else that I would need for my day to day programming tasks.  Even though it was originally built for mathematicians and scientist, almost anybody can benefit from using Mathematica for their programming needs.</p>

<p>Along with Mathematica 6, <a href="http://www.wolfram.com/">Wolfram Research</a> also released a free <a href="http://www.wolfram.com/products/player/">Mathematica Player</a> that allows you to download and run free Mathematica notebooks from <a href="http://demonstrations.wolfram.com/">Wolfram's Demonstration Project</a> and allows you to experience what Mathematica 6 can do!</p>
</div>  ]]>
  </description>
  <author>admin@codeangel.org (Chad Emrys Minick)</author>
  <pubDate>Tue, 01 May 2007 16:03:09 CST</pubDate>
      <category>Programming</category>
    <category>Math</category>
    <guid>http://www.codeangel.org/article/mathematica_6_is_released</guid>
</item>
<item>
  <title>Teenage Mutant Ninja Turtles</title>
  <link>http://www.codeangel.org/article/teenage_mutant_ninja_turtles</link>
  <description>
  <![CDATA[
    <div class="intro">
<p>
This movie was a great way to re-live my childhood.  A story about 4 Teenage Mutant Ninja Turtles.  Ninjas + Turtles = Win.  I have been waiting for the release of this film since I first heard of it 9 months ago.  I was enthralled when I saw the first trailer about 3 months ago.  I had to see it on opening day.
</p>
<p>
When I was a wee lad, I watched the cartoon religiously.  I had the toys.  In fact I  recall that a Michaelangelo action figure is the first toy I bought with my own money.  I dressed up like Splinter for Halloween one year as a kid.   I probably drove my parents crazy watching the movies over and over.
</p>
<p>
I remember the first three movies.  Live action movies with men in big rubber suits and makeup that they could hardly even move was the theme to all of the movies.  Big rubber suits are not conducive to ninja like skillz, not to mention make the turtles look really really fat.
</p>
<p>
Then this new movie came out.  Done with computer animation, the way it was meant to be.  Turtles could actually act and move like ninjas.  The fight scenes were awesome.  The characters were done very well.  The villains were cool.  This movie just all out rocked.
</p>
<p>
Only complaint I heard was the fact that April O'Neil has a unbelievable skinny waist and hoooge boobs that made her look like an alien.  Those complaints were from the girls I went to see the movie with.  I, however, approved. ^_^
</p>
<p>
So, if you grew up with the turtles, this movie is awesome.  If you have kids, take them to see the movie, they'll love it.  For everyone else, well, you'll find it entertaining at least.  This movie seems to target either kids or people who grew up with turtles on their T.V.  But, I think most audiences would love this movie.
</p>
<p>
I give this movie 4.5 angel wings out of 5.</p></div>  ]]>
  </description>
  <author>admin@codeangel.org (Chad Emrys Minick)</author>
  <pubDate>Fri, 23 Mar 2007 23:01:05 CST</pubDate>
      <category>Movies</category>
    <guid>http://www.codeangel.org/article/teenage_mutant_ninja_turtles</guid>
</item>
<item>
  <title>Crack a Mac with Firewire</title>
  <link>http://www.codeangel.org/article/crack_a_mac_with_firewire</link>
  <description>
  <![CDATA[
    <div class="intro">
<img style="float: left;" src="/public/img/var/apple_logo.jpg" alt="apple logo" /><p>Last week I took my family and friends out to see the Engineering Open House (EOH) at the University of Illinois.   The open house showcased the different aspects of engineering in a science fair format.  The exhibits ranged from things interesting and cool for adults, to things fun and exciting for the kids.  One exhibit, titled <b>R.A.G.E. Beyond The Ether</b>, located in the Computer Science section was the highlight of my day.  Second place would have to go to a Distributed Music Library system which I might highlight in another article.</p>

<p><b>R.A.G.E. Beyond the Ether</b> was, in my opinion, an overly pompous name.   Cool for kids I guess.  I believe the main point of the exhibit was to see how computer vulnerabilities were discovered, and what was at risk.  Unfortunately I believe the college kids at this exhibit were misunderstood, as an older gentleman asking questions quickly labeled the students as Virus Writers.  The students, and most certainly I, dismissed such an ignorant statement.  The students, rather than writing and distributing virii primarily aimed at selling male enhancement pills, were actually working on a potentially important discovery in computer security.</p>
</div>

<p>The actual demonstration consisted of an attack between two Macintosh laptops.  The attacking mac was connected via a Firewire cable to the victim mac.  A walking by spectator would inquire on what the exhibit was about, interrupting the poor student's Magic: The Gathering game.  The students would ask the spectator to enter in a password on the the attacking machine and hit enter.  When the spectator hit enter, a python script was run.  When the script finished, the spectator was directed to go to the victim machine and hit shutdown on the login panel.  Instead of the machine shutting down, the login screen blinked.  The spectator was then asked to log in as an adminstrator on the victim's machine using the password he entered in on the attacking machine.  Low and Behold, it worked!  The attacking machine was able to change the admin password on the victim by just hooking up to another computer via Firewire and running a script.  If that doesn't scare you, you haven't heard the least of it yet.</p>

<p>After seeing this demonstration I grilled the students on the details of this attack.  Given that there won't be a vulnerability report or any sort of release until more testing is done on the nature of this attack, I will only divulge on how the attack works. I will also discuss potential theories and hazards that this discovery could uncover.</p>

<p>Don't worry Mac Users, the vulnerability isn't necessarily a Mac problem.  The issue is the implementation of Firewire.  Firewire uses Direct Memory Access (DMA).   The exploit took advantage of this feature and used DMA to directly write to the memory and change the behavior of the shutdown button on the login screen.  Instead of shutting down, the code was replaced with a program that changed the root password on the mac.</p>

<p>The theory is we now have a potential security problem with any operating system and any technology that uses DMA and is capable of a remote connection to another computer or device.   Firewire? USB 2.0? Some Gigabit Ethernet chipsets? BlueTooth?  Are you scared yet?</p>

<p>Moral of this story? Think twice when somebody wants to connect their iPod to your computer.  The iPod, or any computer device, could potentially be modified to run the same code that changed the computer's password. </p>  ]]>
  </description>
  <author>admin@codeangel.org (Chad Emrys Minick)</author>
  <pubDate>Mon, 19 Mar 2007 21:17:20 CST</pubDate>
      <category>Mac</category>
    <category>Security</category>
    <guid>http://www.codeangel.org/article/crack_a_mac_with_firewire</guid>
</item>
<item>
  <title>Welcome to CodeAngel</title>
  <link>http://www.codeangel.org/article/welcome_to_codeangel</link>
  <description>
  <![CDATA[
    <div class="intro">
<p><img src="/public/img/var/Waddle_Dee_Dance.gif" alt="yay" /></p>
<p>It's Here at last! CodeAngel.org is a project I have been working on, on and off, for almost a year!  CodeAngel.org is my blog.  The software behind this was written by me, and of course those who wrote the libraries behind it.  The application base was written with the Zend Framework.  I started writing this blog when Zend Framework was on 0.1.2 and at this time of writing is running on 0.8.0, I'll continue to update this blog based on Zend Framework perhaps perpetually.</p>
<p>The main reason I wrote my own blog software, instead of say use any of those 100s of other blog and content management software out there, is for two reasons.  One reason is that I wanted a project to better understand MVC and how it applied to Web Development.  The other reason why I reinvented the wheel, all the wheels out there didn't fit my car.</p>
</div>
<p>The main features I wanted for a cms/blog software is something aimed at developers, coders, nerds etc.  First I wanted something that allowed for multiple or single page blog posts, allowing to write short little blurbs famous amongst blogs, or to pour on page after page in some sort of technical tutorial (I already have quite a few planned).  Also I added on Text Highlighting, with Pear Text::Highlight:</p>
<div class="hl-main"><pre><span class="hl-code"> 
</span><span class="hl-brackets">{</span><span class="hl-code"> </span><span class="hl-reserved">package</span><span class="hl-code"> </span><span class="hl-identifier">Animal</span><span class="hl-code">;
  </span><span class="hl-reserved">use</span><span class="hl-special"> Carp</span><span class="hl-code"> </span><span class="hl-quotes">qw(</span><span class="hl-string">croak</span><span class="hl-quotes">)</span><span class="hl-code">;
  
  </span><span class="hl-comment">##constructors</span><span class="hl-code">
  </span><span class="hl-reserved">sub</span><span class="hl-code"> </span><span class="hl-identifier">named</span><span class="hl-code"> </span><span class="hl-brackets">{</span><span class="hl-code">
    </span><span class="hl-reserved">ref</span><span class="hl-brackets">(</span><span class="hl-reserved">my</span><span class="hl-code"> </span><span class="hl-var">$class</span><span class="hl-code"> = </span><span class="hl-reserved">shift</span><span class="hl-brackets">)</span><span class="hl-code"> </span><span class="hl-reserved">and</span><span class="hl-code"> </span><span class="hl-identifier">croak</span><span class="hl-code"> </span><span class="hl-quotes">&quot;</span><span class="hl-string">class name needed</span><span class="hl-quotes">&quot;</span><span class="hl-code">;
    </span><span class="hl-reserved">my</span><span class="hl-code"> </span><span class="hl-var">$name</span><span class="hl-code"> = </span><span class="hl-reserved">shift</span><span class="hl-code">;
    </span><span class="hl-reserved">my</span><span class="hl-code"> </span><span class="hl-var">$self</span><span class="hl-code"> = </span><span class="hl-brackets">{</span><span class="hl-code"> </span><span class="hl-quotes">'</span><span class="hl-string">Name</span><span class="hl-quotes">'</span><span class="hl-code"> =&gt; </span><span class="hl-var">$name</span><span class="hl-code">, </span><span class="hl-quotes">'</span><span class="hl-string">Color</span><span class="hl-quotes">'</span><span class="hl-code"> -&gt; </span><span class="hl-var">$class</span><span class="hl-code">-&gt;</span><span class="hl-identifier">default_color</span><span class="hl-code"> </span><span class="hl-brackets">}</span><span class="hl-code">;
    </span><span class="hl-reserved">bless</span><span class="hl-code"> </span><span class="hl-var">$self</span><span class="hl-code">, </span><span class="hl-var">$class</span><span class="hl-code">;
  </span><span class="hl-brackets">}</span><span class="hl-code">
</span><span class="hl-brackets">}</span></pre></div>
<p>The best thing about Text_Highlight is that it is extensible. I have plans for adding on some modules to it so that it supports Bash, C#, and maybe VB.Net.</p>

<p>Next page I touch on the future plans CodeAngel</p>  ]]>
  </description>
  <author>admin@codeangel.org (Chad Emrys Minick)</author>
  <pubDate>Wed, 14 Mar 2007 23:40:15 CST</pubDate>
      <category>Hammer Time</category>
    <category>CodeAngel</category>
    <guid>http://www.codeangel.org/article/welcome_to_codeangel</guid>
</item>
  </channel>
</rss>