Commit 8fa27005 authored by Evan Goldenberg's avatar Evan Goldenberg
Browse files

remove CAPTCHAs in preparation for new anti-spam features


Signed-off-by: default avatarEvan Goldenberg <evang@catalyst.net.nz>
parent 1d3049d2
......@@ -206,18 +206,6 @@ $siteoptionform = array(
'defaultvalue' => get_config('institutionautosuspend'),
'help' => true,
),
'captchaonregisterform' => array(
'type' => 'checkbox',
'title' => get_string('captchaonregisterform', 'admin'),
'description' => get_string('captchaonregisterformdescription', 'admin'),
'defaultvalue' => get_config('captchaonregisterform'),
),
'captchaoncontactform' => array(
'type' => 'checkbox',
'title' => get_string('captchaoncontactform', 'admin'),
'description' => get_string('captchaoncontactformdescription', 'admin'),
'defaultvalue' => get_config('captchaoncontactform'),
),
'showselfsearchsideblock' => array(
'type' => 'checkbox',
'title' => get_string('showselfsearchsideblock', 'admin'),
......@@ -286,7 +274,7 @@ function siteoptions_submit(Pieform $form, $values) {
'defaultaccountlifetime', 'defaultaccountinactiveexpire', 'defaultaccountinactivewarn',
'allowpublicviews', 'allowpublicprofiles', 'creategroups', 'createpublicgroups', 'searchplugin',
'registration_sendweeklyupdates', 'institutionexpirynotification', 'institutionautosuspend',
'captchaonregisterform', 'captchaoncontactform', 'showselfsearchsideblock', 'showtagssideblock',
'showselfsearchsideblock', 'showtagssideblock',
'tagssideblockmaxtags', 'country', 'viewmicroheaders', 'userscanchooseviewthemes',
'remoteavatars', 'userscanhiderealnames'
);
......
<?php
/**
* Mahara: Electronic portfolio, weblog, resume builder and social networking
* Copyright (C) 2006-2009 Catalyst IT Ltd and others; see:
* http://wiki.mahara.org/Contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package mahara
* @subpackage core
* @author Catalyst IT Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006-2009 Catalyst IT Ltd http://catalyst.net.nz
*
*/
define('INTERNAL', 1);
define('PUBLIC', 1);
require('init.php');
$name = param_alphanumext('name', 'captcha');
// Get 5 random letters.
$code = get_random_key(5);
$angles = array(40, 0, 340, 20, 310);
$lefts = array(30, 50, 70, 95, 110);
$bottoms = array(24, 20, 28, 34, 33);
$file = $THEME->get_path('images/captcha.png');
$img = imagecreatefrompng($file);
$black = imagecolorallocate($img, 60, 60, 60);
$ttf = $THEME->get_path('captcha.ttf');
$captcha = '';
for ($i = 0; $i < strlen($code); $i++) {
imagettftext($img, 18, $angles[$i], $lefts[$i], $bottoms[$i], $black, $ttf, $code{$i});
$captcha .= $code{$i};
}
$SESSION->set($name, $captcha);
header('Content-type: image/png');
imagepng($img);
?>
......@@ -79,15 +79,6 @@ $elements = array(
)
);
if (get_config('captchaoncontactform') && !$USER->is_logged_in()) {
$elements['captcha'] = array(
'type' => 'captcha',
'title' => get_string('captchatitle'),
'description' => get_string('captchadescription'),
'rules' => array('required' => true)
);
}
$elements['userid'] = array(
'type' => 'hidden',
'value' => $userid,
......@@ -104,13 +95,6 @@ $contactform = pieform(array(
'elements' => $elements
));
function contactus_validate(Pieform $form, $values) {
global $USER;
if (get_config('captchaoncontactform') && !$USER->is_logged_in() && !$values['captcha']) {
$form->set_error('captcha', get_string('captchaincorrect'));
}
}
function contactus_submit(Pieform $form, $values) {
global $SESSION;
$data = new StdClass;
......
......@@ -148,10 +148,6 @@ $string['allowpublicviews'] = 'Allow public views';
$string['allowpublicviewsdescription'] = 'If set to yes, users will be able to create portfolio Views that are accessable to the public rather than only to logged in users';
$string['allowpublicprofiles'] = 'Allow public profiles';
$string['allowpublicprofilesdescription'] = 'If set to yes, users will be able to set their profile Views to be accessable to the public rather than only to logged in users';
$string['captchaonregisterform'] = 'Captcha required for registration';
$string['captchaonregisterformdescription'] = 'Require users to type letters from a captcha image when submitting the registration form';
$string['captchaoncontactform'] = 'Captcha required for contact us';
$string['captchaoncontactformdescription'] = 'Require logged-out users to type letters from a captcha image when submitting the Contact Us form';
$string['defaultaccountinactiveexpire'] = 'Default account inactivity time';
$string['defaultaccountinactiveexpiredescription'] = 'How long a user account will remain active without the user logging in';
$string['defaultaccountinactivewarn'] = 'Warning time for inactivity/expiry';
......
......@@ -325,10 +325,6 @@ $string['invalidsesskey'] = 'Invalid session key';
$string['cannotremovedefaultemail'] = 'You cannot remove your primary email address';
$string['emailtoolong'] = 'E-mail addresses cannot be longer that 255 characters';
$string['mustspecifyoldpassword'] = 'You must specify your current password';
$string['captchatitle'] = 'CAPTCHA Image';
$string['captchaimage'] = 'CAPTCHA Image';
$string['captchadescription'] = 'Enter the characters you see in the picture. Letters are not case sensitive';
$string['captchaincorrect'] = 'Enter the letters as they are shown in the image';
$string['Site'] = 'Site';
// Misc. register stuff that could be used elsewhere
......
......@@ -1194,13 +1194,6 @@ function xmldb_core_upgrade($oldversion=0) {
drop_field($table, $field);
}
if ($oldversion < 2009082600) {
$captcha = get_config('captcha_on_contact_form');
set_config('captchaoncontactform', (int) (is_null($captcha) || $captcha));
$captcha = get_config('captcha_on_register_form');
set_config('captchaonregisterform', (int) (is_null($captcha) || $captcha));
}
if ($oldversion < 2009090700) {
set_config('showselfsearchsideblock', 1);
set_config('showtagssideblock', 1);
......
<?php
/**
* Mahara: Electronic portfolio, weblog, resume builder and social networking
* Copyright (C) 2006-2009 Catalyst IT Ltd and others; see:
* http://wiki.mahara.org/Contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package mahara
* @subpackage form
* @author Catalyst IT Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006-2009 Catalyst IT Ltd http://catalyst.net.nz
*
*/
function pieform_element_captcha(Pieform $form, $element) {
$id = $form->get_name() . '_' . $element['name'];
$image = '<img src="' . get_config('wwwroot') . 'captcha.php?name=' . $id . '" alt="' . get_string('captchaimage') . '" style="padding: 2px 0;"><br>';
$input = '<input type="text" class="text required" id="' . $id . '" name="' . $element['name'] . '" style="width: 137px;" tabindex="' . $form->get_property('tabindex') . '">';
return $image . ' ' . $input;
}
function pieform_element_captcha_get_value(Pieform $form, $element) {
global $SESSION;
$name = $element['name'];
$global = ($form->get_property('method') == 'get') ? $_GET : $_POST;
return isset($global[$name]) && strtolower($global[$name]) == strtolower($SESSION->get($form->get_name() . '_' . $name));
}
?>
......@@ -666,8 +666,6 @@ function core_install_firstcoredata_defaults() {
set_config('createpublicgroups', 'all');
set_config('allowpublicviews', 1);
set_config('allowpublicprofiles', 1);
set_config('captchaoncontactform', 1);
set_config('captchaonregisterform', 1);
set_config('showselfsearchsideblock', 0);
set_config('showtagssideblock', 1);
set_config('tagssideblockmaxtags', 20);
......
......@@ -237,15 +237,6 @@ $elements['tandc'] = array(
'separator' => ' &nbsp; '
);
if (get_config('captchaonregisterform')) {
$elements['captcha'] = array(
'type' => 'captcha',
'title' => get_string('captchatitle'),
'description' => get_string('captchadescription'),
'rules' => array('required' => true)
);
}
$elements['submit'] = array(
'type' => 'submit',
'value' => get_string('register'),
......@@ -295,11 +286,6 @@ function register_validate(Pieform $form, $values) {
$form->set_error('tandc', get_string('youmaynotregisterwithouttandc', 'auth.internal'));
}
// CAPTCHA image
if (get_config('captchaonregisterform') && !$values['captcha']) {
$form->set_error('captcha', get_string('captchaincorrect'));
}
$institution = get_record_sql('
SELECT
i.name, i.maxuseraccounts, i.registerallowed, COUNT(u.id)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment