<?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>Computer Hat</title>
	<atom:link href="http://www.miketmoore.com/computerhat/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.miketmoore.com/computerhat</link>
	<description>&#34;Time to put on my computer hat.&#34;</description>
	<lastBuildDate>Thu, 29 Jul 2010 18:54:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>PHP output and flash.net.URLLoader bytesTotal property</title>
		<link>http://www.miketmoore.com/computerhat/?p=25</link>
		<comments>http://www.miketmoore.com/computerhat/?p=25#comments</comments>
		<pubDate>Thu, 29 Jul 2010 18:54:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[actionscript-3]]></category>
		<category><![CDATA[bytesLoaded]]></category>
		<category><![CDATA[bytesTotal]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[flash.net.URLLoader]]></category>
		<category><![CDATA[loading]]></category>
		<category><![CDATA[ProgressEvent]]></category>
		<category><![CDATA[URLLoader]]></category>

		<guid isPermaLink="false">http://www.miketmoore.com/computerhat/?p=25</guid>
		<description><![CDATA[I hit a problem this week that had me stumped (what&#8217;s new?). So, I put on my scuba gear and dove into the code&#8230;. More after the jump&#8230;The setup: An SWF loads a PHP document which outputs XML: var url:String = 'some_relative_url.php'; var loader:URLLoader = new URLLoader(); var request:URLRequest = new URLRequest(url); loader.addEventListener(Event.COMPLETE, loadHandler); loader.addEventListener(ProgressEvent.PROGRESS, [...]]]></description>
			<content:encoded><![CDATA[<p>I hit a problem this week that had me stumped (what&#8217;s new?). So, I put on my scuba gear and dove into the code&#8230;.</p>
<p><a href="http://thepoodleanddogblog.typepad.com/.a/6a00d83451580669e20120a5be24aa970b-pi"><img src="http://thepoodleanddogblog.typepad.com/.a/6a00d83451580669e20120a5be24aa970b-pi" alt="" width="245" height="280" /></a></p>
<p>More after the jump&#8230;<span id="more-25"></span>The setup:</p>
<p>An SWF loads a PHP document which outputs XML:</p>
<pre class="brush: xml;">
var url:String = 'some_relative_url.php';
var loader:URLLoader = new URLLoader();
var request:URLRequest = new URLRequest(url);
loader.addEventListener(Event.COMPLETE, loadHandler);
loader.addEventListener(ProgressEvent.PROGRESS, progressHandler);

function progressHandler(event:ProgressEvent):void
{
  trace('Progress: ' + event.bytesLoaded + '/' + event.bytesTotal);
  if(event.bytesLoaded == event.bytesTotal)
    dispatchLoadComplete();
}

function loadHandler(event:Event):void
{
  trace('XML has loaded.');
  var xml:XML = XML(event.target.data);
  trace(xml);
}

//Why am I dispatching that the event is complete? Because this example is from the innards of
//a custom preloader that I created, in which the preloader animation finishes and then the
//preloader announces when the XML is finished loading (Source for the preloader below)
function dispatchLoadComplete():void
{
  dispatchEvent(new Event(Event.COMPLETE));
}
</pre>
<p>The above code works just fine when loading a file which already has content (for example: loading a pre-existing XML file such as `some_file.xml`. The above code <strong>DOES NOT</strong> work if the URLLoader is loading a PHP script that <em>outputs</em> the XML, even with correct headers. Here is an example of the PHP script I was loading into Flash:</p>
<pre class="brush: xml;">
&lt;?php
$xml = &quot;&lt;?xml version=&quot;1.0&quot;?&gt;&lt;root&gt;&lt;urls&gt;&lt;url name=&quot;Google&quot; value=&quot;http://www.google.com&quot;&gt;&lt;/url&gt;&lt;/urls&gt;&lt;/root&gt;&quot;;
file_put_contents('somefile.xml', $xml);

//Output XML for Flash
ob_start();
header('Content-Type: text/xml');
header('Content-Transfer-Encoding: binary');
header(&quot;Content-Length: &quot; . filesize('../xml/dynamic.xml') . &quot;;&quot;);
//header(&quot;filename='dynamic.xml'&quot;);
echo $xmlMaker-&gt;getDoc();
ob_end_flush();
?&gt;
</pre>
<p>The above PHP script does load, but the ProgressEvent handler is unable to retrieve the correct file size, and as such only retrieves 0. </p>
<p><strong>Solution</strong><br />
Change the PHP script to redirect to the new file rather than just outputting it, like this:</p>
<pre class="brush: xml;">
&lt;?php
$xml = &quot;&lt;?xml version=&quot;1.0&quot;?&gt;&lt;root&gt;&lt;urls&gt;&lt;url name=&quot;Google&quot; value=&quot;http://www.google.com&quot;&gt;&lt;/url&gt;&lt;/urls&gt;&lt;/root&gt;&quot;;
file_put_contents('somefile.xml', $xml);

header('Location: somefile.xml');
?&gt;
</pre>
<p>That works, as the URLLoader&#8217;s ProgressEvent is able to retrieve the correct file size.</p>
<p><strong>Source code for my custom preloader</strong></p>
<p>A library MovieClip extends this class in the Flash IDE and contains a TextField (messageTxt) and a MovieClip (progressBar) within it. Example usage below.</p>
<pre class="brush: xml;">
package mtm.wl.display
{
	import fl.transitions.easing.Regular;
	import fl.transitions.Tween;
	import flash.display.Loader;
	import flash.display.LoaderInfo;
	import flash.display.MovieClip;
	import flash.events.ErrorEvent;
	import flash.events.Event;
	import flash.events.IOErrorEvent;
	import flash.events.ProgressEvent;
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	import flash.text.TextField;
	import mtm.net.MultiLoader;
	import mtm.net.MultiURLRequests;
	import mtm.wl.events.WLPreloaderEvent;
	import nl.demonsters.debugger.MonsterDebugger;

	/**
	 * ...
	 * @author Michael T. Moore
	 */
	public class WLPreloader extends MovieClip
	{
		//Stage Instances (must be public)
		public var messageTxt:TextField;
		public var progressBar:MovieClip;

		protected var tween:Tween;

		protected var _loader:*;
		protected var _request:*;
		protected var _completeHandler:Function;
		protected var _target:*;
		protected var preloadComplete:Boolean = false;

		public static const PROGRESS_BAR_MAX_WIDTH:uint = 112;

		private var debugger:MonsterDebugger;

		public function WLPreloader()
		{
			debugger = new MonsterDebugger(this);

			this.alpha = 0;
		}

		public function set message(message:String):void
		{
			messageTxt.text = message;
		}

		public function prepare(loader:*, request:*, completeHandler:Function, msg:String):void
		{
			MonsterDebugger.trace(this, 'prepare()');

			//Check loader type
			if ((loader is URLLoader) || (loader is Loader) || (loader is MultiLoader))
				_loader = loader;
			else
				throw new Error('Argument loader is not correct type. Must be: 1)URLLoader, 2)Loader, or 3)MultiLoader in WLPreloader.prepare()');

			//Check request type
			if (loader is MultiLoader)
			{
				if (request is MultiURLRequests)
					_request = request;
				else
					throw new Error('Loader is of type MultiLoader, but request is not of type MultiURLRequests in WLPreloader.prepare()');
			}
			else if ((loader is URLLoader) || (loader is Loader))
			{
				if (request is URLRequest)
					_request = request;
				else
					throw new Error('Argument request is not correct type. Must be: URLRequest in WLPreloader.prepare()');
			}

			_completeHandler = completeHandler;
			message = msg;
			init();
		}

		protected function init():void
		{
			MonsterDebugger.trace(this, 'init()');

			resetProgressBar();
			preloadComplete = false;
			if (_loader is URLLoader)
			{
				MonsterDebugger.trace(this, '_loader is URLLoader');
				_loader.addEventListener(Event.COMPLETE, getEventData);
				_loader.addEventListener(IOErrorEvent.IO_ERROR, catchError);
				_loader.addEventListener(ProgressEvent.PROGRESS, increment);
				_loader.load(_request);
			}
			else if (_loader is Loader)
			{
				MonsterDebugger.trace(this, '_loader is Loader');
				_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, getEventData);
				_loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, catchError);
				_loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, increment);
				_loader.load(_request);
			}
			else if (_loader is MultiLoader)
			{
				MonsterDebugger.trace(this, '_loader is MultiLoader');
				_loader.addEventListener(Event.COMPLETE, getEventData);
				_loader.addEventListener(IOErrorEvent.IO_ERROR, catchError);
				_loader.addEventListener(ProgressEvent.PROGRESS, increment);
				_loader.load(_request);
			}
		}

		protected function resetProgressBar():void { progressBar.width = 0; }

		public static function percentage(loaded:uint, total:uint):uint
		{
			return Math.round(loaded / (total / PROGRESS_BAR_MAX_WIDTH));
		}

		public function increment(event:ProgressEvent):void
		{
			progressBar.width = percentage(ProgressEvent(event).bytesLoaded, ProgressEvent(event).bytesTotal);
			MonsterDebugger.trace(this, 'Progress: ' + event.bytesLoaded + '/' + event.bytesTotal);
			if (progressBar.width == PROGRESS_BAR_MAX_WIDTH)
			{
				MonsterDebugger.trace(this, 'progressBar.width == PROGRESS_BAR_MAX_WIDTH');
				addEventListener(Event.ENTER_FRAME, check);
			}
		}

		protected function getEventData(event:Event):void
		{
			MonsterDebugger.trace(this, 'getEventData()');
			_target = null;

			if (event.target is URLLoader)
				_target = URLLoader(event.target);
			else if (event.target is LoaderInfo)
				_target = LoaderInfo(event.target);
			else if (event.target is MultiLoader)
				_target = MultiLoader(event.target);

			MonsterDebugger.trace(this, '_target = ' + _target);

			preloadComplete = true;
		}

		protected function check(event:Event):void
		{
			if (preloadComplete)
			{
				MonsterDebugger.trace(this, 'preloadComplete == true');
				removeEventListener(Event.ENTER_FRAME, check);
				dispatchPreloadCompleteEvent();
			}
		}

		protected function dispatchPreloadCompleteEvent():void
		{
			MonsterDebugger.trace(this, 'dispatchPreloadCompleteEvent()');
			_completeHandler(new Event(Event.COMPLETE));
			//dispatchEvent(new Event(Event.COMPLETE));
		}

		public function show(fade = true):void
		{
			(fade) ? tween = new Tween(this, &quot;alpha&quot;, Regular.easeIn, 0, 1, 5) : this.alpha = 1;
		}

		public function hide(fade = true):void
		{
			(fade) ? tween = new Tween(this, &quot;alpha&quot;, Regular.easeIn, 1, 0, 5) : this.alpha = 0;
		}

		protected function catchError(event:ErrorEvent):void
		{
			if (event is IOErrorEvent)
				throw new Error('IOErrorEvent caught in ' + this + ': ' + event.text);
			else
				throw new Error('Error caught in ' + this + ': ' + event.text);
		}

		public function get target():*
		{
			return _target;
		}

	}

}
</pre>
<p>Use the preloader like this:</p>
<pre class="brush: xml;">
preloader.prepare(new URLLoader(), new URLRequest('someurl.php'), completeHandler, 'Loading Something');
function completeHandler(event:Event):void
{
  var loader:URLLoader = URLLoader(preloader.target);
}
</pre>
<p>If you are curious about my <tt>MultiLoader</tt> and <tt>MultiURLRequests</tt> classes, just let me know and I&#8217;ll post them.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.miketmoore.com/computerhat/?feed=rss2&amp;p=25</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Array.sortOn()</title>
		<link>http://www.miketmoore.com/computerhat/?p=23</link>
		<comments>http://www.miketmoore.com/computerhat/?p=23#comments</comments>
		<pubDate>Sat, 24 Jul 2010 16:50:46 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[actionscript-3]]></category>
		<category><![CDATA[Array]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[sorting]]></category>

		<guid isPermaLink="false">http://www.miketmoore.com/computerhat/?p=23</guid>
		<description><![CDATA[In a current AS3 project I am maintaining information about images in a custom Image class that extends Object. One of the properties of an Image instance is .orderNum. When I retrieve a list of Image instances, I store them in an Array instance. I need to sort the images within the array by the [...]]]></description>
			<content:encoded><![CDATA[<p>In a current AS3 project I am maintaining information about images in a custom <tt>Image</tt> class that extends <tt>Object</tt>. One of the properties of an <tt>Image</tt> instance is <tt>.orderNum</tt>. When I retrieve a list of <tt>Image</tt> instances, I store them in an <tt>Array</tt> instance. I need to sort the images within the array by the <tt>.orderNum</tt> property. Enter the <a href="http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/Array.html#sortOn%28%29"><tt>Array.sortOn()</tt> method</a>&#8230;</p>
<pre class="brush: xml;">
//Create an array to hold Objects representing images
var images:Array = new Array();

//Create some objects representing images
images[0] = new Object();
images[0].filename = 'cat.jpg';
images[0].orderNum = 0;

images[1] = new Object();
images[1].filename = 'dog.jpg';
images[1].orderNum = 2;

images[2] = new Object();
images[2].filename = 'dragon.jpg';
images[2].orderNum = 1;

display(images);
/*
Contents of images:
images[0].orderNum = 0
images[1].orderNum = 2
images[2].orderNum = 1
*/

//Sort the images array by the &quot;orderNum&quot; property of each Object value
images.sortOn(&quot;orderNum&quot;);

display(images);
/*
Contents of images:
images[0].orderNum = 0
images[1].orderNum = 1
images[2].orderNum = 2
*/

function display(images:Array):void
{
  trace('Contents of images:');
  for(var i:int = 0; i &lt; images.length; i++)
  {
    trace('images[' + i + '].orderNum = ' + images[i].orderNum);
  }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.miketmoore.com/computerhat/?feed=rss2&amp;p=23</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Programmatically embed fonts with AS3</title>
		<link>http://www.miketmoore.com/computerhat/?p=21</link>
		<comments>http://www.miketmoore.com/computerhat/?p=21#comments</comments>
		<pubDate>Wed, 21 Jul 2010 05:53:48 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AS3]]></category>

		<guid isPermaLink="false">http://www.miketmoore.com/computerhat/?p=21</guid>
		<description><![CDATA[I just learned how to embed a font into an AS3 class I am developing—without doing anything in the Flash IDE! Credit goes to this blog and this answer on stackoverflow.com. Where&#8217;s your font file? Find the location of the truetype (TTF) file for the font you are going to embed. I am using Futura [...]]]></description>
			<content:encoded><![CDATA[<p>I just learned how to embed a font into an AS3 class I am developing—without doing anything in the Flash IDE! Credit goes to this <a href="http://marumushi.com/news/embedding-fonts-in-as3" target="_blank">blog</a> and <a href="http://stackoverflow.com/questions/537811/programmatically-embed-kanji-in-textfield">this answer on stackoverflow.com</a>.</p>
<p><strong>Where&#8217;s your font file?</strong><br />
Find the location of the truetype (TTF) file for the font you are going to embed. I am using Futura Std Book, and it&#8217;s truetype file is located at <tt>C:\Windows\Fonts\FuturaStd-Book.ttf</tt>.</p>
<p><strong>The code</strong><br />
Add the following code to your AS3 class. I added mine alongside my class property definitions:</p>
<pre>[Embed(source="C:\WINDOWS\Fonts\FuturaStd-Book.ttf", fontFamily="Futura Std Book")]</pre>
<p><strong>Note:</strong> The <tt>fontFamily</tt> variable in the above code must be the family name for your font. So, for example, I <em>had</em> to use &#8220;Futura Std Book&#8221;. I could not have chosen something custom like &#8220;Futura&#8221; or &#8220;futurefont&#8221; or &#8220;bacon&#8221;. Mmmm&#8230; bacon&#8230;</p>
<p>This was a bit of a pain because the font file did not have spaces (&#8220;FuturaStd-Book.ttf&#8221;), but if you are on Windows, you can double-click your TTF file and it will see the &#8220;Font name&#8221; that you need to use. Here&#8217;s a screenshot from my computer:</p>
<p><a href="http://www.miketmoore.com/computerhat/wp-content/uploads/2010/07/font.jpg"><img class="alignnone size-full wp-image-22" title="font" src="http://www.miketmoore.com/computerhat/wp-content/uploads/2010/07/font.jpg" alt="" width="343" height="218" /></a></p>
<p><strong>Setup the TextFormat instance</strong></p>
<pre>//Imports
import flash.text.TextFormat;
import flash.text.AntiAliasType;
import flash.text.TextField;

//Declare your TextFormat instance
protected var format:TextFormat = new TextFormat();

//Setup the font with your TextFormat instance
//This must be exactly what you set as "fontFamily" in the Embed code
format.font = "Futura Std Book";
format.embedFonts = true;
format.antiAliasType = AntiAliasType.ADVANCED;
format.size = 14;

var textField:TextField = new TextField();
textField.setTextFormat(format);
textField.text = 'Awesome!';
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.miketmoore.com/computerhat/?feed=rss2&amp;p=21</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Security Sandbox Violation Error #2121</title>
		<link>http://www.miketmoore.com/computerhat/?p=20</link>
		<comments>http://www.miketmoore.com/computerhat/?p=20#comments</comments>
		<pubDate>Mon, 19 Jul 2010 00:04:16 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.miketmoore.com/computerhat/?p=20</guid>
		<description><![CDATA[I encountered my first Security Sandbox error while testing an AS3 project on the production server. I have a primary SWF called top.swf that loads an XML file with a list of URLs for other SWF files that will be loaded as sub-SWFs in top.swf. The XML file loads fine (it is located in a [...]]]></description>
			<content:encoded><![CDATA[<p>I encountered my first Security Sandbox error while testing an AS3 project on the production server.</p>
<p>I have a primary SWF called <tt>top.swf</tt> that loads an XML file with a list of URLs for other SWF files that will be loaded as sub-SWFs in <tt>top.swf</tt>.</p>
<p>The XML file loads fine (it is located in a directory below <tt>top.swf</tt>). The issue is in the loading of the sub-SWFs (all located in a directory below <tt>top.swf</tt> called <tt>swf</tt>. To avoid this error/security violation, add the following line to the constructor of each of your sub-SWF&#8217;s Document class:</p>
<pre>Security.allowDomain('*');</pre>
<p>You will need to add the following import to each of the Document classes as well:</p>
<pre>import flash.system.Security;</pre>
<p><strong>Note:</strong> You must have the Flash Debug Player installed to catch Security Sandbox violations in your browser.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.miketmoore.com/computerhat/?feed=rss2&amp;p=20</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Preventing caching in Flash CS3 IDE</title>
		<link>http://www.miketmoore.com/computerhat/?p=19</link>
		<comments>http://www.miketmoore.com/computerhat/?p=19#comments</comments>
		<pubDate>Sun, 11 Jul 2010 20:42:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.miketmoore.com/computerhat/?p=19</guid>
		<description><![CDATA[I am working on an AS3 project and developing it with the Flash CS3 IDE and FlashDevelop 3.0.6. I write all of the code in FlashDevelop and use the Flash IDE to create visual elements that would be a pain in the arse to code. When using flash.net.URLLoader to load external XML data and working [...]]]></description>
			<content:encoded><![CDATA[<p>I am working on an AS3 project and developing it with the Flash CS3 IDE and FlashDevelop 3.0.6. I write all of the code in FlashDevelop and use the Flash IDE to create visual elements that would be a pain in the arse to code.</p>
<p>When using <tt>flash.net.URLLoader</tt> to load external XML data and working on the local server, if the XML is updated between compiles, Flash CS3 will keep loading the previous version. In my case I have a PHP file that is called and the PHP file outputs XML.</p>
<p><strong>To prevent the cache issue:</strong></p>
<p>Append a randomly generated number to the URL string that points to the XML file (or, in my case, the PHP file).</p>
<pre>
var xmlUrl:String = 'some_url.php';
var randomNumber:int = Math.round(Math.random()*100000000);
xmlUrl += '?prevent_cache=' + randomNumber;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.miketmoore.com/computerhat/?feed=rss2&amp;p=19</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Storing functions in an array and then calling them.</title>
		<link>http://www.miketmoore.com/computerhat/?p=17</link>
		<comments>http://www.miketmoore.com/computerhat/?p=17#comments</comments>
		<pubDate>Sat, 10 Jul 2010 16:15:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AS3]]></category>

		<guid isPermaLink="false">http://www.miketmoore.com/computerhat/?p=17</guid>
		<description><![CDATA[I devised a way to store functions in an array and then call them later. I used this for implementing a loading queue that calls each consecutive function when an asynchronous load process completes. var functionsArray:Array = new Array(); register(testA); register(testB); for each(var f:Function in functionsArray) { f(); } function register(f:Function):void { functionsArray.push(f); } function [...]]]></description>
			<content:encoded><![CDATA[<p>I devised a way to store functions in an array and then call them later. I used this for implementing a loading queue that calls each consecutive function when an asynchronous load process completes.</p>
<pre>
var functionsArray:Array = new Array();

register(testA);
register(testB);

for each(var f:Function in functionsArray)
{
	f();
}

function register(f:Function):void
{
  functionsArray.push(f);
}

function testA():void
{
  trace('testA() called.');
}

function testB():void
{
  trace('testB() called.');
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.miketmoore.com/computerhat/?feed=rss2&amp;p=17</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Configure Dreamweaver CS3 to color *.inc files as it does *.php files on Windows Vista</title>
		<link>http://www.miketmoore.com/computerhat/?p=15</link>
		<comments>http://www.miketmoore.com/computerhat/?p=15#comments</comments>
		<pubDate>Thu, 03 Jun 2010 21:07:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Software Configuration]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[adobe]]></category>
		<category><![CDATA[cs3]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[dreamweaver]]></category>
		<category><![CDATA[inc]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://www.miketmoore.com/computerhat/?p=15</guid>
		<description><![CDATA[I have Dreamweaver CS3 installed on Windows Vista (Home Premium). It turns out that if you want Dreamweaver to color *.inc files as it does *.php files, you need to add inc to the file called MMDocumentTypes.xml. The document is located at C:\Program Files\Adobe\Adobe Dreamweaver CS3\configuration\DocumentTypes\MMDocumentTypes.xml on my machine. Edit the winfileextension and macfileextension attributes [...]]]></description>
			<content:encoded><![CDATA[<p>I have Dreamweaver CS3 installed on Windows Vista (Home Premium). It turns out that if you want Dreamweaver to color <tt>*.inc</tt> files as it does <tt>*.php</tt> files, you need to add <tt>inc</tt> to the file called <tt>MMDocumentTypes.xml</tt>. The document is located at <tt>C:\Program Files\Adobe\Adobe Dreamweaver CS3\configuration\DocumentTypes\MMDocumentTypes.xml</tt> on my machine.</p>
<p>Edit the <tt>winfileextension</tt> and <tt>macfileextension</tt> attributes to include <tt>inc</tt>.</p>
<p><b>Before:</b></p>
<pre class="brush: xml;">
&lt;documenttype id=&quot;PHP_MySQL&quot; servermodel=&quot;PHP MySQL&quot; internaltype=&quot;Dynamic&quot; winfileextension=&quot;php,php3,php4,php5&quot; macfileextension=&quot;php,php3,php4,php5&quot; file=&quot;Default.php&quot; writebyteordermark=&quot;false&quot;&gt;
</pre>
<p><b>After:</b></p>
<pre class="brush: xml;">
&lt;documenttype id=&quot;PHP_MySQL&quot; servermodel=&quot;PHP MySQL&quot; internaltype=&quot;Dynamic&quot; winfileextension=&quot;php,php3,php4,php5,inc&quot; macfileextension=&quot;php,php3,php4,php5,inc&quot; file=&quot;Default.php&quot; writebyteordermark=&quot;false&quot;&gt;
</pre>
<p>Save the file and restart Dreamweaver. Worked for me! Thanks to <a href="http://superuser.com/users/1931/john-t">John T</a> on <a href="http://www.superuser.com">superuser</a> for this <a href="http://superuser.com/questions/115614/how-make-dreamweaver-color-the-code-as-php-for-inc-files/115617#115617">solution</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.miketmoore.com/computerhat/?feed=rss2&amp;p=15</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[PHP] Upload Script (For JPEG Files) &#8211; Part 1</title>
		<link>http://www.miketmoore.com/computerhat/?p=13</link>
		<comments>http://www.miketmoore.com/computerhat/?p=13#comments</comments>
		<pubDate>Tue, 25 May 2010 21:34:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[error-handling]]></category>

		<guid isPermaLink="false">http://www.miketmoore.com/computerhat/?p=13</guid>
		<description><![CDATA[I have been having some serious issues building a thorough file upload script for JPEG files using PHP. It is surprising to me how little information I can find about writing upload scripts that check errors and try to make the experience as user-friendly as possible when errors occur. I will document my discoveries in [...]]]></description>
			<content:encoded><![CDATA[<p>I have been having some serious issues building a thorough file upload script for JPEG files using PHP. It is surprising to me how little information I can find about writing upload scripts that check errors and try to make the experience as user-friendly as possible when errors occur.</p>
<p>I will document my discoveries in a series of posts, starting with this one.</p>
<p><b>The post_max_size setting in php.ini:</b></p>
<p>Per <a href="http://stackoverflow.com/users/47773/matthew-flaschen">Matthew Flaschen&#8217;s</a> answer to <a href="http://stackoverflow.com/questions/2902016/php-what-exactly-does-it-mean-when-files-is-empty">my question</a> &#8220;What exactly does it mean when $_FILES is empty?&#8221;, it is most likely due to the size of the to-be-uploaded-file exceeding what <tt>post_max_size</tt> is set to in <tt>php.ini</tt>. This was the problem when I tried uploading a 17MB TIFF image file to test what would happen on the user&#8217;s end. Specifically, the <tt>$_FILES</tt> superglobal (and <tt>$_POST</tt>) were returning empty. Had I read through <a href="http://php.net/manual/en/ini.core.php">this PHP manual page</a>, I would have figured that out (scroll down to <tt>post_max_size</tt> in that link).</p>
<p>So, now I check if <tt>$_POST</tt> or <tt>$_FILES</tt> are empty with:</p>
<pre>
if(empty($_POST) || empty($_FILES))
{
    //Do some friendly error-checking here
}
</pre>
<p>As of right now, I am displaying an error recommending that the user check the size of their file. In the current project I am working on, it is very likely that the client is attempting to upload original high-resolution image files (which are typically well over the 2M default <tt>upload_max_filesize</tt> and most definitely well over the 8M default <tt>post_max_size</tt> in <tt>php.ini</tt>).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.miketmoore.com/computerhat/?feed=rss2&amp;p=13</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ZIP-a-Dee-Doo-Dah</title>
		<link>http://www.miketmoore.com/computerhat/?p=11</link>
		<comments>http://www.miketmoore.com/computerhat/?p=11#comments</comments>
		<pubDate>Tue, 25 May 2010 19:11:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.miketmoore.com/computerhat/?p=11</guid>
		<description><![CDATA[I am using unzip for the first time in Linux. I had to apt-get install unzip zip first. I am installing WordPress 2.9.2 on my development server, which means I downloaded the WordPress ZIP file and FTPed it to my server. I found this tutorial which led me to the proper command to unzip WordPress [...]]]></description>
			<content:encoded><![CDATA[<p>I am using
<pre>unzip</pre>
<p> for the first time in Linux. I had to <code>apt-get install unzip zip</code> first.</p>
<p>I am installing WordPress 2.9.2 on my development server, which means I downloaded the WordPress ZIP file and FTPed it to my server. I found <a href="http://www.cyberciti.biz/tips/how-can-i-zipping-and-unzipping-files-under-linux.html">this tutorial</a> which led me to the proper command to unzip WordPress into a specified directory:</p>
<pre>unzip wordpress-2.9.2.zip -d /var/www</pre>
<p>This gave me
<pre>/var/www/wordpress</pre>
<p>, which I renamed to
<pre>/var/www/miketmoore</pre>
<p> by using
<pre>mv /var/www/wordpress /var/www/miketmoore</pre>
<p>.</p>
<p>Yay for zipping!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.miketmoore.com/computerhat/?feed=rss2&amp;p=11</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting up Ubuntu Server Edition 10.04</title>
		<link>http://www.miketmoore.com/computerhat/?p=10</link>
		<comments>http://www.miketmoore.com/computerhat/?p=10#comments</comments>
		<pubDate>Mon, 24 May 2010 18:31:12 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[lamp]]></category>
		<category><![CDATA[lucid lynx]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[vsftpd]]></category>

		<guid isPermaLink="false">http://www.miketmoore.com/computerhat/?p=10</guid>
		<description><![CDATA[I recently bartered for a Dell Dimension 4500 and set it up as a LAMP server. I started with Ubuntu Server Edition 10.04 (Lucid Lynx) and then switched to Debian server, but had internet connection issues with Debian, so I switched back to Ubuntu and haven&#8217;t had any issues. This is the primary resource that [...]]]></description>
			<content:encoded><![CDATA[<p>I recently bartered for a Dell Dimension 4500 and set it up as a <a href="http://en.wikipedia.org/wiki/LAMP_%28software_bundle%29">LAMP</a> server. I started with <a href="http://www.ubuntu.com/getubuntu/download-server">Ubuntu Server Edition</a> 10.04 (Lucid Lynx) and then switched to Debian server, but had internet connection issues with Debian, so I switched back to Ubuntu and haven&#8217;t had any issues. <a href="http://www.howtoforge.com/perfect-server-ubuntu-10.04-lucid-lynx-ispconfig-2">This</a> is the primary resource that I used for setting up the server.</p>
<p>This is my first direct experience with Linux. I also grabbed a copy of <a href="http://www.granneman.com/">Scott Granneman&#8217;s</a> <a href="http://www.amazon.com/gp/product/0672328380/">Linux Phrasebook</a>. It&#8217;s a great book for introductory <a href="http://en.wikipedia.org/wiki/Shell_%28computing%29">shell</a> commands. I also have needed to consult various internet resources for some things (mainly with learning about <a href="http://www.zzee.com/solutions/linux-permissions.shtml">Linux permissions</a>).</p>
<p>The primary reason that I wanted an actual server in the first place (rather than stick with my previous setup of <a href="http://www.wampserver.com/en/">WAMPServer</a>) was to learn more about what my hosting service deals with and to understand security risks better. In the week that I&#8217;ve had the server set up I have learned a great deal about how permissions settings on files and directories affect public access. In addition, I have learned some basic administration for <a href="http://vsftpd.beasts.org/">vsftpd</a> (FTP server I installed). Specifically, in editing `vsftpd.conf`, which is located at `/etc/vsftpd.conf`.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.miketmoore.com/computerhat/?feed=rss2&amp;p=10</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
