<?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>RAM and Whiskey &#187; PHP</title>
	<atom:link href="http://ramandwhiskey.com/category/programming/php-programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://ramandwhiskey.com</link>
	<description>A Foray Into the World of IT</description>
	<lastBuildDate>Sun, 10 Aug 2008 19:34:55 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Laconica, PHP5, and GD Woes &#8211; and a quick patch!</title>
		<link>http://ramandwhiskey.com/2008/07/26/laconica-php5-and-gd-woes-and-a-quick-patch/</link>
		<comments>http://ramandwhiskey.com/2008/07/26/laconica-php5-and-gd-woes-and-a-quick-patch/#comments</comments>
		<pubDate>Fri, 25 Jul 2008 21:23:45 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Laconica]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://ramandwhiskey.com/2008/07/26/laconica-php5-and-gd-woes-and-a-quick-patch/</guid>
		<description><![CDATA[So, I&#8217;ve been playing around a bit with Laconica, an open source micro-blogging engine used to power Identi.ca.  I finally have it up and running smoothly, however, I&#8217;ve found that the &#8220;official&#8221; installation documentation is a bit sparse and missing a few steps and dependencies.  Because of this, a few snags in the setup process [...]]]></description>
			<content:encoded><![CDATA[<p>So, I&#8217;ve been playing around a bit with <a href="http://www.laconi.ca/" title="Laconica Homepage" target="_blank">Laconica</a>, an open source micro-blogging engine used to power <a href="http://identi.ca/" title="Identi.ca Homepage" target="_blank">Identi.ca</a>.  I finally have it up and running smoothly, however, I&#8217;ve found that the &#8220;official&#8221; installation documentation is a bit sparse and missing a few steps and dependencies.  Because of this, a few snags in the setup process had me scratching my head.  What did help me immensely in the process is the following blog entry on 0xDECAFBA &#8211; <a href="http://decafbad.com/blog/2008/07/03/getting-laconica-up-and-running" target="_blank">Getting Laconica up and running</a>.</p>
<p>The problem I ran into was with the avatar upload.  When I tried to upload my avatar, I would be greeted with a blank page (the &#8220;oh-crap-internal-server-error-where&#8217;s-my-whiskey&#8221; kind of blank page).  I opened up my /var/log/httpd/error_log to seek out what exactly occurred.  Here&#8217;s what I found:<br />
<code>[Wed Jul 23 13:01:55 2008] [error] [client 10.6.132.139] PHP Fatal error:  Call to undefined function image_type_to_extension() in /var/www/html/laconica/classes/Profile.php on line 85, ...</code></p>
<p>Interesting.  My brand new fancy avatar is now reduced to a broken image in Laconica.  To revert back to the default gray and apathetic face avatar, simply remove all entries in the avatar table of your Laconica DB instance.</p>
<p>Some quick background about the configuration:</p>
<p><code>$ uname -srvpio<br />
Linux 2.6.18-92.1.6.el5PAE #1 SMP Fri Jun 20 02:51:01 EDT 2008 i686 i386 GNU/Linux</code></p>
<p><code>$ php -version<br />
PHP 5.1.6 (cli) (built: Jun 12 2008 05:02:35)<br />
Copyright (c) 1997-2006 The PHP Group<br />
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies</code></p>
<p>A fairly recent setup.  Since this was a fresh install, I figured something had to be wrong with the installation of the <a href="http://us2.php.net/manual/en/book.image.php" target="_blank">PHP GD libraries</a>.  Naturally the next step would be to do a var_dump(gd_info()); to confirm any issues:<br />
<code>array(12) {<br />
["GD Version"]=&gt;string(27) "bundled (2.0.28 compatible)"<br />
["FreeType Support"]=&gt;bool(true)<br />
["FreeType Linkage"]=&gt;string(13) "with freetype"<br />
["T1Lib Support"]=&gt;bool(false)<br />
["GIF Read Support"]=&gt;bool(true)<br />
["GIF Create Support"]=&gt;bool(true)<br />
["JPG Support"]=&gt;bool(true)<br />
["PNG Support"]=&gt;bool(true)<br />
["WBMP Support"]=&gt;bool(true)<br />
["XPM Support"]=&gt;bool(false)<br />
["XBM Support"]=&gt;bool(true)<br />
["JIS-mapped Japanese Font Support"]=&gt;bool(false)<br />
}</code><br />
Nope.  Everything looks fine with the setup.  And according to PHP.net, <a href="http://us2.php.net/manual/en/function.image-type-to-extension.php" target="_blank">image_type_to_extension()</a> should be available for &gt;=PHP5.0.  This, however, doesn&#8217;t appear to be the case.  As Chris <a href="http://us2.php.net/manual/en/function.image-type-to-extension.php#77354" target="_blank">notes</a>:</p>
<blockquote><p>Function was added in PHP 5.2, not PHP 5 (you would assume this means 5.0)</p></blockquote>
<p>So, evidently, my current version of PHP (and the most recent in the RHEL5 repos) does in fact not support the image_type_to_extension() function. If you have the most recent version of PHP, you should be fine.  If not, here&#8217;s the fix: To work around this issue, I devised a simple modification that would overwrite the image_type_to_extension() functionality if you&#8217;re experiencing the same issues.  Head to $LACONICA_HOME/classes/, back up Profile.php, and then open it up in your favorite editor.  Head to Lines #84 and #85 <code>$filename = common_avatar_filename($this-&gt;id, image_type_to_extension($info[2]), NULL, common_timestamp());</code> and replace it with the following code snippet below:</p>
<p><code># Start - More RAM.<br />
if(function_exists(image_type_to_extension))<br />
{<br />
$extension = strtolower(substr(image_type_to_extension($info[2]),1));<br />
}<br />
else<br />
{<br />
list(,,$imageType) = getimagesize($image);<br />
switch($imageType)<br />
{<br />
case IMG_GIF:<br />
$extension = ".gif";<br />
break;<br />
case IMG_JPG:<br />
$extension = ".jpg";<br />
break;<br />
case IMG_PNG:<br />
$extension = ".png";<br />
break;<br />
}<br />
}<br />
$filename = common_avatar_filename($this-&gt;id,$extension,NULL, common_timestamp());<br />
#END - More whiskey.</code></p>
<p>Save Profile.php, and now try to upload a new avatar.  Problem fixed!</p>
]]></content:encoded>
			<wfw:commentRss>http://ramandwhiskey.com/2008/07/26/laconica-php5-and-gd-woes-and-a-quick-patch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 0.149 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2009-11-01 23:23:25 -->

