<?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>LAMP with ·dotmanila &#187; HTML</title>
	<atom:link href="http://dotmanila.com/blog/category/html/feed/" rel="self" type="application/rss+xml" />
	<link>http://dotmanila.com/blog</link>
	<description>Linux Security, Apache Tuning, MySQL Optimization and PHP Programming</description>
	<lastBuildDate>Sun, 01 Aug 2010 01:54:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Zend_Validate_StringEquals</title>
		<link>http://dotmanila.com/blog/2010/01/zend_validate_stringequals/</link>
		<comments>http://dotmanila.com/blog/2010/01/zend_validate_stringequals/#comments</comments>
		<pubDate>Sat, 23 Jan 2010 14:54:23 +0000</pubDate>
		<dc:creator>jervin</dc:creator>
				<category><![CDATA[Application Security]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[ZendFramework]]></category>
		<category><![CDATA[Zend_Input_Filter]]></category>
		<category><![CDATA[Zend_Validate]]></category>

		<guid isPermaLink="false">http://dotmanila.com/blog/?p=121</guid>
		<description><![CDATA[If you ever wonder where that 'StringEquals' validator rule taken as example from the Zend_Filter_Input documentation page results in an error like below, well read again. It was clearly stated as 'hypothetical'. Plugin by name 'StringEquals' was not found in the registry; used paths: Zend_Validate_: Zend/Validate/ Given such validator would be useful on a number [...]]]></description>
			<content:encoded><![CDATA[<p>If you ever wonder where that 'StringEquals' validator rule taken as example from the Zend_Filter_Input documentation page results in an error like below, well read again. It was clearly stated as 'hypothetical'.</p>
<blockquote>
<h3>Plugin by name 'StringEquals' was not found in the registry; used paths: Zend_Validate_: Zend/Validate/</h3>
</blockquote>
<p>Given such validator would be useful on a number of situations i.e. confirming passwords, emails, etc. I present to you my own version of the class.</p>
<pre class="php"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">&lt;?php</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">class</span> Zend_Validate_StringEquals <span style="color: #000000; font-weight: bold;">extends</span> Zend_Validate_Abstract</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    const NOT_EQUAL	= <span style="color: #ff0000;">'stringNotEqual'</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    const MISSING	= <span style="color: #ff0000;">'stringMissing'</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #808080; font-style: italic;">/**</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp;    * @var array</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp;    */</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    protected <span style="color: #0000ff;">$_messageTemplates</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        self::<span style="color: #006600;">NOT_EQUAL</span>	=&gt; <span style="color: #ff0000;">&quot;%field1% and %field2% are not equal.&quot;</span>,</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        self::<span style="color: #006600;">MISSING</span>	=&gt; <span style="color: #ff0000;">&quot;One or both strings are missing.&quot;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #808080; font-style: italic;">/**</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp;    * @var array</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp;    */</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    protected <span style="color: #0000ff;">$_messageVariables</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #ff0000;">'field1'</span> =&gt; <span style="color: #ff0000;">'_field1'</span>,</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #ff0000;">'field2'</span> =&gt; <span style="color: #ff0000;">'_field2'</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    protected <span style="color: #0000ff;">$_case</span> = <span style="color: #000000; font-weight: bold;">false</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    protected <span style="color: #0000ff;">$_field1</span> = <span style="color: #000000; font-weight: bold;">null</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    protected <span style="color: #0000ff;">$_field2</span> = <span style="color: #000000; font-weight: bold;">null</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #808080; font-style: italic;">/**</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp;    * Sets validator options</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp;    *</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp;    * @param  boolean $case</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp;    * @return void</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp;    */</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$case</span> = <span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #0000ff;">$this</span>-&gt;_case = <span style="color: #0000ff;">$case</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #808080; font-style: italic;">/**</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp;    * Defined by Zend_Validate_Interface</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp;    *</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp;    * Returns true if and only if the the 2 strings are equal</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp;    *</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp;    * @param  array $value</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp;    * @return boolean</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp;    */</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> isValid<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$value</span><span style="color: #66cc66;">&#41;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    	<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>!<a href="http://www.php.net/is_array"><span style="color: #000066;">is_array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$value</span><span style="color: #66cc66;">&#41;</span> OR <a href="http://www.php.net/sizeof"><span style="color: #000066;">sizeof</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$value</span><span style="color: #66cc66;">&#41;</span> &lt; <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">			<span style="color: #0000ff;">$this</span>-&gt;_error<span style="color: #66cc66;">&#40;</span>self::<span style="color: #006600;">MISSING</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    	<span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    	<span style="color: #0000ff;">$this</span>-&gt;_field1 = <a href="http://www.php.net/array_shift"><span style="color: #000066;">array_shift</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$value</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    	<span style="color: #0000ff;">$this</span>-&gt;_field2 = <a href="http://www.php.net/array_shift"><span style="color: #000066;">array_shift</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$value</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$this</span>-&gt;_case === <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span> <span style="color: #0000ff;">$function</span> = <span style="color: #ff0000;">'strcmp'</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #b1b100;">else</span> <span style="color: #0000ff;">$function</span> = <span style="color: #ff0000;">'strcasecmp'</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span> !== <span style="color: #0000ff;">$function</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$this</span>-&gt;_field1,<span style="color: #0000ff;">$this</span>-&gt;_field2<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #0000ff;">$this</span>-&gt;_error<span style="color: #66cc66;">&#40;</span>self::<span style="color: #006600;">NOT_EQUAL</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/count"><span style="color: #000066;">count</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$this</span>-&gt;_messages<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">            <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">false</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">            <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">true</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p>Here is a sample test case. Validate password and confirm password elements represented by 'password' and 'cpassword' element names respectively.</p>
<pre class="php"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$filters</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'password'</span> =&gt; <span style="color: #ff0000;">'StringTrim'</span>, <span style="color: #ff0000;">'cpassword'</span> =&gt; <span style="color: #ff0000;">'StringTrim'</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$validators</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #ff0000;">'Password'</span> =&gt; <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #ff0000;">'presence'</span> =&gt; <span style="color: #ff0000;">'required'</span>,</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'StringLength'</span>,<span style="color: #cc66cc;">5</span>,<span style="color: #cc66cc;">15</span><span style="color: #66cc66;">&#41;</span>,</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #ff0000;">'fields'</span> =&gt; <span style="color: #ff0000;">'password'</span>,</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #ff0000;">'messages'</span> =&gt; <span style="color: #ff0000;">&quot;Passwords must be between 5 and 15 characters in length.&quot;</span><span style="color: #66cc66;">&#41;</span>,</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #ff0000;">'Confirm password'</span> =&gt; <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'StringEquals'</span><span style="color: #66cc66;">&#41;</span>,</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #ff0000;">'fields'</span> =&gt; <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'password'</span>,<span style="color: #ff0000;">'cpassword'</span><span style="color: #66cc66;">&#41;</span>,</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #ff0000;">'messages'</span> =&gt; <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">            <span style="color: #cc66cc;">0</span> =&gt; <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">                Zend_Validate_StringEquals::<span style="color: #006600;">NOT_EQUAL</span> =&gt; <span style="color: #ff0000;">&quot;Passwords does not match.&quot;</span>,</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">                Zend_Validate_StringEquals::<span style="color: #006600;">MISSING</span> =&gt; <span style="color: #ff0000;">&quot;Both password fields must be filled.&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$inputdata</span> = <span style="color: #000000; font-weight: bold;">new</span> Zend_Filter_Input<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$filter</span>,<span style="color: #0000ff;">$validators</span>,<span style="color: #0000ff;">$_POST</span>,<span style="color: #0000ff;">$options</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-knowledge">
<ul class="socials">
		<li class="shr-blogger">
			<a href="http://www.blogger.com/blog_this.pyra?t&amp;u=http://dotmanila.com/blog/2010/01/zend_validate_stringequals/&amp;n=Zend_Validate_StringEquals&amp;pli=1" rel="nofollow" class="external" title="Blog this on Blogger">Blog this on Blogger</a>
		</li>
		<li class="shr-comfeed">
			<a href="http://dotmanila.com/blog/2010/01/zend_validate_stringequals/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://dotmanila.com/blog/2010/01/zend_validate_stringequals/&amp;title=Zend_Validate_StringEquals" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://dotmanila.com/blog/2010/01/zend_validate_stringequals/&amp;t=Zend_Validate_StringEquals" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-gmail">
			<a href="https://mail.google.com/mail/?ui=2&amp;view=cm&amp;fs=1&amp;tf=1&amp;su=Zend_Validate_StringEquals&amp;body=Link: http://dotmanila.com/blog/2010/01/zend_validate_stringequals/ (sent via shareaholic)%0D%0A%0D%0A----%0D%0A If%20you%20ever%20wonder%20where%20that%20%27StringEquals%27%20validator%20rule%20taken%20as%20example%20from%20the%20Zend_Filter_Input%20documentation%20page%20results%20in%20an%20error%20like%20below%2C%20well%20read%20again.%20It%20was%20clearly%20stated%20as%20%27hypothetical%27.%0D%0A%0D%0APlugin%20by%20name%20%27StringEquals%27%20was%20not%20found%20in%20the%20registry%3B%20used%20paths%3A%20Zend_Valida" rel="nofollow" class="external" title="Email this via Gmail">Email this via Gmail</a>
		</li>
		<li class="shr-googlebookmarks">
			<a href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://dotmanila.com/blog/2010/01/zend_validate_stringequals/&amp;title=Zend_Validate_StringEquals" rel="nofollow" class="external" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
		<li class="shr-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://dotmanila.com/blog/2010/01/zend_validate_stringequals/&amp;title=Zend_Validate_StringEquals&amp;summary=If%20you%20ever%20wonder%20where%20that%20%27StringEquals%27%20validator%20rule%20taken%20as%20example%20from%20the%20Zend_Filter_Input%20documentation%20page%20results%20in%20an%20error%20like%20below%2C%20well%20read%20again.%20It%20was%20clearly%20stated%20as%20%27hypothetical%27.%0D%0A%0D%0APlugin%20by%20name%20%27StringEquals%27%20was%20not%20found%20in%20the%20registry%3B%20used%20paths%3A%20Zend_Valida&amp;source=LAMP with ·dotmanila" rel="nofollow" class="external" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://dotmanila.com/blog/2010/01/zend_validate_stringequals/&amp;title=Zend_Validate_StringEquals" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Zend_Validate_StringEquals+-+http://b2l.me/adk2nc&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://dotmanila.com/blog/2010/01/zend_validate_stringequals/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fetch Smarty Templates From MySQL Database</title>
		<link>http://dotmanila.com/blog/2009/03/fetch-smarty-templates-from-mysql-database/</link>
		<comments>http://dotmanila.com/blog/2009/03/fetch-smarty-templates-from-mysql-database/#comments</comments>
		<pubDate>Sun, 22 Mar 2009 11:40:57 +0000</pubDate>
		<dc:creator>jervin</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[php smarty]]></category>
		<category><![CDATA[smarty mysql]]></category>
		<category><![CDATA[templates database]]></category>

		<guid isPermaLink="false">http://dotmanila.com/blog/?p=48</guid>
		<description><![CDATA[I was recently working on a mailing application. With the nature of the bulk mailing routine, it was designed to store templates made by its users and email designers. Since most of them have been exposed to Smarty templating before we decided to base our email template parsing to Smarty.]]></description>
			<content:encoded><![CDATA[<p>I was recently working on a mailing application. With the nature of the bulk mailing routine, it was designed to store templates made by its users and email designers. Since most of them have been exposed to Smarty templating before we decided to base our email template parsing to Smarty.</p>
<p>Smarty does not come with the ability to parse templates from database natively, but it is easy to extend it to do just that.</p>
<p>DISCLAIMER: This is a quick and dirty hack I provided with my colleagues. Improvement required!</p>
<p>This approach should work on both PHP 4 and PHP 5, since Smarty.class.php is written on PHP 4.</p>
<p>What we will need to do is extend Smarty.class.php on a new class and override function <code>_fetch_resource_info</code> and replace the <code>if</code> clause demonstrated below to use our code that actually fetches database stored templates.</p>
<pre>
class Smarty
{
    function _fetch_resource_info(&amp;$params) {
        ....
        if ($this->_parse_resource_name($_params)) {
            .....
        }
        ....
    }
}
</pre>
<p>Our resulting class would look something like:</p>
<pre>
require_once 'Smarty.class.php';

class Smarty_Db extends Smarty
{
    function _fetch_resource_info(&amp;$params) {
        ....
        $_resource_type = $_params['resource_type'];
        $_resource_name = $_params['resource_name'];

	$db = new Template_Db;
	if ($params['get_source']) {
            $params['source_content'] = $db->fetchTemplate($myTemplateId);
        }
	$params['resource_timestamp'] = now();
        $_return = true;
        ....
    }
}
</pre>
<p>So you would then use your Smarty extended class like:</p>
<pre>
$smarty = new Smarty_Db;
$smarty->compile_dir = '/path/to/my/compile/dir';

$compiledTemplateFromDb = $smarty->fetch($myTemplateId);
</pre>
<p>That is all there is to it actually. I haven't went through all the Smarty pre and post processing, but this should suffice the requirements for now.</p>
<p>Hope this helps.</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-knowledge">
<ul class="socials">
		<li class="shr-blogger">
			<a href="http://www.blogger.com/blog_this.pyra?t&amp;u=http://dotmanila.com/blog/2009/03/fetch-smarty-templates-from-mysql-database/&amp;n=Fetch+Smarty+Templates+From+MySQL+Database&amp;pli=1" rel="nofollow" class="external" title="Blog this on Blogger">Blog this on Blogger</a>
		</li>
		<li class="shr-comfeed">
			<a href="http://dotmanila.com/blog/2009/03/fetch-smarty-templates-from-mysql-database/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://dotmanila.com/blog/2009/03/fetch-smarty-templates-from-mysql-database/&amp;title=Fetch+Smarty+Templates+From+MySQL+Database" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://dotmanila.com/blog/2009/03/fetch-smarty-templates-from-mysql-database/&amp;t=Fetch+Smarty+Templates+From+MySQL+Database" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-gmail">
			<a href="https://mail.google.com/mail/?ui=2&amp;view=cm&amp;fs=1&amp;tf=1&amp;su=Fetch+Smarty+Templates+From+MySQL+Database&amp;body=Link: http://dotmanila.com/blog/2009/03/fetch-smarty-templates-from-mysql-database/ (sent via shareaholic)%0D%0A%0D%0A----%0D%0A I%20was%20recently%20working%20on%20a%20mailing%20application.%20With%20the%20nature%20of%20the%20bulk%20mailing%20routine%2C%20it%20was%20designed%20to%20store%20templates%20made%20by%20its%20users%20and%20email%20designers.%20Since%20most%20of%20them%20have%20been%20exposed%20to%20Smarty%20templating%20before%20we%20decided%20to%20base%20our%20email%20template%20parsing%20to%20Smarty." rel="nofollow" class="external" title="Email this via Gmail">Email this via Gmail</a>
		</li>
		<li class="shr-googlebookmarks">
			<a href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://dotmanila.com/blog/2009/03/fetch-smarty-templates-from-mysql-database/&amp;title=Fetch+Smarty+Templates+From+MySQL+Database" rel="nofollow" class="external" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
		<li class="shr-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://dotmanila.com/blog/2009/03/fetch-smarty-templates-from-mysql-database/&amp;title=Fetch+Smarty+Templates+From+MySQL+Database&amp;summary=I%20was%20recently%20working%20on%20a%20mailing%20application.%20With%20the%20nature%20of%20the%20bulk%20mailing%20routine%2C%20it%20was%20designed%20to%20store%20templates%20made%20by%20its%20users%20and%20email%20designers.%20Since%20most%20of%20them%20have%20been%20exposed%20to%20Smarty%20templating%20before%20we%20decided%20to%20base%20our%20email%20template%20parsing%20to%20Smarty.&amp;source=LAMP with ·dotmanila" rel="nofollow" class="external" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://dotmanila.com/blog/2009/03/fetch-smarty-templates-from-mysql-database/&amp;title=Fetch+Smarty+Templates+From+MySQL+Database" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Fetch+Smarty+Templates+From+MySQL+Database+-+http://b2l.me/adk3cc&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://dotmanila.com/blog/2009/03/fetch-smarty-templates-from-mysql-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CSS Gradient Text Effect</title>
		<link>http://dotmanila.com/blog/2009/01/css-gradient-text-effect/</link>
		<comments>http://dotmanila.com/blog/2009/01/css-gradient-text-effect/#comments</comments>
		<pubDate>Sun, 04 Jan 2009 11:30:42 +0000</pubDate>
		<dc:creator>jervin</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[css effects]]></category>
		<category><![CDATA[text gradients]]></category>

		<guid isPermaLink="false">http://dotmanila.com/blog/?p=34</guid>
		<description><![CDATA[This is a very useful and cool CSS design approach, saves time and effort and still SEO friendly. Hit the link for more.]]></description>
			<content:encoded><![CDATA[<p>This is a very useful and cool CSS design approach, saves time and effort and still SEO friendly. Hit the link for more.</p>
<blockquote><p>Do you want to create fancy headings without rendering each heading with Photoshop? Here is a simple CSS trick to show you how to create gradient text effect with a PNG image (pure CSS, no Javascript or Flash). All you need is an empty <span> tag in the heading and apply the background image overlay using the CSS position:absolute property. This trick has been tested on most browsers: Firefox, Safari, Opera, and even Internet Explorer 6. Continue to read this article to find out how.<br />
</span></p></blockquote>
<p><a href="http://www.webdesignerwall.com/tutorials/css-gradient-text-effect/" target="_blank">http://www.webdesignerwall.com/tutorials/css-gradient-text-effect/</a></p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-knowledge">
<ul class="socials">
		<li class="shr-blogger">
			<a href="http://www.blogger.com/blog_this.pyra?t&amp;u=http://dotmanila.com/blog/2009/01/css-gradient-text-effect/&amp;n=CSS+Gradient+Text+Effect&amp;pli=1" rel="nofollow" class="external" title="Blog this on Blogger">Blog this on Blogger</a>
		</li>
		<li class="shr-comfeed">
			<a href="http://dotmanila.com/blog/2009/01/css-gradient-text-effect/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://dotmanila.com/blog/2009/01/css-gradient-text-effect/&amp;title=CSS+Gradient+Text+Effect" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://dotmanila.com/blog/2009/01/css-gradient-text-effect/&amp;t=CSS+Gradient+Text+Effect" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-gmail">
			<a href="https://mail.google.com/mail/?ui=2&amp;view=cm&amp;fs=1&amp;tf=1&amp;su=CSS+Gradient+Text+Effect&amp;body=Link: http://dotmanila.com/blog/2009/01/css-gradient-text-effect/ (sent via shareaholic)%0D%0A%0D%0A----%0D%0A This%20is%20a%20very%20useful%20and%20cool%20CSS%20design%20approach%2C%20saves%20time%20and%20effort%20and%20still%20SEO%20friendly.%20Hit%20the%20link%20for%20more." rel="nofollow" class="external" title="Email this via Gmail">Email this via Gmail</a>
		</li>
		<li class="shr-googlebookmarks">
			<a href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://dotmanila.com/blog/2009/01/css-gradient-text-effect/&amp;title=CSS+Gradient+Text+Effect" rel="nofollow" class="external" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
		<li class="shr-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://dotmanila.com/blog/2009/01/css-gradient-text-effect/&amp;title=CSS+Gradient+Text+Effect&amp;summary=This%20is%20a%20very%20useful%20and%20cool%20CSS%20design%20approach%2C%20saves%20time%20and%20effort%20and%20still%20SEO%20friendly.%20Hit%20the%20link%20for%20more.&amp;source=LAMP with ·dotmanila" rel="nofollow" class="external" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://dotmanila.com/blog/2009/01/css-gradient-text-effect/&amp;title=CSS+Gradient+Text+Effect" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=CSS+Gradient+Text+Effect+-+http://b2l.me/adxf2b&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://dotmanila.com/blog/2009/01/css-gradient-text-effect/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
