From d080afebbe835c70ed5b6937f71df5a36aeb906e Mon Sep 17 00:00:00 2001 From: Eric Helgeson Date: Mon, 16 Nov 2009 11:44:31 -0500 Subject: [PATCH] Refactored Recaptcha plugin to use addPlugin() Also nicer log messages --- plugins/{recaptcha => Recaptcha}/LICENSE | 0 plugins/Recaptcha/README | 28 +++++++++++++++++++ .../RecaptchaPlugin.php} | 18 ++++++------ .../{recaptcha => Recaptcha}/recaptchalib.php | 0 plugins/recaptcha/README | 23 --------------- 5 files changed, 38 insertions(+), 31 deletions(-) rename plugins/{recaptcha => Recaptcha}/LICENSE (100%) create mode 100644 plugins/Recaptcha/README rename plugins/{recaptcha/recaptcha.php => Recaptcha/RecaptchaPlugin.php} (87%) rename plugins/{recaptcha => Recaptcha}/recaptchalib.php (100%) delete mode 100644 plugins/recaptcha/README diff --git a/plugins/recaptcha/LICENSE b/plugins/Recaptcha/LICENSE similarity index 100% rename from plugins/recaptcha/LICENSE rename to plugins/Recaptcha/LICENSE diff --git a/plugins/Recaptcha/README b/plugins/Recaptcha/README new file mode 100644 index 0000000000..49c4b9c27d --- /dev/null +++ b/plugins/Recaptcha/README @@ -0,0 +1,28 @@ +StatusNet reCAPTCHA plugin 0.3 11/16/09 +======================================= +Adds a captcha to your registration page to reduce automated spam bots registering. + +Use: +1. Get an API key from http://recaptcha.net + +2. In config.php add: +addPlugin('recaptcha', array('private_key' => 'YourKeyHere', + 'public_key' => 'ReplaceWithYourKey')); +or +addPlugin('recaptcha', array('private_key' => 'YourKeyHere', + 'public_key' => 'ReplaceWithYourKey', + 'display_errors' => true)); +Changelog +========= +0.1 initial release +0.2 Work around for webkit browsers +0.3 Moved to new plugin arch for SN + **YOU WILL NEED TO CHANGE YOUR CONFIG.PHP!** + +reCAPTCHA Lib README +==================== + +The reCAPTCHA PHP Lirary helps you use the reCAPTCHA API. Documentation +for this library can be found at + + http://recaptcha.net/plugins/php diff --git a/plugins/recaptcha/recaptcha.php b/plugins/Recaptcha/RecaptchaPlugin.php similarity index 87% rename from plugins/recaptcha/recaptcha.php rename to plugins/Recaptcha/RecaptchaPlugin.php index 94cf0ccd17..1a51b16beb 100644 --- a/plugins/recaptcha/recaptcha.php +++ b/plugins/Recaptcha/RecaptchaPlugin.php @@ -33,7 +33,9 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { define('RECAPTCHA', '0.2'); -class recaptcha extends Plugin +require_once(INSTALLDIR.'/plugins/Recaptcha/recaptchalib.php'); + +class RecaptchaPlugin extends Plugin { var $private_key; var $public_key; @@ -41,13 +43,13 @@ class recaptcha extends Plugin var $failed; var $ssl; - function __construct($public_key, $private_key, $display_errors=false) - { - parent::__construct(); - require_once(INSTALLDIR.'/plugins/recaptcha/recaptchalib.php'); - $this->public_key = $public_key; - $this->private_key = $private_key; - $this->display_errors = $display_errors; + function onInitializePlugin(){ + if(!isset($this->private_key)){ + common_log(LOG_ERR, "Recaptcha: Must specify private_key in config.php"); + } + if(!isset($this->public_key)){ + common_log(LOG_ERR, "Recaptcha: Must specify public_key in config.php"); + } } function checkssl(){ diff --git a/plugins/recaptcha/recaptchalib.php b/plugins/Recaptcha/recaptchalib.php similarity index 100% rename from plugins/recaptcha/recaptchalib.php rename to plugins/Recaptcha/recaptchalib.php diff --git a/plugins/recaptcha/README b/plugins/recaptcha/README deleted file mode 100644 index b996f96cc3..0000000000 --- a/plugins/recaptcha/README +++ /dev/null @@ -1,23 +0,0 @@ -StatusNet reCAPTCHA plugin 0.2 8/3/09 -==================================== -Adds a captcha to your registration page to reduce automated spam bots registering. - -Use: -1. Get an API key from http://recaptcha.net - -2. In config.php add: -include_once('plugins/recaptcha/recaptcha.php'); -$captcha = new recaptcha(publickey, privatekey, showErrors); - -Changelog -========= -0.1 initial release -0.2 Work around for webkit browsers - -reCAPTCHA README -================ - -The reCAPTCHA PHP Lirary helps you use the reCAPTCHA API. Documentation -for this library can be found at - - http://recaptcha.net/plugins/php -- 2.39.5