<?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>langui.sh &#187; php</title>
	<atom:link href="http://langui.sh/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://langui.sh</link>
	<description>Fun hacks, WP plugins, photography, and PKI junk.  Languishing since 2008.</description>
	<lastBuildDate>Tue, 17 Jan 2012 20:23:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://superfeedr.com/hubbub"/>		<item>
		<title>Writing Compatible PHP For WordPress</title>
		<link>http://langui.sh/2009/12/07/writing-compatible-php-for-wordpress/</link>
		<comments>http://langui.sh/2009/12/07/writing-compatible-php-for-wordpress/#comments</comments>
		<pubDate>Tue, 08 Dec 2009 02:36:30 +0000</pubDate>
		<dc:creator>Paul Kehrer</dc:creator>
				<category><![CDATA[Posts]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://langui.sh/?p=875</guid>
		<description><![CDATA[<a href="http://langui.sh/2009/12/07/writing-compatible-php-for-wordpress/" title="Writing Compatible PHP For WordPress"></a>One of the big problems I&#8217;ve run into as a WordPress plugin developer is the diversity of PHP installations. Simply stating you only support PHP5 and greater is insufficient to ensure compatibility. Things you may take for granted in your &#8230;<p class="read-more"><a href="http://langui.sh/2009/12/07/writing-compatible-php-for-wordpress/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://langui.sh/2009/12/07/writing-compatible-php-for-wordpress/" title="Writing Compatible PHP For WordPress"></a><p>One of the big problems I&#8217;ve run into as a WordPress plugin developer is the diversity of PHP installations.  Simply stating you only support PHP5 and greater is insufficient to ensure compatibility.  Things you may take for granted in your development environment may be missing or worse, partially functional.  I&#8217;ve decided to document a few of the bigger &#8220;gotchas&#8221; I&#8217;ve run into so future WordPress hackers will have a starting point for investigating problems.</p>
<h3>Minimum PHP Version</h3>
<p>One easy way to reduce compatibility confusion is specifying a minimum version of PHP for your WordPress plugin or widget. To do so you can use PHP&#8217;s version_compare function:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">version_compare</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">PHP_VERSION</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'5.0.0'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'&lt;'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">sprintf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'You are currently running PHP version %s and you must have at least PHP 5.0.x'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">PHP_VERSION</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Take a look at the <a href="http://us.php.net/manual/en/function.version-compare.php">version_compare documentation</a> for more information. </p>
<h3>PHP Modules</h3>
<p>The biggest single thing to remember is that any module for PHP is optional.  If you want to require something like curl, that&#8217;s great, but be aware that some non-trivial percentage of your potential users may not have it.  Still want to use that module?  Test for its presence during the instantiation of your plugin and die if it&#8217;s not present.  This will prevent users from being able to successfully install your &#8220;broken&#8221; product if they don&#8217;t have the proper requirements.</p>
<p>Sometimes you&#8217;ll find yourself using functions you think are core to PHP like &#8220;mime_content_type&#8221;.  This is not the case.  In fact, I have frequently run into PHP installations that have no MIME detection facilities at all.  Consider writing a fallback for suffix detection<sup class='footnote'><a href='#fn-875-1' id='fnref-875-1'>1</a></sup> in addition to coding for mime_content_type and the finfo_* methods.</p>
<h3>Safe Mode and Related Problems</h3>
<p>Another common issue is safe_mode and open_basedir. These flags enforce certain security restrictions (must have the same group as PHP when writing to a directory, can&#8217;t open files beneath the basedir, et cetera).  However, they also impact some modules.  For instance, using curl you can&#8217;t use CURLOPT_FOLLOWLOCATION.  This will trigger the error &#8220;CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set&#8221;.</p>
<h3>Network Communication</h3>
<p>I&#8217;ve already talked a bit about the curl module, but you may also be tempted to use file_get_contents() assuming allow_url_fopen is enabled.  This is very frequently untrue in shared hosting environments.  Luckily, you don&#8217;t need to rely on curl or allow_url_fopen or write your own fsockopen() wrapper class.  Instead, WordPress has integrated <a href="http://sourceforge.net/projects/snoopy/">Snoopy</a> into the core.  Invoking it to fetch just the contents of a URL could not be easier!</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span> ABSPATH <span style="color: #339933;">.</span> <span style="color: #0000ff;">'wp-includes/class-snoopy.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$snoopy</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Snoopy<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$snoopy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fetch</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</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;">$result</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$response</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$snoopy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">results</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Just hit up Google for the class docs to learn everything Snoopy can do for you.</p>
<p>There are many more where these came from, so drop your problems and solutions in the comments!</p>
<div class='footnotes'>
<div class='footnotedivider'></div>
<ol>
<li id='fn-875-1'>This can be a security risk in certain circumstances, so be careful. <span class='footnotereverse'><a href='#fnref-875-1'>&#8617;</a></span></li>
</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://langui.sh/2009/12/07/writing-compatible-php-for-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Basic WebDAV Bridge For Cloud Files</title>
		<link>http://langui.sh/2009/05/19/basic-webdav-bridge-for-cloud-files/</link>
		<comments>http://langui.sh/2009/05/19/basic-webdav-bridge-for-cloud-files/#comments</comments>
		<pubDate>Wed, 20 May 2009 03:39:52 +0000</pubDate>
		<dc:creator>Paul Kehrer</dc:creator>
				<category><![CDATA[Posts]]></category>
		<category><![CDATA[cloud files]]></category>
		<category><![CDATA[cloudfiles]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[webdav]]></category>

		<guid isPermaLink="false">http://langui.sh/?p=507</guid>
		<description><![CDATA[<a href="http://langui.sh/2009/05/19/basic-webdav-bridge-for-cloud-files/" title="Basic WebDAV Bridge For Cloud Files"></a>Awhile back I signed up for Skitch, a service that lets you create quick screenshots, edit them, and upload them to a variety of services. Unfortunately, despite the abundance of choices, Cloud Files support is not an option. This was &#8230;<p class="read-more"><a href="http://langui.sh/2009/05/19/basic-webdav-bridge-for-cloud-files/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://langui.sh/2009/05/19/basic-webdav-bridge-for-cloud-files/" title="Basic WebDAV Bridge For Cloud Files"></a><p>Awhile back I signed up for Skitch, a service that lets you create quick screenshots, edit them, and upload them to a variety of services.  Unfortunately, despite the abundance of choices, Cloud Files support is not an option.  This was irritating, and since I&#8217;ve never been one to let phrases like &#8220;ridiculous kludge&#8221; or &#8220;bereft of all sanity&#8221; deter me an idea was born. <strong>Why not write a (very) rudimentary WebDAV interface in PHP and use that to bridge to Cloud Files?</strong><br />
To accomplish this feat it turns out we really only need 3 distinct pieces of functionality.   The actual plumbing that communicates to Cloud Files will be provided by the PHP Cloud Files API.</p>
<ol>
<li>HTTP Basic Auth to capture the necessary Cloud Files credentials</li>
<li>PUT method for WebDAV</li>
<li>DELETE method for WebDAV</li>
</ol>
<p>The code below represents the minimum subset of WebDAV functionality required to support Skitch without issues (uploading and deleting).  It is nowhere near a complete WebDAV implementation.  Additionally, some code (mime_types function and some logging and error handling) have been omitted.  You can <a href='http://cdn.langui.sh/2009/05/cf_webdav_bridge_01.zip'>download</a> the full package for use on your own server.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">require</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'cloudfiles.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_AUTHORIZATION'</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: #990000;">list</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'PHP_AUTH_USER'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'PHP_AUTH_PW'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">':'</span><span style="color: #339933;">,</span><span style="color: #990000;">base64_decode</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_AUTHORIZATION'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">6</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'PHP_AUTH_USER'</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: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'WWW-Authenticate: Basic realm=&quot;CloudFiles&quot;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'HTTP/1.1 401 Unauthorized'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'You must be authorized!'</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">exit</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000088;">$auth</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> CF_Authentication<span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'PHP_AUTH_USER'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'PHP_AUTH_PW'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
try <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$auth</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">authenticate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
catch<span style="color: #009900;">&#40;</span>AuthenticationException <span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'CF Authentication failure'</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">exit</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000088;">$conn</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> CF_Connection<span style="color: #009900;">&#40;</span><span style="color: #000088;">$auth</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$skitch_container</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$conn</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">create_container</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'skitch'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$public_uri</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$skitch_container</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">make_public</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">switch</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REQUEST_METHOD'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'DELETE'</span><span style="color: #339933;">:</span>
		<span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REQUEST_URI'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">strrpos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REQUEST_URI'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'/'</span><span style="color: #009900;">&#41;</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: #339933;">;</span>
		try <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$skitch_container</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">delete_object</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		catch<span style="color: #009900;">&#40;</span>NoSuchObjectException <span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'no such object to delete'</span><span style="color: #339933;">;</span>
			<span style="color: #990000;">exit</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		catch<span style="color: #009900;">&#40;</span>InvalidResponseException <span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'invalid response to delete request'</span><span style="color: #339933;">;</span>
			<span style="color: #990000;">exit</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'PUT'</span><span style="color: #339933;">:</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$datain</span> <span style="color: #339933;">=</span> <span style="color: #990000;">fopen</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'php://input'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'r'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!@</span><span style="color: #990000;">feof</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$datain</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$data</span> <span style="color: #339933;">.=</span> <span style="color: #990000;">fgets</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$datain</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">4096</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #339933;">@</span><span style="color: #990000;">fclose</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$datain</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</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><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'PATH_INFO'</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;">$file_name</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'PATH_INFO'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #000088;">$mime</span> <span style="color: #339933;">=</span> mime_types<span style="color: #009900;">&#40;</span><span style="color: #000088;">$file_name</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$object</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$skitch_container</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">create_object</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file_name</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$object</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">content_type</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$mime</span><span style="color: #339933;">;</span>
			try <span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$object</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">write</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			catch<span style="color: #009900;">&#40;</span>InvalidResponseException <span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Invalid response error from CF'</span><span style="color: #339933;">;</span>
				<span style="color: #990000;">exit</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			catch<span style="color: #009900;">&#40;</span>SyntaxException <span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Syntax exception error from CF'</span><span style="color: #339933;">;</span>
				<span style="color: #990000;">exit</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>To wire this up now, we have just a few steps to perform.</p>
<ol>
<li>WebDAV can&#8217;t return the public base URL for the container, so use another program to create a container named &#8220;skitch&#8221;, mark it public, then copy the URL.</li>
<li>Go to the Webpost tab in Skitch and create a new account using WebDAV.</li>
<li>Set server to the server you uploaded the file to, user to your CF username, password to your API key, directory to the name of your script (potentially /path/to/script.php if it isn&#8217;t at the root of your server&#8217;s httpdocs), and finally paste the base URL (without a trailing /).  A screenshot of a sample config can be seen below.</li>
</ol>
<p><a href="http://cdn.langui.sh/2009/04/skitch.png"><img src="http://cdn.langui.sh/2009/04/skitch-300x204.png" alt="skitch" title="skitch" width="300" height="204" class="aligncenter size-medium wp-image-512" /></a></p>
<p>Success!  I&#8217;ve been using this several weeks and haven&#8217;t had an issue, but this hack does make me wonder how usable a full blown WebDAV translation layer would be&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://langui.sh/2009/05/19/basic-webdav-bridge-for-cloud-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CDN Tools Initial Release</title>
		<link>http://langui.sh/2009/02/25/cdn-tools-initial-release/</link>
		<comments>http://langui.sh/2009/02/25/cdn-tools-initial-release/#comments</comments>
		<pubDate>Thu, 26 Feb 2009 01:59:51 +0000</pubDate>
		<dc:creator>Paul Kehrer</dc:creator>
				<category><![CDATA[Posts]]></category>
		<category><![CDATA[cdn]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://langui.sh/?p=312</guid>
		<description><![CDATA[<a href="http://langui.sh/2009/02/25/cdn-tools-initial-release/" title="CDN Tools Initial Release"></a>I am pleased to announce the initial public release of CDN Tools, my latest WordPress plugin! What is CDN Tools? Well, it&#8217;s a WordPress plugin that lets you load javascript files and your blog&#8217;s media (pictures, movies, audio, et cetera) &#8230;<p class="read-more"><a href="http://langui.sh/2009/02/25/cdn-tools-initial-release/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://langui.sh/2009/02/25/cdn-tools-initial-release/" title="CDN Tools Initial Release"></a><p>I am pleased to announce the initial public release of <a href="http://langui.sh/cdn-tools/">CDN Tools</a>, my latest WordPress plugin!</p>
<h3>What is CDN Tools?</h3>
<p>Well, it&#8217;s a WordPress plugin that lets you load javascript files and your blog&#8217;s media (pictures, movies, audio, et cetera) to a content distribution network (CDN) to speed up page loading.  You can load up all your javascript and media with a single click and then your media will be automatically sideloaded to the CDN after that.  The plugin will operate totally transparently.</p>
<h3>Do I need a CDN account?</h3>
<p>No!  You can offload prototype and jQuery to Google&#8217;s servers with this tool with just a single click.  These are large libraries so moving them to Google&#8217;s bandwidth is very useful!</p>
<h3>What if I want to remove it?</h3>
<p>Simply deactivate the plugin and everything will revert to normal.  Since CDN Tools only temporarily rewrites the URLs of your uploads, nothing is lost if you choose to stop using it.</p>
<p>If you&#8217;ve got a WordPress blog why not give it a shot?  <a href="http://wordpress.org/extend/plugins/cdn-tools/">Download</a> today!  You can also check the version history and get more information at the plugin&#8217;s <a href="http://langui.sh/cdn-tools/">homepage</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://langui.sh/2009/02/25/cdn-tools-initial-release/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using memcached
Page Caching using memcached
Database Caching 11/27 queries in 0.009 seconds using memcached
Object Caching 630/657 objects using memcached

Served from: langui.sh @ 2012-02-07 06:27:28 -->
