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

<channel>
	<title>Witheringtree</title>
	<atom:link href="http://www.witheringtree.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.witheringtree.com</link>
	<description>If a tree falls in the forest and no one is around to hear it fall… yeah, it still makes a sound.</description>
	<lastBuildDate>Mon, 23 Jan 2012 02:07:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Can&#8217;t Argue With That Logic</title>
		<link>http://www.witheringtree.com/2012/01/cant-argue-with-that-logic/</link>
		<comments>http://www.witheringtree.com/2012/01/cant-argue-with-that-logic/#comments</comments>
		<pubDate>Mon, 23 Jan 2012 02:07:39 +0000</pubDate>
		<dc:creator>David Freerksen</dc:creator>
				<category><![CDATA[Entertainment]]></category>
		<category><![CDATA[Misc]]></category>
		<category><![CDATA[Self]]></category>
		<category><![CDATA[Cool]]></category>
		<category><![CDATA[Funny]]></category>
		<category><![CDATA[Me]]></category>

		<guid isPermaLink="false">http://www.witheringtree.com/?p=964</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.witheringtree.com/wp-content/uploads/2012/01/logic.png" rel="shadowbox[sbpost-964];player=img;"><img class="alignnone size-medium wp-image-965" title="Can't Argue With That Logic" src="http://www.witheringtree.com/wp-content/uploads/2012/01/logic-300x277.png" alt="" width="300" height="277" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.witheringtree.com/2012/01/cant-argue-with-that-logic/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Dream Team</title>
		<link>http://www.witheringtree.com/2011/12/the-dream-team/</link>
		<comments>http://www.witheringtree.com/2011/12/the-dream-team/#comments</comments>
		<pubDate>Sat, 31 Dec 2011 05:35:04 +0000</pubDate>
		<dc:creator>David Freerksen</dc:creator>
				<category><![CDATA[Work]]></category>

		<guid isPermaLink="false">http://www.witheringtree.com/?p=960</guid>
		<description><![CDATA[Torus Marketing]]></description>
			<content:encoded><![CDATA[<p>Torus Marketing<br />
<a href="http://www.witheringtree.com/wp-content/uploads/2011/12/390532_312310245456265_170819309605360_1007615_2090785016_n.jpg" rel="shadowbox[sbpost-960];player=img;"><img src="http://www.witheringtree.com/wp-content/uploads/2011/12/390532_312310245456265_170819309605360_1007615_2090785016_n-300x214.jpg" alt="" title="Torus Marketing" width="300" height="214" class="alignnone size-medium wp-image-961" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.witheringtree.com/2011/12/the-dream-team/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Add a digital signature to a PDF using Preview</title>
		<link>http://www.witheringtree.com/2011/11/add-a-digital-signature-to-a-pdf-using-preview/</link>
		<comments>http://www.witheringtree.com/2011/11/add-a-digital-signature-to-a-pdf-using-preview/#comments</comments>
		<pubDate>Sun, 06 Nov 2011 16:07:01 +0000</pubDate>
		<dc:creator>David Freerksen</dc:creator>
				<category><![CDATA[Mac]]></category>
		<category><![CDATA[Misc]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[Apple Software]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Tips/Tricks]]></category>

		<guid isPermaLink="false">http://www.witheringtree.com/?p=954</guid>
		<description><![CDATA[Apple always builds all kinds of hidden things into their stuff. Today I had to sign a contract. The contract was sent over as a PDF. I really didn’t want to print it, sign it, and mail or fax it back or rescan it and email it back. I don’t have a scanner and I &#8230; <a href="http://www.witheringtree.com/2011/11/add-a-digital-signature-to-a-pdf-using-preview/" title="Continue reading">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Apple always builds all kinds of hidden things into their stuff. Today I had to sign a contract. The contract was sent over as a PDF. I really didn’t want to print it, sign it, and mail or fax it back or rescan it and email it back. I don’t have a scanner and I don’t have a printer. I started playing with Preview and it turns out, it’s built in now. This is available in Lion.</p>
<ol>
<li>Open the PDF that needs a signature with Preview.</li>
<li>Click the <strong>Annotate</strong> tab to display the annotate toolbar.</li>
<li>Select the <strong>Signature</strong> button.</li>
<li>If you do not have a signature loaded already, click <strong>Create Signature from Built-In iSight&#8230;</strong>. If you already have one loaded, skip to step 7<br /><a href="http://www.witheringtree.com/wp-content/uploads/2011/11/signature_annotate.png" rel="shadowbox[sbpost-954];player=img;"><img src="http://www.witheringtree.com/wp-content/uploads/2011/11/signature_annotate-300x80.png" alt="" title="signature_annotate" width="300" height="80" class="alignnone size-medium wp-image-956" /></a></li>
<li>In the <strong>Signatures</strong> tab, click <strong>Create Signature&#8230;</strong></li>
<li>Sign your name to a white piece of paper and hold it up to your iSight camera.</li>
<li>Click <strong>Accept</strong> when your signature is positioned correctly inside the preview area.<br /><a href="http://www.witheringtree.com/wp-content/uploads/2011/11/signature_capture.png" rel="shadowbox[sbpost-954];player=img;"><img src="http://www.witheringtree.com/wp-content/uploads/2011/11/signature_capture-300x146.png" alt="" title="signature_capture" width="300" height="146" class="alignnone size-medium wp-image-957" /></a></li>
<li>With the Signature button selected (it should be blue), click and drag where you want to place your signature.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.witheringtree.com/2011/11/add-a-digital-signature-to-a-pdf-using-preview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Now I&#8217;m Confused</title>
		<link>http://www.witheringtree.com/2011/09/now-im-confused/</link>
		<comments>http://www.witheringtree.com/2011/09/now-im-confused/#comments</comments>
		<pubDate>Wed, 21 Sep 2011 03:24:32 +0000</pubDate>
		<dc:creator>David Freerksen</dc:creator>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Funny]]></category>

		<guid isPermaLink="false">http://www.witheringtree.com/?p=950</guid>
		<description><![CDATA[I&#8217;m working on a Magento module and I got an error message saying &#8220;An error occurred while saving the page.&#8221; Right under it I gut a success message saying &#8220;The page has been saved.&#8221;]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m working on a Magento module and I got an error message saying &#8220;An error occurred while saving the page.&#8221; Right under it I gut a success message saying &#8220;The page has been saved.&#8221;</p>
<p><a href="http://www.witheringtree.com/wp-content/uploads/2011/09/fail_but_save.png" rel="shadowbox[sbpost-950];player=img;"><img class="alignnone size-medium wp-image-951" title="fail_but_save" src="http://www.witheringtree.com/wp-content/uploads/2011/09/fail_but_save-300x234.png" alt="" width="300" height="234" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.witheringtree.com/2011/09/now-im-confused/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Custom CodeIgniter Validation Methods</title>
		<link>http://www.witheringtree.com/2011/09/custom-codeigniter-validation-methods/</link>
		<comments>http://www.witheringtree.com/2011/09/custom-codeigniter-validation-methods/#comments</comments>
		<pubDate>Mon, 19 Sep 2011 21:12:05 +0000</pubDate>
		<dc:creator>David Freerksen</dc:creator>
				<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Tips/Tricks]]></category>

		<guid isPermaLink="false">http://www.witheringtree.com/?p=944</guid>
		<description><![CDATA[CodeIgniter&#8217;s Form Validation library isn&#8217;t bad. It takes a little getting use to but it can be very powerful. Most of the validation that comes with CodeIgniter are pretty much the only ones you will ever need. Every now and then you will need something else. Extending CodeIgniter libraries is very easy. These are some &#8230; <a href="http://www.witheringtree.com/2011/09/custom-codeigniter-validation-methods/" title="Continue reading">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>CodeIgniter&#8217;s <a href="http://codeigniter.com/user_guide/libraries/form_validation.html" title="CodeIgniter Form Validation" target="_blank">Form Validation</a> library isn&#8217;t bad. It takes a little getting use to but it can be very powerful. Most of the validation that comes with CodeIgniter are pretty much the only ones you will ever need. Every now and then you will need something else. <a href="http://codeigniter.com/user_guide/general/creating_libraries.html" title="Creating and Extending CodeIgniter Libraries" target="_blank">Extending CodeIgniter libraries</a> is very easy. These are some of the custom form validation I&#8217;ve had to do in previous projects</p>
<p>First of all, you have to create a library that will extend CodeIgniter&#8217;s library. Create a new file named MY_Form_validation.php and put it in the application/libraries/ directory. Here is what that library will look like:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span> <span style="color: #990000;">defined</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'BASEPATH'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #990000;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'No direct script access allowed'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> MY_Form_validation <span style="color: #000000; font-weight: bold;">extends</span> CI_Form_validation <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$CI</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		parent<span style="color: #339933;">::</span>__construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">CI</span> <span style="color: #339933;">=&amp;</span> get_instance<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The first validation method I used for a project where the user would enter a fraction and I didn&#8217;t really want to convert a decimal to a fraction. So I just created a validation method.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
 * Fraction
 *
 * @access  public
 * @param   string  $str
 * @return  bool
 */</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> fraction<span style="color: #009900;">&#40;</span><span style="color: #000088;">$str</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">CI</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">form_validation</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_message</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'fraction'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'The %s field must be a valid fraction.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span> <span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/^(\d++(?! */))? *-? *(?:(\d+) */ *(\d+))?.*$/&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$str</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #009900; font-weight: bold;">FALSE</span> <span style="color: #339933;">:</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Usage example:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">form_validation</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_rules</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'screen_size'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Screen Size'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'fraction'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This was a fun validation to make. When a user signs up or is changing their password, their password must be <a href="http://www.pcicomplianceguide.org/" title="PCI Compliance" target="_blank">PCI compliant</a>. For a password to be PCI compliant, it must meet the following:<br />
1) Must be between 6 and 99 characters in length<br />
2) Must not contain two consecutively repeating characters<br />
3) Must contain at least one upper-case letter<br />
4) Must contain at least one lower-case letter<br />
5) Must contain at least one number<br />
6) Must contain at least one special character</p>
<p>Please note that the validation message is really long. You may want to simplify it a little before using it</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
 * PCI compliance password
 *
 * @access  public
 * @param   $str
 * @return  bool
 */</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> pci_password<span style="color: #009900;">&#40;</span><span style="color: #000088;">$str</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$special</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'!@#$%*-_=+.'</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">CI</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">form_validation</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_message</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'pci_password'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'For PCI compliance, %s must be between 6 and 99 characters in length, must not contain two consecutively repeating characters, contain at least one upper-case letter, at least one lower-case letter, at least one number, and at least one special character ('</span><span style="color: #339933;">.</span><span style="color: #000088;">$special</span><span style="color: #339933;">.</span><span style="color: #0000ff;">')'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/^(?=^.{6,99}$)(?=.*[0-9])(?=.*[A-Z])(?=.*[a-z])(?=.*['</span><span style="color: #339933;">.</span><span style="color: #000088;">$special</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'])(?!.*?(.)\1{1,})^.*$/'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$str</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #009900; font-weight: bold;">TRUE</span> <span style="color: #339933;">:</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Usage example:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">form_validation</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_rules</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'password'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Password'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'pci_password'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>CodeIgniter already has a validation method for <em>required</em>. But I needed one to be required if a different field had a value. A couple weeks later I needed to have method to make a field required if another field had a certain value.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
 * Required if another field has a value (related fields) or if a field has a certain value
 *
 * @access  public
 * @param   string  $str
 * @param   string  $field
 * @return  bool
 */</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> required_if<span style="color: #009900;">&#40;</span><span style="color: #000088;">$str</span><span style="color: #339933;">,</span> <span style="color: #000088;">$field</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #990000;">list</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fld</span><span style="color: #339933;">,</span> <span style="color: #000088;">$val</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">','</span><span style="color: #339933;">,</span> <span style="color: #000088;">$field</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">CI</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">form_validation</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_message</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'required_if'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'The %s field is required.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// $fld is filled out</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$fld</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// Must have specific value</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$val</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #666666; font-style: italic;">// Not the specific value we are looking for</span>
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$fld</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$val</span> AND <span style="color: #339933;">!</span> <span style="color: #000088;">$str</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Usage example:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">form_validation</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_rules</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'bar'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Bar'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'required_if[foo]'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// required if field 'foo' has a value</span>
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">form_validation</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_rules</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'foobar'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Foo Bar'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'required_if[foo,bar]'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// required if field 'foo' has a value of 'bar'</span></pre></div></div>

<p>There are a lot of examples of this validation floating around. It requires that a value being passed has a unique value in the database. This one also takes into account the database prefix.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
 * Unique
 *
 * @access	public
 * @param	string
 * @param	field
 * @return	bool
 */</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> unique<span style="color: #009900;">&#40;</span><span style="color: #000088;">$str</span><span style="color: #339933;">,</span> <span style="color: #000088;">$field</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #990000;">list</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$table</span><span style="color: #339933;">,</span> <span style="color: #000088;">$column</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">','</span><span style="color: #339933;">,</span> <span style="color: #000088;">$field</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">CI</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">form_validation</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_message</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'unique'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'The %s that you requested is already in use.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">CI</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SELECT COUNT(*) AS dupe FROM {<span style="color: #006699; font-weight: bold;">$this-&gt;CI</span>-&gt;db-&gt;dbprefix(<span style="color: #006699; font-weight: bold;">$table</span>)} WHERE <span style="color: #006699; font-weight: bold;">{$column}</span> = '<span style="color: #006699; font-weight: bold;">{$str}</span>'&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$row</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">row</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">dupe</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> ? <span style="color: #009900; font-weight: bold;">FALSE</span> <span style="color: #339933;">:</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Usage example:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">form_validation</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_rules</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'email'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Email'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'unique[DBTABLE,DBFIELD]'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	<span style="color: #666666; font-style: italic;">// DBTABLE is the database table and DBFIELD is the database field to validation against</span></pre></div></div>

<p>I took the previous validation a step further so that the field value must be unique in the database EXCEPT for a certain record ID. This one is really good for if you have an existing user in the system and they are updating their profile. You want to make sure that their email address is unique. If you run the previous <em>unique</em> validation it will fail because the email address is already in use by the user currently being edited. So we need to exclude that users ID from the validation. This one also takes into account the database prefix.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
 * Unique except. Check if a specific value is in use except when the value is attached to a specific row ID
 *
 * @param	string
 * @param	field
 * @return	bool
 */</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> unique_exclude<span style="color: #009900;">&#40;</span><span style="color: #000088;">$str</span><span style="color: #339933;">,</span> <span style="color: #000088;">$field</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #990000;">list</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$table</span><span style="color: #339933;">,</span> <span style="color: #000088;">$column</span><span style="color: #339933;">,</span> <span style="color: #000088;">$fld</span><span style="color: #339933;">,</span> <span style="color: #000088;">$id</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">','</span><span style="color: #339933;">,</span> <span style="color: #000088;">$field</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">4</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">CI</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">form_validation</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_message</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'unique_exclude'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'The %s that you requested is already in use.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">CI</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SELECT COUNT(*) AS dupe FROM {<span style="color: #006699; font-weight: bold;">$this-&gt;CI</span>-&gt;db-&gt;dbprefix(<span style="color: #006699; font-weight: bold;">$table</span>)} WHERE <span style="color: #006699; font-weight: bold;">{$column}</span> = '<span style="color: #006699; font-weight: bold;">$str</span>' AND <span style="color: #006699; font-weight: bold;">{$fld}</span> &lt;&gt; <span style="color: #006699; font-weight: bold;">{$id}</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$row</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">row</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">dupe</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> ? <span style="color: #009900; font-weight: bold;">FALSE</span> <span style="color: #339933;">:</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Usage example:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">form_validation</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_rules</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'email'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Email'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'unique[DBTABLE,DBFIELD,IDFIELD,ID]'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	<span style="color: #666666; font-style: italic;">// DBTABLE is the database table, DBFIELD is the database field, IDFIELD is the primary key for the table, and ID is the unique ID for the user</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.witheringtree.com/2011/09/custom-codeigniter-validation-methods/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Cross Browser Support for inline-block in CSS</title>
		<link>http://www.witheringtree.com/2011/09/cross-browser-support-for-inline-block-in-css/</link>
		<comments>http://www.witheringtree.com/2011/09/cross-browser-support-for-inline-block-in-css/#comments</comments>
		<pubDate>Sun, 18 Sep 2011 00:44:17 +0000</pubDate>
		<dc:creator>David Freerksen</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[IE]]></category>
		<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[Tips/Tricks]]></category>

		<guid isPermaLink="false">http://www.witheringtree.com/?p=940</guid>
		<description><![CDATA[I&#8217;ve been using this method for cross browser inline-block displays for a while and thought everyone else knew about it too. One of my co-workers was shocked to find out they had been doing it wrong for so long. So I thought I would share it in case someone else didn&#8217;t know about it. Inline-block &#8230; <a href="http://www.witheringtree.com/2011/09/cross-browser-support-for-inline-block-in-css/" title="Continue reading">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been using this method for cross browser inline-block displays for a while and thought everyone else knew about it too. One of my co-workers was shocked to find out they had been doing it wrong for so long. So I thought I would share it in case someone else didn&#8217;t know about it. </p>
<p>Inline-block is very powerful. It is very useful for horizontal lists and even makes vertical alignment work properly. Unfortunately, it’s supported pretty poorly. *cough*Internet Explorer*cough*</p>
<p>Older versions of Firefox support inline-block with a special &#8220;-moz&#8221; tag. But not the one you think. It uses &#8216;-moz-inline-stack&#8217; instead of &#8216;-moz-inline-block&#8217;. And when I say older versions I mean anything before version 4 I believe. So really, you don&#8217;t have to add it if you don&#8217;t want to. I don&#8217;t. But if you keep it, make sure &#8216;display:-moz-inline-stack&#8217; comes BEFORE &#8216;display:inline-block&#8217; so newer versions of Firefox can use the standard style.</p>
<p>IE supports inline-block, but only for elements that are natively inline, such as span and strong. When &#8216;zoom: 1&#8242; is set, it triggers hasLayout and magically IE supports inline-block. The *property is an IE hack that does not get run for non-IE browsers.</p>
<p>So, without further adieus, cross-browser inline-block support:</p>
<pre>
.myStyle {
	display: -moz-inline-stack;  /* optional */
	display: inline-block;
	zoom: 1;  /* triggers hasLayout for IE */
	*display: inline;  /* target IE7 only */
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.witheringtree.com/2011/09/cross-browser-support-for-inline-block-in-css/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Blocks in Magento</title>
		<link>http://www.witheringtree.com/2011/09/blocks-in-magento/</link>
		<comments>http://www.witheringtree.com/2011/09/blocks-in-magento/#comments</comments>
		<pubDate>Sat, 17 Sep 2011 00:41:11 +0000</pubDate>
		<dc:creator>David Freerksen</dc:creator>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.witheringtree.com/?p=937</guid>
		<description><![CDATA[One of the things Magento got right is blocks. It&#8217;s one of the few things I am continually impressed by. There are a lot of ways to add a static block to the page. XML is probably the most common place to add a static block. You find whatever block you want to add your &#8230; <a href="http://www.witheringtree.com/2011/09/blocks-in-magento/" title="Continue reading">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>One of the things Magento got right is blocks. It&#8217;s one of the few things I am continually impressed by. There are a lot of ways to add a static block to the page.</p>
<p><strong>XML</strong> is probably the most common place to add a static block. You find whatever block you want to add your static block into and you add something like:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;block</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;cms/block&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;YOUR_BLOCK_ID&quot;</span> <span style="color: #000066;">before</span>=<span style="color: #ff0000;">&quot;-&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;action</span> <span style="color: #000066;">method</span>=<span style="color: #ff0000;">&quot;setBlockId&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;block_id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>YOUR_BLOCK_ID<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/block_id<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/action<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/block<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Adding a static clock through <strong>layout XML</strong> can be very useful if you need to add a static block to a sidebar on a single page for example instead of all pages.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;reference</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;left&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;block</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;cms/block&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;YOUR_BLOCK_ID&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;action</span> <span style="color: #000066;">method</span>=<span style="color: #ff0000;">&quot;setBlockId&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;block_id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>YOUR_BLOCK_ID<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/block_id<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/action<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/block<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/reference<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Adding you static block through <strong>PHP</strong> may be the least common way. This, however, can be very useful if you want to define areas in your theme where a menu or a widgets could go. To add a static block in PHP you would use:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getLayout</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">createBlock</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'cms/block'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setBlockId</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'YOUR_BLOCK_ID'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">toHtml</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Adding a static block through a short code is very powerful. It allows you to add a static block into a CMS page or even your products.</p>

<div class="wp_syntax"><div class="code"><pre class="smarty" style="font-family:monospace;"><span style="color: #D36900;">&#123;</span><span style="color: #D36900;">&#123;</span>block type<span style="color: #D36900;">=</span><span style="color: #ff0000;">&quot;cms/block&quot;</span> block_id<span style="color: #D36900;">=</span><span style="color: #ff0000;">&quot;YOUR_BLOCK_ID&quot;</span><span style="color: #D36900;">&#125;</span>}</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.witheringtree.com/2011/09/blocks-in-magento/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>To the shores of Tripoli</title>
		<link>http://www.witheringtree.com/2011/09/to-the-shores-of-tripoli/</link>
		<comments>http://www.witheringtree.com/2011/09/to-the-shores-of-tripoli/#comments</comments>
		<pubDate>Fri, 16 Sep 2011 00:21:46 +0000</pubDate>
		<dc:creator>David Freerksen</dc:creator>
				<category><![CDATA[Self]]></category>
		<category><![CDATA[History]]></category>
		<category><![CDATA[Marine Corps]]></category>
		<category><![CDATA[Military]]></category>

		<guid isPermaLink="false">http://www.witheringtree.com/?p=934</guid>
		<description><![CDATA[Before the uprising in Libya, even though it is part of the Marine Corps Hymn, I really doubt most Marines knew were Tripoli was located. ‘To the shores of Tripoli’ in the Marine Corps Hymn stems from the Battle of Derne. It is the first recorded land battle fought overseas by the United States. It &#8230; <a href="http://www.witheringtree.com/2011/09/to-the-shores-of-tripoli/" title="Continue reading">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Before the uprising in Libya, even though it is part of the Marine Corps Hymn, I really doubt most Marines knew were Tripoli was located. ‘To the shores of Tripoli’ in the Marine Corps Hymn stems from the <a title="Battle of Derne" href="http://en.wikipedia.org/wiki/Battle_of_Derne" target="_blank">Battle of Derne</a>. It is the first recorded land battle fought overseas by the United States. It was after this battle that 1st Lt. O&#8217;Bannon was presented the Mameluke sword, which is still worn by Marine officers today.</p>
<p>More Marines are aware that ‘The Halls of Montezuma’ is from the <a title="Battle of Chapultepec" href="http://en.wikipedia.org/wiki/Battle_of_Chapultepec" target="_blank">Battle of Chapultepec</a>, only because it is from this battle that we get the blood stripe that NCOs wear to commemorate the Marines that died during this battle. I doubt most Marines know that the Battle of Chapultepec was fought during the Mexican-American War were US forces fought Mexican forces holding Chapultepec Castle located west of Mexico City.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.witheringtree.com/2011/09/to-the-shores-of-tripoli/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting Up Virtual Hosts in Zend Server CE on OS X</title>
		<link>http://www.witheringtree.com/2011/07/setting-up-virtual-hosts-in-zend-server-ce-on-os-x/</link>
		<comments>http://www.witheringtree.com/2011/07/setting-up-virtual-hosts-in-zend-server-ce-on-os-x/#comments</comments>
		<pubDate>Tue, 19 Jul 2011 00:40:19 +0000</pubDate>
		<dc:creator>David Freerksen</dc:creator>
				<category><![CDATA[Mac]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Website]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[Tips/Tricks]]></category>

		<guid isPermaLink="false">http://www.witheringtree.com/?p=930</guid>
		<description><![CDATA[What is a virtual host? Virtual hosting is a method for hosting multiple domain names on a computer using a single IP address. Shared hosting uses this same method for all of the sites they host. Aren&#8217;t those URLs you use in Zend Server getting pretty ugly? Would you like to change http://localhost/my/awesome/website into http://www.super-awesome.local &#8230; <a href="http://www.witheringtree.com/2011/07/setting-up-virtual-hosts-in-zend-server-ce-on-os-x/" title="Continue reading">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>
What is a virtual host? Virtual hosting is a method for hosting multiple domain names on a computer using a single IP address. Shared hosting uses this same method for all of the sites they host. Aren&#8217;t those URLs you use in Zend Server getting pretty ugly? Would you like to change http://localhost/my/awesome/website into http://www.super-awesome.local You can!
</p>
<p>
Last time we talked about general Zend Server setup. This time, we will be going through setting up virtual hosts on your local machine. This again will involve Terminal.
</p>
<p>
This assumes you have Zend Server set up and running. If it is not, <a href="http://www.witheringtree.com/2011/07/installing-zend-server-ce-on-os-x-a-guide-for-the-terminal-timid/" title="Installing Zend Server CE on OS X: A Guide For the Terminal Timid">go here</a>.
</p>
<p><span id="more-930"></span></p>
<ol>
<li>
<p>
		Open Terminal. Terminal can be found at /Applications/Utilities/Terminal.app
	</p>
<p>
		You can also open it from Spotlight by typing &#8220;Terminal&#8221;
	</p>
</li>
<li>
<p>
		We are going to edit our httpd.conf file. In Terminal type:<br />
		<code><br />
			sudo vi /usr/local/zend/apache2/conf/httpd.conf<br />
		</code>
	</p>
<p>
		Enter your password if prompted
	</p>
</li>
<li>
<p>
		Use the up, down, left, right arrow keys to scroll down to where you see:<br />
		<code><br />
			# Virtual hosts<br />
			#Include conf/extra/httpd-vhosts.conf<br />
		</code>
	</p>
</li>
<li>
<p>
		In Terminal press &#8220;i&#8221;. This will take you into edit mode to edit the file.
	</p>
</li>
<li>
<p>
		Remove the &#8220;#&#8221; before &#8220;Include&#8221;. It should look like this now:<br />
		<code><br />
			# Virtual hosts<br />
			Include conf/extra/httpd-vhosts.conf<br />
		</code>
	</p>
</li>
<li>
<p>
		Press the escape key to exit out of edit mode. Press &#8220;:x&#8221; to save your changes.
	</p>
</li>
<li>
<p>
		Now we are going to edit our httpd-vhosts.conf file. In Terminal type:<br />
		<code><br />
			sudo vi /usr/local/zend/apache2/conf/extra/httpd-vhosts.conf<br />
		</code>
	</p>
<p>
		Enter your password when prompted
	</p>
</li>
<li>
<p>
		In Terminal press &#8220;i&#8221; to go into edit mode.
	</p>
</li>
<li>
<p>
		Use the up, down, left, right arrow keys to scroll down to where you see:<br />
		<code><br />
			NameVirtualHost *:10088<br />
		</code>
	</p>
<p>
		In the previous tutorial we change the port to 80. So now we have to change this line to read:<br />
		<code><br />
			NameVirtualHost *:80<br />
		</code>
	</p>
</li>
<li>
<p>
		Let&#8217;s say you want to have a local virtual host for http://www.super-awesome.local that needs to be pointed at the /Users/YOUR_USERNAME/Sites/super-awesome directory. We need to add the following to the httpd-vhosts.conf file:<br />
		<code><br />
			&lt;VirtualHost *:80&gt;<br />
			&nbsp;&nbsp;&nbsp;&nbsp;DocumentRoot "/Users/YOUR_USERNAME/Sites/super-awesome"<br />
			&nbsp;&nbsp;&nbsp;&nbsp;ServerName www.super-awesome.local<br />
			&nbsp;&nbsp;&nbsp;&nbsp;ServerAlias super-awesome.local<br />
			&lt;/VirtualHost&gt;<br />
		</code>
	</p>
<p>
		* Note: .local is just what I picked. You can change that to .dev or .blah or whatever you like. Try to stay away from common domain extensions like .com or .net. And, yes, you can end it with more than one extension like .foo.bar
	</p>
</li>
<li>
<p>
		Press the escape key to exit out of edit mode. Press &#8220;:x&#8221; to save your changes.
	</p>
</li>
<li>
<p>
		It&#8217;s probably a good idea to make sure we didn&#8217;t mess up syntax or spelling. In Terminal type:<br />
		<code><br />
			sudo apachectl configtest<br />
			sudo apachectl graceful<br />
		</code>
	</p>
<p>
		Enter your password if prompted
	</p>
<p>
		If there are any errors they will be displayed to you. Repeat steps 10 and 11 as many times as needed.
	</p>
</li>
<li>
<p>
		Let&#8217;s go ahead and restart Zend Server so it can get the changes. In Terminal type:<br />
		<code><br />
			sudo /usr/local/zend/bin/zendctl.sh restart<br />
		</code>
	</p>
<p>
		Enter your password if prompted
	</p>
</li>
<li>
<p>
		Browse to either http://www.super-awesome.local or http://super-awesome.local and your site should display
	</p>
</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.witheringtree.com/2011/07/setting-up-virtual-hosts-in-zend-server-ce-on-os-x/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Installing Zend Server CE on OS X: A Guide For the Terminal Timid</title>
		<link>http://www.witheringtree.com/2011/07/installing-zend-server-ce-on-os-x-a-guide-for-the-terminal-timid/</link>
		<comments>http://www.witheringtree.com/2011/07/installing-zend-server-ce-on-os-x-a-guide-for-the-terminal-timid/#comments</comments>
		<pubDate>Sat, 16 Jul 2011 17:29:56 +0000</pubDate>
		<dc:creator>David Freerksen</dc:creator>
				<category><![CDATA[Mac]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[Tips/Tricks]]></category>

		<guid isPermaLink="false">http://www.witheringtree.com/?p=921</guid>
		<description><![CDATA[I use MAMP Pro both at home and at work for development. It quick, it&#8217;s easy and I really don&#8217;t have to fiddle with it a lot after it is set up. It&#8217;s perfect for me. At work we have a project to be built with Codeigniter sitting on a Linux machine but we wanted &#8230; <a href="http://www.witheringtree.com/2011/07/installing-zend-server-ce-on-os-x-a-guide-for-the-terminal-timid/" title="Continue reading">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>
	I use <a href="http://mamp.info/" title="MAMP Pro" target="_blank">MAMP Pro</a> both at home and at work for development. It quick, it&#8217;s easy and I really don&#8217;t have to fiddle with it a lot after it is set up. It&#8217;s perfect for me.
</p>
<p>
	At work we have a project to be built with <a href="http://www.codeigniter.com/" title="Codeigniter" target="_blank">Codeigniter</a> sitting on a Linux machine but we wanted to use Microsoft SQL Server on a different machine as the database. Turns out, it&#8217;s not a simple as changing the database type in Codeigniter to &#8220;mssql&#8221; to get it up and running. If this is all you do, you get the dreaded white screen. You need a PHP extension to do it. Problem is, Microsoft only makes this PHP extension for Windows. There are a lot of tutorials out there on how to build the extension yourself on Mac or Linux machine (<a href="http://www.dotvoid.com/2010/01/adding-support-for-ms-sql-server-to-php-in-linux/" target="_blank">this site for example</a>), but none seemed to work for me.
</p>
<p>
	Instead of setting up a Windows virtual machine and being forced into developing that way, I decided to install Zend Server CE. Zend comes with a MSSQL extension, it just needs to be enabled.
</p>
<p>
	This tutorial does include Terminal work. I am going to walk through step-by-step, so even if you are not comfortable with Terminal, you will be up and running with Zend Server CE in no time. The only requirement is you are running an Intel Mac OS X.
</p>
<p><span id="more-921"></span></p>
<ol>
<li>
<p>
			<a href="http://www.zend.com/en/products/server-ce/index" title="Zend Server CE" target="_blank">Download Zend Server CE</a>. CE (Community Edition) is free.
		</p>
</li>
<li>
<p>
			Install Zend Server CE like you would any other application. You can optionally drop/drop Zend Controller.app into your applications directory if you want.
		</p>
</li>
<p>
			Once installed, in your applications directory, open ZendServer.app. This will open a browser window. Go through the three steps. Congratulations! You have Zend Server CE set up and running. But we aren&#8217;t done yet.
		</p>
<p>
			By default, the root folder of your Zend Server is at /usr/local/zend/htdocs. Since /usr is a hidden directory, it&#8217;s not easily accessible.
		</p>
<p>
			But first&#8230;
		</p>
</li>
<li>
<p>
			Open Terminal. Terminal can be found at /Applications/Utilities/Terminal.app
		</p>
<p>
			You can also open it from Spotlight by typing &#8220;Terminal&#8221;
		</p>
</li>
<li>
<p>
			OS X comes with Apache already installed. We don&#8217;t want to use that version. We want to use the Zend Server version.
		</p>
<p>
			In Terminal type:<br />
			<code><br />
				sudo /usr/local/zend/bin/zendctl.sh stop<br />
			</code><br />
			To stop Zend Server. Then type:<br />
			<code><br />
			sudo apachectl stop<br />
			</code></p>
<p>
			Enter your password if prompted
		</p>
</li>
<li>
<p>
			We need to move apachectl to a safe place, such as your home directory. In Terminal type:<br />
			<code><br />
				cd /usr/sbin/<br />
				sudo mv apachectl /Users/YOUR_USERNAME/<br />
			</code>
		</p>
</li>
<li>
<p>
			Then create a symbolic link to Zend Server&#8217;s apachectl. In Terminal type:<br />
			<code><br />
				sudo ln -s /usr/local/zend/apache2/bin/apachectl ./<br />
			</code>
		</p>
</li>
<li>
<p>
			Start Zend Server&#8217;s Apache. In Terminal type:<br />
			<code><br />
				sudo apachectl start<br />
			</code>
		</p>
<p>
			You should then see:<br ><br />
			<code><br />
				/usr/sbin/apachectl start [OK]<br />
			</code>
		</p>
</li>
<li>
<p>
			If you go to http://localhost/ in your browser, you will either get a forbidden or a 404 message. We&#8217;ll change that next.
		</p>
</li>
<li>
<p>
			Zend Studio&#8217;s Apache comes preconfigured to use port 10088. Let&#8217;s change this to port 80 like the default Apache port uses.
		</p>
<p>
			Now we are getting into <a href="http://en.wikipedia.org/wiki/Vi" target="_blank">vi</a> editing. I think this scares a lot of people. But don&#8217;t worry. It&#8217;s very simple.
		</p>
<p>
			We are going to edit our httpd.conf file. In Terminal type:<br />
			<code><br />
				sudo vi /usr/local/zend/apache2/conf/httpd.conf<br />
			</code>
		</p>
<p>
			Enter your password when prompted
		</p>
</li>
<li>
<p>
			You are in vi edit mode so you won&#8217;t be able to type in Terminal like you normally would. Typing only gives you the the OS X bump sound. That&#8217;s normal. You can use the up, down, left, right arrow keys.
		</p>
<p>
			Look for the line that says &#8220;Listen 10088&#8243;
		</p>
<p>
			In Terminal, type &#8220;i&#8221; to go into edit mode to start editing the file. At the bottom of the Terminal window it will say &#8220;&#8211; INSERT &#8211;&#8221; to notify you that you are editing the file.
		</p>
</li>
<li>
<p>
			With your blinker over the &#8220;L&#8221; on &#8220;Listen&#8221;, type &#8220;#&#8221; to comment out that line
		</p>
<p>
			Use the down arrow to go to the next line.
		</p>
<p>
			Type:<br />
			<code><br />
				Listen 80<br />
			</code>
		</p>
</li>
<li>
<p>
			Since we are already editing this file, we will go ahead and change our root directory since, as I mentioned earlier, the /usr directory is a hidden directory.
		</p>
<p>
			Use the down arrow to scroll down to where it says<br />
			<code><br />
				DocumentRoot "/usr/local/zend/apache2/htdocs"<br />
			</code>
		</p>
<p>
			With your blinker over the &#8220;D&#8221; on &#8220;DocumentRoot&#8221;, type &#8220;#&#8221; to comment out that line
		</p>
<p>
			Use the down arrow to go to the next line.
		</p>
<p>
			Type:<br />
			<code><br />
				DocumentRoot "/Users/YOUR_USERNAME/Sites"<br />
			</code>
		</p>
<p>
			This is the default web root for OS X sites. This is a pretty good place to put out root as well.
		</p>
</li>
<li>
<p>
			Use the down arrow again to scroll down to where it says<br />
			<code><br />
				&lt;Directory "/usr/local/zend/apache2/htdocs"&gt;<br />
			</code>
		</p>
<p>
			With your blinker over the &#8220;&lt;&#8221;, type &#8220;#&#8221; to comment out that line
		</p>
<p>
			Use the down arrow to go to the next line.
		</p>
<p>
			Type:<br />
			<code><br />
				&lt;Directory "/Users/YOUR_USERNAME/Sites"&gt;<br />
			</code>
	</li>
<li>
<p>
			We are done editing this file. Now we need to save it. In Terminal, hit the escape key to edit out of editing mode. The &#8220;&#8211; INSERT &#8211;&#8221; at the bottom will go away.
		</p>
<p>
			In Terminal again, type &#8220;:x&#8221;. This exits vi mode and saves what you changed
		</p>
</li>
<li>
<p>
			Restart apachectl type typing:<br />
			<code><br />
				sudo apachectl restart<br />
			</code>
		</p>
<p>
			Enter your password when prompted
		</p>
</li>
<li>
<p>			If you go to http://localhost/ in your browser, you will see the default Mac OS X homepage now.
		</p>
</li>
<li>
<p>
			To configure Zend Framework, type:<br />
			<code><br />
				sudo ln -s /usr/local/zend/share/ZendFramework/bin/zf.sh ./zf<br />
			</code>
	</li>
<li>
<p>
			To Configure Pear, type<br />
			<code><br />
				sudo ln -s /usr/local/zend/bin/pear ./<br />
				sudo pear upgrade pear<br />
			</code>
		</p>
</li>
<li>
<p>
			Now we have to configure MySQL. In terminal type:<br />
			<code><br />
				sudo ln -s /usr/local/zend/mysql/bin/mysql ./<br />
				sudo ln -s /usr/local/zend/mysql/bin/mysqladmin ./<br />
			</code>
		</p>
</li>
<li>
<p>
			We have to edit some settings in my.cnf for MySQL, so we go back to vi. In Terminal, type:<br />
			<code><br />
				sudo vi /usr/local/zend/mysql/data/my.cnf<br />
			</code>
		</p>
<p>
			To edit the file, it is similar to what you did in step 10.
		</p>
<p>
			Use the down arrow to scroll down to where it says:<br />
			<code><br />
				socket = /usr/local/zend/mysql/tmp/mysql.sock<br />
			</code>
		</p>
<p>
			With your blinker over the &#8220;s&#8221; on &#8220;socket&#8221;, type &#8220;#&#8221; to comment out that line
		</p>
<p>
			Use the down arrow to go to the next line.
		</p>
<p>
			Type:<br />
			<code><br />
				socket = /tmp/mysql.sock<br />
			</code>
		</p>
</li>
<li>
<p>
			By default, the password that comes with Zend Server is blank. You can change this by removing the &#8220;#&#8221; next to &#8220;password&#8221; and then changing &#8220;you_password&#8221; to whatever you want. Make sure you remember what the password is though.
		</p>
</li>
<li>
<p>
			To save the file, it is similar to what you did in step 14.
		</p>
</li>
<li>
<p>
			Configure phpMyAdmin. Since we changed the web root for Apache, we will have to create a Directory entry and Alias for phpMyAdmin, since it exists somewhere else. To edit the httpd.conf file again, in Terminal type:<br />
			<code><br />
				sudo vi /usr/local/zend/apache2/conf/httpd.conf<br />
			</code>
		</p>
<p>
			Enter your password when prompted
		</p>
</li>
<li>
<p>
			To start editing the file, use similar steps from step 10.
		</p>
<p>
			Somewhere in the file (I put it at the very end), type:<br />
			<code><br />
				Alias /phpMyAdmin /usr/local/zend/share/phpmyadmin<br />
				&lt;Directory "/usr/local/zend/share/phpmyadmin"&gt;<br />
					&nbsp;&nbsp;&nbsp;&nbsp;Options Indexes FollowSymLinks<br />
					&nbsp;&nbsp;&nbsp;&nbsp;AllowOverride All<br />
					&nbsp;&nbsp;&nbsp;&nbsp;Order allow,deny<br />
					&nbsp;&nbsp;&nbsp;&nbsp;Allow from all<br />
				&lt;/Directory&gt;<br />
			</code>
		</p>
<p>
			* Hint: Yes, you can copy/paste this if you don&#8217;t want to type it all out yourself.
		</p>
<p>
			To save the file, use similar steps from step 14.
		</p>
</li>
<li>
		Go ahead and restart Zend Server. In Terminal, type:<br />
		sudo /usr/local/zend/bin/zendctl.sh restart
	</li>
</ol>
<h3>Where do I put the file for my website(s)?</h3>
<p>
	Files will be places in /Users/YOUR_USERNAME/Sites
</p>
<p>
	Yes, of course you can create directories within that folder.
</p>
<h3>What is the URL for my site?</h3>
<p>
	The root of your site is now at <a href="http://localhost/" target="_blank">http://localhost/</a> If you have a directory within the /Users/YOUR_USERNAME/Sites directory, the URL would become http://localhost/FOLDER_NAME
</p>
<p>
	To configure Zend Server, you can get to it by going to <a href="http://localhost:10081/ZendServer/" target="_blank">http://localhost:10081/ZendServer/</a> or simply by opening ZendServer.app
</p>
<p>
	phpMyAdmin is located at <a href="http://localhost/phpMyAdmin" target="_blank">http://localhost/phpMyAdmin</a> The default username is &#8220;zend&#8221; and the password is left blank. You can also use &#8220;root&#8221; as the username. Again, with no password.
</p>
<h3>How do I start/stop/restart Zend Server?</h3>
<p>
	To start Zend Server, in Terminal type:<br />
	<code><br />
		sudo /usr/local/zend/bin/zendctl.sh start<br />
	</code>
</p>
<p>
	To stop Zend Server, in Terminal type:<br />
	<code><br />
		sudo /usr/local/zend/bin/zendctl.sh stop<br />
	</code>
</p>
<p>
	To restart Zend Server, in Terminal type:<br />
	<code><br />
		sudo /usr/local/zend/bin/zendctl.sh restart<br />
	</code>
</p>
<h3>Uninstalling Zend Server</h3>
<ol>
<li>
<p>
			Open Terminal
		</p>
</li>
<li>
<p>
			Enter<br />
			<code><br />
				sudo /usr/local/zend/bin/uninstall.sh<br />
			</code>
		</p>
<p>
			This will:</p>
<ol>
<li>Stop all Zend Server processes</li>
<li>Delete all Zend Server installed files</li>
<li>Remove the ZendServer.app from /Applications</li>
<li>Remove Zend users</li>
</ol>
</li>
<li>
<p>
			It will ask for your password. Enter your password
		</p>
</li>
<li>
<p>
			It will ask you if you are sure you want to remove Zend Server. Type &#8220;yes&#8221; (without the double quotes)
		</p>
</li>
<li>
<p>
			It tells you it will a couple directories, including your MySQL databases. Type &#8220;cont&#8221; (without the double quotes) to continue
		</p>
</li>
<li>
<p>
			In your applications directory, drag Zend Controller.app to the trash (if it is installed)
		</p>
</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.witheringtree.com/2011/07/installing-zend-server-ce-on-os-x-a-guide-for-the-terminal-timid/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

