<?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>Grep My Mind &#187; PHP</title>
	<atom:link href="http://www.grepmymind.com/topics/web-development/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.grepmymind.com</link>
	<description>Wonder what’s on my mind? Now you know.</description>
	<lastBuildDate>Wed, 14 Oct 2009 22:20:07 +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>Diving into the Yahoo! Open Stack &#8211; SF PHP Meetup April 2nd, 2009</title>
		<link>http://www.grepmymind.com/2009/03/11/diving-into-the-yahoo-open-stack-sf-php-meetup-april-2nd-2009/</link>
		<comments>http://www.grepmymind.com/2009/03/11/diving-into-the-yahoo-open-stack-sf-php-meetup-april-2nd-2009/#comments</comments>
		<pubDate>Wed, 11 Mar 2009 16:03:35 +0000</pubDate>
		<dc:creator>Michael Tougeron</dc:creator>
				<category><![CDATA[Events]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[dustin whittle]]></category>
		<category><![CDATA[php meetup]]></category>
		<category><![CDATA[yahoo!]]></category>
		<category><![CDATA[yahoo! open stack]]></category>

		<guid isPermaLink="false">http://www.grepmymind.com/?p=319</guid>
		<description><![CDATA[When: 6:30pm Thursday April 2nd, 2009 Where: CBS Interactive &#8211; 235 2nd Street San Francisco, CA RSVP: Diving into the Yahoo! Open Stack Join the SF PHP Meetup for an exploration into the Yahoo! Open Stack and learn how to leverage Yahoo&#8217;s platforms and scalability to build your next application. We will examine the components [...]]]></description>
			<content:encoded><![CDATA[<p>When: 6:30pm Thursday April 2nd, 2009<br />
Where: CBS Interactive &#8211; 235 2nd Street San Francisco, CA<br />
RSVP: <a href="http://www.meetup.com/sf-php/calendar/9864926/">Diving into the Yahoo! Open Stack</a></p>
<hr />
Join the <a href="http://www.meetup.com/sf-php/">SF PHP Meetup</a> for an exploration into the <a href="http://developer.yahoo.com/" target="_blank">Yahoo! Open Stack</a> and learn how to leverage Yahoo&#8217;s platforms and scalability to build your next application. We will examine the components that make up Yahoo&#8217;s open stack: developer tools (<a href="http://developer.yahoo.com/yui/" target="_blank">YUI</a>), data apis (<a href="http://developer.yahoo.com/yql/" target="_blank">YQL</a>, <a href="http://developer.yahoo.com/search/boss/" target="_blank">BOSS</a>), social apis, and the application platform (<a href="http://developer.yahoo.com/yap/" target="_blank">YAP</a>).</p>
<ul>
<li>Overview
<ul>
<li>What is the Yahoo! Open Stack?
<ul>
<li>Developer Tools &#8211; YUI, Tutorials</li>
<li>YOS SDK for PHP</li>
</ul>
</li>
<li> Data APIs &#8211; YQL, BOSS &#8230;</li>
<li> Social APIs &#8211; Profiles, Connections, Updates, &#8230;</li>
<li> Application Platform
<ul>
<li> OpenSocial Support</li>
</ul>
</li>
</ul>
</li>
<li> How does it all work?
<ul>
<li> Development Workflow</li>
</ul>
</li>
<li> Building an open application with PHP and YOS</li>
<li> Common Problems &amp; Solutions
<ul>
<li> CAJA</li>
<li> OpenSocial</li>
</ul>
</li>
</ul>
<p><span id="more-319"></span></p>
<hr /><a href="http://www.linkedin.com/in/iamdustinwhittle" target="_blank">Dustin Whittle</a> is a Technical Yahoo! and Developer Evangelist for Yahoo&#8217;s Open Strategy. When he is not evangelizing Yahoo&#8217;s Open Stack, he helps develop it through his work on the Yahoo! Developer Network and Yahoo! Application Platform. Prior to his work helping create an open Yahoo!, he has contributed to Yahoo! Answers and Delicious. When not focused on Yahoo!, he is an active open source contributor for the <a href="http://symfony-project.com/" target="_blank">symfony project</a> and is a regular speaker at technical conferences around the world.</p>
<hr />
Agenda:<br />
6:30 &#8211; 7:15 &#8212; Doors open/general socializing &amp; food provided by Yahoo!<br />
7:15 &#8211; 8:30 &#8212; Main presentation by Dustin Whittle on the Yahoo! Open Stack<br />
8:30 &#8211; 9:00 &#8212; Main presentation Q&amp;A<br />
9:00 &#8211; 10:00 &#8212; General discussion/Q&amp;A/networking/etc.<br />
10:00ish &#8212; end of group</p>
]]></content:encoded>
			<wfw:commentRss>http://www.grepmymind.com/2009/03/11/diving-into-the-yahoo-open-stack-sf-php-meetup-april-2nd-2009/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>svn pre-commit &amp; post-commit hooks</title>
		<link>http://www.grepmymind.com/2009/03/07/svn-pre-commit-post-commit-hooks/</link>
		<comments>http://www.grepmymind.com/2009/03/07/svn-pre-commit-post-commit-hooks/#comments</comments>
		<pubDate>Sat, 07 Mar 2009 16:47:55 +0000</pubDate>
		<dc:creator>Michael Tougeron</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[post-commit]]></category>
		<category><![CDATA[pre-commit]]></category>
		<category><![CDATA[svn]]></category>
		<category><![CDATA[svn commit hooks]]></category>
		<category><![CDATA[svn hooks]]></category>

		<guid isPermaLink="false">http://www.grepmymind.com/?p=311</guid>
		<description><![CDATA[I have to say I love subversion (svn) hooks.  I&#8217;ve only been playing around with the concept fairly recently and I&#8217;m surprised that I lasted this long without them.  I wanted to take a few minutes and share my favorite ways of using them.  As well as a few that I don&#8217;t use but I [...]]]></description>
			<content:encoded><![CDATA[<p>I have to say I love <a href="http://subversion.tigris.org/">subversion</a> (svn) hooks.  I&#8217;ve only been playing around with the concept fairly recently and I&#8217;m surprised that I lasted this long without them.  I wanted to take a few minutes and share my favorite ways of using them.  As well as a few that I don&#8217;t use but I think could be pretty helpful.</p>
<p>Before we keep going, if you don&#8217;t know what svn hooks are you can read up on them at <a href="http://svnbook.red-bean.com/en/1.1/ch05s02.html">http://svnbook.red-bean.com/en/1.1/ch05s02.html</a>.  svnbook.red-bean.com is my reference site of choice whenever I need to look up a svn command.</p>
<p>My #1, all-time, greatest in the world, bestest favorite is a svn pre-commit hook to syntax check my <a href="http://php.net">PHP</a> code.  There is nothing I hate more than a developer checking in code with syntax errors and breaking qa or stage or even, god-forbid, production.  It&#8217;s as easy as setting up the hook to run a script that calls &#8220;/path/to/php -l /path/to/file.php&#8221; and on failure reject the commit.  This way code that has syntax errors will never make it into SVN.  Now if only open-source projects like <a href="http://framework.zend.com/">ZendFramework</a> did something like this before releasing their code.  To be fair, the syntax errors are in their documentation not in the /library/ files but that&#8217;s still pretty dumb &amp; annoying.</p>
<p>Another nice way to use a post-commit hook is to run something like <a href="http://pear.php.net/package/PHP_CodeSniffer">PHP_CodeSniffer</a> against the commit.  CodeSniffer is an awesome <a href="http://pear.php.net">PEAR </a>package that scans your file and flags coding standards violations.  It comes pre-packaged with sniffers for the PHPCS, <a href="http://pear.php.net/manual/en/standards.php">PEAR</a>, <a href="http://squiz.net">Squiz</a> and  <a href="http://framework.zend.com/manual/en/coding-standard.html">Zend</a>.  Set it up to run and if it finds coding standard violations you can have the hook send out nasty little blame messages.  <img src='http://www.grepmymind.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />   This isn&#8217;t something that I&#8217;d want to run on pre-commit just in case you really need to get something into production NOW.  But if I hosted an open source project, <a href="http://pear.php.net/manual/en/package.php.php-codesniffer.svn-pre-commit.php">I&#8217;d consider it</a>.</p>
<p>Having minified JavaScript &amp; CSS has become the standard way of serving JS &amp; CSS.  But who really wants to take the time to minify or combine them?  Once again, enter svn hooks.  One of the developers set this up for <a href="http://www.gamespot.com/">GameSpot</a> and it has been working great!  Basically it checks the commits against a defined naming standard, file.src.js or file.src.css, and then runs the <a href="http://developer.yahoo.com/yui/compressor/">YUI! Compressor</a> on it and commits in file.min.(js|css).  He also made it check a global.conf in the file&#8217;s directory so it came mash up smaller js files into a global.min.js so we serve one file instead of ten.</p>
<p>Of course, let&#8217;s not forget about what is probably the most common svn hook; the post-commit email hook.  I like <a href="http://opensource.perlig.de/svnmailer/">svnmailer</a> better than <a href="http://subversion.tigris.org/tools_contrib.html#mailer_py">mailer.py</a> that comes with svn by default.  I think it&#8217;s easier to configure/change and to setup rules for how you want the emails to look or where to go.</p>
<p>If you&#8217;re using a ticket tracking system like <a href="http://www.bugzilla.org/">Bugzilla</a> or <a href="http://trac.edgewall.org/">Trac</a> that doesn&#8217;t have its own way of peeking into svn (like <a href="http://www.atlassian.com/software/jira/">JIRA</a> can with this <a href="http://confluence.atlassian.com/display/JIRAEXT/JIRA+Subversion+plugin">plugin</a>) you can write a post-commit hook to update the ticket when something is committed.  You can see how Trac recommends you do it at <a href="http://trac.edgewall.org/browser/trunk/contrib/trac-post-commit-hook">http://trac.edgewall.org/browser/trunk/contrib/trac-post-commit-hook</a>.</p>
<p>To help you on the way to creating your own svn hooks, tigris has a few <a href="http://subversion.tigris.org/tools_contrib.html#hook_scripts">hooks that are distributed</a> with svn.  They can be quite helpful so you should take a look at them.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.grepmymind.com/2009/03/07/svn-pre-commit-post-commit-hooks/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Validating HTML with tidy</title>
		<link>http://www.grepmymind.com/2009/01/15/validating-html-with-tidy/</link>
		<comments>http://www.grepmymind.com/2009/01/15/validating-html-with-tidy/#comments</comments>
		<pubDate>Thu, 15 Jan 2009 20:41:32 +0000</pubDate>
		<dc:creator>Michael Tougeron</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[html parsing]]></category>
		<category><![CDATA[tidy]]></category>
		<category><![CDATA[tidyhtml]]></category>

		<guid isPermaLink="false">http://www.grepmymind.com/?p=42</guid>
		<description><![CDATA[If you ever have to do HTML validation or parsing in PHP the tidy extension is the way to do it! This extension lets you use the abilities of tidy in some pretty powerful ways. The extension, written by John Coggeshall, has been around for several years now. I can see how if someone just [...]]]></description>
			<content:encoded><![CDATA[<p>If you ever have to do HTML validation or parsing in PHP the <a href="http://us2.php.net/manual/en/book.tidy.php">tidy extension</a> is the way to do it!  This extension lets you use the abilities of <a href="http://tidy.sourceforge.net/">tidy</a> in some pretty powerful ways.  The extension, written by <a href="http://www.coggeshall.org/">John Coggeshall</a>, has been around for several years now.  I can see how if someone just took a quick glance at it they could think it was nice, but not really something they need.  How wrong they would be!  If you take a few minutes and look under the hood, tidy is an extremely powerful tool.  Not only can it format html to standards (what most people use it for), it can also be a powerful parser and validation tool.</p>
<p>When I&#8217;m dealing with user inputted data where I want to allow HTML I have two concerns.  First, I don&#8217;t want to allow XSS (some xml parsers think &lt;p kkk=&#8221;&gt;&lt;/p&gt;&#8221; closes the &lt;p&gt; tag).  Second, the user frequently enters invalid html (e.g., doesn&#8217;t close the &lt;a&gt; tag).  Fortunately tidy can easily deal with both.  The second issue is the easiest to solve by running tidy-&gt;cleanRepair() on the html.  The first is taken care of by looping through the tidy nodes and rebuilding the html using a whitelist. More about how to do this after the break.  <span id="more-4"></span></p>
<p>To start, you&#8217;ll need to setup your <a href="http://tidy.sourceforge.net/docs/quickref.html">tidy options</a>.  I tend to use the following options.  The <a href="http://tidy.sourceforge.net/docs/quickref.html#word-2000">word-2000</a> option is great because it strips out all of the annoying html, css, etc. that Microsoft Word inserts for its formatting.</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="re0">$config</span> = <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="st0">&#8216;indent&#8217;</span> =&gt; <span class="kw2">false</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="st0">&#8216;output-xhtml&#8217;</span> =&gt; <span class="kw2">true</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="st0">&#8216;wrap&#8217;</span> =&gt; <span class="nu0">0</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="st0">&#8216;fix-uri&#8217;</span> =&gt; <span class="kw2">true</span>,</div>
</li>
<li class="li2">
<div class="de2">&nbsp; <span class="st0">&#8216;word-2000&#8242;</span> =&gt; <span class="kw2">true</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="st0">&#8216;show-body-only&#8217;</span> =&gt; <span class="kw2">true</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="st0">&#8216;drop-proprietary-attributes&#8217;</span> =&gt; <span class="kw2">true</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="st0">&#8216;ncr&#8217;</span> =&gt; <span class="kw2">false</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="st0">&#8216;drop-empty-paras&#8217;</span> =&gt; <span class="kw2">false</span>,</div>
</li>
<li class="li2">
<div class="de2">&nbsp; <span class="st0">&#8216;hide-endtags&#8217;</span> =&gt; <span class="kw2">true</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="st0">&#8216;lower-literals&#8217;</span> =&gt; <span class="kw2">true</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="st0">&#8216;markup&#8217;</span> =&gt; <span class="kw2">true</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="st0">&#8216;quote-ampersand&#8217;</span> =&gt; <span class="kw2">true</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="st0">&#8216;force-output&#8217;</span> =&gt; <span class="kw2">true</span><span class="br0">&#41;</span>;</div>
</li>
</ol>
</div>
<p>Add/Remove these options as it works best for you.  I&#8217;ve found that these work best for the cleaning &amp; repairing of accidentally invalid HTML.  Read the tidy docs for what each of these mean and how they affect what tidy does.  Please note that in the above options I include &#8220;force-output&#8221; so that I can display back to the user what the results of trying to fix the HTML is so that they can fix their input.</p>
<p>If you&#8217;re parsing user generated content, usually they are just entering the tags and HTML for the specific content they want posted.  This means you&#8217;ll need to wrap that input in the &lt;!DOCTYPE&gt;, &lt;HTML&gt; and &lt;BODY&gt; tags before processing it through tidy.</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="co1">// Let&#8217;s initialize tidy with our HTML and config options.</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$tidy</span> = tidy_parse_string<span class="br0">&#40;</span><span class="re0">$html</span>, <span class="re0">$config</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// Not let&#8217;s clean &amp;amp; repair to try and &quot;fix&quot; user errors</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$tidy</span>-&gt;<span class="me1">cleanRepair</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2"><span class="co1">// Start tracking any errors at this point so we can give good feedback to the user</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">if</span> <span class="br0">&#40;</span>tidy_error_count<span class="br0">&#40;</span><span class="re0">$tidy</span><span class="br0">&#41;</span> &amp;amp;&amp;amp; <span class="re0">$tidy</span>-&gt;<span class="me1">errorBuffer</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="re0">$errors</span> = <a href="http://www.php.net/explode"><span class="kw3">explode</span></a><span class="br0">&#40;</span><span class="st0">&quot;<span class="es0">\n</span>&quot;</span>, <span class="re0">$tidy</span>-&gt;<span class="me1">errorBuffer</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">foreach</span> <span class="br0">&#40;</span> <span class="re0">$errors</span> <span class="kw1">as</span> <span class="re0">$key</span> =&gt; <span class="re0">$error</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="re0">$errors</span><span class="br0">&#91;</span><span class="re0">$key</span><span class="br0">&#93;</span> = <a href="http://www.php.net/htmlentities"><span class="kw3">htmlentities</span></a><span class="br0">&#40;</span><span class="re0">$error</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// Once tidy has cleaned &amp;amp; repaired the initial user input</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// we need to loop through the object and validate each</span></div>
</li>
<li class="li2">
<div class="de2"><span class="co1">// HTML tag block. &nbsp;We will only need to do that though if</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// the $body actually has child tags</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$body</span> = <span class="re0">$tidy</span>-&gt;<span class="me1">body</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">if</span> <span class="br0">&#40;</span> <span class="re0">$body</span>-&gt;<span class="me1">child</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="co1">// we need to validate each HTML tag in the &lt;body&gt;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; <span class="co1">// validateTidyNode() will be called recursively for</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="co1">// any sub-tag blocks</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">foreach</span> <span class="br0">&#40;</span> <span class="re0">$body</span>-&gt;<span class="me1">child</span> <span class="kw1">as</span> <span class="re0">$key</span> =&gt; <span class="re0">$child</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="re0">$error</span> = validateTidyNode<span class="br0">&#40;</span><span class="re0">$child</span>, <span class="re0">$new_html</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="re0">$body</span>-&gt;<span class="me1">child</span><span class="br0">&#91;</span><span class="re0">$key</span><span class="br0">&#93;</span> = <span class="re0">$child</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; <span class="co1">// And of course track the errors as they</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="co1">// appear to give good feedback to the user</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span> <span class="re0">$error</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="re0">$errors</span> = <a href="http://www.php.net/array_merge"><span class="kw3">array_merge</span></a><span class="br0">&#40;</span><span class="br0">&#40;</span><a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#41;</span><span class="re0">$errors</span>, <span class="br0">&#40;</span><a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#41;</span><span class="re0">$error</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">return</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="st0">&#8216;html&#8217;</span> =&gt; <span class="re0">$new_html</span>, <span class="st0">&#8216;errors&#8217;</span> =&gt; <span class="re0">$errors</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">function</span> validateTidyNode<span class="br0">&#40;</span>&amp;amp;<span class="re0">$tidy_node</span>, &amp;amp;<span class="re0">$html</span>, <span class="re0">$allowed_tags</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; <span class="re0">$bad_tag</span> = <span class="kw2">false</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="co1">// If the node is text, just add the text to the HTML</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span> <span class="re0">$tidy_node</span>-&gt;<span class="me1">type</span> == TIDY_NODETYPE_TEXT <span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="re0">$html</span> .= <span class="re0">$tidy_node</span>-&gt;<span class="me1">value</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">return</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="co1">// If the node does not exist in your array of acceptable HTML tags</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="co1">// then track and error message and set the $bad_tag flag.</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">elseif</span> <span class="br0">&#40;</span> !<a href="http://www.php.net/array_key_exists"><span class="kw3">array_key_exists</span></a><span class="br0">&#40;</span><a href="http://www.php.net/strtolower"><span class="kw3">strtolower</span></a><span class="br0">&#40;</span><span class="re0">$tidy_node</span>-&gt;<span class="me1">name</span><span class="br0">&#41;</span>, <span class="re0">$allowed_tags</span><span class="br0">&#41;</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="re0">$errors</span><span class="br0">&#91;</span><span class="br0">&#93;</span> = <span class="st0">&#8216;Tag: &#8216;</span> . <span class="re0">$tidy_node</span>-&gt;<span class="me1">name</span> . <span class="st0">&#8216; is not allowed and has been removed.&#8217;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; <span class="re0">$bad_tag</span> = <span class="kw2">true</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span> <span class="re0">$tidy_node</span>-&gt;<span class="me1">child</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="re0">$html2</span> = <span class="st0">&#8221;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">foreach</span> <span class="br0">&#40;</span> <span class="re0">$tidy_node</span>-&gt;<span class="me1">child</span> <span class="kw1">as</span> <span class="re0">$key</span> =&gt; <span class="re0">$child</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; <span class="re0">$error</span> = validateTidyNode<span class="br0">&#40;</span><span class="re0">$child</span>, <span class="re0">$html2</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="re0">$tidy_node</span>-&gt;<span class="me1">child</span><span class="br0">&#91;</span><span class="re0">$key</span><span class="br0">&#93;</span> = <span class="re0">$child</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span> <span class="re0">$error</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$errors</span> = <a href="http://www.php.net/array_merge"><span class="kw3">array_merge</span></a><span class="br0">&#40;</span><span class="br0">&#40;</span><a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#41;</span><span class="re0">$errors</span>, <span class="br0">&#40;</span><a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#41;</span><span class="re0">$error</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span> <span class="re0">$bad_tag</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// I prefer to &quot;display&quot; the bad HTML tags so that the</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// user can see that it was not accepted. &nbsp;But you</span></div>
</li>
<li class="li2">
<div class="de2"><span class="co1">// may prefer to just strip the tag.</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co1">//&nbsp; &nbsp; $html .= &#8216; &#8216;;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="re0">$html</span> .= <span class="st0">&#8216;&amp;amp;lt;&#8217;</span> . <span class="re0">$tidy_node</span>-&gt;<span class="me1">name</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">else</span> <span class="br0">&#123;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="re0">$html</span> .= <span class="st0">&#8216;&lt;&#8217;</span> . <span class="re0">$tidy_node</span>-&gt;<span class="me1">name</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span> <span class="re0">$tidy_node</span>-&gt;<span class="me1">attribute</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <a href="http://www.php.net/unset"><span class="kw3">unset</span></a><span class="br0">&#40;</span><span class="re0">$found_attribs</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw1">foreach</span> <span class="br0">&#40;</span> <span class="re0">$tidy_node</span>-&gt;<span class="me1">attribute</span> <span class="kw1">as</span> <span class="re0">$attrib_name</span> =&gt; <span class="re0">$attrib_value</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li2">
<div class="de2"><span class="co1">// verify that the tag is allowed to have the specified attribute.</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span> !<a href="http://www.php.net/array_key_exists"><span class="kw3">array_key_exists</span></a><span class="br0">&#40;</span><a href="http://www.php.net/strtolower"><span class="kw3">strtolower</span></a><span class="br0">&#40;</span><span class="re0">$attrib_name</span><span class="br0">&#41;</span>, <span class="re0">$allowed_tags</span><span class="br0">&#91;</span><span class="re0">$tidy_node</span>-&gt;<span class="me1">name</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st0">&#8216;attribs&#8217;</span><span class="br0">&#93;</span><span class="br0">&#41;</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$errors</span><span class="br0">&#91;</span><span class="br0">&#93;</span> = <span class="st0">&#8216;Tag &#8216;</span> . <span class="re0">$tidy_node</span>-&gt;<span class="me1">name</span> . <span class="st0">&#8216; is not allowed to have the attribute &#8216;</span> . <span class="re0">$attrib_name</span> . <span class="st0">&#8216; and has been removed.&#8217;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/unset"><span class="kw3">unset</span></a><span class="br0">&#40;</span><span class="re0">$tidy_node</span>-&gt;<span class="me1">attribute</span><span class="br0">&#91;</span><span class="re0">$attrib_name</span><span class="br0">&#93;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">else</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// validate the attribute&#8217;s value. &nbsp;We don&#8217;t want invalid values.</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$res</span> = validateHTMLTagAttribute<span class="br0">&#40;</span><span class="re0">$tidy_node</span>-&gt;<span class="me1">name</span>, <span class="re0">$attrib_name</span>, <span class="re0">$attrib_value</span>, <span class="re0">$allowed_tags</span><span class="br0">&#91;</span><span class="re0">$tidy_node</span>-&gt;<span class="me1">name</span><span class="br0">&#93;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span> !<span class="re0">$res</span><span class="br0">&#91;</span><span class="st0">&#8216;remove&#8217;</span><span class="br0">&#93;</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$html</span> .= <span class="st0">&#8216; &#8216;</span> . <span class="re0">$res</span><span class="br0">&#91;</span><span class="st0">&#8216;attrib_name&#8217;</span><span class="br0">&#93;</span> . <span class="st0">&#8216;=&quot;&#8217;</span> . <span class="re0">$res</span><span class="br0">&#91;</span><span class="st0">&#8216;attrib_value&#8217;</span><span class="br0">&#93;</span> . <span class="st0">&#8216;&quot;&#8217;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span> <span class="re0">$res</span><span class="br0">&#91;</span><span class="st0">&#8216;errors&#8217;</span><span class="br0">&#93;</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$errors</span><span class="br0">&#91;</span><span class="br0">&#93;</span> = <span class="re0">$res</span><span class="br0">&#91;</span><span class="st0">&#8216;errors&#8217;</span><span class="br0">&#93;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span> <a href="http://www.php.net/trim"><span class="kw3">trim</span></a><span class="br0">&#40;</span><span class="re0">$attrib_name</span><span class="br0">&#41;</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$found_attribs</span><span class="br0">&#91;</span><span class="br0">&#93;</span> = <span class="re0">$attrib_name</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// check to make sure that required attributes are set. &nbsp;e.g. &lt;img&gt; needs to have the src attribute</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span> <span class="re0">$allowed_tags</span><span class="br0">&#91;</span><span class="re0">$tidy_node</span>-&gt;<span class="me1">name</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st0">&#8216;attribs&#8217;</span><span class="br0">&#93;</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw1">foreach</span> <span class="br0">&#40;</span> <span class="re0">$allowed_tags</span><span class="br0">&#91;</span><span class="re0">$tidy_node</span>-&gt;<span class="me1">name</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st0">&#8216;attribs&#8217;</span><span class="br0">&#93;</span> <span class="kw1">as</span> <span class="re0">$attrib_name</span> =&gt; <span class="re0">$attrib_settings</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span> <span class="re0">$attrib_settings</span><span class="br0">&#91;</span><span class="st0">&#8216;required&#8217;</span><span class="br0">&#93;</span> &amp;amp;&amp;amp; <span class="br0">&#40;</span>!<span class="re0">$found_attribs</span> || !<a href="http://www.php.net/in_array"><span class="kw3">in_array</span></a><span class="br0">&#40;</span><span class="re0">$attrib_name</span>, <span class="re0">$found_attribs</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$errors</span><span class="br0">&#91;</span><span class="br0">&#93;</span> = <span class="st0">&#8216;Tag &#8216;</span> . <span class="re0">$tidy_node</span>-&gt;<span class="me1">name</span> . <span class="st0">&#8216; is required to have the attribute &#8216;</span> . <span class="re0">$attrib_name</span> . <span class="st0">&#8216;.&#8217;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li2">
<div class="de2"><span class="co1">// some tags require at least one of a set of attributes. &nbsp;e.g. &lt;a&gt; needs to have either the href or name attribute.</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span> <span class="re0">$allowed_tags</span><span class="br0">&#91;</span><span class="re0">$tidy_node</span>-&gt;<span class="me1">name</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st0">&#8216;required_attribs&#8217;</span><span class="br0">&#93;</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="re0">$attrib_found</span> = <span class="kw2">false</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span> <span class="re0">$found_attribs</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">foreach</span> <span class="br0">&#40;</span> <span class="re0">$allowed_tags</span><span class="br0">&#91;</span><span class="re0">$tidy_node</span>-&gt;<span class="me1">name</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st0">&#8216;required_attribs&#8217;</span><span class="br0">&#93;</span> <span class="kw1">as</span> <span class="re0">$attrib_name</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span> <a href="http://www.php.net/in_array"><span class="kw3">in_array</span></a><span class="br0">&#40;</span><span class="re0">$attrib_name</span>, <span class="re0">$found_attribs</span><span class="br0">&#41;</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$attrib_found</span> = <span class="kw2">true</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span> !<span class="re0">$attrib_found</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$errors</span><span class="br0">&#91;</span><span class="br0">&#93;</span> = <span class="st0">&#8216;Tag &#8216;</span> . <span class="re0">$tidy_node</span>-&gt;<span class="me1">name</span> . <span class="st0">&#8216; is required to have one of the following attributes: &#8216;</span> . <a href="http://www.php.net/implode"><span class="kw3">implode</span></a><span class="br0">&#40;</span><span class="st0">&#8216;, &#8216;</span>, <span class="re0">$allowed_tags</span><span class="br0">&#91;</span><span class="re0">$tidy_node</span>-&gt;<span class="me1">name</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st0">&#8216;required_attribs&#8217;</span><span class="br0">&#93;</span><span class="br0">&#41;</span> . <span class="st0">&#8216;.&#8217;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span> <a href="http://www.php.net/isset"><span class="kw3">isset</span></a><span class="br0">&#40;</span><span class="re0">$allowed_tags</span><span class="br0">&#91;</span><span class="re0">$tidy_node</span>-&gt;<span class="me1">name</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st0">&#8216;settings&#8217;</span><span class="br0">&#93;</span><span class="br0">&#41;</span> &amp;amp;&amp;amp; !<span class="re0">$allowed_tags</span><span class="br0">&#91;</span><span class="re0">$tidy_node</span>-&gt;<span class="me1">name</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st0">&#8216;settings&#8217;</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st0">&#8216;require_close&#8217;</span><span class="br0">&#93;</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="re0">$html</span> .= <span class="st0">&#8216; /&#8217;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span> <span class="re0">$bad_tag</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li2">
<div class="de2"><span class="co1">//&nbsp; &nbsp; $html .= &#8216; &#8216;;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="re0">$html</span> .= <span class="st0">&#8216;&amp;amp;gt;&#8217;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">else</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="re0">$html</span> .= <span class="st0">&#8216;&gt;&#8217;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="re0">$html</span> .= <span class="re0">$html2</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span> <span class="re0">$bad_tag</span> || <span class="re0">$allowed_tags</span><span class="br0">&#91;</span><span class="re0">$tidy_node</span>-&gt;<span class="me1">name</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st0">&#8216;settings&#8217;</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st0">&#8216;require_close&#8217;</span><span class="br0">&#93;</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span> <span class="re0">$bad_tag</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="re0">$html</span> .= <span class="st0">&#8216;&amp;amp;lt;/&#8217;</span> . <span class="re0">$tidy_node</span>-&gt;<span class="me1">name</span> . <span class="st0">&#8216;&amp;amp;gt;&#8217;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">else</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="re0">$html</span> .= <span class="st0">&#8216;&lt;/&#8217;</span> . <span class="re0">$tidy_node</span>-&gt;<span class="me1">name</span> . <span class="st0">&#8216;&gt;&#8217;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; <span class="kw1">return</span> <span class="re0">$errors</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">function</span> validateHTMLTagAttribute<span class="br0">&#40;</span> <span class="re0">$tag_name</span>, <span class="re0">$attrib_name</span>, <span class="re0">$attrib_value</span>, <span class="re0">$tag_data</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="co1">// set to the unmodified version first. &nbsp;if modified, it will change at the end of the method.</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; <span class="re0">$res</span><span class="br0">&#91;</span><span class="st0">&#8216;attrib_name&#8217;</span><span class="br0">&#93;</span> = <span class="re0">$attrib_name</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="re0">$res</span><span class="br0">&#91;</span><span class="st0">&#8216;attrib_value&#8217;</span><span class="br0">&#93;</span> = <span class="re0">$attrib_value</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span> !<span class="re0">$tag_data</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="re0">$res</span><span class="br0">&#91;</span>errors<span class="br0">&#93;</span> = <span class="st0">&quot;$tag_name could not be found. &nbsp;Invalid tag/attribute.&quot;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; <span class="kw1">return</span> <span class="re0">$res</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span> <span class="re0">$tag_data</span><span class="br0">&#91;</span><span class="st0">&#8216;attribs&#8217;</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st0">&#8216;unlimited_attribs&#8217;</span><span class="br0">&#93;</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="re0">$res</span><span class="br0">&#91;</span><span class="st0">&#8216;valid&#8217;</span><span class="br0">&#93;</span> = <span class="kw2">true</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; <span class="kw1">return</span> <span class="re0">$res</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="re0">$attrib</span> = <span class="re0">$tag_data</span><span class="br0">&#91;</span><span class="st0">&#8216;attribs&#8217;</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="re0">$attrib_name</span><span class="br0">&#93;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">switch</span> <span class="br0">&#40;</span> <span class="re0">$attrib</span><span class="br0">&#91;</span><span class="st0">&#8216;type&#8217;</span><span class="br0">&#93;</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li2">
<div class="de2"><span class="co1">// no restrictions on the value of the attributes (not normally recommended)</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">case</span> <span class="st0">&#8216;unrestricted&#8217;</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw1">break</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// the attribute can only have one of the defined values</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">case</span> <span class="st0">&#8216;fixed&#8217;</span>:</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span> !<a href="http://www.php.net/in_array"><span class="kw3">in_array</span></a><span class="br0">&#40;</span><a href="http://www.php.net/strtolower"><span class="kw3">strtolower</span></a><span class="br0">&#40;</span><span class="re0">$attrib_value</span><span class="br0">&#41;</span>, <span class="re0">$attrib</span><span class="br0">&#91;</span><span class="st0">&#8216;values&#8217;</span><span class="br0">&#93;</span><span class="br0">&#41;</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$res</span><span class="br0">&#91;</span><span class="st0">&#8216;errors&#8217;</span><span class="br0">&#93;</span> = <span class="st0">&quot;$attrib_name is not set to an accepted value for $tag_name tag.&quot;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="re0">$res</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw1">break</span>;</div>
</li>
<li class="li2">
<div class="de2"><span class="co1">// some basic numeric checks</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">case</span> <span class="st0">&#8216;numeric&#8217;</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">case</span> <span class="st0">&#8216;px&#8217;</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">case</span> <span class="st0">&#8216;percent&#8217;</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="re0">$attrib_value</span> = <a href="http://www.php.net/intval"><span class="kw3">intval</span></a><span class="br0">&#40;</span><span class="re0">$attrib_value</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span> <span class="re0">$attrib_value</span> &gt; <span class="re0">$attrib</span><span class="br0">&#91;</span><span class="st0">&#8216;max&#8217;</span><span class="br0">&#93;</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$res</span><span class="br0">&#91;</span><span class="st0">&#8216;errors&#8217;</span><span class="br0">&#93;</span> = <span class="st0">&quot;$attrib_name is greater than the max value (&quot;</span> . <span class="re0">$attrib</span><span class="br0">&#91;</span><span class="st0">&#8216;max&#8217;</span><span class="br0">&#93;</span> . <span class="st0">&quot;) allowed for $tag_name tag.&quot;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="re0">$res</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw1">elseif</span> <span class="br0">&#40;</span> <span class="re0">$attrib_value</span> &lt; <span class="re0">$attrib</span><span class="br0">&#91;</span><span class="st0">&#8216;min&#8217;</span><span class="br0">&#93;</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$res</span><span class="br0">&#91;</span><span class="st0">&#8216;errors&#8217;</span><span class="br0">&#93;</span> = <span class="st0">&quot;$attrib_name is less than the max value (&quot;</span> . <span class="re0">$attrib</span><span class="br0">&#91;</span><span class="st0">&#8216;min&#8217;</span><span class="br0">&#93;</span> . <span class="st0">&quot;) allowed for $tag_name tag.&quot;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="re0">$res</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span> <span class="re0">$attrib</span><span class="br0">&#91;</span><span class="st0">&#8216;type&#8217;</span><span class="br0">&#93;</span> == <span class="st0">&#8216;percent&#8217;</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$attrib_value</span> = <span class="re0">$attrib_value</span> . <span class="st0">&quot;%&quot;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw1">elseif</span> <span class="br0">&#40;</span> <span class="re0">$attrib</span><span class="br0">&#91;</span><span class="st0">&#8216;type&#8217;</span><span class="br0">&#93;</span> == <span class="st0">&#8216;px&#8217;</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$attrib_value</span> = <span class="re0">$attrib_value</span> . <span class="st0">&quot;px&quot;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw1">break</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; <span class="kw1">case</span> <span class="st0">&#8216;hex&#8217;</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="co1">// 6 characters of A-F and 0-9</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="co1">// optionally allow a # in front for a total</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="co1">// of 7 characters</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw1">break</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; <span class="kw1">case</span> <span class="st0">&#8216;url&#8217;</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="co1">// validate according to your valid URL criteria</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="co1">// e.g., only allow for current domain or if the</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="co1">// tag is &quot;img&quot; make sure the extension is .jpg or .gif</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw1">break</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; <span class="kw1">case</span> <span class="st0">&#8216;string&#8217;</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="co1">// validate for a string. &nbsp;I usually consider _-. and similar</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="co1">// characters acceptable for a &quot;string&quot; even though they are</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="co1">// not truly a string</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw1">break</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; <span class="kw2">default</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="re0">$res</span><span class="br0">&#91;</span><span class="st0">&#8216;errors&#8217;</span><span class="br0">&#93;</span> = <span class="st0">&quot;ERROR! &nbsp;Do not know how to process the tag $tag_name!&quot;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw1">break</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="re0">$res</span><span class="br0">&#91;</span><span class="st0">&#8216;attrib_name&#8217;</span><span class="br0">&#93;</span> = <span class="re0">$attrib_name</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; <span class="re0">$res</span><span class="br0">&#91;</span><span class="st0">&#8216;attrib_value&#8217;</span><span class="br0">&#93;</span> = <span class="re0">$attrib_value</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="re0">$res</span><span class="br0">&#91;</span><span class="st0">&#8216;valid&#8217;</span><span class="br0">&#93;</span> = <span class="kw2">true</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">return</span> <span class="re0">$res</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
</ol>
</div>
<p>So how you setup the array for tag validation is pretty much up to you.  The format I used looks a lot like this:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="re0">$tags</span> = <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;a&#8217;</span> =&gt; <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span>&nbsp;<span class="st0">&#8216;settings&#8217;</span> =&gt; <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="st0">&#8216;require_close&#8217;</span> =&gt; <span class="kw2">true</span><span class="br0">&#41;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;attribs&#8217;</span> =&gt; <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span>&nbsp;<span class="st0">&#8216;href&#8217;</span> =&gt; <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="st0">&#8216;type&#8217;</span> =&gt; <span class="st0">&#8216;url&#8217;</span><span class="br0">&#41;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;name&#8217;</span> =&gt; <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="st0">&#8216;type&#8217;</span> =&gt; <span class="st0">&#8216;string&#8217;</span><span class="br0">&#41;</span>,</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;id&#8217;</span> =&gt; <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span> <span class="st0">&#8216;type&#8217;</span> =&gt; <span class="st0">&#8216;string&#8217;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;auth_level&#8217;</span> =&gt; AUTH_LEVEL_TRUSTED_USER</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#41;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;class&#8217;</span> =&gt; <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span> <span class="st0">&#8216;type&#8217;</span> =&gt; <span class="st0">&#8216;unrestricted&#8217;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;auth_level&#8217;</span> =&gt; AUTH_LEVEL_TRUSTED_USER</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#41;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;onclick&#8217;</span> =&gt; <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span> <span class="st0">&#8216;type&#8217;</span> =&gt; <span class="st0">&#8216;unrestricted&#8217;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;auth_level&#8217;</span> =&gt; AUTH_LEVEL_TRUSTED_USER</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#41;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;onmouseover&#8217;</span> =&gt; <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span> <span class="st0">&#8216;type&#8217;</span> =&gt; <span class="st0">&#8216;unrestricted&#8217;</span>,</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;auth_level&#8217;</span> =&gt; AUTH_LEVEL_TRUSTED_USER</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#41;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;required_attribs&#8217;</span> =&gt; <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span> <span class="st0">&#8216;href&#8217;</span>, <span class="st0">&#8216;name&#8217;</span> <span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#41;</span>,</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;b&#8217;</span> =&gt; <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="st0">&#8216;settings&#8217;</span> =&gt; <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span>&nbsp;<span class="st0">&#8216;require_close&#8217;</span> =&gt; <span class="kw2">true</span><span class="br0">&#41;</span><span class="br0">&#41;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="st0">&#8216;img&#8217;</span> =&gt; <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span>&nbsp; <span class="st0">&#8216;settings&#8217;</span> =&gt; <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span>&nbsp; <span class="st0">&#8216;require_close&#8217;</span> =&gt; <span class="kw2">false</span><span class="br0">&#41;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;attribs&#8217;</span> =&gt; <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span>&nbsp;&nbsp; <span class="st0">&#8216;src&#8217;</span> =&gt; <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span>&nbsp;<span class="st0">&#8216;type&#8217;</span> =&gt; <span class="st0">&#8216;url&#8217;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;required&#8217;</span> =&gt; <span class="kw2">true</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#41;</span>,</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;alt&#8217;</span> =&gt; <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="st0">&#8216;type&#8217;</span> =&gt; <span class="st0">&#8216;string&#8217;</span><span class="br0">&#41;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;border&#8217;</span> =&gt; <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span> &nbsp;<span class="st0">&#8216;type&#8217;</span> =&gt; <span class="st0">&#8216;numeric&#8217;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;min&#8217;</span> =&gt; <span class="nu0">0</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;max&#8217;</span> =&gt; <span class="nu0">5</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="br0">&#41;</span>,</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;align&#8217;</span> =&gt; <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span>&nbsp;<span class="st0">&#8216;type&#8217;</span> =&gt; <span class="st0">&#8216;fixed&#8217;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;values&#8217;</span> =&gt; <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span>&nbsp; <span class="st0">&#8216;center&#8217;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;left&#8217;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;right&#8217;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#41;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#41;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;height&#8217;</span> =&gt; <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span> &nbsp;<span class="st0">&#8216;type&#8217;</span> =&gt; <span class="st0">&#8216;numeric&#8217;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;min&#8217;</span> =&gt; <span class="nu0">1</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;max&#8217;</span> =&gt; <span class="nu0">2048</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="br0">&#41;</span>,</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;width&#8217;</span> =&gt; <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span> &nbsp; <span class="st0">&#8216;type&#8217;</span> =&gt; <span class="st0">&#8216;numeric&#8217;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;min&#8217;</span> =&gt; <span class="nu0">1</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;max&#8217;</span> =&gt; <span class="nu0">2048</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="br0">&#41;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;title&#8217;</span> =&gt; <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="st0">&#8216;type&#8217;</span>=&gt;<span class="st0">&#8216;string&#8217;</span><span class="br0">&#41;</span>,</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;hspace&#8217;</span> =&gt; <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span>&nbsp; <span class="st0">&#8216;type&#8217;</span> =&gt; <span class="st0">&#8216;numeric&#8217;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;min&#8217;</span> =&gt; <span class="nu0">0</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;max&#8217;</span> =&gt; <span class="nu0">10</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="br0">&#41;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;vspace&#8217;</span> =&gt; <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span>&nbsp; <span class="st0">&#8216;type&#8217;</span> =&gt; <span class="st0">&#8216;numeric&#8217;</span>,</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;min&#8217;</span> =&gt; <span class="nu0">0</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;max&#8217;</span> =&gt; <span class="nu0">10</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="br0">&#41;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;id&#8217;</span> =&gt; <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span> <span class="st0">&#8216;type&#8217;</span> =&gt; <span class="st0">&#8216;string&#8217;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;auth_level&#8217;</span> =&gt; AUTH_LEVEL_TRUSTED_USER</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#41;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;class&#8217;</span> =&gt; <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span> <span class="st0">&#8216;type&#8217;</span> =&gt; <span class="st0">&#8216;unrestricted&#8217;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;auth_level&#8217;</span> =&gt; AUTH_LEVEL_TRUSTED_USER</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#41;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;onclick&#8217;</span> =&gt; <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span> <span class="st0">&#8216;type&#8217;</span> =&gt; <span class="st0">&#8216;unrestricted&#8217;</span>,</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;auth_level&#8217;</span> =&gt; AUTH_LEVEL_TRUSTED_USER</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#41;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;onmouseover&#8217;</span> =&gt; <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span> <span class="st0">&#8216;type&#8217;</span> =&gt; <span class="st0">&#8216;unrestricted&#8217;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;auth_level&#8217;</span> =&gt; AUTH_LEVEL_TRUSTED_USER</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#41;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#41;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#41;</span>;</div>
</li>
</ol>
</div>
<p>The auth_level is a filter that I have in place to only allow users with a certain amount of access, such as internal staff, to use that attribute.  As you probably already know, attributes like onmouseover are an easy gateway to XSS exploits.  As you add new elements to the tag rule definition you just need to update the validate function in order to validate against it.</p>
<p>You may have noticed that I&#8217;m using the deprecated HTML attributes instead of putting all of this in a &#8220;style&#8221; attribute.  I&#8217;ve found that most users don&#8217;t know CSS styles and are familiar with the old-style HTML attributes.  If you force your users to use styles you&#8217;ll have whole other validation routine to ensure exploits are not in the CSS.</p>
<p>Note: Please don&#8217;t just copy/paste this code into your code and use it.  I&#8217;m quite positive there are bugs and typos all throughout.  Oh, and no, this is <strong>not </strong>the code used by the sites I work on.  It is similar but definitely not the same. <img src='http://www.grepmymind.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.grepmymind.com/2009/01/15/validating-html-with-tidy/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Making frameworks suck less &#8211; SF PHP Meetup Nov 2008</title>
		<link>http://www.grepmymind.com/2008/10/09/making-frameworks-suck-less-sf-php-meetup-nov-2008/</link>
		<comments>http://www.grepmymind.com/2008/10/09/making-frameworks-suck-less-sf-php-meetup-nov-2008/#comments</comments>
		<pubDate>Thu, 09 Oct 2008 14:58:35 +0000</pubDate>
		<dc:creator>Michael Tougeron</dc:creator>
				<category><![CDATA[Events]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[php meetup]]></category>
		<category><![CDATA[terry chay]]></category>

		<guid isPermaLink="false">http://www.grepmymind.com/?p=71</guid>
		<description><![CDATA[Terry Chay will be returning to speak again!  Due to popular demand Terry has agreed to give his recent &#8220;Making frameworks suck less&#8221; talk that he gave to the ZendCon08 UnCon this year. Be sure to wear comfortable shoes &#8217;cause Terry will pack the room! RSVP here: http://php.meetup.com/139/calendar/8911737/ The blurb from ZendCon08: Terry Chay, the [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://terrychay.com/blog/">Terry Chay</a> will be returning to speak again!  Due to popular demand Terry has agreed to give his recent &#8220;<a href="http://terrychay.com/blog/article/frameworks-suck-1.shtml">Making frameworks suck less</a>&#8221; talk that he gave to the <a href="http://www.zendcon.com/ZendCon08/public/wiki/UnCon_Talks">ZendCon08 UnCon</a> this year.  Be sure to wear comfortable shoes &#8217;cause Terry will pack the room!</p>
<p>RSVP here: <a href="http://php.meetup.com/139/calendar/8911737/">http://php.meetup.com/139/calendar/8911737/</a></p>
<p>The blurb from ZendCon08:<br />
Terry Chay, the original PHP Terrorist, is well known for his criticism and ridicule of the Ruby on Rails framework. He criticizes, mocks, and f-bombs his enemies into surrender. In this discussion, Terry will share his ideas and thoughts on making frameworks better.</p>
<p><a href="http://maps.google.com/maps?f=q&amp;hl=en&amp;geocode=&amp;time=&amp;date=&amp;ttype=&amp;q=235+2nd+St,+San+Francisco,+CA+94105&amp;sll=37.0625,-95.677068&amp;sspn=28.444641,57.65625&amp;ie=UTF8&amp;ll=37.786038,-122.397265&amp;spn=0.003455,0.007038&amp;z=18&amp;om=1" target="_blank">Map to CNET Networks, Inc. </a><br />
When you arrive, please look for the PHP Meetup sign pointing you to the conference room. Please RSVP if you are attending so that I can prepare enough snacks and beverages.</p>
<p>Look forward to seeing you there!</p>
<p>This event can be found at:<br />
<a href="http://php.meetup.com/139/calendar/8911737/">http://php.meetup.com/139/calendar/8911737/</a><br />
<a href="http://www.facebook.com/event.php?eid=39294579201">http://www.facebook.com/event.php?eid=39294579201</a><br />
<a href="http://upcoming.yahoo.com/event/1195581/">http://upcoming.yahoo.com/event/1195581/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.grepmymind.com/2008/10/09/making-frameworks-suck-less-sf-php-meetup-nov-2008/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SF PHP Meetup July 2008 &#8211; PHP::$unicode-&gt;i18n()</title>
		<link>http://www.grepmymind.com/2008/06/29/sf-php-meetup-july-2008-phpunicode-i18n/</link>
		<comments>http://www.grepmymind.com/2008/06/29/sf-php-meetup-july-2008-phpunicode-i18n/#comments</comments>
		<pubDate>Sun, 29 Jun 2008 18:15:14 +0000</pubDate>
		<dc:creator>Michael Tougeron</dc:creator>
				<category><![CDATA[Events]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[andrei zmievski]]></category>
		<category><![CDATA[php meetup]]></category>
		<category><![CDATA[unicode]]></category>

		<guid isPermaLink="false">http://www.grepmymind.com/?p=62</guid>
		<description><![CDATA[Kudos to Mariano for taking the lead while I&#8217;m out on paternity leave (I&#8217;m going to write about that ones of these days) and setting up July&#8217;s PHP Meetup.  Thanks to an introduction from Terry, Mariano asked Andrei Zmievski to talk about the unicode updates to PHP 6.  Due to the 4th of July, we&#8217;ve [...]]]></description>
			<content:encoded><![CDATA[<p>Kudos to <a href="http://petersonpages.com/mariano/blog/">Mariano</a> for taking the lead while I&#8217;m out on paternity leave (I&#8217;m going to write about that ones of these days) and setting up July&#8217;s PHP Meetup.  Thanks to an introduction from <a href="http://terrychay.com/blog/">Terry</a>, Mariano asked <a href="http://gravitonic.com/">Andrei Zmievski</a> to talk about the <a href="http://en.wikipedia.org/wiki/Unicode">unicode</a> updates to PHP 6.  Due to the 4th of July, we&#8217;ve moved the meetup from it&#8217;s normal date/time to Thursday July 10th @ 7pm.  It is still <a href="http://maps.google.com/?q=loc%3A+235+2nd+St,+San+Francisco,+CA" target="_blank">at CNET</a> like usual (thanks to <a href="http://www.gamespot.com/">GameSpot.com</a> funding the meetup).</p>
<p>Title: PHP::$unicode-&gt;i18n()</p>
<p>Description:<br />
PHP 6 brings fully functional and mature Unicode support to the Web world. This talk will cover all the layers of the PHP (bread)/Unicode (butter)/i18n (jam) sandwich. Come and find out how to work with locales, use collation to compare and sort strings, and format numbers, currencies, and dates for any country in the world. Bring your appetite because the toasty goodness is waiting.</p>
<p>When: Thursday, July 10th, 2008 at 7pm<br />
Where: <a href="http://www.cnetnetworks.com/">CNET Networks</a>: <a href="http://maps.google.com/?q=loc%3A+235+2nd+St,+San+Francisco,+CA">235 2nd St, San Francisco, CA  94518</a></p>
<p>You can RSVP on the <a href="http://php.meetup.com/139/calendar/8090193/">SF PHP Meetup&#8217;s site</a> or just show up.  I always like it when people RSVP so that I know how much food to buy.  But it isn&#8217;t a prereq or anything.</p>
<p>EDIT: I just saw that <a href="http://terrychay.com/blog/article/internationalization-pbj.shtml">Terry mentioned PB&amp;J</a> and I like the idea.  So PB&amp;J it is; plus the usual chips, sodas, candy, etc. of course.  <img src='http://www.grepmymind.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.grepmymind.com/2008/06/29/sf-php-meetup-july-2008-phpunicode-i18n/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GameSpot and TV are hiring</title>
		<link>http://www.grepmymind.com/2008/05/29/gamespot-and-tv-are-hiring/</link>
		<comments>http://www.grepmymind.com/2008/05/29/gamespot-and-tv-are-hiring/#comments</comments>
		<pubDate>Thu, 29 May 2008 23:04:18 +0000</pubDate>
		<dc:creator>Michael Tougeron</dc:creator>
				<category><![CDATA[memcached]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Chow.com]]></category>
		<category><![CDATA[CNET]]></category>
		<category><![CDATA[GameSpot.com]]></category>
		<category><![CDATA[job]]></category>
		<category><![CDATA[TV.com]]></category>

		<guid isPermaLink="false">http://www.grepmymind.com/?p=60</guid>
		<description><![CDATA[A shameless plug for CNET&#8230; We&#8217;re hiring a few Senior Software Engineers for GameSpot.com, TV.com and Chow.com. Yes, that&#8217;s a Sr SE positions for each of those sites. We&#8217;re raising the bar and looking to bring on some powerful coders to expand the functionality of our sites. Here&#8217;s a brief list of the job skill [...]]]></description>
			<content:encoded><![CDATA[<p>A shameless plug for CNET&#8230;  We&#8217;re hiring a few Senior Software Engineers for <a href="http://www.gamespot.com">GameSpot.com</a>, <a href="http://www.tv.com">TV.com</a> and <a href="http://www.chow.com">Chow.com</a>.  Yes, that&#8217;s a Sr SE positions for each of those sites.   We&#8217;re raising the bar and looking to bring on some powerful coders to expand the functionality of our sites.  Here&#8217;s a brief list of the job skill requirements:</p>
<p><span style="text-decoration:underline;">Must Have:</span></p>
<ul>
<li>Expert PHP skills, bonus for RoR</li>
<li>5-7 years of real world experience engineering web solutions for LAMP stacks</li>
<li>Strong relational DB knowledge (table optimization, query optimization)</li>
<li>Ability to prioritize and lead multiple simultaneous projects effectively</li>
<li>Excellent understanding of OO software engineering concepts</li>
<li>Ability to arhitect solid, scalable, extensible solutions for SE needs</li>
<li>Excited by working on high-level design and architecture</li>
<li>Comfortable mentoring junior engineers</li>
<li>Expereince with formal release processes</li>
<li>Strong verbal, written, analytical and communication skills</li>
</ul>
<p><span style="text-decoration:underline;">Bonus for:<br />
</span></p>
<ul>
<li>Admin experience with MySQL, Apache, SVN</li>
<li>Background developing in a more structured language (C, C++, Java, etc)</li>
<li>At least 3 years experience in high-traffic/high-availability web sites</li>
<li>Strong UI experience with javaScript and AJAX using mootools or other JS Frameworks</li>
<li>Experience with following technologies:  Memcached, Smarty, SOLR, Lucene, Zend Framework</li>
</ul>
<p>If you think you have what it takes, head over to our <a href="https://careers.cnetnetworks.com/joblist.html">Jobs site</a> and apply: <a href="https://careers.cnetnetworks.com/joblist.html">https://careers.cnetnetworks.com/joblist.html</a></p>
<p>If you want to discuss the job in more detail first, please don&#8217;t hesitate to send me an<br />
 at michael[<br />
]tougeron[<br />
]cnet[<br />
]com.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.grepmymind.com/2008/05/29/gamespot-and-tv-are-hiring/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL Conf 2008 &#8211; PHP/DBUnit (Day 2)</title>
		<link>http://www.grepmymind.com/2008/04/15/mysql-conf-2008-phpdbunit-day-2/</link>
		<comments>http://www.grepmymind.com/2008/04/15/mysql-conf-2008-phpdbunit-day-2/#comments</comments>
		<pubDate>Tue, 15 Apr 2008 20:50:39 +0000</pubDate>
		<dc:creator>Michael Tougeron</dc:creator>
				<category><![CDATA[Events]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[dbunit]]></category>
		<category><![CDATA[mysql08]]></category>
		<category><![CDATA[mysqlconf08]]></category>
		<category><![CDATA[phpunit]]></category>

		<guid isPermaLink="false">http://www.grepmymind.com/?p=51</guid>
		<description><![CDATA[I started off the day today listening to the keynotes at the MySQL Conference. Unfortunately I had to work on something so I wasn&#8217;t able to really pay attention. I hope I didn&#8217;t miss anything important. After the keynotes, I decided to start off with the Testing PHP/MySQL Applications with PHPUnit/DbUnit session by Sebastian Bermann. [...]]]></description>
			<content:encoded><![CDATA[<p>I started off the day today listening to the keynotes at the MySQL Conference.  Unfortunately I had to work on something so I wasn&#8217;t able to really pay attention.  <img src='http://www.grepmymind.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' />   I hope I didn&#8217;t miss anything important.</p>
<p>After the keynotes, I decided to start off with the <a href="http://en.oreilly.com/mysql2008/public/schedule/detail/165">Testing PHP/MySQL Applications with PHPUnit/DbUnit</a> session by <a href="http://sebastian-bergmann.de/">Sebastian Bermann</a>.  I know I should already be using <a href="http://www.phpunit.de/">PHPUnit</a>, but honestly I&#8217;ve never gotten around to it.  I&#8217;m hoping that this will give me the kick in the ass that I need to start.  <img src='http://www.grepmymind.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p><span id="more-22"></span></p>
<p>The first thing that Sebastian wanted us to note is that the PHPUnit listed on SourceForget.net is not the real PHPUnit.  I kind of thought that weird and confusing.  You&#8217;d think by now that he could get that old project de-listed.</p>
<p>Installing PHPUnit is fairly simple.  It is not hosted off the standard PEAR channel, but by a quick extra command you can get access to it.<br />
pear channel-discover pear.phpunit.de<br />
pear install phpunit/PHPUnit</p>
<p>By setting up a reusable testing environment with PHPUnit you&#8217;ll be able to do automatic execution of your test code.  This would be good for things like over night tests of the latest code commits.  If a test fails, the developer team can be immediately notified.  Be sure to enforce strict separation between production and testing environments.  The last thing you want to happen is to have your test cases somehow break production.</p>
<p>Setting up a test case can be as simple or complex as you need it to be.  You setup a class for each element/object you need to test.  Each test case is a member function of this class where you assert value comparisons.  While the <a href="http://www.phpunit.de/pocket_guide/3.2/en/writing-tests-for-phpunit.html">documentation examples are best</a>, here is a very simple example:</p>
<pre>
&lt;?php
class BankAccountTest extends PHPUnit_Framework_TestCase {

    public function testBalanceIsInitiallyZero() {
        $ba = new BankAccount;
        $this-&gt;assertEquals(0, $ba-&gt;getBalance());
    }
}
?&gt;</pre>
<p>Where things can now start to get interesting is when you use the <a href="http://www.phpunit.de/wiki/TestDatabase">database extension</a> to PHPUnit.  The DBUnit extension was ported from <a href="http://www.junit.org/">jUnit</a> by <a href="http://www.ds-o.com/">Michael Lively Jr</a>.</p>
<p>DBUnit uses PDO to talk to a default SQLite database.  However, a database it not required as it can emulate a database in memory or via XML.  It also works with MySQL, but if the tests are written in a way that is compatible with SQLite, then the tests can be faster by about 20%.</p>
<p>Once of the nice things about how DBUnit works is how it puts the db into a known state between each test run.  This means it avoids problems with one test case corrupting the db for other tests.  By using its ability to import/export data to/from XML datasets, your db tests will run reliably and accurately.</p>
<p>Like with PHPUnit, DBUnit has assert methods like &#8220;assertTableEquals(expected, actual)&#8221; and can use PHP arrays for comparison.  This can be good for comparing records in the database.  e.g., The db gets updated via a PHPunit test and you then do a DBUnit test to verify the action.</p>
<p>A quick example of a DBUnit test case:</p>
<pre>
&lt;?php
class BankAccountTest extends PHPUnit_Extensions_Database_TestCase {
    protected $pdo;

    public function __construct() {
        $this-&gt;pdo = PHPUnit_Util_PDO::factory($dsn);
        BankAccount::createTable($this-&gt;pdo);
    }

    protected function getConnection() {
        return $tihs-&gt;createDefaultDBConnection($this-&gt;pdo, 'mysql');
    }

    protect function getDataSet() {
        return $this-&gt;createFlatXMLDataSet('/path/to/seed.xml');
    }
}
?&gt;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.grepmymind.com/2008/04/15/mysql-conf-2008-phpdbunit-day-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>April SF PHP Meetup &#8211; symfony</title>
		<link>http://www.grepmymind.com/2008/03/28/april-sf-php-meetup-symfony/</link>
		<comments>http://www.grepmymind.com/2008/03/28/april-sf-php-meetup-symfony/#comments</comments>
		<pubDate>Fri, 28 Mar 2008 18:25:19 +0000</pubDate>
		<dc:creator>Michael Tougeron</dc:creator>
				<category><![CDATA[Events]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[dustin whittle]]></category>
		<category><![CDATA[php meetup]]></category>

		<guid isPermaLink="false">http://www.grepmymind.com/2008/03/28/april-sf-php-meetup-symfony/</guid>
		<description><![CDATA[Wow, I just realized how long it has been since I last posted here. It has been a crazy few weeks. Everything from setting up the baby furniture to fixing my rental condo, taxes to layoffs at CNET and more. I&#8217;m beat. Anway to the topic at hand&#8230; April&#8217;s PHP Meetup is looking like it [...]]]></description>
			<content:encoded><![CDATA[<p>Wow, I just realized how long it has been since I last posted here.  It has been a crazy few weeks.  Everything from setting up the <a href="http://www.target.com/Winsor-Convertible-4-in-1-Crib-Pine/dp/B000IMLIYC/qid=1206728661/ref=br_1_1/602-6759973-9185462?ie=UTF8&amp;node=10747331&amp;frombrowse=1&amp;rh=&amp;page=1">baby furniture</a> to fixing my rental condo, taxes to <a href="http://www.reuters.com/article/marketsNews/idUKN2645321620080326?rpc=44">layoffs at CNET</a> and more.  I&#8217;m beat.</p>
<p>Anway to the topic at hand&#8230;</p>
<p><a href="http://php.meetup.com/139/calendar/7472617/">April&#8217;s PHP Meetup</a> is looking like it will have another great turn out.  The group just keeps growing and growing.  Our average attendance for the last two months have been over 70 people!  I still have a hard time believing that this many shy, techie geeks like me actually show up.  <img src='http://www.grepmymind.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p><a href="http://php.meetup.com/139/calendar/7472617/">April&#8217;s topic</a> will be run by <a href="http://www.dustinwhittle.com/">Dustin Whittle</a> from Yahoo! and will be about the <a href="http://www.symfony-project.org/">symfony framework</a>.  He&#8217;ll be doing a brief overview of the framework and then walk people through setting up a site.  If you&#8217;re planning on attending, bring your laptop and code along with us.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.grepmymind.com/2008/03/28/april-sf-php-meetup-symfony/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Feb 2008 PHP Meetup &#8211; Terry Chay: OOps! The PHP Fear and Loathing Guide to OO Design</title>
		<link>http://www.grepmymind.com/2008/01/18/feb-2008-php-meetup-terry-chay-oops-the-php-fear-and-loathing-guide-to-oo-design/</link>
		<comments>http://www.grepmymind.com/2008/01/18/feb-2008-php-meetup-terry-chay-oops-the-php-fear-and-loathing-guide-to-oo-design/#comments</comments>
		<pubDate>Fri, 18 Jan 2008 23:27:05 +0000</pubDate>
		<dc:creator>Michael Tougeron</dc:creator>
				<category><![CDATA[Events]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[php meetup]]></category>
		<category><![CDATA[terry chay]]></category>

		<guid isPermaLink="false">http://www.grepmymind.com/2008/01/18/feb-2008-php-meetup-terry-chay-oops-the-php-fear-and-loathing-guide-to-oo-design/</guid>
		<description><![CDATA[We have a topic now for February&#8217;s PHP Meetup thanks to Terry Chay.  He&#8217;s going to clean up and update a talk he has on object-orientated PHP programming and give it to the group on Feb 7th. Terry has had a strong presence in the last couple of meetups; they probably wouldn&#8217;t have been successes [...]]]></description>
			<content:encoded><![CDATA[<p>We have a topic now for <a href="http://php.meetup.com/139/calendar/7027564/">February&#8217;s PHP Meetup</a> thanks to <a href="http://terrychay.com/blog/">Terry Chay</a>.  He&#8217;s going to clean up and update a talk he has on object-orientated PHP programming and give it to the group on Feb 7th.</p>
<p>Terry has had a strong presence in the last couple of meetups; they probably wouldn&#8217;t have been successes without him.  This talk should be pretty interesting and should draw a good sized crowd.</p>
<p>On a side note, what&#8217;s up with meetup.com lately and their email system?  It used to be I&#8217;d email the group and it&#8217;d arrive in my inbox a few minutes later.  Still nothing.  Weird.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.grepmymind.com/2008/01/18/feb-2008-php-meetup-terry-chay-oops-the-php-fear-and-loathing-guide-to-oo-design/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>last night&#8217;s geekSessions 1.3</title>
		<link>http://www.grepmymind.com/2008/01/16/last-nights-geeksessions-13/</link>
		<comments>http://www.grepmymind.com/2008/01/16/last-nights-geeksessions-13/#comments</comments>
		<pubDate>Wed, 16 Jan 2008 19:22:38 +0000</pubDate>
		<dc:creator>Michael Tougeron</dc:creator>
				<category><![CDATA[Events]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[geeksessions]]></category>

		<guid isPermaLink="false">http://www.grepmymind.com/2008/01/16/last-nights-geeksessions-13/</guid>
		<description><![CDATA[Last night&#8217;s geekSession as pretty interesting. The panel of PHP superstars knew their stuff (of course) and gave a high level 15 minute talk. For some reason I always enjoy watching when panelist debate back and forth over what the best approach is. Like when Lucas @ Facebook.com was talking about a few milliseconds of [...]]]></description>
			<content:encoded><![CDATA[<p>Last night&#8217;s <a href="http://www.geeksessions.com/2008/01/02/geeksessions-13-php-scalability-performance-and-the-future/">geekSession</a> as pretty interesting.  The panel of PHP superstars knew their stuff (of course) and gave a high level 15 minute talk.  For some reason I always enjoy watching when panelist debate back and forth over what the best approach is.  Like when <a href="http://www.facebook.com/people/Lucas_Nealan/10030226">Lucas</a> @ <a href="http://www.facebook.com">Facebook.com</a> was talking about a few milliseconds of speed and <a href="http://blog.libssh2.org/">Sara Golemon</a> @ Yahoo! said it didn&#8217;t matter.  <img src='http://www.grepmymind.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' />   All in good humor and it highlights that there are many solutions to the same problem.  Some may work and be essential  for one company and not make a difference for others.  Facebook does get a shit load of traffic so they&#8217;re always looking to get that extra little bit out of things.</p>
<p>It was nice to meet <a href="http://www.iamcal.com">Cal Henderson</a>, I <strong><em>love</em></strong> his book about site scalability &#8220;<a href="http://www.amazon.com/Building-Scalable-Web-Sites-applications/dp/0596102356/ref=pd_bbs_sr_1?ie=UTF8&amp;s=books&amp;qid=1200510673&amp;sr=8-1">Building Scalable Web Sites: Building, scaling, and optimizing the next generation of web applications</a>&#8221;  I highly recommend buying it if you haven&#8217;t already.  Of course I didn&#8217;t want to be a groupie or anything so I didn&#8217;t tell him that.  Wanted to though.  <img src='http://www.grepmymind.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p>I didn&#8217;t get an opportunity to talk with <a href="http://www.gravitonic.com/">Andrei</a>; I didn&#8217;t recognize him (stupid eyes) and it was too noisy to really hear his introduction.  I a bit too shy to try to re-introduce myself.</p>
<p>Surprisingly <a href="http://terrychay.com/blog/">Terry Chay</a> was quite quiet.  Didn&#8217;t stop the speakers from cussing for him.  Really glad he introduced me to Lucas though.  That was a big help.</p>
<p>Speaking of Lucas, he&#8217;s working on a new talk and wants to try it out before going to the conferences with it.  He&#8217;s thinking about bringing it to the <a href="http://php.meetup.com/139/">PHP Meetup</a> in the next couple of months to see how it goes.  I hope that happens, bringing more well known PHP names to the group will help take it to the next level.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.grepmymind.com/2008/01/16/last-nights-geeksessions-13/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

