<?php
// $Id: hiragana_captcha.module,v 1.1 2008/11/29 0829 Exp $
/**
* Implementation of hook_menu().
*/
function hiragana_captcha_menu() {
$items['admin/user/captcha/hiragana_captcha'] = array(
'title' => 'Hiragana CAPTCHA',
'file' => 'hiragana_captcha.admin.inc',
'page callback' => 'drupal_get_form',
'page arguments' => array('hiragana_captcha_settings_form'),
'access arguments' => array('administer CAPTCHA settings'),
'type' => MENU_LOCAL_TASK,
);
return $items;
}
/**
* Implementation of hook_help().
*/
function hiragana_captcha_help($path, $arg) {
switch ($path) {
case 'admin/user/captcha/hiragana_captcha':
return '<p>'. t('The hiragana CAPTCHA ask for the n<sup>th</sup> word of a predetermined phrase like text CAPTCHA.') .'</p>';
}
}
/**
* Implementation of hook_captcha().
*/
function hiragana_captcha_captcha($op, $captcha_type='') {
switch ($op) {
case 'list':
return array('Hiragana');
case 'generate':
require_once drupal_get_path('module', 'hiragana_captcha') . '/hiragana_captcha.user.inc';
if ($captcha_type == 'Hiragana') {
$words = _hiragana_captcha_generate_words(variable_get('hiragana_captcha_quantity', 5));
$question = _hiragana_captcha_generate_phrase($words, 'question');
$answer = _hiragana_captcha_generate_phrase($words, 'answer');
$key = array_rand($question, 1);
$nth = _hiragana_captcha_ordinal($key + 1);
$result = array();
$result['solution'] = $answer[$key];
$result['form']['captcha_response'] = array(
'#type' => 'textfield',
'#title' => t('What is the @nth word in the phrase "@words"?', array('@nth' => $nth, '@words' => implode(' / ', $question))),
'#description' => t('Input the @nth word in <strong>hiragana</strong>. Whether the answer word is hiragana or katakana, input it by hiragana entirely.', array('@nth' => $nth)),
'#weight' => 0,
'#size' => 15,
'#required' => TRUE,
);
return $result;
}
}
}
// $Id: hiragana_captcha.module,v 1.1 2008/11/29 0829 Exp $
/**
* Implementation of hook_menu().
*/
function hiragana_captcha_menu() {
$items['admin/user/captcha/hiragana_captcha'] = array(
'title' => 'Hiragana CAPTCHA',
'file' => 'hiragana_captcha.admin.inc',
'page callback' => 'drupal_get_form',
'page arguments' => array('hiragana_captcha_settings_form'),
'access arguments' => array('administer CAPTCHA settings'),
'type' => MENU_LOCAL_TASK,
);
return $items;
}
/**
* Implementation of hook_help().
*/
function hiragana_captcha_help($path, $arg) {
switch ($path) {
case 'admin/user/captcha/hiragana_captcha':
return '<p>'. t('The hiragana CAPTCHA ask for the n<sup>th</sup> word of a predetermined phrase like text CAPTCHA.') .'</p>';
}
}
/**
* Implementation of hook_captcha().
*/
function hiragana_captcha_captcha($op, $captcha_type='') {
switch ($op) {
case 'list':
return array('Hiragana');
case 'generate':
require_once drupal_get_path('module', 'hiragana_captcha') . '/hiragana_captcha.user.inc';
if ($captcha_type == 'Hiragana') {
$words = _hiragana_captcha_generate_words(variable_get('hiragana_captcha_quantity', 5));
$question = _hiragana_captcha_generate_phrase($words, 'question');
$answer = _hiragana_captcha_generate_phrase($words, 'answer');
$key = array_rand($question, 1);
$nth = _hiragana_captcha_ordinal($key + 1);
$result = array();
$result['solution'] = $answer[$key];
$result['form']['captcha_response'] = array(
'#type' => 'textfield',
'#title' => t('What is the @nth word in the phrase "@words"?', array('@nth' => $nth, '@words' => implode(' / ', $question))),
'#description' => t('Input the @nth word in <strong>hiragana</strong>. Whether the answer word is hiragana or katakana, input it by hiragana entirely.', array('@nth' => $nth)),
'#weight' => 0,
'#size' => 15,
'#required' => TRUE,
);
return $result;
}
}
}

