<?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>Josh Highland &#187; php</title>
	<atom:link href="http://joshhighland.com/blog/category/tech/programming/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://joshhighland.com/blog</link>
	<description>the living internet</description>
	<lastBuildDate>Sat, 14 Apr 2012 03:00:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Non-abstract method Foo::bar() must contain body</title>
		<link>http://joshhighland.com/blog/2011/12/01/non-abstract-method-foobar-must-contain-body/</link>
		<comments>http://joshhighland.com/blog/2011/12/01/non-abstract-method-foobar-must-contain-body/#comments</comments>
		<pubDate>Fri, 02 Dec 2011 04:00:48 +0000</pubDate>
		<dc:creator>Josh Highland</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[error code]]></category>

		<guid isPermaLink="false">http://joshhighland.com/blog/?p=14731</guid>
		<description><![CDATA[I was working on one of my PHP based projects, and I was getting the following error: Non-abstract method Foo::bar() must contain body in Foo.php on line 10 The problem was that I had accidentally put a semicolon at the end of the first line of the function: WRONG WAY: class Foo &#123; function bar&#40;&#41;; [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>I was working on one of my PHP based projects, and I was getting the following error:</p>
<blockquote><p>Non-abstract method Foo::bar() must contain body in Foo.php on line 10</p></blockquote>
<p>The problem was that I had accidentally put a semicolon at the end of the first line of the function:</p>
<p>WRONG WAY:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> Foo 
<span style="color: #009900;">&#123;</span> 
    <span style="color: #000000; font-weight: bold;">function</span> bar<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// extra semicolon! </span>
    <span style="color: #009900;">&#123;</span> 
        <span style="color: #666666; font-style: italic;">// stuff </span>
    <span style="color: #009900;">&#125;</span> 
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>RIGHT WAY:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> Foo 
<span style="color: #009900;">&#123;</span> 
    <span style="color: #000000; font-weight: bold;">function</span> bar<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>    <span style="color: #666666; font-style: italic;">// no semicolon, yay </span>
    <span style="color: #009900;">&#123;</span> 
        <span style="color: #666666; font-style: italic;">// stuff </span>
    <span style="color: #009900;">&#125;</span> 
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://joshhighland.com/blog/2011/12/01/non-abstract-method-foobar-must-contain-body/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Letting the database to the heavy lifting: Capitalization via SQL</title>
		<link>http://joshhighland.com/blog/2011/02/12/letting-the-database-to-the-heavy-lifting-capitalization-via-sql/</link>
		<comments>http://joshhighland.com/blog/2011/02/12/letting-the-database-to-the-heavy-lifting-capitalization-via-sql/#comments</comments>
		<pubDate>Sun, 13 Feb 2011 07:33:04 +0000</pubDate>
		<dc:creator>Josh Highland</dc:creator>
				<category><![CDATA[coldfusion]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Capitalization]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[ucfirst]]></category>

		<guid isPermaLink="false">http://joshhighland.com/blog/?p=14626</guid>
		<description><![CDATA[Years ago I had the pleasure of meeting Ben Forta and listen to his thoughts on web development. One thing that stuck with me was his statement that: &#8220;Dynamic programming languages like PHP and Coldfusion are great, but developers need to leverage the database more. Allow the database to do it&#8217;s job, the heavy lifting&#8221; [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><img class="alignleft size-full wp-image-14627" title="Letting the database to the heavy lifting: Capitalization via SQL " src="http://joshhighland.com.s3.amazonaws.com/blog/wp-content/uploads/2011/02/databaseStrength.jpg" alt="databaseStrength Letting the database to the heavy lifting: Capitalization via SQL " width="332" height="318" />Years ago I had the pleasure of meeting <a href="http://en.wikipedia.org/wiki/Ben_Forta">Ben Forta</a> and listen to his  thoughts on web development. One thing that stuck with me was his  statement that:</p>
<blockquote><p><em>&#8220;Dynamic programming languages like PHP and Coldfusion  are great, but developers need to leverage the database more. Allow the  database to do it&#8217;s job, the heavy lifting&#8221;</em></p></blockquote>
<p>With that being said, I was recently working with a database that  contained users first names. The data was not snantized at entry, and  contained a mix of lower cased (ex. josh) and upper cased (ex. Josh)  first characters in the firstname column. I needed to always present the  users first name in a capitalized format.</p>
<p>The first solution that most developers would reach for is  dynamically parsing the users first name, then upper-casing the first character. This works, but in my opinion isn&#8217;t the most elegant solution.</p>
<p>With a simple SQL statement, like the one below, we can return the users first name already in a capitalized state.</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">UPPER</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">LEFT</span><span style="color: #66cc66;">&#40;</span>firstname<span style="color: #66cc66;">,</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">+</span><span style="color: #993333; font-weight: bold;">SUBSTRING</span><span style="color: #66cc66;">&#40;</span>firstname<span style="color: #66cc66;">,</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">,</span>LEN<span style="color: #66cc66;">&#40;</span>firstname<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> firstname 
<span style="color: #993333; font-weight: bold;">FROM</span> users</pre></div></div>

<div>It&#8217;s quick to implement, its easy to work with, and it&#8217;s also very fast on the performance scale.</div>
<div></div>
<div>Yes, I understand that there are cool convenience functions in like <a href="http://php.net/manual/en/function.ucfirst.php">ucfirst()</a> in PHP, but I&#8217;m a lazy programmer and I don&#8217;t want to have to remember  to use <a href="http://php.net/manual/en/function.ucfirst.php">ucfirst()</a> every time I&#8217;m dealing with the users name. I&#8217;d rather get  the information in the correct format the first time, then remembering  to groom it every time before I use it. Set it and forget it.</div>
<div></div>
]]></content:encoded>
			<wfw:commentRss>http://joshhighland.com/blog/2011/02/12/letting-the-database-to-the-heavy-lifting-capitalization-via-sql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP and cURL in parallel</title>
		<link>http://joshhighland.com/blog/2011/01/12/php-and-curl-in-parallel/</link>
		<comments>http://joshhighland.com/blog/2011/01/12/php-and-curl-in-parallel/#comments</comments>
		<pubDate>Thu, 13 Jan 2011 06:26:45 +0000</pubDate>
		<dc:creator>Josh Highland</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[curl]]></category>
		<category><![CDATA[performance]]></category>

		<guid isPermaLink="false">http://joshhighland.com/blog/?p=14607</guid>
		<description><![CDATA[I was recently working on a php based project for a client. I needed to pull in content from 10 different URLs, then process that data into something useful. I have a growing love affair with cURL, so it was my natural selection for the project. In my first approach, I looped over the list [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><img class="alignleft size-full wp-image-14570" title="PHP and cURL in parallel" src="http://joshhighland.com.s3.amazonaws.com/blog/wp-content/uploads/2010/11/curl.png" alt="curl PHP and cURL in parallel" width="200" height="200" />I was recently working on a php based project for a client. I needed to  pull in content from 10 different URLs, then process that data into  something useful.</p>
<p>I have a <a href="http://joshhighland.com/blog/tag/curl/">growing love affair with cURL</a>, so it was my natural selection for the project.</p>
<p>In my first approach, I looped over the list of URLs, sent the cURL  request, wait for the response, stored the data. repeat until done.</p>
<p>That worked, but it was very slow process. The page was taking between 30 &#8211;  45 seconds to load. That doesn&#8217;t sound long, but in terms of web applications,  that&#8217;s an eternity.</p>
<p>I tried several tricks to speed the application up, but the bottle  neck was the cURL calls. Each call was done in a synchronous manner.  Every call to cURL had to be completed before the next could be made.</p>
<p>After doing to research on how to speed this up, I came across the following php <a href="http://php.net/manual/en/book.curl.php">cURL functions</a>:</p>
<blockquote><p>curl_multi_init();<br />
curl_multi_add_handle();<br />
curl_multi_select();<br />
curl_multi_exec();<br />
curl_multi_getcontent();<br />
curl_multi_info_read();<br />
curl_multi_remove_handle();</p></blockquote>
<p>Using these methods allow for cURL to send asynchronous requests, solving my pervious problem.</p>
<p>A little more searching, and I found an awesome wrapper library that  takes the guesswork out of the using the curl_multi methods.  &#8220;ParallelCurl&#8221; <a href="https://github.com/petewarden/ParallelCurl" target="_blank">https://github.com/petewarden/ParallelCurl</a></p>
<p>The sample code provided with the library was very straight forward and super easy to use.</p>
<p>After  using asynchronous cURL calls via the <a href="https://github.com/petewarden/ParallelCurl">ParallelCurl library</a>, I was  able to reduce the page load time <strong>from 45 seconds to 15 seconds</strong>. It&#8217;s  still slow, but it&#8217;s a HUGE improvement, and it makes the application usable,  and reduces load on my server. It&#8217;s a win-win-win situation!</p>
]]></content:encoded>
			<wfw:commentRss>http://joshhighland.com/blog/2011/01/12/php-and-curl-in-parallel/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Using cURL and PHP to upload files through a form post</title>
		<link>http://joshhighland.com/blog/2010/11/27/using-curl-and-php-to-upload-files-through-a-form-post/</link>
		<comments>http://joshhighland.com/blog/2010/11/27/using-curl-and-php-to-upload-files-through-a-form-post/#comments</comments>
		<pubDate>Sat, 27 Nov 2010 23:22:49 +0000</pubDate>
		<dc:creator>Josh Highland</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[curl]]></category>
		<category><![CDATA[file upload]]></category>

		<guid isPermaLink="false">http://joshhighland.com/blog/?p=14559</guid>
		<description><![CDATA[Lately I have been working on a project that requires me to use PHP to interact with a REST based service. cURL is the logical choice for making HTTP calls to the REST service. I love cURL, I&#8217;ve blogged about it before, but I recently ran into some major issues. The REST service I was [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><img class="alignleft size-full wp-image-14570" title="Using cURL and PHP to upload files through a form post" src="http://joshhighland.com.s3.amazonaws.com/blog/wp-content/uploads/2010/11/curl.png" alt="curl Using cURL and PHP to upload files through a form post" width="200" height="200" /></p>
<p>Lately I have been working on a project that requires me to use PHP to  interact with a REST based service. cURL is the logical choice for  making HTTP calls to the REST service.</p>
<p>I love cURL, <a href="http://joshhighland.com/blog/2009/01/27/let-curl-do-your-heavy-lifting/">I&#8217;ve blogged about it before</a>, but I recently ran into some major issues.</p>
<p>The  REST service I was using required me to send two files along with some  meta information. easy enough. I used the following code:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$postFields</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//files</span>
<span style="color: #000088;">$postFields</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'file'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;@<span style="color: #006699; font-weight: bold;">$filePath</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$postFields</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'thumbnail'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;@<span style="color: #006699; font-weight: bold;">$thumbnailPath</span>&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//metaData</span>
<span style="color: #000088;">$postFields</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$title</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$postFields</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'description'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$description</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$postFields</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'tags'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$tags</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$postFields</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'licenseinfo'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$licenseinfo</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$postFields</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'token'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$userToken</span>&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$curl_handle</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl_handle</span><span style="color: #339933;">,</span> CURLOPT_URL<span style="color: #339933;">,</span> <span style="color: #000088;">$api_url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl_handle</span><span style="color: #339933;">,</span> CURLOPT_RETURNTRANSFER<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl_handle</span><span style="color: #339933;">,</span> CURLOPT_POST<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl_handle</span><span style="color: #339933;">,</span> CURLOPT_POSTFIELDS<span style="color: #339933;">,</span> <span style="color: #000088;">$http_post_fields</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//execute the API Call</span>
<span style="color: #000088;">$returned_data</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_exec</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl_handle</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The  code worked great, sending an &#8220;at&#8221; sign (@) before the file path  makes sure that cURL sends the file as part of a &#8220;multipart/form-data&#8221;  post. Exactly what we needed.</p>
<p>The form post from cURL worked great, but the REST service was  retuning a 400 error and saying &#8220;The specified thumbnail file is not  supported.&#8221;. I was at a loss. The service documentation stated the &#8220;jpg,  jpeg, gif, and png&#8221; files were supported.</p>
<p>I ended up contacting the developers of the service who told me that  the content type for the file had to be set to &#8220;image/jpg&#8221; (for jpg).</p>
<p>After pouring through the cURL documentation and not finding anything about  how to set the content type for a single file in a &#8220;multipart/form-data&#8221;  post, I turned to Goolge. My searches with about as helpful as the cURL  docs. I sent a few hours hacking my code and trying some things, I ever  read some posts from 2008 saying that is was not possible to do. Then, I  got a break through, a single ray of light. On a message board was a  single sentence replay. &#8220;You should try this&#8230; $image;type=image/jpg&#8221;.</p>
<p>That was the break through I needed. Below is final updated code:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$postFields</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #666666; font-style: italic;">//files</span>
 <span style="color: #000088;">$postFields</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'file'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;@<span style="color: #006699; font-weight: bold;">$filePath</span>&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//get the extension of the image file</span>
<span style="color: #000088;">$tumbnailExtention</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/^.*\.([^.]+)$/D'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'$1'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$thumbnailPath</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$postFields</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'thumbnail'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;@<span style="color: #006699; font-weight: bold;">$thumbnailPath</span>;type=image/<span style="color: #006699; font-weight: bold;">$tumbnailExtention</span>&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//metaData</span>
<span style="color: #000088;">$postFields</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$title</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$postFields</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'description'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$description</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$postFields</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'tags'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$tags</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$postFields</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'licenseinfo'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$licenseinfo</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$postFields</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'token'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$userToken</span>&quot;</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #000088;">$curl_handle</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl_handle</span><span style="color: #339933;">,</span> CURLOPT_URL<span style="color: #339933;">,</span> <span style="color: #000088;">$api_url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl_handle</span><span style="color: #339933;">,</span> CURLOPT_RETURNTRANSFER<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl_handle</span><span style="color: #339933;">,</span> CURLOPT_POST<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl_handle</span><span style="color: #339933;">,</span> CURLOPT_POSTFIELDS<span style="color: #339933;">,</span> <span style="color: #000088;">$http_post_fields</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #666666; font-style: italic;">//execute the API Call</span>
<span style="color: #000088;">$returned_data</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_exec</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl_handle</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>In summary, if you need to set the content type of a file being sent an image through cURL, via a POST, use the following format:<br />
<strong>$postFields['file'] = &#8220;@PATHTOFILE;type=CONTENTTYPEHERE&#8221;;</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://joshhighland.com/blog/2010/11/27/using-curl-and-php-to-upload-files-through-a-form-post/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>timthumb.php returns a 404 Error in WordPress</title>
		<link>http://joshhighland.com/blog/2010/05/20/timthumb-php-returns-a-404-error-in-wordpress/</link>
		<comments>http://joshhighland.com/blog/2010/05/20/timthumb-php-returns-a-404-error-in-wordpress/#comments</comments>
		<pubDate>Fri, 21 May 2010 06:00:56 +0000</pubDate>
		<dc:creator>Josh Highland</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[chmod]]></category>
		<category><![CDATA[linux. php]]></category>
		<category><![CDATA[permissions]]></category>
		<category><![CDATA[timthumb]]></category>

		<guid isPermaLink="false">http://joshhighland.com/blog/?p=1199</guid>
		<description><![CDATA[timthumb is a great little php script that helps create thumbnail images (http://code.google.com/p/timthumb). I&#8217;ve used it before, but recently I purchased a wordpress theme that used it, and it wasn&#8217;t working. I would get a 404 error when I tired to access the directly via a url like this: theDomain.com/wp-content/themes/theTheme/scripts/timthumb.php?src=/wp-content/uploads/2010/05/moose1.jpg&#38;h=207&#38;w=237&#38;zc=1&#38;q=80 After some digging around in [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><a href="http://joshhighland.com.s3.amazonaws.com/blog/wp-content/uploads/2010/05/create-wordpress-thumbnails-300x300.jpg"><img class="alignleft size-thumbnail wp-image-1200" title="timthumb.php returns a 404 Error in Wordpress" src="http://joshhighland.com.s3.amazonaws.com/blog/wp-content/uploads/2010/05/create-wordpress-thumbnails-300x300-150x150.jpg" alt="create wordpress thumbnails 300x300 150x150 timthumb.php returns a 404 Error in Wordpress" width="150" height="150" /></a>timthumb is a great little php script that helps create thumbnail images (<a href="http://code.google.com/p/timthumb">http://code.google.com/p/timthumb</a>). I&#8217;ve used it before, but recently I purchased a wordpress theme that used it, and it wasn&#8217;t working.</p>
<p>I would get a 404 error when I tired to access the directly via a url like this:<br />
theDomain.com/wp-content/themes/theTheme/scripts/timthumb.php?src=/wp-content/uploads/2010/05/moose1.jpg&amp;h=207&amp;w=237&amp;zc=1&amp;q=80</p>
<p>After some digging around in log files on my server I realized the error</p>
<blockquote><p>SoftException in Application.cpp:610: Directory  “/home/usernamehere/public_html/wp-content” is writable by others</p></blockquote>
<p>My problem had to so with the directory permissions! &#8220;writable by others&#8221; means that the permission on the directory were set to &#8220;777&#8243;. I changed the permissions of the directory using chmod to 755, and everything started to work.</p>
<p>Lesson learned, if timthumb.php is not working at giving you 404 errors, check the permission of the directory that contains the php file.</p>
]]></content:encoded>
			<wfw:commentRss>http://joshhighland.com/blog/2010/05/20/timthumb-php-returns-a-404-error-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Removing trailing comas with PHP</title>
		<link>http://joshhighland.com/blog/2009/11/02/removing-trailing-comas-with-php/</link>
		<comments>http://joshhighland.com/blog/2009/11/02/removing-trailing-comas-with-php/#comments</comments>
		<pubDate>Mon, 02 Nov 2009 22:30:56 +0000</pubDate>
		<dc:creator>Josh Highland</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[tutorials]]></category>
		<category><![CDATA[regexp]]></category>
		<category><![CDATA[regular expression]]></category>

		<guid isPermaLink="false">http://joshhighland.com/blog/?p=940</guid>
		<description><![CDATA[Dealing with trailing comas in lists is common problem for developers. I found the best way to handle this situation in PHP is with the following regular expression. $string = eregi_replace&#40;',$', '', $string&#41;; Before: string = &#8220;2, 6, 9,&#8221; After: string = &#8220;2, 6, 9&#8243; Only the trailing coma will be stripped. If no coma [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><img class="alignleft size-full wp-image-939" title="Removing trailing comas with PHP" src="http://joshhighland.com.s3.amazonaws.com/blog/wp-content/uploads/2009/11/php_logo_medium.jpg" alt="php logo medium Removing trailing comas with PHP" width="200" height="108" />Dealing with trailing comas in lists is common problem for developers. I found the best way to handle this situation in PHP is with the following regular expression.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$string</span> <span style="color: #339933;">=</span> <span style="color: #990000;">eregi_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">',$'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><strong>Before:</strong> string = &#8220;2, 6, 9,&#8221;<strong><br />
After:</strong> string = &#8220;2, 6, 9&#8243;</p>
<p>Only the trailing coma will be stripped. If no coma is found, the string simply passes through. It&#8217;s a simple and effective solution.</p>
]]></content:encoded>
			<wfw:commentRss>http://joshhighland.com/blog/2009/11/02/removing-trailing-comas-with-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Create WordPress Thumbnails Automatically</title>
		<link>http://joshhighland.com/blog/2009/09/29/create-wordpress-thumbnails-automatically/</link>
		<comments>http://joshhighland.com/blog/2009/09/29/create-wordpress-thumbnails-automatically/#comments</comments>
		<pubDate>Wed, 30 Sep 2009 00:19:29 +0000</pubDate>
		<dc:creator>Josh Highland</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[tutorials]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[automatically]]></category>
		<category><![CDATA[custom fields]]></category>
		<category><![CDATA[premium theme]]></category>
		<category><![CDATA[thumbnail]]></category>
		<category><![CDATA[timthumb]]></category>

		<guid isPermaLink="false">http://joshhighland.com/blog/?p=887</guid>
		<description><![CDATA[WordPress has the ability to allow post authors to assign custom fields to a post. This arbitrary extra information is known as meta-data. This meta-data can be used by theme authors to do some pretty cool things. The theme I am currently using allows for a custom field named &#8220;thumb&#8221;. If you create the &#8220;thumb&#8221; [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><img class="alignleft size-medium wp-image-890" title="Create Wordpress Thumbnails Automatically" src="http://joshhighland.com.s3.amazonaws.com/blog/wp-content/uploads/2009/09/create-wordpress-thumbnails-300x300.jpg" alt="create wordpress thumbnails 300x300 Create Wordpress Thumbnails Automatically" width="300" height="300" />WordPress has the ability to allow post authors to assign custom fields to a post. This arbitrary extra information is known as meta-data. This meta-data can be used by theme authors to do some pretty cool things.</p>
<p>The <a href="http://www.studiopress.com/themes/church" rel="nofollow">theme</a> I am currently using allows for a custom field named &#8220;thumb&#8221;. If you create the &#8220;thumb&#8221; custom field in a post and pass in the path to an image, for example &#8220;wp-content/uploads/2008/12/wordpress_logo.png&#8221;, a thumb nail version of the image will appear next the posts title on the home page of my blog. Awesome stuff.</p>
<p>When I discovered this theme and the &#8220;thumb&#8221; custom field, I already had 225 posts in my blog. I didn&#8217;t want to go back and manually create all the custom fields for the existing posts, so I wrote a PHP script to do it for me.</p>
<p>The PHP script cycles through your existing posts and looks for the first image in the post, and creates the thumb field based on it&#8217;s location. The script is configurable, your theme may want a different custom field name, like &#8220;thumbnail&#8221; or &#8220;image&#8221;.</p>
<p>This code is provided as is. If you aren&#8217;t a developer, you should be messing with stuff like this. Be sure to <a href="http://wordpress.org/extend/plugins/wp-db-backup/">back up your wordpress database</a> before running this.</p>
<p><strong>Instruction:<br />
</strong></p>
<ul>
<li>download this code</li>
<li>configure the database connection info and custom field name</li>
<li>upload this code onto your server</li>
<li>point your browser to the file</li>
<li>watch the script do it&#8217;s magic</li>
<li>remove the file from your server</li>
<li><a href="https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&amp;content_ID=marketing_us/send_money" target="_blank">donate $2 to my paypal account</a> (joshhighland@gmail.com)</li>
</ul>
<p><strong>Note:</strong> This is a one time deal, when you create new posts you will need to add the &#8220;thumb&#8221; field and image path manually</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//your database configuration information</span>
<span style="color: #000088;">$username</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;YOUR_USER_NAME&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$password</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;YOUR_PASSWORD&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$database</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;DATABASE&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$databaseLocation</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;localhost&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//name of the Custom Field to use</span>
<span style="color: #000088;">$customFieldName</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;thumb&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/******************* END CONFIGURATION *****************************/</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//get the wordpress posts to work with</span>
<span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT * FROM wp_posts&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$mysqli</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$query</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">//loop over all the posts</span>
	<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$result</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fetch_object</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">//get all the info from the post that we need to work with</span>
		<span style="color: #000088;">$cur_post_id</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$cur_post_content</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_content</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//the pattern to find the html image tag</span>
		<span style="color: #000088;">$pattern</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'/]+src[\\s=\'&quot;]'</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$pattern</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'+([^&quot;\'&gt;\\s]+)/is'</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//try to match the pattern against the post content</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pattern</span><span style="color: #339933;">,</span><span style="color: #000088;">$cur_post_content</span><span style="color: #339933;">,</span><span style="color: #000088;">$match</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #666666; font-style: italic;">//break up the image path</span>
			<span style="color: #000088;">$pieces</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;wp-content/&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$match</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #666666; font-style: italic;">//make sure the file name isnt empty</span>
			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pieces</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</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: #009900;">&#123;</span>
				<span style="color: #666666; font-style: italic;">//build the file path</span>
				<span style="color: #000088;">$imagePath</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;wp-content/&quot;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$pieces[1]</span>&quot;</span><span style="color: #339933;">;</span>
&nbsp;
				<span style="color: #666666; font-style: italic;">//insert the custom field for the post</span>
				<span style="color: #000088;">$insertQuery</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;INSERT INTO wp_postmeta (post_id, meta_key, meta_value) VALUES (<span style="color: #006699; font-weight: bold;">$cur_post_id</span>, '<span style="color: #006699; font-weight: bold;">$customFieldName</span>', '<span style="color: #006699; font-weight: bold;">$imagePath</span>')&quot;</span><span style="color: #339933;">;</span>
&nbsp;
				<span style="color: #000088;">$mysqli</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$insertQuery</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
				<span style="color: #666666; font-style: italic;">//debugging stuff</span>
&nbsp;
				<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$mysqli</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">errno</span><span style="color: #009900;">&#41;</span>
				<span style="color: #009900;">&#123;</span>
					<span style="color: #990000;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;failed: <span style="color: #009933; font-weight: bold;">%s</span> <span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$mysqli</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">error</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>
					<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;..... inserting <span style="color: #006699; font-weight: bold;">$imagePath</span> <span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
				<span style="color: #990000;">flush</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: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;---completed---&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://joshhighland.com/blog/2009/09/29/create-wordpress-thumbnails-automatically/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>phpBB admin password manual reset</title>
		<link>http://joshhighland.com/blog/2009/03/31/phpbb-admin-password-manual-reset/</link>
		<comments>http://joshhighland.com/blog/2009/03/31/phpbb-admin-password-manual-reset/#comments</comments>
		<pubDate>Wed, 01 Apr 2009 07:51:36 +0000</pubDate>
		<dc:creator>Josh Highland</dc:creator>
				<category><![CDATA[hacks]]></category>
		<category><![CDATA[internet]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[semi-legal]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[tutorials]]></category>

		<guid isPermaLink="false">http://joshhighland.com/blog/?p=607</guid>
		<description><![CDATA[Today I ran into a situation where I had forgotten the password to my development instance of phpBB 3. I was stuck in a situation were I needed to reset the password. I had full admin access to the database, so changing it there wouldn&#8217;t be the problem. The real problem is that phpBB uses [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><img class="alignnone size-full wp-image-606" title="phpBB admin password manual reset" src="http://joshhighland.com.s3.amazonaws.com/blog/wp-content/uploads/2009/03/phpbb_logo.jpg" alt="phpbb logo phpBB admin password manual reset" width="206" height="158" /></p>
<p>Today I ran into a situation where I had forgotten the password to my development instance of <a href="http://www.phpbb.com">phpBB</a> 3. I was stuck in a situation were I needed to reset the password. I had full admin access to the database, so changing it there wouldn&#8217;t be the problem. The real problem is that phpBB uses its own password hashing, not MD5.</p>
<p>In a work around, I created a new user and used the password &#8220;123456&#8243; looking at the database , in the users table of the phpBB install. I saw the &#8220;user_password&#8221; field was &#8220;e10adc3949ba59abbe56e057f20f883e&#8221;.</p>
<p>I then changed my admin accounts user to the same string, &#8220;e10adc3949ba59abbe56e057f20f883e&#8221;.</p>
<p><a href="http://joshhighland.com.s3.amazonaws.com/blog/wp-content/uploads/2009/03/phpbbpasswordreset.gif"><img class="alignnone size-full wp-image-608" title="phpBB admin password manual reset" src="http://joshhighland.com.s3.amazonaws.com/blog/wp-content/uploads/2009/03/phpbbpasswordreset.gif" alt="phpbbpasswordreset phpBB admin password manual reset" width="536" height="66" /></a></p>
<p>I went to the phpBB login screen, fillled out my username, and entered the password &#8220;123456&#8243;&#8230; BINGO! it worked.</p>
<p>So to save you the work. You can follow what I did or just use these hashes to reset your own password:</p>
<p><strong>Hash:</strong> e10adc3949ba59abbe56e057f20f883e<br />
<strong>Password:</strong> 123456</p>
<p><strong>Hash:</strong> $H$9Ae3Uk.ECdWW5ya13M4ErWhr4c.761/<br />
<strong>Password:</strong> password</p>
<p>I hope this helps someone else out there.</p>
]]></content:encoded>
			<wfw:commentRss>http://joshhighland.com/blog/2009/03/31/phpbb-admin-password-manual-reset/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Modifying MimboPro to Add Paged Navigation To Category Pages</title>
		<link>http://joshhighland.com/blog/2008/12/08/modifying-mimbopro-to-add-paged-navigation-to-category-pages/</link>
		<comments>http://joshhighland.com/blog/2008/12/08/modifying-mimbopro-to-add-paged-navigation-to-category-pages/#comments</comments>
		<pubDate>Tue, 09 Dec 2008 02:39:55 +0000</pubDate>
		<dc:creator>Josh Highland</dc:creator>
				<category><![CDATA[hacks]]></category>
		<category><![CDATA[internet]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[tutorials]]></category>
		<category><![CDATA[web 2.0]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[MimboPro]]></category>

		<guid isPermaLink="false">http://joshhighland.com/blog/?p=453</guid>
		<description><![CDATA[Recently I have been doing a lot of work with WordPress. I love WordPress. one of the things I like most about WordPress is the plugins and themes. I recently bought a copy of the MimboPro theme. Mimbo is clean and very professional. More of a CMS theme then a blogging theme, prefect for what [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><img class="alignnone size-full wp-image-462" title="Modifying MimboPro to Add Paged Navigation To Category Pages" src="http://joshhighland.com.s3.amazonaws.com/blog/wp-content/uploads/2008/12/mimbologo.jpg" alt="mimbologo Modifying MimboPro to Add Paged Navigation To Category Pages" width="240" height="100" /></p>
<p>Recently I have been doing a lot of work with WordPress. I love WordPress. one of the things I like most about WordPress is the plugins and themes.</p>
<p>I recently bought a copy of the <a href="http://prothemedesign.com/themes/mimbo-pro/">MimboPro theme</a>. Mimbo is clean and very professional. More of a CMS theme then a blogging theme, prefect for what I want to use it for.</p>
<p>As I dug into MimboPro and WordPress, I realized something strange, the MimboPro theme doesn&#8217;t support paging in a category view. What this means is EVERY SINGLE post you make is shown on one page. If you have a very active site, like the one I&#8217;m working on, this quickly gets out of hand. Look at this image and you will see what I mean (click for full version).</p>
<p><a href="http://joshhighland.com.s3.amazonaws.com/blog/wp-content/uploads/2008/12/prehack.gif"><img class="alignnone size-medium wp-image-454" title="Modifying MimboPro to Add Paged Navigation To Category Pages" src="http://joshhighland.com.s3.amazonaws.com/blog/wp-content/uploads/2008/12/prehack-111x300.gif" alt="prehack 111x300 Modifying MimboPro to Add Paged Navigation To Category Pages" width="111" height="300" /></a></p>
<p>One of the reasons I like MimboPro was the support that the authors of the theme offer. I headed over to their message forums and found other people like me asking for the <a href="http://forum.prothemedesign.com/topic/adding-paged-navigation-to-category-page">Additon of Paged Navigation To Category Pages</a>. The original post was 8 months ago, and no one had resolved anything. I made a post to the MimboPro authors only to be told that there is going to be a new theme that will handle this and it will be available at a deep discount to MimboPro owner. This upset me a bit, so taking matters into my own hand, I fixed what Mimbo wont, and I am handing out my own patch to solve this issue. Below are the instructions to hack your own files, or you can just download my zip file with the pre-hacked files.</p>
<p><strong>Pre-Hacked Files:</strong><br />
Download with pre-hacked files: <a href="http://joshhighland.com.s3.amazonaws.com/blog/wp-content/uploads/2008/12/joshhighlands_mimbopro_categorypaginghack.zip">JoshHighlands_MimboPro_CategoryPagingHack.zip</a></p>
<p><strong>DIY INSTRUCTIONS</strong> (click images for full sizes):</p>
<ol>
<li>Save a copy of your current categories.php and styles.css files inside of the MimboPro theme directory to a safe location</li>
<li>Open up categories.php inside of the MimboPro theme directory, and find line 17<br />
<a href="http://joshhighland.com.s3.amazonaws.com/blog/wp-content/uploads/2008/12/mimbohack1.gif"><img class="alignnone size-full wp-image-455" title="Modifying MimboPro to Add Paged Navigation To Category Pages" src="http://joshhighland.com.s3.amazonaws.com/blog/wp-content/uploads/2008/12/mimbohack1.gif" alt="mimbohack1 Modifying MimboPro to Add Paged Navigation To Category Pages" width="500" height="133" /></a></li>
<li>Comment line 17 with a double back slash (//)<br />
<a href="http://joshhighland.com.s3.amazonaws.com/blog/wp-content/uploads/2008/12/mimbohack2.gif"><img class="alignnone size-full wp-image-456" title="Modifying MimboPro to Add Paged Navigation To Category Pages" src="http://joshhighland.com.s3.amazonaws.com/blog/wp-content/uploads/2008/12/mimbohack2.gif" alt="mimbohack2 Modifying MimboPro to Add Paged Navigation To Category Pages" width="500" height="183" /></a></li>
<li>Go to line 87 of category.php and add the following code<br />
<a href="http://joshhighland.com.s3.amazonaws.com/blog/wp-content/uploads/2008/12/mimbohack3.gif"><img class="alignnone size-medium wp-image-457" title="Modifying MimboPro to Add Paged Navigation To Category Pages" src="http://joshhighland.com.s3.amazonaws.com/blog/wp-content/uploads/2008/12/mimbohack3-300x68.gif" alt="mimbohack3 300x68 Modifying MimboPro to Add Paged Navigation To Category Pages" width="300" height="68" /></a></li>
<li>Save and close category.php</li>
<li>Open up style.css inside of the MimboPro theme directory</li>
<li>Add the following CSS code to the bottom of the file (should be close to line 852)<br />
<a href="http://joshhighland.com.s3.amazonaws.com/blog/wp-content/uploads/2008/12/minbohack4.gif"><img class="alignnone size-full wp-image-458" title="Modifying MimboPro to Add Paged Navigation To Category Pages" src="http://joshhighland.com.s3.amazonaws.com/blog/wp-content/uploads/2008/12/minbohack4.gif" alt="minbohack4 Modifying MimboPro to Add Paged Navigation To Category Pages" width="351" height="192" /></a></li>
<li>Save styles.css</li>
<li>Upload categories.php and styles.css to the MimboPro theme directory on your server</li>
<li>Everything should be working. Here is what my wordpress running MimboPro looks like<br />
<a href="http://joshhighland.com.s3.amazonaws.com/blog/wp-content/uploads/2008/12/posthack.gif"><img class="alignnone size-medium wp-image-459" title="Modifying MimboPro to Add Paged Navigation To Category Pages" src="http://joshhighland.com.s3.amazonaws.com/blog/wp-content/uploads/2008/12/posthack-220x300.gif" alt="posthack 220x300 Modifying MimboPro to Add Paged Navigation To Category Pages" width="220" height="300" /></a></li>
</ol>
<p>That&#8217;s it! MimboPro will now have paging in all of the categories. The next and previous links will only show up when you have enough posts. The WordPress default is 10 posts. You can edit the number of posts by going to change the number of posts to show on a category page, go into to the admin and under &#8220;setting&#8221; &gt; &#8220;reading&#8221; you will find the option, as highlighted here.<br />
<a href="http://joshhighland.com.s3.amazonaws.com/blog/wp-content/uploads/2008/12/admin.gif"><img class="alignnone size-medium wp-image-461" title="Modifying MimboPro to Add Paged Navigation To Category Pages" src="http://joshhighland.com.s3.amazonaws.com/blog/wp-content/uploads/2008/12/admin-252x300.gif" alt="admin 252x300 Modifying MimboPro to Add Paged Navigation To Category Pages" width="252" height="300" /></a></p>
<p>If you had any problem reading the code in the image files, download the zip files with the pre-hacked files in them.</p>
<p>Download with pre-hacked files: <a href="http://joshhighland.com.s3.amazonaws.com/blog/wp-content/uploads/2008/12/joshhighlands_mimbopro_categorypaginghack.zip">JoshHighlands_MimboPro_CategoryPagingHack.zip</a></p>
<p>If you have any further questions, please post them in the comment.<br />
<a href="http://joshhighland.com.s3.amazonaws.com/blog/wp-content/uploads/2008/12/joshhighlands_mimbopro_categorypaginghack.zip"></a></p>
]]></content:encoded>
			<wfw:commentRss>http://joshhighland.com/blog/2008/12/08/modifying-mimbopro-to-add-paged-navigation-to-category-pages/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>WordPress 2.7 is almost here!</title>
		<link>http://joshhighland.com/blog/2008/12/03/wordpress-27-is-almost-here/</link>
		<comments>http://joshhighland.com/blog/2008/12/03/wordpress-27-is-almost-here/#comments</comments>
		<pubDate>Thu, 04 Dec 2008 05:09:56 +0000</pubDate>
		<dc:creator>Josh Highland</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[web 2.0]]></category>

		<guid isPermaLink="false">http://joshhighland.com/blog/?p=450</guid>
		<description><![CDATA[OMG OMG OMG! WordPress 2.7 is almost here. Here is a long list of the changes that are going to be in the latest release. I have been a huge wordpress fan for some years now. Its always treated me well. Its treated me so well that I have decided to move my main website, [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><img class="size-medium wp-image-449 alignnone" title="WordPress 2.7 is almost here!" src="http://joshhighland.com.s3.amazonaws.com/blog/wp-content/uploads/2008/12/wordpress_logo.png" alt="wordpress logo WordPress 2.7 is almost here!" width="280" height="280" />OMG OMG OMG! WordPress 2.7 is almost here. <a href="http://en.blog.wordpress.com/2008/12/03/27-gets-here-in-two-days/">Here is a long list of the changes</a> that are going to be in the latest release. I have been a huge wordpress fan for some years now. Its always treated me well. Its treated me so well that I have decided to move my main website, <a href="http://notpopular.com">notPopular.com</a>, to the wordpress platform for content management. I&#8217;m really nervous though, I have done a lot of custom work on the notpop install of wordpress, and it isnt released yet. I hope that my plugins and custom code doesnt break to badly. I will have a full review of wordpress 2.7 once it is released later this week.</p>
]]></content:encoded>
			<wfw:commentRss>http://joshhighland.com/blog/2008/12/03/wordpress-27-is-almost-here/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 disk: basic (Feed is rejected)
Page Caching using disk: enhanced
Database Caching 19/44 queries in 0.009 seconds using disk: basic
Object Caching 1288/1331 objects using disk: basic
Content Delivery Network via Amazon Web Services: S3: joshhighland.com.s3.amazonaws.com

Served from: joshhighland.com @ 2012-05-22 02:35:31 -->
