Dashboard > blojsom > ... > Available Plugins > SCode Plugin
  blojsom Log In   View a printable version of the current page.  
  SCode Plugin
Added by David Czarnecki, last edited by Cliffano Subagio on Jan 23, 2007  (view change)
Labels: 
(None)

Availability

SCode Plugin v0.2-0.3 can be downloaded from Blojsom2 Plugins download page.

Overview

SCode plugin creates a CAPTCHA image of a random security code numbers which would be used to prevent comment spam. The security code on the image will then be checked against the user input.

SCode Plugin is based on Movable Type's SCode idea by James Seng.

Screenshot

Changelog

v0.3 (22-01-2006): Requires Blojsom 2.22 or later. SCode checking logic is modified to anticipate comment spam directly attacking Blojsom servlet.

v0.2 (12-01-2005): Requires Blojsom 2.22 or later. Generates PNG image (much smaller size compared to JPG). Incorrect SCode marks the comment as to be deleted. Allow the ability to add image engines, includes some sample ImageEngine which uses JCaptcha library to generate image.

v0.1 (04-12-2004): Initial release. Requires Blojsom 2.21 or later.

Build

SCode Plugin uses Ant to build the source.

ant jar-pkg

 

Installation

Add the jar file jcaptcha-all-1.0-RC2.jar in your /WEB-INF/lib directory. You can download the jar from JCaptcha's web site, or you can download it from SCode Plugin src download.

Place scodeplugin-version.jar in WEB-INF/lib directory.

In your global /WEB-INF/plugin.properties file, add the following line:

scode=com.mbledug.blojsom.plugin.scode.SCodePlugin

 

Add "scode" to one of the flavor-based plugin chains. These plugin chains can be found in the individual blog's plugin.properties file. Note that scode should be chained before comment plugin:

html.blojsom-plugin-chain=..., scode, comment, ...

 

Enable scode by adding this line to the individual blog's blog.properties file.

scode-enabled=true

 

Add plugin-scode init param to Blojsom servlet.

<servlet>
  <servlet-name>blojsom</servlet-name>
  <servlet-class>org.blojsom.servlet.BlojsomServlet</servlet-class>
  ...
  <init-param>
    <param-name>plugin-scode</param-name>
    <param-value>scode.properties</param-value>
  </init-param>
  ...
</servlet>

 

Add the SCodeServlet that will generate the dynamic image with the random Security Code. This is referenced in /WEB-INF/web.xml.

<servlet>
  <servlet-name>SCode</servlet-name>
  <servlet-class>com.mbledug.blojsom.plugin.scode.SCodeServlet</servlet-class>
</servlet>

<servlet-mapping>
  <servlet-name>SCode</servlet-name>
  <url-pattern>/scode</url-pattern>
</servlet-mapping>

 

Place the scode.properties file in the respective /WEB-INF/blog-id directory, and contains the following key-value pairs of flavor and image engine class name:

simple = com.mbledug.blojsom.plugin.scode.engine.SimpleImageEngine
gradient = com.mbledug.blojsom.plugin.scode.engine.GradientImageEngine
funky = com.mbledug.blojsom.plugin.scode.engine.FunkyImageEngine

 

Make sure the following Java system property is set if running blojsom in a server environment without a display:

-Djava.awt.headless=true

 

Headless Hosting

Some BSD/Linux virtual private/dedicated server hosts do not load the libraries necessary to run Java in a headless environment.

If you have root on a host missing X11 support, load the libraries with your favorite updater.

See Philip Isenhour's Linux X11 Libraries for Headless Mode for background and detailed notes. YMMV depending on OS, Java version, updating tool, and memory and storage limits with the host.

 

Usage

To add the image with the random Security Code, copy paste the following HTML snippet to your comment template.
Note that the img tag must have its src attribute set to "scode" (after your context path), and the input text field must have its name attribute set to "scode".

<p class="label">SCode (<span class="red">*</span>):</p>
<p class="input">
<img src="$BLOJSOM_BLOG.getBlogBaseURL()/scode" alt="SCode"/><br/>
<input type="text" name="scode" size="6" maxlength="6"/><br/>
Please enter the code as seen in the image above to post your comment.
</p>

 

To use a different flavor for the image engine, add the flavor request parameter on the image tag's src attribute value. E.g.

<img src="$BLOJSOM_BLOG.getBlogBaseURL()/scode?flavor=funky" alt="SCode"/>

 

simple gradient funky

Extending

Starting from version 0.2, the SCode Plugin allows an easy way to add image engine in anticipation of spambots ability to do better image character recognition. To add your own image engine, follow these instructions:

Create an engine class that implements com.mbledug.blojsom.plugin.scode.engine.ImageEngine.

Add the flavor and the engine class name to scode.properties file.

Add the flavor to the image tag's src attribute.

Place any jar dependencies in /WEB-INF/lib

Demo

A demo is available at Melbourne Photoblog.

Site running on a free Atlassian Confluence Open Source Project License granted to blojsom. Evaluate Confluence today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.5.4 Build:#809 Jun 12, 2007) - Bug/feature request - Contact Administrators