<?xml version="1.0" encoding="utf-8" ?>

<rss version="2.0" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/"
   xmlns:content="http://purl.org/rss/1.0/modules/content/"
   >
<channel>
    <title>Mike's Page - Tech</title>
    <link>http://boonedocks.net/mike/</link>
    <description>Just breaking the surface</description>
    <dc:language>en</dc:language>
    <generator>Serendipity 1.2 - http://www.s9y.org/</generator>
    
    <image>
        <url>http://boonedocks.net/mike/templates/default/img/s9y_banner_small.png</url>
        <title>RSS: Mike's Page - Tech - Just breaking the surface</title>
        <link>http://boonedocks.net/mike/</link>
        <width>100</width>
        <height>21</height>
    </image>

<item>
    <title>Printer held Hostage by Ink Cartridge</title>
    <link>http://boonedocks.net/mike/archives/166-Printer-held-Hostage-by-Ink-Cartridge.html</link>
            <category>Tech</category>
    
    <comments>http://boonedocks.net/mike/archives/166-Printer-held-Hostage-by-Ink-Cartridge.html#comments</comments>
    <wfw:comment>http://boonedocks.net/mike/wfwcomment.php?cid=166</wfw:comment>

    <slash:comments>1</slash:comments>
    <wfw:commentRss>http://boonedocks.net/mike/rss.php?version=2.0&amp;type=comments&amp;cid=166</wfw:commentRss>
    

    <author>nospam@example.com (Mike Boone)</author>
    <content:encoded>
    I&#039;ve had a Canon Pixma MX700 multifunction printer since the beginning of the year. I&#039;ve been pretty happy with it. It&#039;s worked well for scanning, copying, faxing and printing. Until today. Today I needed to scan something, and was greeted with the following message when I turned it on:
&lt;blockquote&gt;&lt;b&gt;U150&lt;/b&gt; The following ink tank cannot be recognized.&lt;/blockquote&gt;
The yellow cartridge was indicated. I though that it was an odd problem, but I didn&#039;t care for the moment, because I didn&#039;t want to print, just scan. But no button on the printer would bypass this error and let me scan.&lt;br /&gt;&lt;br /&gt;
I ended up calling Canon, and happily received a domestic phone rep. He had me try a couple things, but eventually decided that the yellow ink would need to be replaced. They would send me one free. I asked if there was any way to bypass the error so I could just scan, and he said there was not. If I wanted to use it today I would have to go out and buy a yellow ink cartridge. So after driving all the way across town and spending $16, I have my printer back...for now.&lt;br /&gt;&lt;br /&gt;
It seems like questionable design to cripple all the functions of the printer just because one color cartridge is faulty. A better failure mode would be to only prevent color printing. Black and white printing, and the other printer functions should still be usable. Hey Canon, how about updated firmware for this? Please?
 
    </content:encoded>

    <pubDate>Mon, 07 Apr 2008 20:57:03 -0400</pubDate>
    <guid isPermaLink="false">http://boonedocks.net/mike/archives/166-guid.html</guid>
    
</item>
<item>
    <title>Determining Image File Types in Ruby</title>
    <link>http://boonedocks.net/mike/archives/162-Determining-Image-File-Types-in-Ruby.html</link>
            <category>Ruby</category>
    
    <comments>http://boonedocks.net/mike/archives/162-Determining-Image-File-Types-in-Ruby.html#comments</comments>
    <wfw:comment>http://boonedocks.net/mike/wfwcomment.php?cid=162</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://boonedocks.net/mike/rss.php?version=2.0&amp;type=comments&amp;cid=162</wfw:commentRss>
    

    <author>nospam@example.com (Mike Boone)</author>
    <content:encoded>
    Today I came across a PNG file that had been uploaded from a browser with a .JPG extension and image/jpeg MIME type. It&#039;s too bad that MIME types are apparently unreliable when it comes to file uploads. I went looking for a way to determine the file type by actually reading the file. This is probably a solved problem, but I was unsuccessful Googling for the answer. I came up with the following Ruby method which decides the image file type using up to the first 10 bytes:&lt;br /&gt;&lt;br /&gt;
&lt;div style=&quot;font-family: monospace;&quot;&gt;
def image_type(file)&lt;br /&gt;
&amp;#160;&amp;#160;case IO.read(file, 10)&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;when /^GIF8/: &#039;gif&#039;&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;when /^\x89PNG/: &#039;png&#039;&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;when /^\xff\xd8\xff\xe0\x00\x10JFIF/: &#039;jpg&#039;&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;when /^\xff\xd8\xff\xe1(.*){2}Exif/: &#039;jpg&#039;&lt;br /&gt;
&amp;#160;&amp;#160;else &#039;unknown&#039;&lt;br /&gt;
&amp;#160;&amp;#160;end&lt;br /&gt;
end&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
This works well on a small set of test files (400+ from a browser temp files directory). Let me know if there&#039;s a case where this code doesn&#039;t work, or if there&#039;s a better solution in general.
 
    </content:encoded>

    <pubDate>Mon, 10 Mar 2008 22:22:03 -0400</pubDate>
    <guid isPermaLink="false">http://boonedocks.net/mike/archives/162-guid.html</guid>
    
</item>
<item>
    <title>I'm in Rails</title>
    <link>http://boonedocks.net/mike/archives/159-Im-in-Rails.html</link>
            <category>Ruby</category>
    
    <comments>http://boonedocks.net/mike/archives/159-Im-in-Rails.html#comments</comments>
    <wfw:comment>http://boonedocks.net/mike/wfwcomment.php?cid=159</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://boonedocks.net/mike/rss.php?version=2.0&amp;type=comments&amp;cid=159</wfw:commentRss>
    

    <author>nospam@example.com (Mike Boone)</author>
    <content:encoded>
    I&#039;ve made a code contribution to Ruby on Rails. It was minor, but I&#039;m glad I could help. See &lt;a href=&quot;http://dev.rubyonrails.org/ticket/10435&quot;&gt;ticket 10435&lt;/a&gt; and &lt;a href=&quot;http://dev.rubyonrails.org/changeset/8386&quot;&gt;changeset 8386&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;
Supposed to get some rain today...keeping my fingers crossed.&lt;br /&gt;&lt;br /&gt;
&lt;b&gt;Update 2007-12-17:&lt;/b&gt; Looks like my patch made it into &lt;a href=&quot;http://weblog.rubyonrails.com/2007/12/17/rails-2-0-2-some-new-defaults-and-a-few-fixes&quot;&gt;Rails 2.0.2&lt;/a&gt;. And we did get that rain, but more would be good.&lt;br /&gt;&lt;br /&gt;
&lt;b&gt;Update 2008-03-17:&lt;/b&gt; I managed to get another &lt;a href=&quot;http://dev.rubyonrails.org/ticket/11353&quot;&gt;small patch&lt;/a&gt; committed. Go open source!
 
    </content:encoded>

    <pubDate>Sat, 15 Dec 2007 07:55:47 -0500</pubDate>
    <guid isPermaLink="false">http://boonedocks.net/mike/archives/159-guid.html</guid>
    
</item>
<item>
    <title>Formatting a Javascript Date for MySQL</title>
    <link>http://boonedocks.net/mike/archives/157-Formatting-a-Javascript-Date-for-MySQL.html</link>
            <category>Tech</category>
    
    <comments>http://boonedocks.net/mike/archives/157-Formatting-a-Javascript-Date-for-MySQL.html#comments</comments>
    <wfw:comment>http://boonedocks.net/mike/wfwcomment.php?cid=157</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://boonedocks.net/mike/rss.php?version=2.0&amp;type=comments&amp;cid=157</wfw:commentRss>
    

    <author>nospam@example.com (Mike Boone)</author>
    <content:encoded>
    I don&#039;t like to code in JavaScript, but that&#039;s the Ajax-y wave of the future. So I write it when I have to. This week I needed to format a Javascript date as a MySQL-style date like 2007-12-08.&lt;br /&gt;&lt;br /&gt; JavaScript apparently doesn&#039;t have a nice date formatting function or even a generalized sprintf. Another Javascript quirk is that the Date.getMonth() function returns 0-11, while the getDate() function returns 1-31. I&#039;m not sure what the designer was thinking on that one.&lt;br /&gt;&lt;br /&gt;

I came up with this function...feel free to use it in your code with or without credit:&lt;br /&gt;&lt;br /&gt;
&lt;div style=&quot;font-family: monospace;&quot;&gt;
function formatDate(date1) {&lt;br /&gt;
&amp;#160;&amp;#160;return date1.getFullYear() + &#039;-&#039; +&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;(date1.getMonth() &lt; 9 ? &#039;0&#039; : &#039;&#039;) + (date1.getMonth()+1) + &#039;-&#039; +&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;(date1.getDate() &lt; 10 ? &#039;0&#039; : &#039;&#039;) + date1.getDate();&lt;br /&gt;
}&lt;br /&gt;
&lt;/div&gt;
 
    </content:encoded>

    <pubDate>Sat, 08 Dec 2007 08:59:50 -0500</pubDate>
    <guid isPermaLink="false">http://boonedocks.net/mike/archives/157-guid.html</guid>
    
</item>
<item>
    <title>Improving upon Rails' validates_inclusion_of</title>
    <link>http://boonedocks.net/mike/archives/152-Improving-upon-Rails-validates_inclusion_of.html</link>
            <category>Ruby</category>
    
    <comments>http://boonedocks.net/mike/archives/152-Improving-upon-Rails-validates_inclusion_of.html#comments</comments>
    <wfw:comment>http://boonedocks.net/mike/wfwcomment.php?cid=152</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://boonedocks.net/mike/rss.php?version=2.0&amp;type=comments&amp;cid=152</wfw:commentRss>
    

    <author>nospam@example.com (Mike Boone)</author>
    <content:encoded>
    I&#039;m fairly new to the Ruby language and the Ruby on Rails framework, but it worked nicely for quickly building my website &lt;a href=&quot;http://birdsite.org/&quot;&gt;BirdSite&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;

I was using &lt;a href=&quot;http://api.rubyonrails.org/classes/ActiveRecord/Validations/ClassMethods.html#M000946&quot;&gt;validates_inclusion_of &lt;/a&gt; fairly regularly to make sure the data in my models was valid. But then, watching the development log, I noticed extra SQL queries being made when I accessed my main model. It seems that validates_inclusion_of was forcing the model to make queries to the related models even when I didn&#039;t need data from them.&lt;br /&gt;&lt;br /&gt;

Some Googling led to a &lt;a href=&quot;http://www.elctech.com/2007/5/3/dry-validates_inclusion_of-with-introspection&quot;&gt;blog post that did the validation a different way&lt;/a&gt;. It worked well, until I added the code to a new model today and it broke. The code was translating the model field name into a string from which to call the model itself. But the code assumed that the model would be a single word. I added a change to strip the spaces out, and it worked again.&lt;br /&gt;&lt;br /&gt;

I contacted the company that hosts the blog and they confirmed that it was a problem, and they didn&#039;t know of a nicer Ruby way to correct it short of dropping the spaces with search/replace. They updated their code.&lt;br /&gt;&lt;br /&gt;

I&#039;m glad I could help out. It really works better than the standard validates_inclusion_of.
 
    </content:encoded>

    <pubDate>Tue, 28 Aug 2007 16:36:34 -0400</pubDate>
    <guid isPermaLink="false">http://boonedocks.net/mike/archives/152-guid.html</guid>
    
</item>
<item>
    <title>Rails acts_as_ferret without DRb</title>
    <link>http://boonedocks.net/mike/archives/151-Rails-acts_as_ferret-without-DRb.html</link>
            <category>Ruby</category>
    
    <comments>http://boonedocks.net/mike/archives/151-Rails-acts_as_ferret-without-DRb.html#comments</comments>
    <wfw:comment>http://boonedocks.net/mike/wfwcomment.php?cid=151</wfw:comment>

    <slash:comments>7</slash:comments>
    <wfw:commentRss>http://boonedocks.net/mike/rss.php?version=2.0&amp;type=comments&amp;cid=151</wfw:commentRss>
    

    <author>nospam@example.com (Mike Boone)</author>
    <content:encoded>
    I wanted to add a search feature to my Ruby on Rails application &lt;a href=&quot;http://birdsite.org/&quot;&gt;BirdSite&lt;/a&gt;. There is a plugin called &quot;&lt;a href=&quot;http://projects.jkraemer.net/acts_as_ferret/wiki&quot;&gt;acts_as_ferret&lt;/a&gt;&quot; which allows Rails applications to use the Ferret search engine (based on Lucene).&lt;br /&gt;&lt;br /&gt;

Using &lt;a href=&quot;http://www.railsenvy.com/2007/2/19/acts-as-ferret-tutorial&quot;&gt;this tutorial&lt;/a&gt;, I was able to get search up an running. It worked great on my development system. But there was a warning that you needed to run the indexer using a DRb server instead of directly from the Rails app. This is because the index cannot handle multiple processes writing to it simultaneously. (I also ran into this problem using PHP with another
engine called &lt;a href=&quot;http://www.xapian.org/&quot;&gt;Xapian&lt;/a&gt;).&lt;br /&gt;&lt;br /&gt;

I was hoping my new site was low traffic enough to avoid problems. Since I&#039;m hosting it on a shared server, I can&#039;t run a DRb server there anyway. But I got my first indexing exceptions less than 24 hours after I loaded my stuff onto the live server.&lt;br /&gt;&lt;br /&gt;

So I decided to try periodic indexing by a cron job. This would allow me to update the index once an hour, from a single process. The downside is that the search index is only updated hourly, but I decided I could live with that.&lt;br /&gt;&lt;br /&gt;

The first step is telling your Rails app to not index the content when updating. My model already had a before_save method, so I added this code:&lt;br /&gt;&lt;br /&gt;

&lt;div style=&quot;font-family: monospace;&quot;&gt;
# in the model&lt;br /&gt;
def before_save&lt;br /&gt;
&amp;#160;&amp;#160;# other stuff goes here&lt;br /&gt;&lt;br /&gt;
&amp;#160;&amp;#160;# disable automatic ferret indexing...move it to a cron job&lt;br /&gt;
&amp;#160;&amp;#160;self.disable_ferret(:always)&lt;br /&gt;
end
&lt;/div&gt;&lt;br /&gt;

Then I had to create a rake task which would build the index:&lt;br /&gt;&lt;br /&gt;

&lt;div style=&quot;font-family: monospace;&quot;&gt;
# ferret_index.rake&lt;br /&gt;
desc &quot;Updates the ferret index for the application.&quot;&lt;br /&gt;
task :ferret_index =&gt; [ :environment ] do | t |&lt;br /&gt;
&amp;#160;&amp;#160;MyModel.rebuild_index&lt;br /&gt;
&amp;#160;&amp;#160;# here I could add other model index rebuilds&lt;br /&gt;
&amp;#160;&amp;#160;puts &quot;Completed Ferret Index Rebuild&quot;&lt;br /&gt;
end
&lt;/div&gt;&lt;br /&gt;

This task is simplified: I&#039;m telling it to rebuild the entire index each hour. I&#039;m guessing when my dataset gets big enough, this will be really slow. In that case I&#039;ll need to track all the model instances that got updated in the past hour and just index those.&lt;br /&gt;&lt;br /&gt;

Finally, I needed a cron job to run the rake task, making sure to set the environment to &quot;production&quot;:&lt;br /&gt;&lt;br /&gt;

&lt;div style=&quot;font-family: monospace;&quot;&gt;
cd /rails_app &amp;&amp;amp; rake ferret_index RAILS_ENV=production
&lt;/div&gt;&lt;br /&gt;

So far this is working well, and I haven&#039;t received any indexing exceptions since.
 
    </content:encoded>

    <pubDate>Tue, 14 Aug 2007 17:17:38 -0400</pubDate>
    <guid isPermaLink="false">http://boonedocks.net/mike/archives/151-guid.html</guid>
    
</item>
<item>
    <title>Check out the BirdSite!</title>
    <link>http://boonedocks.net/mike/archives/149-Check-out-the-BirdSite!.html</link>
            <category>Nature</category>
            <category>Photo</category>
            <category>Ruby</category>
    
    <comments>http://boonedocks.net/mike/archives/149-Check-out-the-BirdSite!.html#comments</comments>
    <wfw:comment>http://boonedocks.net/mike/wfwcomment.php?cid=149</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://boonedocks.net/mike/rss.php?version=2.0&amp;type=comments&amp;cid=149</wfw:commentRss>
    

    <author>nospam@example.com (Mike Boone)</author>
    <content:encoded>
    &lt;div style=&quot;padding-left: 1em; padding-right: 0.5em; padding-top: 0.5em; padding-bottom: 0.5em; float: right;&quot;&gt;&lt;a href=&quot;http://birdsite.org&quot;&gt;
&lt;img border=&quot;0&quot; src=&quot;http://boonedocks.net/mike/images/birdsite_small.png&quot;&gt;&lt;/a&gt;&lt;/div&gt;
I recently published a new website: &lt;a href=&quot;http://birdsite.org/&quot;&gt;birdsite.org&lt;/a&gt;.
This site was inspired by &lt;a href=&quot;http://bugguide.net/&quot;&gt;BugGuide&lt;/a&gt;, where I&#039;ve been
a participant for several years, both as a photographer and a developer. I&#039;d been
thinking about doing a similar site for other fauna that I photograph.
&lt;a href=&quot;http://bugguide.net/node/view/62076&quot;&gt;This forum thread&lt;/a&gt; made it clear
that others were interested in such a site for birds. I decided to build it. For my
own programming amusement I created this site as my first project with
&lt;a href=&quot;http://rubyonrails.org/&quot;&gt;Ruby on Rails&lt;/a&gt;. I still have lots of features to
add but I wanted to get the bare bones up and running.
 
    </content:encoded>

    <pubDate>Fri, 06 Jul 2007 14:50:51 -0400</pubDate>
    <guid isPermaLink="false">http://boonedocks.net/mike/archives/149-guid.html</guid>
    
</item>
<item>
    <title>Drupal Anti-spam Registration Question</title>
    <link>http://boonedocks.net/mike/archives/147-Drupal-Anti-spam-Registration-Question.html</link>
            <category>Tech</category>
    
    <comments>http://boonedocks.net/mike/archives/147-Drupal-Anti-spam-Registration-Question.html#comments</comments>
    <wfw:comment>http://boonedocks.net/mike/wfwcomment.php?cid=147</wfw:comment>

    <slash:comments>2</slash:comments>
    <wfw:commentRss>http://boonedocks.net/mike/rss.php?version=2.0&amp;type=comments&amp;cid=147</wfw:commentRss>
    

    <author>nospam@example.com (Mike Boone)</author>
    <content:encoded>
    Last year I had to &lt;a href=&quot;http://boonedocks.net/mike/archives/143-PHPBB-Anti-spam-Registration-Question.html&quot;&gt;add an anti-spam question to my PHPBB forum&lt;/a&gt; to prevent spam bots from signing up and wreaking havoc. Lately the same bot problem has crept up on a site I have running Drupal 4.7.x. So I resorted to the same solution, though this one is implemented as a Drupal module. It is very simple...the only thing you configure is the question and answer you want to use. &lt;a href=&quot;http://boonedocks.net/code/antispamquestion.module.phps&quot;&gt;Click here&lt;/a&gt; to see it, and follow the instructions in the comments. I hope it helps you. 
    </content:encoded>

    <pubDate>Wed, 30 May 2007 14:27:06 -0400</pubDate>
    <guid isPermaLink="false">http://boonedocks.net/mike/archives/147-guid.html</guid>
    
</item>
<item>
    <title>PHPBB Anti-spam Registration Question</title>
    <link>http://boonedocks.net/mike/archives/143-PHPBB-Anti-spam-Registration-Question.html</link>
            <category>PHPBB</category>
    
    <comments>http://boonedocks.net/mike/archives/143-PHPBB-Anti-spam-Registration-Question.html#comments</comments>
    <wfw:comment>http://boonedocks.net/mike/wfwcomment.php?cid=143</wfw:comment>

    <slash:comments>33</slash:comments>
    <wfw:commentRss>http://boonedocks.net/mike/rss.php?version=2.0&amp;type=comments&amp;cid=143</wfw:commentRss>
    

    <author>nospam@example.com (Mike Boone)</author>
    <content:encoded>
    &lt;span style=&quot;font-size: 90%;&quot;&gt;If you are not comfortable installing this on your own, I&#039;ll do it for you. If you&#039;re using PHPBB 2.0.23 and the SubSilver template, I will install it for $25 via Paypal. (If you&#039;re using a different template or need an older site updated to the latest PHPBB, I can do that too, but it will take longer and cost extra). &lt;a href=&quot;http://boonedocks.net/mailmike.php&quot;&gt;Contact me&lt;/a&gt;.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;

I&#039;ve been meaning to document this for a while now, and I finally made myself write it up. The simple measure I will describe has been working for my PHPBB website since last December. It has kept spam accounts from registering and posting anything on my site.&lt;br /&gt;&lt;br /&gt;

This idea involves asking a question during registration that spam bots do not know how to answer. You can choose any question and answer that you want. The website that I run PHPBB on is a sailing website, so I asked a question that sailors could answer. For this example I chose another question.&lt;br /&gt;&lt;br /&gt;

You have to change two files, templates/(your template)/profile_add_body.tpl and includes/usercp_register.php.&lt;br /&gt;&lt;br /&gt;

In templates/(your template)/profile_add_body.tpl, add this after the &amp;lt;!-- END switch_confirm --&amp;gt; line (&lt;i&gt;about line number 68&lt;/i&gt;):&lt;br /&gt;&lt;br /&gt;

&lt;div style=&quot;font-family: monospace;&quot;&gt;
&amp;lt;!-- BEGIN switch_add_profile --&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt; &lt;br /&gt;
&amp;#160;&amp;#160;&amp;lt;td class=&amp;quot;row1&amp;quot;&amp;gt;&amp;lt;span class=&amp;quot;gen&amp;quot;&amp;gt;Anti-Spam Question:&amp;lt;/span&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;#160;&amp;#160;&amp;lt;td class=&amp;quot;row2&amp;quot;&amp;gt;&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;lt;span style=&amp;quot;font-size: small;&amp;quot;&amp;gt;Enter the name Luke Skywalker&#039;s&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;father. Check your spelling!&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;Requiring this question to be answered will hopefully limit&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;spammers who try to sign up.&amp;lt;/span&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;lt;input type=&amp;quot;text&amp;quot; class=&amp;quot;post&amp;quot; style=&amp;quot;width: 200px&amp;quot;&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;name=&amp;quot;bonusq&amp;quot; size=&amp;quot;25&amp;quot; maxlength=&amp;quot;255&amp;quot; value=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;#160;&amp;#160;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;!-- END switch_add_profile --&amp;gt;&lt;br /&gt;&lt;br /&gt;
&lt;/div&gt;

In includes/usercp_register.php, add this after else if ( $mode == &#039;register&#039; ) { (&lt;i&gt;about line number 275&lt;/i&gt;):&lt;br /&gt;&lt;br /&gt;

&lt;div style=&quot;font-family: monospace;&quot;&gt;
// mod by MB to require human data to prevent spam bots&lt;br /&gt;
if(trim(strtolower($_POST[&#039;bonusq&#039;]))!=&#039;darth vader&#039;) {&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;$error = TRUE;&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;$error_msg .= ( ( isset($error_msg) ) ? &#039;&amp;lt;br /&amp;gt;&#039; : &#039;&#039; ) .&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&#039;You did not answer the Anti-Spam question correctly...&#039; .&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&#039;please try again.&#039;;&lt;br /&gt;
}&lt;br /&gt;
// end mod&lt;br /&gt;&lt;br /&gt;
&lt;/div&gt;

So there you have it. I&#039;m sure there are some sophisticated PHPBB mods out there that will do the same and more for you, but this simple change has saved me a lot of trouble. I&#039;m keeping my fingers crossed that it will last.
&lt;br /&gt;&lt;br /&gt;
&lt;b&gt;Update 2007-05-23:&lt;/b&gt; I omitted one other mod to make this work. You also need to edit your includes/usercp_register.php file. Find the line if ( $mode == &#039;editprofile&#039; ) (&lt;i&gt;about line number 941&lt;/i&gt;) and modify that block to look like this:&lt;br /&gt;&lt;br /&gt;
&lt;div style=&quot;font-family: monospace;&quot;&gt;
if ( $mode == &#039;editprofile&#039; )&lt;br /&gt;
{&lt;br /&gt;
&amp;#160;&amp;#160;$template-&gt;assign_block_vars(&#039;switch_edit_profile&#039;, array());&lt;br /&gt;
} else {&lt;br /&gt;
&amp;#160;&amp;#160;// Else block is Mod by MB 2006-08-11&lt;br /&gt;
&amp;#160;&amp;#160;$template-&gt;assign_block_vars(&#039;switch_add_profile&#039;, array());&lt;br /&gt;
}&lt;br /&gt;
&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;b&gt;Update 2007-06-24:&lt;/b&gt; Several folks wrote in expressing confusion about where these blocks of code belonged. I apologize, and I amended the article to give approximate line numbers where the mods belong. I used PHPBB 2.0.22 as my reference. Note that if you have made other modifications to your PHPBB files, the line numbers might not be quite right.
&lt;br/&gt;&lt;br /&gt;
&lt;b&gt;Update 2007-06-27:&lt;/b&gt; Bug fix. See comment #7 below.&lt;br /&gt;&lt;br /&gt;
&lt;b&gt;Update 2007-09-29:&lt;/b&gt; A lot of people have written in having trouble with this modification when it comes to users editing their profile. To avoid problems, I have applied the modification to a new copy of PHPBB 2.0.22 and tested it. I made copies of the modified files and they are &lt;a href=&quot;http://boonedocks.net/code/phpbb-anti-spam.zip&quot;&gt;available to download&lt;/a&gt;. The modification as it appears in this blog post is what I used, and it works fine for me. I did not make any of the other changes from the comments (except the bug fix from June which has already been incorporated into this post).&lt;br /&gt;&lt;br /&gt;
&lt;b&gt;Update 2008-02-27:&lt;/b&gt; The update works just fine for me in PHPBB 2.0.23 as well. Neither profile_add_body.tpl nor usercp_register.php were changed between 2.0.22 and 2.0.23. 
    </content:encoded>

    <pubDate>Sat, 21 Apr 2007 13:45:19 -0400</pubDate>
    <guid isPermaLink="false">http://boonedocks.net/mike/archives/143-guid.html</guid>
    
</item>
<item>
    <title>Java Runtime Environment Space Eater</title>
    <link>http://boonedocks.net/mike/archives/142-Java-Runtime-Environment-Space-Eater.html</link>
            <category>Tech</category>
    
    <comments>http://boonedocks.net/mike/archives/142-Java-Runtime-Environment-Space-Eater.html#comments</comments>
    <wfw:comment>http://boonedocks.net/mike/wfwcomment.php?cid=142</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://boonedocks.net/mike/rss.php?version=2.0&amp;type=comments&amp;cid=142</wfw:commentRss>
    

    <author>nospam@example.com (Mike Boone)</author>
    <content:encoded>
    If you&#039;re looking for some spare disk space, check out your C:\Program Files\Java folder. Mine was full of various folders like jre1.5.0_7, jre1.5.0_11, etc. I&#039;m not sure how they all got there, but I&#039;m guessing they came from installing several versions of &lt;a href=&quot;http://www.openoffice.org/&quot;&gt;OpenOffice&lt;/a&gt; over the years. Looking at the Add/Remove programs in the Control Panel, I had like 8 versions of the Java Runtime Environment, collectively eating up several hundred megabytes. So I cleared out all but the latest and things are nice and tidy for the moment.
 
    </content:encoded>

    <pubDate>Wed, 18 Apr 2007 17:03:28 -0400</pubDate>
    <guid isPermaLink="false">http://boonedocks.net/mike/archives/142-guid.html</guid>
    
</item>
<item>
    <title>Creating a Date Range Array with PHP</title>
    <link>http://boonedocks.net/mike/archives/137-Creating-a-Date-Range-Array-with-PHP.html</link>
            <category>Tech</category>
    
    <comments>http://boonedocks.net/mike/archives/137-Creating-a-Date-Range-Array-with-PHP.html#comments</comments>
    <wfw:comment>http://boonedocks.net/mike/wfwcomment.php?cid=137</wfw:comment>

    <slash:comments>12</slash:comments>
    <wfw:commentRss>http://boonedocks.net/mike/rss.php?version=2.0&amp;type=comments&amp;cid=137</wfw:commentRss>
    

    <author>nospam@example.com (Mike Boone)</author>
    <content:encoded>
    I recently needed to come up with an array of dates between two given dates. I typically work in the MySQL-compatible
&#039;YYYY-MM-DD&#039; date format, so I wanted it to use dates like that. So I came up with the following function:&lt;br /&gt;&lt;br /&gt;

&lt;span style=&quot;font-family: monospace;&quot;&gt;
function createDateRangeArray($strDateFrom,$strDateTo) {&lt;br /&gt;
&amp;#160;&amp;#160;// takes two dates formatted as YYYY-MM-DD and creates an&lt;br /&gt;
&amp;#160;&amp;#160;// inclusive array of the dates between the from and to dates.&lt;br /&gt;
&lt;br /&gt;
&amp;#160;&amp;#160;// could test validity of dates here but I&#039;m already doing&lt;br /&gt;
&amp;#160;&amp;#160;// that in the main script&lt;br /&gt;
&lt;br /&gt;
&amp;#160;&amp;#160;$aryRange=array();&lt;br /&gt;
&lt;br /&gt;
&amp;#160;&amp;#160;$iDateFrom=mktime(1,0,0,substr($strDateFrom,5,2),
&amp;#160;&amp;#160;&amp;#160;&amp;#160;substr($strDateFrom,8,2),substr($strDateFrom,0,4));&lt;br /&gt;
&amp;#160;&amp;#160;$iDateTo=mktime(1,0,0,substr($strDateTo,5,2),
&amp;#160;&amp;#160;&amp;#160;&amp;#160;substr($strDateTo,8,2),substr($strDateTo,0,4));&lt;br /&gt;
&lt;br /&gt;
&amp;#160;&amp;#160;if ($iDateTo&gt;=$iDateFrom) {&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;array_push($aryRange,date(&#039;Y-m-d&#039;,$iDateFrom)); // first entry&lt;br /&gt;
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;while ($iDateFrom&lt;$iDateTo) {&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;$iDateFrom+=86400; // add 24 hours&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;array_push($aryRange,date(&#039;Y-m-d&#039;,$iDateFrom));&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;}&lt;br /&gt;
&amp;#160;&amp;#160;}&lt;br /&gt;
&amp;#160;&amp;#160;return $aryRange;&lt;br /&gt;
}&lt;br /&gt;
&lt;/span&gt;
&lt;br /&gt;
Note that the first parameter of my mktime function calls is a 1 due to
&lt;a href=&quot;http://boonedocks.net/mike/archives/114-Figuring-the-Start-of-the-Week-with-PHP.html&quot;&gt;problems I experienced before with Daylight Savings Time&lt;/a&gt;.
 
    </content:encoded>

    <pubDate>Mon, 08 Jan 2007 15:16:37 -0500</pubDate>
    <guid isPermaLink="false">http://boonedocks.net/mike/archives/137-guid.html</guid>
    
</item>
<item>
    <title>PHPBB Inactive Member Removal Cron Job</title>
    <link>http://boonedocks.net/mike/archives/134-PHPBB-Inactive-Member-Removal-Cron-Job.html</link>
            <category>PHPBB</category>
    
    <comments>http://boonedocks.net/mike/archives/134-PHPBB-Inactive-Member-Removal-Cron-Job.html#comments</comments>
    <wfw:comment>http://boonedocks.net/mike/wfwcomment.php?cid=134</wfw:comment>

    <slash:comments>7</slash:comments>
    <wfw:commentRss>http://boonedocks.net/mike/rss.php?version=2.0&amp;type=comments&amp;cid=134</wfw:commentRss>
    

    <author>nospam@example.com (Mike Boone)</author>
    <content:encoded>
    A commenter to a &lt;a href=&quot;http://boonedocks.net/mike/archives/124-PHPBB-Fake-Members.html&quot;&gt;previous article&lt;/a&gt; asked exactly how I delete inactive members from a PHPBB forum that I run. So I&#039;ll try to explain. This solution runs on Linux/Unix systems...I&#039;m sure it could be done for Windows, but I&#039;ll leave the particulars to you.&lt;br /&gt;&lt;br /&gt;

It&#039;s really two separate steps. First, you need a script which will handle the deletion of inactive members. I called mine cron.php. It deletes all inactive PHPBB users who don&#039;t activate within 48 hours. It looks like this:&lt;br /&gt;&lt;br /&gt;

&lt;span style=&quot;font-family: monospace;&quot;&gt;
#!/usr/bin/php -q&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&amp;#160;&amp;#160;// cron job to delete inactive users older than 48 hours&lt;br /&gt;
&amp;#160;&amp;#160;$db=mysql_connect(&#039;server&#039;,&#039;user&#039;,&#039;password&#039;);&lt;br /&gt;
&amp;#160;&amp;#160;mysql_select_db(&#039;your_phpbb_database_here&#039;,$db);&lt;br /&gt;
&amp;#160;&amp;#160;$strSQL=&quot;DELETE phpbb_users u, phpbb_user_group ug, &quot; .&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&quot;phpbb_groups AS g FROM phpbb_users u, &quot; .&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&quot;phpbb_user_group ug, phpbb_groups g WHERE &quot; .&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&quot;u.user_active=0 AND u.user_id&amp;gt;0 AND &quot; .&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&quot;u.user_id=ug.user_id AND ug.group_id=g.group_id &quot; .&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&quot;AND g.group_single_user=1 AND &quot; .&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&quot;FROM_UNIXTIME(u.user_regdate)&lt;&quot; .&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&quot;DATE_SUB(NOW(),INTERVAL 2 DAY);&quot;;&lt;br /&gt;
&amp;#160;&amp;#160;mysql_query($strSQL,$db) or die(mysql_error());&lt;br /&gt;
&amp;#160;&amp;#160;mysql_close($db);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;&lt;br /&gt;
&lt;/span&gt;

You&#039;ll need to make sure the /usr/bin/php points to the location of PHP on your system, and replace the MySQL server name, user, and password with yours.&lt;br /&gt;&lt;br /&gt;

Now that you have a script, you need to tell the system to run it daily. You can do this with a &lt;a href=&quot;http://en.wikipedia.org/wiki/Crontab&quot;&gt;cron&lt;/a&gt; job. If you have command line access to your website, you might be able to do this with &quot;crontab -e&quot;. But my webhost has an administrative panel that lets you set up cron jobs on the web. If you can&#039;t set up a cron job, you could put the script into a web-accessible folder and periodically call its URL, either manually or through an automated process on your local PC.&lt;br /&gt;&lt;br /&gt;

This idea works great if the majority of your spam registrations don&#039;t activate their account. Usually they just want their spam links in your member list. But I&#039;m finding that more and more spammers are activating and posting, so it remains that we want to stop spammers from registering in the first place. I&#039;m experimenting with another method, which I&#039;ll post about when I see some results.&lt;br /&gt;&lt;br /&gt;

&lt;b&gt;Update 2007-11-28:&lt;/b&gt; I replaced my original SQL statement with the SQL in comment #1 below, which I finally tested and it seems to work well.
 
    </content:encoded>

    <pubDate>Tue, 05 Dec 2006 09:25:36 -0500</pubDate>
    <guid isPermaLink="false">http://boonedocks.net/mike/archives/134-guid.html</guid>
    
</item>
<item>
    <title>Splitting a large XML file on Linux 2.4</title>
    <link>http://boonedocks.net/mike/archives/128-Splitting-a-large-XML-file-on-Linux-2.4.html</link>
            <category>Tech</category>
    
    <comments>http://boonedocks.net/mike/archives/128-Splitting-a-large-XML-file-on-Linux-2.4.html#comments</comments>
    <wfw:comment>http://boonedocks.net/mike/wfwcomment.php?cid=128</wfw:comment>

    <slash:comments>5</slash:comments>
    <wfw:commentRss>http://boonedocks.net/mike/rss.php?version=2.0&amp;type=comments&amp;cid=128</wfw:commentRss>
    

    <author>nospam@example.com (Mike Boone)</author>
    <content:encoded>
    A client recently had a problem processing an XML with his PHP script. &quot;File too large&quot; was the error, and the data file was over 2 gigabytes in size.&lt;br /&gt;&lt;br /&gt;

It turns out you can recompile PHP to deal with large files (see &lt;a href=&quot;http://php.net/manual/en/ref.filesystem.php&quot;&gt;Requirements section here&lt;/a&gt;). But &lt;a href=&quot;http://blog.thinkphp.de/archives/131-Handling-large-files-without-PHP.html&quot;&gt;this blog entry&lt;/a&gt; made recompiling sound problematic...you get access to the large file but certain file functions break due to integer overflows. So I wanted to avoid this option.&lt;br /&gt;&lt;br /&gt;

The Linux command line tools seemed to be able to deal with it OK: stuff like less, head and tail were working on it. So I decided to try to break the XML file into parts. The split command worked but indiscriminately cut right through the middle of a data record. I considered using csplit, but as this file contained over 700,000 data records, I didn&#039;t want to deal with that many individual XML files.&lt;br /&gt;&lt;br /&gt;

I decided to write a Perl script to split the file into blocks of 100,000 records each. It didn&#039;t take long to put together and Perl&#039;s regular expression matching made handling the records easy on the small test data. For some reason I thought Perl would be OK with the large data file, but when I went to run the script, it too choked on the large file. I would have to recompile Perl to get around it. As the client&#039;s box is using a Red Hat package for Perl, I didn&#039;t want to mess with it.&lt;br /&gt;&lt;br /&gt;

Then I had an idea. Since the Linux command line tools were handling the file OK, I wondered if I could trick my script by feeding it one line at a time. Instead of looping an open file in the Perl script, I used a loop like this:&lt;br /&gt;&lt;br /&gt;

&lt;span style=&quot;font-family: monospace;&quot;&gt;
while( $line = &amp;lt;STDIN&amp;gt; ) {&lt;br /&gt;
&amp;#160;&amp;#160;# do stuff&lt;br /&gt;
}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;

Then I called the script like this:&lt;br /&gt;&lt;br /&gt;

&lt;span style=&quot;font-family: monospace;&quot;&gt;cat bigfile.xml | ./split.pl&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;

And it worked!
 
    </content:encoded>

    <pubDate>Wed, 06 Sep 2006 21:01:50 -0400</pubDate>
    <guid isPermaLink="false">http://boonedocks.net/mike/archives/128-guid.html</guid>
    
</item>
<item>
    <title>Drupal: An image module that uses filemanager module</title>
    <link>http://boonedocks.net/mike/archives/125-Drupal-An-image-module-that-uses-filemanager-module.html</link>
            <category>Tech</category>
    
    <comments>http://boonedocks.net/mike/archives/125-Drupal-An-image-module-that-uses-filemanager-module.html#comments</comments>
    <wfw:comment>http://boonedocks.net/mike/wfwcomment.php?cid=125</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://boonedocks.net/mike/rss.php?version=2.0&amp;type=comments&amp;cid=125</wfw:commentRss>
    

    <author>nospam@example.com (Mike Boone)</author>
    <content:encoded>
    I&#039;m working on a personal project using &lt;a href=&quot;http://drupal.org/&quot;&gt;Drupal&lt;/a&gt;. The &lt;a href=&quot;http://drupal.org/project/image&quot;&gt;image module&lt;/a&gt; allows you to let users post images to the site. However, it puts all of its files into a single directory, which is a performance concern if you want to have a lot of images on your site. The &lt;a href=&quot;http://drupal.org/project/filemanager&quot;&gt;filemanager module&lt;/a&gt; has support for lots of files, but the image module was not written to use it.&lt;br /&gt;&lt;br /&gt;
So I decided to try my hand at Drupal coding. I started with image.module and overhauled it to work with filemanager.module. Along the way I found that Drupal 4.7 doesn&#039;t offer a good way to maintain certain data through the form preview, so I &lt;a href=&quot;http://drupal.org/node/77161&quot;&gt;filed a bug&lt;/a&gt;. The workaround I came up with, and also used by a prominent Drupal coder, was to use the $_SESSION variable to maintain that data.&lt;br /&gt;&lt;br /&gt;
So anyway, &lt;a href=&quot;http://boonedocks.net/code/image.module.phps&quot;&gt;here is the new image.module code&lt;/a&gt;. Please feel free to try it and let me know what I should fix.&lt;br /&gt;&lt;br /&gt;
Some notes: the current version 0.1, requires you to use only the original, preview, and thumbnail sizes, and also requires a database table called image_fm. I also could not come up with an elegant way to handle the case of a single user posting multiple images at the same time, sicne the $_SESSION variable used only allows for one per user at a time. This may be easy to fix, but I don&#039;t fully understand the Drupal form API yet.
 
    </content:encoded>

    <pubDate>Sun, 27 Aug 2006 18:31:35 -0400</pubDate>
    <guid isPermaLink="false">http://boonedocks.net/mike/archives/125-guid.html</guid>
    
</item>
<item>
    <title>PHPBB Fake Members</title>
    <link>http://boonedocks.net/mike/archives/124-PHPBB-Fake-Members.html</link>
            <category>PHPBB</category>
    
    <comments>http://boonedocks.net/mike/archives/124-PHPBB-Fake-Members.html#comments</comments>
    <wfw:comment>http://boonedocks.net/mike/wfwcomment.php?cid=124</wfw:comment>

    <slash:comments>19</slash:comments>
    <wfw:commentRss>http://boonedocks.net/mike/rss.php?version=2.0&amp;type=comments&amp;cid=124</wfw:commentRss>
    

    <author>nospam@example.com (Mike Boone)</author>
    <content:encoded>
    It&#039;s becoming frustrating to be a PHPBB administrator, at least if you want to keep your memberlist clean. Form bots out there create fake users on your site in the hopes that your memberlist will show their spam URL. It&#039;s been an ongoing, and losing battle, to keep them out.
&lt;ul&gt;
&lt;li&gt;First I tried to &lt;a href=&quot;http://boonedocks.net/mike/archives/49-PHPBB-Member-List-Link-Spam.html&quot;&gt;change the account creation form&lt;/a&gt; slightly.&lt;/li&gt;
&lt;li&gt;Next, I &lt;a href=&quot;http://boonedocks.net/mike/archives/70-PHPBB-Member-List-Link-Spam-Part-2.html&quot;&gt;instructed search engines to not index the memberlist and user profile pages&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Several months ago I turned on PHPBB&#039;s &quot;captcha&quot; feature that was included with a more recent version&lt;/li&gt;
&lt;li&gt;Last week, I removed the URL field completely from the signup form, and any bot that tries to submit it will fail. This might have stopped some of the bots, but there are still fake users being created. Their profiles list no websites, but you can still tell they are bogus when they list their interest as &quot;pills&quot; on a sailing website!&lt;/li&gt;
&lt;/ul&gt;
I think my next move will be to create a cron job to delete user accounts that are not activated within 24 hours, as many spam accounts never activate.&lt;br /&gt;&lt;br /&gt;
&lt;b&gt;Update 2006-08-22:&lt;/b&gt; The fake users keep coming. So I came up with a cron job that runs this query once per day. It will remove inactive PHPBB users older than 48 hours. This gives time for the new users to properly activate.&lt;br /&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: monospace;&quot;&gt;DELETE FROM phpbb_users WHERE user_active=0 AND user_id&amp;gt;0 AND FROM_UNIXTIME(user_regdate)&amp;lt;DATE_SUB(NOW(),INTERVAL 2 DAY);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;
The user_id&amp;gt;0 part is to avoid deleting the Anonymous user, which has a user ID of -1 on my installation.
 
    </content:encoded>

    <pubDate>Thu, 17 Aug 2006 10:14:55 -0400</pubDate>
    <guid isPermaLink="false">http://boonedocks.net/mike/archives/124-guid.html</guid>
    
</item>

</channel>
</rss>