Skip to content
Snippets Groups Projects
Commit c0e47636 authored by enmasksteve's avatar enmasksteve
Browse files

changes done and committed

parent d7ccc912
No related branches found
No related tags found
No related merge requests found
......@@ -3,30 +3,13 @@ README.txt
Regular text based and hosted Captcha, better Captcha experience.
With this plugin you will be able to put the Enmask captcha in your Drupal forms easily.
Features of the module
Forms in Drupal in which you can implement Enmask captcha are:
1. Configure from Admin panel.
2. Setting to hide the CAPTCHA from logged in users and or administrators.
3. Setting to show the CAPTCHA on the forms for different Contact forms.
4. Valid HTML.
Contact forms
- Personal contact form
- Site-wide contact form
User register form
Article comment form
Page comment form
Lost password form
Please register in http://www.enmask.com, so we can provide you better service.
Features of the plugin
1. Configure from Admin panel
2. Setting to hide the CAPTCHA from logged in users and or admins
3. Setting to show the CAPTCHA on the forms for Contact forms(Personal contact form and Site-wide contact form), User register form, Article comment form, Page comment form, Lost password form
4. Valid HTML
Please register in http://www.enmask.com, so we can provide you better service
If you have any suggestions regarding the plugin please email us at support@enmask.com
INSTALLATION NOTE
================
This module was intended to be installed at /sites/all/modules/enmask
\ No newline at end of file
If you have any suggestions regarding the module please email us at support@enmask.com.
\ No newline at end of file
<?php
/**
* @file
* Enmask Drupal admin forms
* Enmask Drupal admin forms.
*/
function enmask_settings() {
$options = array('contact_site_form' => t('Enable for Site-wide contact form'),
'user_register_form' => t('Enable for user register form'),
'comment_node_article_form' => t('Enable for article comment form'),
'comment_node_page_form' => t('Enable for page comment form'),
'contact_personal_form' => t('Enable for user contact form'),
'user_pass' => t('Enable for lost password'),
);
$form['admin_captcha_forms'] = array('#title' => t('Enmask CAPTCHA settings'),
'#type' => 'checkboxes',
'#default_value' => variable_get('enmask_form_ids', array('comment_node_article_form', 'user_pass')),
'#description' => t('EnMask is founded with the ideas of helping people control their online content, privacy and freedom. For the detail information please') . '<a href="http://www.enmask.com" title="enmask.com" target="_blank">' . t('click here') . '</a>',
'#options' => $options,
);
$form['#submit'][] = 'enmask_admin_submit';
return system_settings_form($form);
$options = array('contact_site_form' => t('Enable for Site-wide contact form'),
'user_register_form' => t('Enable for user register form'),
'comment_node_article_form' => t('Enable for article comment form'),
'comment_node_page_form' => t('Enable for page comment form'),
'contact_personal_form' => t('Enable for user contact form'),
'user_pass' => t('Enable for lost password'),
);
$form['admin_captcha_forms'] = array('#title' => t('Enmask CAPTCHA settings'),
'#type' => 'checkboxes',
'#default_value' => variable_get('enmask_form_ids', array('comment_node_article_form', 'user_pass')),
'#description' => t('EnMask is founded with the ideas of helping people control their online content, privacy and freedom. For the detail information please') . '<a href="http://www.enmask.com" title="enmask.com" target="_blank">' . t('click here') . '</a>',
'#options' => $options,
);
$form['#submit'][] = 'enmask_admin_submit';
return system_settings_form($form);
}
\ No newline at end of file
......@@ -2,7 +2,7 @@
/**
* @file
* Enmask Captcha Class freely available
* Enmask Captcha Class freely available.
* @version 1.0
* @copyright 2011
* @Author : Enmask.com
......@@ -20,10 +20,10 @@ class EnmaskCaptcha {
}
public function getHtml($name) {
//only valid for drupal
// Only valid for drupal.
global $language;
$lang_code = $language->language;
//ends drupal code
// Ends drupal code.
if ($lang_code != '') {
$js_append = 'data-enmask-langcode="' . $lang_code . '"';
......@@ -37,8 +37,8 @@ class EnmaskCaptcha {
}
/*
* validating by posting data in enmask server using drupal_http_request
*/
* Validating by posting data in enmask server using drupal_http_request.
*/
public function validate($captchaResponse, $captchaChallenge) {
$url = $this->protocol . $this->server . $this->port . "/CaptchaFont/ValidateCaptcha";
$headers = array('Content-Type' => 'application/x-www-form-urlencoded');
......@@ -46,7 +46,8 @@ class EnmaskCaptcha {
'response' => $captchaResponse,
'challenge' => $captchaChallenge);
$buffer = drupal_http_request($url, array('headers' => array('Content-Type' => 'application/x-www-form-urlencoded'), 'method' => 'POST', 'data' => http_build_query($data, '', '&')));
$result=json_decode($buffer->data);
return array($result->isValid, t('Captcha you entered was not valid.')); //return message will be from the enmask server.
$result = json_decode($buffer->data);
// Return message will be from the enmask server.
return array($result->isValid, t('Captcha you entered was not valid.'));
}
}
\ No newline at end of file
......@@ -17,29 +17,28 @@ function enmask_form_alter(&$form, &$form_state, $form_id) {
if ($selector_id == 'comment-node-article-form' || $selector_id == 'comment-node-page-form') {
$selector_id = 'comment-form';
}
// start for showing captcha
require_once('enmask.captcha.php');
// Start for showing captcha.
$enmask_captcha = new EnmaskCaptcha();
$mycaptcha = $enmask_captcha->getHtml('myCaptcha');
$form['enmask_captcha'] = array('#type' => 'item',
$form['enmask_captcha'] = array(
'#type' => 'item',
'#title' => t('Captcha'),
'#suffix' => $mycaptcha,
'#required' => TRUE);
//end for showing captcha
// End for showing captcha.
//Give it a function for validation
// Give it a function for validation.
$form['#validate'][] = 'enmask_form_validate';
}
}
/**
* validate the captcha
* Validate the captcha.
*/
function enmask_form_validate($form, &$form_state) {
if (trim(check_plain($_POST['myCaptcha']))!='') {
//start for validating captcha
require_once('enmask.captcha.php');
if (trim(check_plain($_POST['myCaptcha'])) != '') {
// Start for validating captcha.
$enmask_captcha = new EnmaskCaptcha();
$captchaChallenge = trim(check_plain($_POST['myCaptcha_challenge']));
$captchaResponse = trim(check_plain($_POST['myCaptcha']));
......@@ -47,7 +46,7 @@ function enmask_form_validate($form, &$form_state) {
list($isValid, $message) = $enmask_captcha->validate($captchaResponse, $captchaChallenge);
if (!$isValid) {
form_set_error('', check_plain( t($message)));
form_set_error('', check_plain(t($message)));
watchdog('Enmask Captcha', 'Please enter captcha text correctly', array(), WATCHDOG_NOTICE);
}
}
......@@ -67,7 +66,7 @@ function enmask_menu() {
'description' => 'Activation options for enmask captcha',
'page callback' => 'drupal_get_form',
'page arguments' => array('enmask_settings'),
'access arguments' => array('Activation options Enmask Captcha'),
'access arguments' => array('Administer Enmask Captcha'),
'type' => MENU_NORMAL_ITEM,
'file' => 'enmask.admin.inc',
);
......@@ -75,34 +74,29 @@ function enmask_menu() {
}
/**
* Save the Enmask configuration
* Save the Enmask configuration.
*/
function enmask_admin_submit($form, &$form_state) {
variable_set('enmask_form_ids', array_filter($form_state['values']['admin_captcha_forms']));
variable_set('enmask_form_ids', array_filter($form_state['values']['admin_captcha_forms']));
}
/**
* Show Help information by using hook_help().
*/
function enmask_help($path, $arg) {
if ($path == 'admin/help#enmask') {
$output = '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('EnMask Captcha is based on encrypted text and paired with matching web fonts so user will see clearly the challenge text while the spam programs see the underlying encrypted text. Users will have much better Captcha experience then trying to guess the difficult twisted image based Captcha solution. It\'s fun and helps improving user accuracy rate when the answer characters showing the same font.') . '</p>
<p>' . t('It is ideal for iPhone and Android phones.') . '</p>
<p>' . t('EnMask Captcha is a free cloud base service (Service as a Service, SaaS), You only need to install once, the Captcha fonts and styles changes real time to make it difficult for spam programs.') . '</p>
<p>' . t('With this plugin you will be able to show enmask captcha in drupal forms.') . '</p>';
return $output;
}
if ($path == 'admin/help#enmask') {
$output = '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('EnMask Captcha is based on encrypted text and paired with matching web fonts so user will see clearly the challenge text while the spam programs see the underlying encrypted text. Users will have much better Captcha experience then trying to guess the difficult twisted image based Captcha solution. It\'s fun and helps improving user accuracy rate when the answer characters showing the same font.') . '</p>
<p>' . t('It is ideal for iPhone and Android phones.') . '</p>
<p>' . t('EnMask Captcha is a free cloud base service (Service as a Service, SaaS), You only need to install once, the Captcha fonts and styles changes real time to make it difficult for spam programs.') . '</p>
<p>' . t('With this plugin you will be able to show enmask captcha in drupal forms.') . '</p>';
return $output;
}
}
/**
* Implements hook_permission().
*/
function enmask_permission() {
return array('administer Enmask Captcha' => array('title' => t('Administer Enmask Captcha'),
'description' => t('Perform administration tasks for Enmask Captcha.')),
);
return array('administer Enmask Captcha' => array('title' => t('Administer Enmask Captcha'), 'description' => t('Perform administration tasks for Enmask Captcha.')));
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment