<?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>Navarr&#039;s Tech Side &#187; Code</title>
	<atom:link href="http://tech.navarr.me/tag/code/feed" rel="self" type="application/rss+xml" />
	<link>http://tech.navarr.me</link>
	<description>The Technical Side of my Life</description>
	<lastBuildDate>Sun, 11 Jul 2010 00:52:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
<cloud domain='tech.navarr.me' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
		<item>
		<title>How to create a socket server in PHP</title>
		<link>http://tech.navarr.me/2010/07/how-to-create-a-socket-server-in-php.html</link>
		<comments>http://tech.navarr.me/2010/07/how-to-create-a-socket-server-in-php.html#comments</comments>
		<pubDate>Wed, 30 Jun 2010 23:47:28 +0000</pubDate>
		<dc:creator>Navarr</dc:creator>
				<category><![CDATA[class::IRCServer]]></category>
		<category><![CDATA[class::SocketServer]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[irc]]></category>
		<category><![CDATA[oop]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[php5]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[sockets]]></category>

		<guid isPermaLink="false">http://tech.gtaero.net/?p=470</guid>
		<description><![CDATA[Ever tried searching for information on how to properly create a multi-client socket server in PHP?  You’ll get plenty of results with outdated and messy source code, some of which won’t even work. This was the my state a couple days ago when I decided that I wanted to build an IRC server.  The why [...]]]></description>
			<content:encoded><![CDATA[<p>Ever tried searching for information on how to properly create a multi-client socket server in PHP?  You’ll get plenty of results with outdated and messy source code, some of which won’t even work.</p>
<p>This was the my state a couple days ago when I decided that I wanted to build an IRC server.  The why is not important… (<em>For the fun of building an IRC Server</em>).  So I googled around a <span style="text-decoration: line-through;">hell of a lot</span> bit until I finally found some code that worked on its own, and quickly built a semi-functional IRC server using it, and headed off to sleep at 5am.</p>
<p>The next day I was very, very happy with the results of my hard labor, but it wasn’t good enough, so I started re-writing it from scratch as an Object, and thus I created <a href="http://gist.github.com/457900">class::IRCServer</a>.</p>
<p>Today, once I felt that I was finished screwing around with my newly built IRCd, I decided to modify the function enough to be used on its own as a socket server, to share with the world.</p>
<p>And thus, <a href="http://gist.github.com/459321">class::SocketServer</a> was created.</p>
<pre><div id="wpshdo_1" class="wp-synhighlighter-outer"><div id="wpshdt_1" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_1"></a><a id="wpshat_1" class="wp-synhighlighter-title" href="#codesyntax_1"  onClick="javascript:wpsh_toggleBlock(1)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_1" onClick="javascript:wpsh_code(1)" title="Show code only"><img border="0" style="border: 0 none" src="http://tech.navarr.me/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_1" onClick="javascript:wpsh_print(1)" title="Print code"><img border="0" style="border: 0 none" src="http://tech.navarr.me/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://tech.navarr.me/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://tech.navarr.me/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_1" class="wp-synhighlighter-inner" style="display: block;"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span> ?php
	<span style="color: #666666; font-style: italic;">/*!	@class		SocketServer
		@author		Navarr Barnier
		@abstract 	A Framework for creating a multi-client server using the PHP language.
	 */</span>
	<span style="color: #000000; font-weight: bold;">class</span> SocketServer
	<span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">/*!	@var		config
			@abstract	Array - an array of configuration information used by the server.
		 */</span>
		protected <span style="color: #000088;">$config</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">/*!	@var		hooks
			@abstract	Array - a dictionary of hooks and the callbacks attached to them.
		 */</span>
		protected <span style="color: #000088;">$hooks</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">/*!	@var		master_socket
			@abstract	resource - The master socket used by the server.
		 */</span>
		protected <span style="color: #000088;">$master_socket</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">/*!	@var		max_clients
			@abstract	unsigned int - The maximum number of clients allowed to connect.
		 */</span>
		<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000088;">$max_clients</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">/*!	@var		max_read
			@abstract	unsigned int - The maximum number of bytes to read from a socket at a single time.
		 */</span>
		<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000088;">$max_read</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1024</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">/*!	@var		clients
			@abstract	Array - an array of connected clients.
		 */</span>
		<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000088;">$clients</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">/*!	@function	__construct
			@abstract	Creates the socket and starts listening to it.
			@param		string	- IP Address to bind to, NULL for default.
			@param		int	- Port to bind to
			@result		void
		 */</span>
		<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #000088;">$bind_ip</span><span style="color: #339933;">,</span><span style="color: #000088;">$port</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<a href="http://www.php.net/set_time_limit"><span style="color: #990000;">set_time_limit</span></a><span style="color: #009900;">&#40;</span>0<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">hooks</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">config</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;ip&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$bind_ip</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">config</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;port&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$port</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">master_socket</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/socket_create"><span style="color: #990000;">socket_create</span></a><span style="color: #009900;">&#40;</span>AF_INET<span style="color: #339933;">,</span> SOCK_STREAM<span style="color: #339933;">,</span> 0<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<a href="http://www.php.net/socket_bind"><span style="color: #990000;">socket_bind</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">master_socket</span><span style="color: #339933;">,</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">config</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;ip&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">config</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;port&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> or <a href="http://www.php.net/die"><span style="color: #990000;">die</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Issue Binding&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<a href="http://www.php.net/socket_getsockname"><span style="color: #990000;">socket_getsockname</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">master_socket</span><span style="color: #339933;">,</span><span style="color: #000088;">$bind_ip</span><span style="color: #339933;">,</span><span style="color: #000088;">$port</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<a href="http://www.php.net/socket_listen"><span style="color: #990000;">socket_listen</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">master_socket</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			SocketServer<span style="color: #339933;">::</span><span style="color: #004000;">debug</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Listenting for connections on <span style="color: #006699; font-weight: bold;">{$bind_ip}</span>:<span style="color: #006699; font-weight: bold;">{$port}</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">/*!	@function	hook
			@abstract	Adds a function to be called whenever a certain action happens.  Can be extended in your implementation.
			@param		string	- Command
			@param		callback- Function to Call.
			@see		unhook
			@see		trigger_hooks
			@result		void
		 */</span>
		<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> hook<span style="color: #009900;">&#40;</span><span style="color: #000088;">$command</span><span style="color: #339933;">,</span><span style="color: #000088;">$function</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$command</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/strtoupper"><span style="color: #990000;">strtoupper</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$command</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">hooks</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$command</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">hooks</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$command</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
			<span style="color: #000088;">$k</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array_search"><span style="color: #990000;">array_search</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$function</span><span style="color: #339933;">,</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">hooks</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$command</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$k</span> <span style="color: #339933;">===</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">hooks</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$command</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$function</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">/*!	@function	unhook
			@abstract	Deletes a function from the call list for a certain action.  Can be extended in your implementation.
			@param		string	- Command
			@param		callback- Function to Delete from Call List
			@see		hook
			@see		trigger_hooks
			@result		void
		 */</span>
		<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> unhook<span style="color: #009900;">&#40;</span><span style="color: #000088;">$command</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #339933;">,</span><span style="color: #000088;">$function</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$command</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/strtoupper"><span style="color: #990000;">strtoupper</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$command</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$command</span> <span style="color: #339933;">!==</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$k</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array_search"><span style="color: #990000;">array_search</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$function</span><span style="color: #339933;">,</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">hooks</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$command</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$k</span> <span style="color: #339933;">!==</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #009900;">&#41;</span>
				<span style="color: #009900;">&#123;</span>
					<a href="http://www.php.net/unset"><span style="color: #990000;">unset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">hooks</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$command</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$k</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$k</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array_search"><span style="color: #990000;">array_search</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">user_funcs</span><span style="color: #339933;">,</span><span style="color: #000088;">$function</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$k</span> <span style="color: #339933;">!==</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #009900;">&#41;</span>
				<span style="color: #009900;">&#123;</span>
					<a href="http://www.php.net/unset"><span style="color: #990000;">unset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">user_funcs</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$k</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">/*!	@function	loop_once
			@abstract	Runs the class's actions once.
			@discussion	Should only be used if you want to run additional checks during server operation.  Otherwise, use infinite_loop()
			@param		void
			@see		infinite_loop
			@result 	bool	- True
		*/</span>
		<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> loop_once<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #666666; font-style: italic;">// Setup Clients Listen Socket For Reading</span>
			<span style="color: #000088;">$read</span><span style="color: #009900;">&#91;</span>0<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">master_socket</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">max_clients</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">clients</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
				<span style="color: #009900;">&#123;</span>
					<span style="color: #000088;">$read</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">+</span> 1<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">clients</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">socket</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span>
&nbsp;
			<span style="color: #666666; font-style: italic;">// Set up a blocking call to socket_select</span>
			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/socket_select"><span style="color: #990000;">socket_select</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$read</span><span style="color: #339933;">,</span><span style="color: #000088;">$write</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #339933;">,</span> <span style="color: #000088;">$except</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #339933;">,</span> <span style="color: #000088;">$tv_sec</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">5</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
			<span style="color: #666666; font-style: italic;">//	SocketServer::debug(&quot;Problem blocking socket_select?&quot;);</span>
				<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
&nbsp;
			<span style="color: #666666; font-style: italic;">// Handle new Connections</span>
			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/in_array"><span style="color: #990000;">in_array</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">master_socket</span><span style="color: #339933;">,</span> <span style="color: #000088;">$read</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">max_clients</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
				<span style="color: #009900;">&#123;</span>
					<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/empty"><span style="color: #990000;">empty</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">clients</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
					<span style="color: #009900;">&#123;</span>
						<span style="color: #000088;">$temp_sock</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">master_socket</span><span style="color: #339933;">;</span>
						<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">clients</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> SocketServerClient<span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">master_socket</span><span style="color: #339933;">,</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">trigger_hooks</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;CONNECT&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">clients</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						<span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
					<span style="color: #b1b100;">elseif</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">==</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">max_clients</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
					<span style="color: #009900;">&#123;</span>
						SocketServer<span style="color: #339933;">::</span><span style="color: #004000;">debug</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Too many clients...   &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
				<span style="color: #009900;">&#125;</span>
&nbsp;
			<span style="color: #009900;">&#125;</span>
&nbsp;
			<span style="color: #666666; font-style: italic;">// Handle Input</span>
			<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">max_clients</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">// for each client</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">clients</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
				<span style="color: #009900;">&#123;</span>
					<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/in_array"><span style="color: #990000;">in_array</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">clients</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">socket</span><span style="color: #339933;">,</span> <span style="color: #000088;">$read</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
					<span style="color: #009900;">&#123;</span>
						<span style="color: #000088;">$input</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/socket_read"><span style="color: #990000;">socket_read</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">clients</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">socket</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">max_read</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$input</span> <span style="color: #339933;">==</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span>
						<span style="color: #009900;">&#123;</span>
							<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">disconnect</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						<span style="color: #009900;">&#125;</span>
						<span style="color: #b1b100;">else</span>
						<span style="color: #009900;">&#123;</span>
							SocketServer<span style="color: #339933;">::</span><span style="color: #004000;">debug</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">{$i}</span>@{<span style="color: #006699; font-weight: bold;">$this-&gt;clients</span>[<span style="color: #006699; font-weight: bold;">$i</span>]-&gt;ip} --&gt; <span style="color: #006699; font-weight: bold;">{$input}</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
							<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">trigger_hooks</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;INPUT&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">clients</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #000088;">$input</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						<span style="color: #009900;">&#125;</span>
					<span style="color: #009900;">&#125;</span>
				<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">/*!	@function	disconnect
			@abstract	Disconnects a client from the server.
			@param		int	- Index of the client to disconnect.
			@param		string	- Message to send to the hooks
			@result		void
		*/</span>
		<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> disconnect<span style="color: #009900;">&#40;</span><span style="color: #000088;">$client_index</span><span style="color: #339933;">,</span><span style="color: #000088;">$message</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$client_index</span><span style="color: #339933;">;</span>
			SocketServer<span style="color: #339933;">::</span><span style="color: #004000;">debug</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Client <span style="color: #006699; font-weight: bold;">{$i}</span> from {<span style="color: #006699; font-weight: bold;">$this-&gt;clients</span>[<span style="color: #006699; font-weight: bold;">$i</span>]-&gt;ip} Disconnecting&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">trigger_hooks</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;DISCONNECT&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">clients</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #000088;">$message</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">clients</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">destroy</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<a href="http://www.php.net/unset"><span style="color: #990000;">unset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">clients</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">/*!	@function	trigger_hooks
			@abstract	Triggers Hooks for a certain command.
			@param		string	- Command who's hooks you want to trigger.
			@param		object	- The client who activated this command.
			@param		string	- The input from the client, or a message to be sent to the hooks.
			@result		void
		*/</span>
		<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> trigger_hooks<span style="color: #009900;">&#40;</span><span style="color: #000088;">$command</span><span style="color: #339933;">,&amp;</span><span style="color: #000088;">$client</span><span style="color: #339933;">,</span><span style="color: #000088;">$input</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">hooks</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$command</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">hooks</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$command</span><span style="color: #009900;">&#93;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$function</span><span style="color: #009900;">&#41;</span>
				<span style="color: #009900;">&#123;</span>
					SocketServer<span style="color: #339933;">::</span><span style="color: #004000;">debug</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Triggering Hook '<span style="color: #006699; font-weight: bold;">{$function}</span>' for '<span style="color: #006699; font-weight: bold;">{$command}</span>'&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #000088;">$continue</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/call_user_func"><span style="color: #990000;">call_user_func</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$function</span><span style="color: #339933;">,</span><span style="color: #000088;">$this</span><span style="color: #339933;">,</span><span style="color: #000088;">$client</span><span style="color: #339933;">,</span><span style="color: #000088;">$input</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$continue</span> <span style="color: #339933;">===</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
				<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">/*!	@function	infinite_loop
			@abstract	Runs the server code until the server is shut down.
			@see		loop_once
			@param		void
			@result		void
		*/</span>
		<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> infinite_loop<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$test</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">do</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$test</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">loop_once</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$test</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">/*!	@function	debug
			@static
			@abstract	Outputs Text directly.
			@discussion	Yeah, should probably make a way to turn this off.
			@param		string	- Text to Output
			@result		void
		*/</span>
		<span style="color: #000000; font-weight: bold;">public</span> static <span style="color: #000000; font-weight: bold;">function</span> debug<span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">echo</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">{$text}</span><span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">/*!	@function	socket_write_smart
			@static
			@abstract	Writes data to the socket, including the length of the data, and ends it with a CRLF unless specified.
			@discussion	It is perfectly valid for socket_write_smart to return zero which means no bytes have been written. Be sure to use the === operator to check for FALSE in case of an error.
			@param		resource- Socket Instance
			@param		string	- Data to write to the socket.
			@param		string	- Data to end the line with.  Specify a &quot;&quot; if you don't want a line end sent.
			@result		mixed	- Returns the number of bytes successfully written to the socket or FALSE on failure. The error code can be retrieved with socket_last_error(). This code may be passed to socket_strerror() to get a textual explanation of the error.
		*/</span>
		<span style="color: #000000; font-weight: bold;">public</span> static <span style="color: #000000; font-weight: bold;">function</span> socket_write_smart<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span><span style="color: #000088;">$sock</span><span style="color: #339933;">,</span><span style="color: #000088;">$string</span><span style="color: #339933;">,</span><span style="color: #000088;">$crlf</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			SocketServer<span style="color: #339933;">::</span><span style="color: #004000;">debug</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt; -- <span style="color: #006699; font-weight: bold;">{$string}</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$crlf</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$string</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">{$string}</span><span style="color: #006699; font-weight: bold;">{$crlf}</span>&quot;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
			<span style="color: #b1b100;">return</span> <a href="http://www.php.net/socket_write"><span style="color: #990000;">socket_write</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sock</span><span style="color: #339933;">,</span><span style="color: #000088;">$string</span><span style="color: #339933;">,</span><a href="http://www.php.net/strlen"><span style="color: #990000;">strlen</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">/*!	@function	__get
			@abstract	Magic Method used for allowing the reading of protected variables.
			@discussion	You never need to use this method, simply calling $server-&gt;variable works because of this method's existence.
			@param		string	- Variable to retrieve
			@result		mixed	- Returns the reference to the variable called.
		*/</span>
		<span style="color: #000000; font-weight: bold;">function</span> <span style="color: #339933;">&amp;</span>__get<span style="color: #009900;">&#40;</span><span style="color: #000088;">$name</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span><span style="color: #000088;">$name</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">/*!	@class		SocketServerClient
		@author		Navarr Barnier
		@abstract	A Client Instance for use with SocketServer
	 */</span>
	<span style="color: #000000; font-weight: bold;">class</span> SocketServerClient
	<span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">/*!	@var		socket
			@abstract	resource - The client's socket resource, for sending and receiving data with.
		 */</span>
		protected <span style="color: #000088;">$socket</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">/*!	@var		ip
			@abstract	string - The client's IP address, as seen by the server.
		 */</span>
		protected <span style="color: #000088;">$ip</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">/*!	@var		hostname
			@abstract	string - The client's hostname, as seen by the server.
			@discussion	This variable is only set after calling lookup_hostname, as hostname lookups can take up a decent amount of time.
			@see		lookup_hostname
		 */</span>
		protected <span style="color: #000088;">$hostname</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">/*!	@var		server_clients_index
			@abstract	int - The index of this client in the SocketServer's client array.
		 */</span>
		protected <span style="color: #000088;">$server_clients_index</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">/*!	@function	__construct
			@param		resource- The resource of the socket the client is connecting by, generally the master socket.
			@param		int	- The Index in the Server's client array.
			@result		void
		 */</span>
		<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span><span style="color: #000088;">$socket</span><span style="color: #339933;">,</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">server_clients_index</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$i</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">socket</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/socket_accept"><span style="color: #990000;">socket_accept</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$socket</span><span style="color: #009900;">&#41;</span> or <a href="http://www.php.net/die"><span style="color: #990000;">die</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Failed to Accept&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			SocketServer<span style="color: #339933;">::</span><span style="color: #004000;">debug</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;New Client Connected&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<a href="http://www.php.net/socket_getpeername"><span style="color: #990000;">socket_getpeername</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">socket</span><span style="color: #339933;">,</span><span style="color: #000088;">$ip</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ip</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$ip</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">/*!	@function	lookup_hostname
			@abstract	Searches for the user's hostname and stores the result to hostname.
			@see		hostname
			@param		void
			@result		string	- The hostname on success or the IP address on failure.
		 */</span>
		<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> lookup_hostname<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">hostname</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/gethostbyaddr"><span style="color: #990000;">gethostbyaddr</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ip</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">hostname</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">/*!	@function	destroy
			@abstract	Closes the socket.  Thats pretty much it.
			@param		void
			@result		void
		 */</span>
		<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> destroy<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<a href="http://www.php.net/socket_close"><span style="color: #990000;">socket_close</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">socket</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">function</span> <span style="color: #339933;">&amp;</span>__get<span style="color: #009900;">&#40;</span><span style="color: #000088;">$name</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span><span style="color: #000088;">$name</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">function</span> __isset<span style="color: #009900;">&#40;</span><span style="color: #000088;">$name</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">return</span> <a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span><span style="color: #000088;">$name</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span></pre></div></div></pre>
<p>class::SocketServer does all the functions necessary for a server.  It binds to the IP address and starts listening to the port.  Its easy to specify a maximum number of clients to allow, and the way its coded makes it easily modified.</p>
<p>Here is an example of a server (using this class) that listens for a user to send a string, and then echoes the reverse of that string back to the user.</p>
<pre><div id="wpshdo_2" class="wp-synhighlighter-outer"><div id="wpshdt_2" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_2"></a><a id="wpshat_2" class="wp-synhighlighter-title" href="#codesyntax_2"  onClick="javascript:wpsh_toggleBlock(2)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_2" onClick="javascript:wpsh_code(2)" title="Show code only"><img border="0" style="border: 0 none" src="http://tech.navarr.me/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_2" onClick="javascript:wpsh_print(2)" title="Print code"><img border="0" style="border: 0 none" src="http://tech.navarr.me/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://tech.navarr.me/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://tech.navarr.me/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_2" class="wp-synhighlighter-inner" style="display: block;"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span> ?php
	<span style="color: #666666; font-style: italic;">// This is PHP5 Code, by the way.</span>
&nbsp;
	<span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SocketServer.class.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Include the Class File</span>
	<span style="color: #000088;">$server</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> SocketServer<span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span>31337<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Create a Server binding to the default IP address (null) and listen to port 31337 for connections</span>
	<span style="color: #000088;">$server</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">max_clients</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Allow no more than 10 people to connect at a time</span>
	<span style="color: #000088;">$server</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">hook</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;CONNECT&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;handle_connect&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Run handle_connect everytime someone connects</span>
	<span style="color: #000088;">$server</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">hook</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;INPUT&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;handle_input&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Run handle_input whenever text is sent to the server</span>
	<span style="color: #000088;">$server</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">infinite_loop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Run Server Code Until Process is terminated.</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">/*
	 * All hooked functions are sent the parameters $server (The server class), $client (the connection), and $input (anything sent, if anything was sent)
	 * You should save the variables $server and $client using an ampersand (&amp;) to make sure they are references to the objects and not duplications.
	 */</span>
	<span style="color: #000000; font-weight: bold;">function</span> handle_connect<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span><span style="color: #000088;">$server</span><span style="color: #339933;">,&amp;</span><span style="color: #000088;">$client</span><span style="color: #339933;">,</span><span style="color: #000088;">$input</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		SocketServer<span style="color: #339933;">::</span><span style="color: #004000;">socket_write_smart</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$client</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">socket</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;String? &quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Outputs 'String? ' without a Line Ending</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000000; font-weight: bold;">function</span> handle_input<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span><span style="color: #000088;">$server</span><span style="color: #339933;">,&amp;</span><span style="color: #000088;">$client</span><span style="color: #339933;">,</span><span style="color: #000088;">$input</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$trim</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/trim"><span style="color: #990000;">trim</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$input</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Trim the input, Remove Line Endings and Extra Whitespace.</span>
&nbsp;
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/strtolower"><span style="color: #990000;">strtolower</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$trim</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;quit&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">// User Wants to quit the server</span>
		<span style="color: #009900;">&#123;</span>
			SocketServer<span style="color: #339933;">::</span><span style="color: #004000;">socket_write_smart</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$client</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">socket</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;Oh... Goodbye...&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Give the user a sad goodbye message, meany!</span>
			<span style="color: #000088;">$server</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">disconnect</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$client</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">server_clients_index</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Disconnect this client.</span>
			<span style="color: #b1b100;">return</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Ends the function</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000088;">$output</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/strrev"><span style="color: #990000;">strrev</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$trim</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Reverse the String</span>
&nbsp;
		SocketServer<span style="color: #339933;">::</span><span style="color: #004000;">socket_write_smart</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$client</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">socket</span><span style="color: #339933;">,</span><span style="color: #000088;">$output</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Send the Client back the String</span>
		SocketServer<span style="color: #339933;">::</span><span style="color: #004000;">socket_write_smart</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$client</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">socket</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;String? &quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Request Another String</span>
	<span style="color: #009900;">&#125;</span></pre></div></div></pre>
<p>In essence, this class allows you to handle sockets in PHP.  <strong><em>Beautifully</em></strong> handle sockets in PHP, that is.</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.navarr.me/2010/07/how-to-create-a-socket-server-in-php.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Magical Typesetting in PHP</title>
		<link>http://tech.navarr.me/2010/06/magical-typesetting-in-php.html</link>
		<comments>http://tech.navarr.me/2010/06/magical-typesetting-in-php.html#comments</comments>
		<pubDate>Mon, 28 Jun 2010 10:32:39 +0000</pubDate>
		<dc:creator>Navarr</dc:creator>
				<category><![CDATA[class::GenericVariable]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[typesetting]]></category>

		<guid isPermaLink="false">http://tech.gtaero.net/2010/06/magical-typesetting-in-php.html</guid>
		<description><![CDATA[So, well working for Route 50 I came up with a fantastic idea for “typesetting” that well exceeded the norm.  Something we constantly have issues with is what type of string was sent to MySQL originally (some of us have different conventional ideas about where escaping HTML should be located.) as well as outputting that [...]]]></description>
			<content:encoded><![CDATA[<p>So, well working for <a href="http://route50.net/" target="_blank">Route 50</a> I came up with a fantastic idea for “typesetting” that well exceeded the norm.  Something we constantly have issues with is what type of string was sent to MySQL originally (some of us have different conventional ideas about where escaping HTML should be located.) as well as outputting that string in its correct format.</p>
<p>Me, with my fantastic idea, came up with a couple variables classes that I put in a file named <a href="http://gist.github.com/451216">class_typesetting.php</a>.  The version on gist.github is slightly modified from the original version on the server.</p>
<p>It creates three classes, GenericVariable, String, and Number.  So far we haven’t used GenericVariable, but since the introduction of the classes I’ve taken it upon myself to introduce them to any new code I write.  When we create Core v5 (which will Objectify everything) strings taken from SQL will automatically be re-stored as String class variables.</p>
<p>First, lets examine some useful functionality.</p>
<pre><div id="wpshdo_3" class="wp-synhighlighter-outer"><div id="wpshdt_3" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_3"></a><a id="wpshat_3" class="wp-synhighlighter-title" href="#codesyntax_3"  onClick="javascript:wpsh_toggleBlock(3)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_3" onClick="javascript:wpsh_code(3)" title="Show code only"><img border="0" style="border: 0 none" src="http://tech.navarr.me/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_3" onClick="javascript:wpsh_print(3)" title="Print code"><img border="0" style="border: 0 none" src="http://tech.navarr.me/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://tech.navarr.me/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://tech.navarr.me/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_3" class="wp-synhighlighter-inner" style="display: block;"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$title</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> String<span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span>“title”<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// &lt;strong&gt;Hello 'World'&lt;/strong&gt;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
HTML Output: <span style="color: #000000; font-weight: bold;">&lt;?=</span> <span style="color: #000088;">$title</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">html</span> <span style="color: #000000; font-weight: bold;">?&gt;</span> (&amp;lt;strong&amp;gt;Hello 'World'&amp;lt;/strong&amp;gt;)
Text Output: <span style="color: #000000; font-weight: bold;">&lt;?=</span> <span style="color: #000088;">$title</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">text</span> <span style="color: #000000; font-weight: bold;">?&gt;</span> (Hello 'World')
SQL Output: <span style="color: #000000; font-weight: bold;">&lt;?=</span> <span style="color: #000088;">$title</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">sql</span> <span style="color: #000000; font-weight: bold;">?&gt;</span> (&lt;strong&gt;Hello \'World\'&lt;/strong&gt;)
HTML Attribute Output: <span style="color: #000000; font-weight: bold;">&lt;?=</span> <span style="color: #000088;">$title</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">html_attr</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>(&amp;lt;strong&amp;gt;Hello &amp;#039;World&amp;#039;&amp;lt;/strong&amp;gt;)</pre></div></div></pre>
<p>This allows for quick and easy access to the variables without having to worry about escaping them.</p>
<p>I recommend you hit the download link (class_typesetting.php) and play around with it.  Tell me about anything that’s not working correctly and if possible implement it in your future code.  (This means I’m putting this code in the “Public Domain”).</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.navarr.me/2010/06/magical-typesetting-in-php.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Making Google Analytics Work in XHTML</title>
		<link>http://tech.navarr.me/2010/04/making-google-analytics-work-in-xhtml.html</link>
		<comments>http://tech.navarr.me/2010/04/making-google-analytics-work-in-xhtml.html#comments</comments>
		<pubDate>Sun, 04 Apr 2010 16:37:29 +0000</pubDate>
		<dc:creator>Navarr</dc:creator>
				<category><![CDATA[(X)HTML 5]]></category>
		<category><![CDATA[Google Analytics]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[google analytics]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[xhtml]]></category>
		<category><![CDATA[xhtml5]]></category>

		<guid isPermaLink="false">http://tech.gtaero.net/?p=431</guid>
		<description><![CDATA[I was moving my website, Google Voice for Outlook, over from HTML5 to XHTML5 today, and as soon as I did the basic content negotiation filters in PHP so that it would send the appropriate headers if the client supported XHTML as well as only outputting the &#60;?xml if the client supported XHTML, I checked [...]]]></description>
			<content:encoded><![CDATA[<p>I was moving my website, Google Voice for Outlook, over from HTML5 to XHTML5 today, and as soon as I did the basic content negotiation filters in PHP so that it would send the appropriate headers if the client supported XHTML as well as only outputting the &lt;?xml if the client supported XHTML, I checked my developer tools to find a JavaScript error.  It was Google Analytics, of course.  document.write doesn’t exist in XHTML, after all.</p>
<p>The fix was simple, replace the current four line inclusion code with:</p>
<pre><div id="wpshdo_4" class="wp-synhighlighter-outer"><div id="wpshdt_4" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_4"></a><a id="wpshat_4" class="wp-synhighlighter-title" href="#codesyntax_4"  onClick="javascript:wpsh_toggleBlock(4)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_4" onClick="javascript:wpsh_code(4)" title="Show code only"><img border="0" style="border: 0 none" src="http://tech.navarr.me/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_4" onClick="javascript:wpsh_print(4)" title="Print code"><img border="0" style="border: 0 none" src="http://tech.navarr.me/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://tech.navarr.me/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://tech.navarr.me/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_4" class="wp-synhighlighter-inner" style="display: block;"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
	<span style="color: #003366; font-weight: bold;">var</span> gaJsHost <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;https:&quot;</span> <span style="color: #339933;">==</span> document.<span style="color: #660066;">location</span>.<span style="color: #660066;">protocol</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">?</span> <span style="color: #3366CC;">&quot;https://ssl.&quot;</span> <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;http://www.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> script <span style="color: #339933;">=</span> document.<span style="color: #660066;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;script&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	script.<span style="color: #660066;">src</span> <span style="color: #339933;">=</span> gaJsHost <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;google-analytics.com/ga.js&quot;</span><span style="color: #339933;">;</span>
	script.<span style="color: #660066;">type</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">;</span>
	document.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;head&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span>0<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">appendChild</span><span style="color: #009900;">&#40;</span>script<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div></pre>
<p>This will work fine, unless of course you have no head tag.  In which case you should replace getElementsByTagName(“head”) with getElementsByTagName(“html”).</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.navarr.me/2010/04/making-google-analytics-work-in-xhtml.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>TwCLI</title>
		<link>http://tech.navarr.me/2010/03/twcli.html</link>
		<comments>http://tech.navarr.me/2010/03/twcli.html#comments</comments>
		<pubDate>Mon, 01 Mar 2010 10:48:09 +0000</pubDate>
		<dc:creator>Navarr</dc:creator>
				<category><![CDATA[TwCLI]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[CLI]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://tech.gtaero.net/2010/03/twcli.html</guid>
		<description><![CDATA[So, you think you’ve had a lot of fun with twitter on the web and all those twitter clients you’ve played around with?&#160; What if I told you that you haven’t seen anything yet?&#160; What if I told you that you could use Twitter in a TRUE Command Line Interface with specific commands for interacting [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://twcli.koneko-chan.net/"><img style="display: inline; margin-left: 0px; margin-right: 0px" align="right" src="http://twcli.koneko-chan.net/img/logo.png" /></a>So, you think you’ve had a lot of fun with twitter on the web and all those twitter clients you’ve played around with?&#160; What if I told you that you haven’t seen anything yet?&#160; What if I told you that you could use Twitter in a TRUE Command Line Interface with specific commands for interacting with twitter.</p>
<p>Welcome to one of my latest and greatest creations, <a href="http://twcli.koneko-chan.net/"><abbr title="Twitter Command Line Interface">TwCLI</abbr></a>.</p>
<p>TwCLI supports almost everything twitter has to offer, and will soon be expanding to support even more!&#160; <a href="http://tech.gtaero.net/wp-content/uploads/2010/03/image3.png" rel="lightbox[392]"><img style="display: block; float: none; margin-left: auto; margin-right: auto" title="TwCLI (Click to Enlarge)" alt="TwCLI (Click to Enlarge)" src="http://tech.gtaero.net/wp-content/uploads/2010/03/image_thumb3.png" width="500" height="404" /></a> TwCLI includes a long list of commands, help information for each command, a theme-able interface (Specify a Pre-Determined theme, import from your twitter profile, or even specify an external CSS file!), Geo-Location, Retweets, and even Contributor Support!</p>
<p>Go ahead, <a href="http://twcli.koneko-chan.net/">give it a try</a> and tell me what you think!</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.navarr.me/2010/03/twcli.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>simpleTAPI is Broken</title>
		<link>http://tech.navarr.me/2010/02/simpletapi-is-broken.html</link>
		<comments>http://tech.navarr.me/2010/02/simpletapi-is-broken.html#comments</comments>
		<pubDate>Sat, 20 Feb 2010 23:34:08 +0000</pubDate>
		<dc:creator>Navarr</dc:creator>
				<category><![CDATA[simpleTAPI]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://tech.gtaero.net/2010/02/simpletapi-is-broken.html</guid>
		<description><![CDATA[Apparently I’ve completely broken simpleTAPI somewhere between Build 27 and Build 30.&#160; I thought I had fixed it with Build 29, but it seems that I was mistaken. In lieu of this, I am putting simpleTAPI on a temporary hiatus.&#160; I will be re-constructing it from scratch (though, probably looking back and using a good [...]]]></description>
			<content:encoded><![CDATA[<p>Apparently I’ve completely broken simpleTAPI somewhere between Build 27 and Build 30.&#160; I thought I had fixed it with Build 29, but it seems that I was mistaken.</p>
<p>In lieu of this, I am putting simpleTAPI on a temporary hiatus.&#160; I will be re-constructing it from scratch (though, probably looking back and using a good bit of the original code).&#160; The next version should have several configurable options, and will hopefully interact with the Twitter API much better than the previous versions.</p>
<p>Build 30 was supposed to return results as an array([“TAPI”] =&gt; data, [“result”] =&gt; data).&#160; But all I’m getting from it at the moment is “Unable to Authenticate User.”</p>
<p>Those wanting to use simpleTAPI should use <a href="http://github.com/navarr/simpleTAPI/commit/cc1567ce27c270a4314ba030f14d20684b128bf0">Build 27</a>, though you will have to deal with some minor quirks in the way results are returned.&#160; (the TAPI array is simply appended to the results array, making things slightly complicated if you don’t unset($result[“TAPI”]);</p>
<p>What will be simpleTAPI 0.4 should have better error handling, better return data, and better built-in caching.&#160; I’m also hoping to build in support for xAuth and Delegated OAuth, if at all possible.&#160; (Though probably not since simpleTAPI is built upon another OAuth library).</p>
<p>So, I’m asking for any and all feature requests.&#160; Is there something about simpleTAPI you don’t like or want to be improved?&#160; Please, post in the comments below!</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.navarr.me/2010/02/simpletapi-is-broken.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Quick Update to Simple Twitter</title>
		<link>http://tech.navarr.me/2010/01/a-quick-update-to-simple-twitter.html</link>
		<comments>http://tech.navarr.me/2010/01/a-quick-update-to-simple-twitter.html#comments</comments>
		<pubDate>Tue, 26 Jan 2010 23:40:52 +0000</pubDate>
		<dc:creator>Navarr</dc:creator>
				<category><![CDATA[SimpleTwitter]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://tech.gtaero.net/2010/01/a-quick-update-to-simple-twitter.html</guid>
		<description><![CDATA[A lot of people use my Simple Twitter Feed written in JavaScript (for some reason).&#160; Well, today I pushed out a quick update that should fix all the woes users have given me in the past. The code should now be valid XHTML strict, and I know longer use innerHTML for each list element.&#160; Instead, [...]]]></description>
			<content:encoded><![CDATA[<p>A lot of people use my Simple Twitter Feed written in JavaScript (for some reason).&#160; Well, today I pushed out a quick update that should fix all the woes users have given me in the past.</p>
<p>The code should now be valid XHTML strict, and I know longer use innerHTML for each list element.&#160; Instead, I’ve moved from adding the list elements via innerHTML to DOM Manipulation (appendChild).&#160; I’m not sure exactly what the benefits of this are, but I’m sure they exist.</p>
<p>As the previous HTML code seems to have been broken, this may cause some rendering errors for a few websites, but all in all it should work better than it has previously.</p>
<p>I’m not writing out a whole changelog, I’m just going ahead and saying that some changes were made – and hopefully Simple Twitter should work a lot easier for everyone using it.</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.navarr.me/2010/01/a-quick-update-to-simple-twitter.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Webkit JavaScript Notifications API</title>
		<link>http://tech.navarr.me/2010/01/webkit-javascript-notifications-api.html</link>
		<comments>http://tech.navarr.me/2010/01/webkit-javascript-notifications-api.html#comments</comments>
		<pubDate>Mon, 25 Jan 2010 20:29:51 +0000</pubDate>
		<dc:creator>Navarr</dc:creator>
				<category><![CDATA[Google Chrome]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[desktop notifications]]></category>
		<category><![CDATA[google chrome]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://tech.gtaero.net/2010/01/webkit-javascript-notifications-api.html</guid>
		<description><![CDATA[Something I learned about recently by following the updates being issued to Chrome, is that with today’s release they also pushed out the Webkit Notifications API to Chrome Stable (v4).&#160; Surprisingly, this is actually the first I’ve heard of it’s existence.&#160; I took a look and played around with it a bit, and it is [...]]]></description>
			<content:encoded><![CDATA[<p>Something I learned about recently by following the updates being issued to Chrome, is that with today’s release they also pushed out the Webkit Notifications API to Chrome Stable (v4).&#160; Surprisingly, this is actually the first I’ve heard of it’s existence.&#160; I took a look and played around with it a bit, and it is qué cool.</p>
<p>Visit <a href="http://sandbox.gtaero.net/chrome/notifications.php">my Sandbox</a> to see the code in action, or continue reading for some code excerpts.</p>
<p> <span id="more-365"></span>
<p>One interesting thing about this new API is that it not only requires a user to authorize it, but in order for an authorization click to appear, the user has to do something.&#160; You can’t make it appear as soon as the user visits the page, they have to click something or trigger an event.</p>
<p>For the sake of this example, lets say the user clicks a link that triggers the JavaScript function “notification();” and we want to show a notification onscreen.</p>
<pre><div id="wpshdo_5" class="wp-synhighlighter-outer"><div id="wpshdt_5" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_5"></a><a id="wpshat_5" class="wp-synhighlighter-title" href="#codesyntax_5"  onClick="javascript:wpsh_toggleBlock(5)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_5" onClick="javascript:wpsh_code(5)" title="Show code only"><img border="0" style="border: 0 none" src="http://tech.navarr.me/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_5" onClick="javascript:wpsh_print(5)" title="Print code"><img border="0" style="border: 0 none" src="http://tech.navarr.me/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://tech.navarr.me/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://tech.navarr.me/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_5" class="wp-synhighlighter-inner" style="display: block;"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> notification<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">webkitNotifications</span><span style="color: #009900;">&#41;</span> <span style="color: #006600; font-style: italic;">// If we have the Notification API</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> nc <span style="color: #339933;">=</span> window.<span style="color: #660066;">webkitNotifications</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// Set the API to nc for easy access</span>
		<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>nc.<span style="color: #660066;">checkPermission</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #006600; font-style: italic;">// 1 = Not Allowed, 2 = Denied, 0 = Allowed</span>
		<span style="color: #009900;">&#123;</span>
			nc.<span style="color: #660066;">requestPermission</span><span style="color: #009900;">&#40;</span>myNotification<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// Request Permission with a callback to myNotification();</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span> myNotification<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #003366; font-weight: bold;">function</span> myNotification<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000066; font-weight: bold;">try</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> nc <span style="color: #339933;">=</span> window.<span style="color: #660066;">webkitNotifications</span><span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> notif <span style="color: #339933;">=</span> nc.<span style="color: #660066;">createNotification</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;Notification Title&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;Notification Body&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// Parameters: string URL_TO_IMAGE, string Title, string Body</span>
		notif.<span style="color: #660066;">show</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// Show Notification</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">catch</span><span style="color: #009900;">&#40;</span>Err<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>Err.<span style="color: #660066;">message</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// Will output a security error if we don't have permission.</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div></pre>
<p>As you can see from the code, its a fairly straightforward API for showing desktop notifications, and once the user has given the website permission, they can be triggered any time.  Up to five notifications can appear, and the rest will be kept in a queue until the others are dismissed, either by the user or by calling .cancel(); on the notification variable (notif in this case).</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.navarr.me/2010/01/webkit-javascript-notifications-api.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Hunting Down the Bugs &#8211; TwCLI on Chrome for Linux Beta</title>
		<link>http://tech.navarr.me/2009/12/hunting-down-the-bugs-twcli-on-chrome-for-linux-beta.html</link>
		<comments>http://tech.navarr.me/2009/12/hunting-down-the-bugs-twcli-on-chrome-for-linux-beta.html#comments</comments>
		<pubDate>Tue, 15 Dec 2009 18:51:17 +0000</pubDate>
		<dc:creator>Navarr</dc:creator>
				<category><![CDATA[Google Chrome]]></category>
		<category><![CDATA[Hunting Down the Bugs]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[TwCLI]]></category>
		<category><![CDATA[bugs]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[google chrome]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://tech.gtaero.net/2009/12/hunting-down-the-bugs-twcli-on-chrome-for-linux-beta.html</guid>
		<description><![CDATA[This is the first post of a new series, looking at some of the odder bugs encountered while developing for the expanding Web, no matter how basic a bug it may be. Thanks to twitter user @paperfairy, a bug was discovered on my Command Line Twitter Client, TwCLI. For some reason, when submitting a command [...]]]></description>
			<content:encoded><![CDATA[<p><em>This is the first post of a new series, looking at some of the odder bugs encountered while developing for the expanding Web, no matter how basic a bug it may be.</em></p>
<p>Thanks to twitter user @<a href="http://twitter.com/paperfairy" rel="nofollow">paperfairy</a>, a bug was discovered on my Command Line Twitter Client, <a title="Twitter Command Line Interface" href="http://twcli.koneko-chan.net/" rel="me">TwCLI</a>.</p>
<p>For some reason, when submitting a command in Chrome for Linux, the page would simply refresh, and the command would never be sent.&#160; At first, I had no possible way to track down this bug.&#160; I didn’t have a linux box (with a GUI, anyway) so I simply told him that it was unfortunate, but it’d have to stay a bug.&#160; Until a <a href="http://lifehacker.com/5426007/most-popular-free-windows-downloads-of-2009" rel="nofollow">recent post on lifehacker</a> brought my attention to <a href="http://lifehacker.com/5195999/portable-ubuntu-runs-ubuntu-inside-windows">Portable Ubuntu</a>. I immediately installed it, opened up the Chrome website in Firiefox, installed Chrome Beta, and headed over to TwCLI to see what was amiss.</p>
<p>Of course, it was a single line in a detection script to send Geo-Data to Twitter (as long as the user approved it, of course):</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">else</span> <span style="color: #0000ff">if</span>(google.gears) {</pre>
<p><!--CRLF--></div>
</div>
<p>This single line was throwing an exception I hadn’t encountered in other browsers – Google wasn’t defined.&#160; Oddly, I thought it would handle that properly, since google wasn’t defined, it would just skip over it, but instead it threw an error and halted all further javascript code.</p>
<p>The fix was simpler than tracking down the bug, I simply had to add this to the start of the javascript code:</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">try</span>{ <span style="color: #0000ff">if</span>(!google) { google = 0; } } <span style="color: #0000ff">catch</span>(err) { google = 0; }</pre>
<p><!--CRLF--></div>
</div>
<p>And voila, I had both a check for google, and a catch if it decided to throw errors while checking for it.</p>
<p>Whether this is a Chrome bug or not, I don’t know – I simply don’t know enough about JavaScript in order to say so either way.&#160; But, are undefined variables supposed to throw errors, or are they simply supposed to return false?</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.navarr.me/2009/12/hunting-down-the-bugs-twcli-on-chrome-for-linux-beta.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JavaScript &amp; CSS3 Lightbox</title>
		<link>http://tech.navarr.me/2009/12/javascrpit-css3-lightbox.html</link>
		<comments>http://tech.navarr.me/2009/12/javascrpit-css3-lightbox.html#comments</comments>
		<pubDate>Sat, 12 Dec 2009 00:33:33 +0000</pubDate>
		<dc:creator>Navarr</dc:creator>
				<category><![CDATA[CSS3 Lightbox]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[lightbox]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://tech.gtaero.net/2009/12/javascrpit-css3-lightbox.html</guid>
		<description><![CDATA[Usage: Call createLightbox(); to create the actual lightbox element (does not display anything). Call fillLightbox(string content) to fill the lightbox with RAW HTMLor Call appendLightbox(element childElement) to append a DOM Node directly into the lightbox. Call setLightboxSize(int width, int height, null, string unit) to set the width and height of the lightbox.  Unit will default [...]]]></description>
			<content:encoded><![CDATA[<p align="center"><script src="http://gist.github.com/254614.js?file=css3_lightbox.js"></script></p>
<p><strong>Usage</strong>:</p>
<ul>
<li>Call <strong>createLightbox();</strong> to create the actual lightbox element (does not display anything).</li>
<li>Call <strong>fillLightbox(</strong><em>string </em>content<strong>)</strong> to fill the lightbox with RAW HTML<em>or</em>
<p>Call <strong>appendLightbox(</strong><em>element</em> childElement<strong>)</strong> to append a DOM Node directly into the lightbox.</li>
<li>Call <strong>setLightboxSize(</strong><em>int</em> width, <em>int</em> height, <em>null</em>, <em>string</em> unit) to set the width and height of the lightbox.  Unit will default to pixels “px” if not specified.</li>
<li>Call <strong>showLightbox()</strong> to actually display the lightbox to the user.</li>
<li>Call <em>boolean</em> <strong>lightboxVisible()</strong> to determine if the lightbox is still visible or not.</li>
<li>Call <strong>hideLightbox()</strong> to remove the lightbox from view.</li>
<li>Call <strong>cleanLightbox()</strong> to delete all content inside the lightbox container.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://tech.navarr.me/2009/12/javascrpit-css3-lightbox.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google Voice OMS Code on Github</title>
		<link>http://tech.navarr.me/2009/11/google-voice-oms-code-on-github.html</link>
		<comments>http://tech.navarr.me/2009/11/google-voice-oms-code-on-github.html#comments</comments>
		<pubDate>Mon, 30 Nov 2009 00:52:34 +0000</pubDate>
		<dc:creator>Navarr</dc:creator>
				<category><![CDATA[子猫ちゃん GV OMS]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[Google Voice]]></category>
		<category><![CDATA[office]]></category>
		<category><![CDATA[OMS]]></category>
		<category><![CDATA[Outlook]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://tech.gtaero.net/2009/11/google-voice-oms-code-on-github.html</guid>
		<description><![CDATA[I pushed the 子猫ちゃん Google Voice OMS service’s code to github, so you can now download it – albeit, to make it work it’ll take a lot of hacking and a lot more editing. Either way, I’ve gotten no donations and no offers for free SSL hosting, so it looks like this project just will [...]]]></description>
			<content:encoded><![CDATA[<p>I pushed the 子猫ちゃん Google Voice OMS service’s code to github, so you can now download it – albeit, to make it work it’ll take a lot of hacking and a lot more editing.</p>
<p>Either way, I’ve gotten no donations and no offers for free SSL hosting, so it looks like this project just will not be seeing the light of day.&#160; It’s a shame, I worked a long time to make it work, and it’s obviously something a lot of business professionals would be able to find a use for.</p>
<p>Oh well, you can find the project <a href="http://github.com/navarr/Google-Voice-OMS">on github</a>.</p>
<p>Remember to abide by the Usage License!</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.navarr.me/2009/11/google-voice-oms-code-on-github.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
