Notice: Array to string conversion in system/classes/rewriterule.php line 112
Notice: Object of class HabariDateTime could not be converted to int in system/classes/rewriterule.php line 112
Notice: Object of class HabariDateTime could not be converted to int in system/classes/rewriterule.php line 112
Notice: Object of class HabariDateTime could not be converted to int in system/classes/rewriterule.php line 112
Notice: Object of class HabariDateTime could not be converted to int in system/classes/rewriterule.php line 112
Notice: Object of class HabariDateTime could not be converted to int in system/classes/rewriterule.php line 112
Notice: Object of class HabariDateTime could not be converted to int in system/classes/rewriterule.php line 112
Notice: Object of class HabariDateTime could not be converted to int in system/classes/rewriterule.php line 112
Notice: Object of class HabariDateTime could not be converted to int in system/classes/rewriterule.php line 112
http://ryezone.net/death-to-habari-comment-spam" title="Death to Habari Comment spam.">Death to Habari Comment spam.

I love Habari, It has moderated every scum comment spammer that has approached my blog. For some reason they all seem to be fixated on this post. On occasion though, some of them fall through the SPAM filter and the DNS black lists into my Unapproved moderation bin. As much as I want to know about the next poker or porn site, I decided to investigate captcha technology. My search as thus far landed on the Habari Captcha Plugin by Eugene Wee. It didn't work quite right out of the box for me, so here's how I hacked it to work.

First, you need to create an XML for the plugin if Habari tells you the admin screen won't load the plugin without one. Here's the code:

<?xml version="1.0" encoding="utf-8" ?>
<pluggable type="plugin">
  <name>Captcha</name>
  <license url="http://www.opensource.org/licenses/afl-3.0.php">Academic Free License version 3.0</license>
  <author url="http://www.aranel.net">Eugene Wee</author>
  <version>1.0b3</version>
  <url>https://launchpad.net/habari-captcha</url>
  <description><![CDATA[Automatically approve comments that pass CAPTCHA.]]></description>
  <copyright>2008 Eugene Wee <crystalrecursion@gmail.com></copyright>
  <help>
    <value><![CDATA[
      <h3>Introduction</h3>
      <p>
        <ol>
          <li>Unzip the captcha folder to user/plugins.</li>
          <li>Using an editor, appropriately insert this line into your selected theme's
            commentform.php file:<br><br>
            <?php if ( Plugins::is_loaded( 'Captcha' ) ): $theme->show_captcha(); endif; ?>
          </li>
          <li>From your Habari administration panel, activate the CAPTCHA plugin.</li>
          <li>From your Habari administration panel's Configure option, set the reCAPTCHA
            public and private keys. These may be obtained from http://recaptcha.net<br><br>
            If you wish to require the CAPTCHA instead of allowing submitters to leave it
            blank, check the 'CAPTCHA required' checkbox.
          </li>
        </ol>
      </p>      
      <h3>Theme Configuration</h3>
      <p>
        A template (captcha.php) is provided and used by default. To configure this to
        match your theme, copy captcha.php to your selected theme's folder and edit it.<br><br>
        Currently, only the $captcha_script_url variable is made available to the theme.
      </p>
    ]]></value>
  </help>
</pluggable>

Copy and past the code above and save it as captcha.plugin.xml in the captcha plugin folder.

Now that you have the plugin loaded into the admin interface, if you get some PHP error saying that it can't override the info function, comment out the Info function in the captcha.plugin.php file. Commenting is shown below:

<?php
/**
 * Captcha Class.
 *
 * This plugin allows comments to be automatically approved if they pass the
 * CAPTCHA provided by the given provider. If a reader does not attempt the
 * CAPTCHA when posting a comment, his or her comment is added to the moderation
 * queue, unless the plugin is configured to require the CAPTCHA.
 *
 * Currently, the only CAPTCHA provider supported is reCAPTCHA.
 * See the README file provided for more information, including usage.
 *
 * Version: 1.0b3 (tested on Habari 0.5.1)
 * Copyright 2008 Eugene Wee
 * Licensed under the Academic Free License version 3.0
 */
class Captcha extends Plugin
{
  const RecaptchaIndex = 0;
  private $provider = null;
/*
  function info()
  {
    return array(
      'name' => 'Captcha',
      'url' => 'https://launchpad.net/habari-captcha',
      'author' => 'Eugene Wee',
      'authorurl' => 'http://www.aranel.net',
      'version' => '1.0b3',
      'description' => 'Automatically approve comments that pass CAPTCHA.',
      'license' => 'Academic Free License version 3.0'
    );
  }
*/
  function action_init()
  {
    $this->add_template( 'captcha', dirname(__FILE__) . '/captcha.php' );
  }
  function action_update_check()
  {
    Update::add( 'Captcha', '080310f0-41ce-11dd-ae16-0800200c9a66', $this->info->version );
  }
  function filter_comment_insert_allow( $allow, $comment )
  {
    $this->initProvider();
    $allow = $this->provider->check( $allow, $comment );
    if ( $allow ) {
      $comment->status = Comment::STATUS_APPROVED;
      EventLog::log( _t('Comment by ') . $comment->name . _t(' automatically approved.'),
        'info', 'comment', 'Captcha' );
    }
    else if ( !Options::get( 'captcha__required' ) ) {
      $allow = true;
    }
    else {
      // Copied from FeedbackHandler::act_add_comment()
      Session::add_to_set( 'comment', $comment->name, 'name' );
      Session::add_to_set( 'comment', $comment->email, 'email' );
      Session::add_to_set( 'comment', $comment->url, 'url' );
      Session::add_to_set( 'comment', $comment->content, 'content' );
      Session::error( _t('Your CAPTCHA attempt did not succeed. Please try again or leave the CAPTCHA blank.') );
    }
    return $allow;
  }
  function theme_show_captcha( $theme )
  {
    $this->initProvider();
    $this->provider->show( $theme );
    return $theme->fetch( 'captcha' );
  }
  function filter_plugin_config( $actions, $plugin_id )
  {
    if ( $plugin_id == $this->plugin_id ) {
      $actions[] = _t('Configure');
      $actions[] = _t('Choose Provider');
    }
    return $actions;
  }
  function action_plugin_ui( $plugin_id, $action )
  {
    if ( $plugin_id == $this->plugin_id ) {
      $ui = new FormUI( strtolower( get_class( $this ) ) );
      switch ( $action ) {
      case _t('Configure'):
        $ui->append( 'text', 'public_key', 'captcha__public_key', _t('Public key: ') );
        $ui->append( 'text', 'private_key', 'captcha__private_key', _t('Private key: ') );
        $ui->append( 'checkbox', 'captcha_required', 'captcha__required', _t('CAPTCHA required ') );
        break;
      case _t('Choose Provider'):
        $ui->append( 'select', 'provider', 'captcha__provider', _t('Provider: '),
          array( _t('reCAPTCHA') ) );
        break;
      }
      $ui->append( 'submit', 'save', _t('Save') );
      $ui->out();
    }
  }
  private function initProvider()
  {
    if ( $this->provider == null ) {
      switch ( Options::get( 'captcha__provider' ) )
      {
      case Captcha::RecaptchaIndex:
      default:
        require_once 'recaptchaprovider.php';
        $this->provider = new RecaptchaProvider();
      }
    }
  }
}
?>

Once you have commented that function out, you should be able to activate the plugin in the admin interface. After that, all that's left is to make the required modifications in your commentform.php file and sign up for the ReCAPTCHA service which is free. Hope this helps someone.

Notice: Array to string conversion in system/classes/rewriterule.php line 112
Notice: Object of class HabariDateTime could not be converted to int in system/classes/rewriterule.php line 112
Notice: Object of class HabariDateTime could not be converted to int in system/classes/rewriterule.php line 112
Notice: Object of class HabariDateTime could not be converted to int in system/classes/rewriterule.php line 112
Notice: Object of class HabariDateTime could not be converted to int in system/classes/rewriterule.php line 112
Notice: Object of class HabariDateTime could not be converted to int in system/classes/rewriterule.php line 112
Notice: Object of class HabariDateTime could not be converted to int in system/classes/rewriterule.php line 112
Notice: Object of class HabariDateTime could not be converted to int in system/classes/rewriterule.php line 112
Notice: Object of class HabariDateTime could not be converted to int in system/classes/rewriterule.php line 112
Notice: Object of class HabariDateTime could not be converted to int in system/classes/rewriterule.php line 112
http://ryezone.net/shiny-new-blog-backend" title="Shiny new blog backend.">Shiny new blog backend.

You may or may not have noticed that I dumped wordpress as my backend for my blog. I wanted the ability to run multiple sites without having to take the trouble of maintaining multiple installations of wordpress. Not to mention, I am all for trying new open source solutions for my blog. So, how do I like the habari? So far it seems very functional. The wordpress importer on the latest version Habari 0.6-alpha r2951 is a little hairy, so here's how I got my wordpress entries imported.

1. SSH into your webserver.
2. Navigate to the directory that will be serving habari.
3. Run this command: svn checkout http://svn.habariproject.org/habari/tags/0.5.2/htdocs habari
4. Run this command: touch habari/config.php
5. Run this command: touch habari/.htaccess
6. Run this command: chmod o+w habari/config.php
7. Run this command: chmod o+w habari/.htaccess
8. Run this command: chmod o+w habari/user/cache
9. Run this command: mkdir habari/user/files
10. Run this command: chmod o+w habari/user/files
11. Run the installation script by going to the web address of your habari installation.
12. Run this command: chmod o-w habari/.htaccess
13. Run this command: chmod o-w habari/config.php
14. Run the wordpress importer plugin.
15. Run this command: mv habari/config.php .
16. Run this command: mv habari/.htaccess .
17. Run this command: rm -rf habari
18. Run this command: svn checkout http://svn.habariproject.org/habari/trunk/htdocs habari
19. Run this command: mv config.php habari
20. Run this command: mv .htaccess habari
21. Run this command: chmod o+w habari/user/cache
22. Run this command: mkdir habari/user/files
23. Run this command: chmod o+w habari/user/files
24. Pat yourself on the back, grab a cold one and go take a look at your shiny new habari install.

Notice: Array to string conversion in system/classes/rewriterule.php line 112 http://ryezone.net/habari" title="Habari">Habari

This site is running Habari, a state-of-the-art publishing platform! Habari is a community-driven project created and supported by people from all over the world. Please visit http://habariproject.org/ to find out more!

 1

About

User