[Fusionforge-commits] FusionForge branch master updated. ddd41ef31660cd33bc08b457297e5c284d894d20

Franck VILLAUME nerville at fusionforge.org
Fri Aug 23 17:17:38 CEST 2013


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "FusionForge".

The branch, master has been updated
       via  ddd41ef31660cd33bc08b457297e5c284d894d20 (commit)
       via  a90f8c6f4d01deabd0ad9fdfb9dc6306d5fa7214 (commit)
      from  b5332ac145685432de219165a92fbe044ddbd0a8 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit ddd41ef31660cd33bc08b457297e5c284d894d20
Author: Franck Villaume <franck.villaume at trivialdev.com>
Date:   Fri Aug 23 17:17:22 2013 +0200

    sync CHANGES

diff --git a/src/CHANGES b/src/CHANGES
index b81c3d9..f22ac0d 100644
--- a/src/CHANGES
+++ b/src/CHANGES
@@ -28,6 +28,7 @@ Plugins:
 * blocks: improved with a new HTML widget for the project summary page (Alcatel-Lucent)
 * svntracker : this plugin is superseed by scmhook
 * svncommitemail : this plugin is superseed by scmhook
+* new phpcaptcha plugin : enable a captcha in the register page. (TrivialDev)
 
 FusionForge-5.2:
 * Docman: inject zip as a tree (Capgemini)

commit a90f8c6f4d01deabd0ad9fdfb9dc6306d5fa7214
Author: Franck Villaume <franck.villaume at trivialdev.com>
Date:   Fri Aug 23 17:15:24 2013 +0200

    plugin phpcaptcha: first push, implement patch #212 as plugin.

diff --git a/src/etc/config.ini.d/phpcaptcha.ini b/src/etc/config.ini.d/phpcaptcha.ini
new file mode 120000
index 0000000..89e4ed1
--- /dev/null
+++ b/src/etc/config.ini.d/phpcaptcha.ini
@@ -0,0 +1 @@
+../../plugins/phpcaptcha/etc/phpcaptcha.ini
\ No newline at end of file
diff --git a/src/etc/httpd.conf.d/plugin-phpcaptcha.inc b/src/etc/httpd.conf.d/plugin-phpcaptcha.inc
new file mode 100644
index 0000000..305c9ec
--- /dev/null
+++ b/src/etc/httpd.conf.d/plugin-phpcaptcha.inc
@@ -0,0 +1 @@
+Alias /plugins/phpcaptcha {phpcaptcha/phpcaptcha_path}
diff --git a/src/plugins/phpcaptcha/common/phpcaptchaPlugin.class.php b/src/plugins/phpcaptcha/common/phpcaptchaPlugin.class.php
new file mode 100644
index 0000000..27a1e13
--- /dev/null
+++ b/src/plugins/phpcaptcha/common/phpcaptchaPlugin.class.php
@@ -0,0 +1,70 @@
+<?php
+
+/**
+ * phpcaptchaPlugin Class
+ *
+ * Copyright 2010, Luis Daniel Ibáñez
+ * Copyright 2013, Franck Villaume - TrivialDev
+ * http://fusionforge.org
+ *
+ * This file is part of FusionForge. FusionForge 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 2 of the Licence, or (at your option)
+ * any later version.
+ *
+ * FusionForge 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 FusionForge; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+ 
+class phpcaptchaPlugin extends Plugin {
+
+	var $phpcaptcha_path;
+
+	function __construct() {
+		$this->Plugin();
+		$this->name = 'phpcaptcha';
+		$this->text = 'Enable use of phpcaptcha (more information www.phpcaptcha.org)';
+		$this->_addHook('captcha_check');
+		$this->_addHook('captcha_form');
+		$this->phpcaptcha_path = forge_get_config('phpcaptcha_path', 'phpcaptcha');
+	}
+	
+	function captcha_check($params) {
+		$captcha_code = getStringFromRequest('captcha_code');
+		require_once $this->phpcaptcha_path.'/securimage.php';
+		$securimage = new Securimage();
+		if (!$securimage->check($captcha_code)) {
+			$params['valide'] = 0;
+			$params['warning_msg'] = _('Wrong captcha code');
+		}
+	}
+	
+	function captcha_form() {
+		if ($this->checkConfig()) {
+			echo '<p>
+				<img id="captcha" src="/plugins/'.$this->name.'/securimage_show.php" alt="CAPTCHA Image" />
+				<a href="#" onclick="document.getElementById(\'captcha\').src = \'/plugins/'.$this->name.'/securimage_show.php?\' + Math.random(); return false">';
+			echo _('Reload image.').'</a>';
+			echo '</p><p>';
+			echo _('Write captcha here:').'<br />';
+			echo '<input type="text" name="captcha_code" size="10" maxlength="6" />';
+			echo '</p>'; 
+		} else {
+			echo '<p class="information">'._('phpcaptcha seems not installed. Contact your administrator for more informations.').'</p>';
+		}
+	}
+	
+	function checkConfig() {
+		if(!is_file($this->phpcaptcha_path.'/securimage.php') || !extension_loaded('gd'))
+			return false;
+		
+		return true;
+	}
+}
diff --git a/src/plugins/phpcaptcha/etc/phpcaptcha.ini b/src/plugins/phpcaptcha/etc/phpcaptcha.ini
new file mode 100644
index 0000000..8d1c8b6
--- /dev/null
+++ b/src/plugins/phpcaptcha/etc/phpcaptcha.ini
@@ -0,0 +1 @@
+ 
diff --git a/src/www/account/register.php b/src/www/account/register.php
index 758563a..70b586a 100644
--- a/src/www/account/register.php
+++ b/src/www/account/register.php
@@ -5,6 +5,7 @@
  * Copyright 1999-2001 (c) VA Linux Systems
  * Copyright 2010 (c) FusionForge Team
  * Copyright (C) 2011 Alain Peyrat - Alcatel-Lucent
+ * Copyright 2013, Franck Villaume - TrivialDev
  *
  * This file is part of FusionForge. FusionForge is free software;
  * you can redistribute it and/or modify it under the terms of the
@@ -68,10 +69,17 @@ if (getStringFromRequest('submit')) {
 	if (!form_key_is_valid(getStringFromRequest('form_key'))) {
 		exit_form_double_submit('my');
 	}
-
+	
+	$valide = 1;
 	if (forge_get_config('user_registration_accept_conditions') && ! $accept_conditions) {
-		$warning_msg = _("You can't register an account unless you accept the terms of use.") ;
-	} else {
+		$warning_msg = _("You can't register an account unless you accept the terms of use.");
+		$valide = 0;
+	}
+	$params['valide'] =& $valide;
+	$params['warning_msg'] =& $warning_msg;
+	plugin_hook('captcha_check', $params);
+	
+	if ($valide) {
 		$activate_immediately = getIntFromRequest('activate_immediately');
 		if (($activate_immediately == 1) &&
 		    forge_check_global_perm ('forge_admin')) {
@@ -255,7 +263,10 @@ if($toDisplay != "") {
 	<p><input type="checkbox" name="activate_immediately" value="1" />
 <?php print _('Activate this user immediately') ; ?>
 	</p>
-<?php } ?>
+<?php }
+plugin_hook('captcha_form');
+?>
+
 <p>
 <?php printf(_('Fields marked with %s are mandatory.'), utils_requiredField()); ?>
 </p>

-----------------------------------------------------------------------

Summary of changes:
 src/CHANGES                                        |    1 +
 src/etc/config.ini.d/phpcaptcha.ini                |    1 +
 src/etc/httpd.conf.d/plugin-phpcaptcha.inc         |    1 +
 .../phpcaptcha/common/phpcaptchaPlugin.class.php   |   70 ++++++++++++++++++++
 src/plugins/phpcaptcha/etc/phpcaptcha.ini          |    1 +
 src/www/account/register.php                       |   19 ++++--
 6 files changed, 89 insertions(+), 4 deletions(-)
 create mode 120000 src/etc/config.ini.d/phpcaptcha.ini
 create mode 100644 src/etc/httpd.conf.d/plugin-phpcaptcha.inc
 create mode 100644 src/plugins/phpcaptcha/common/phpcaptchaPlugin.class.php
 create mode 100644 src/plugins/phpcaptcha/etc/phpcaptcha.ini


hooks/post-receive
-- 
FusionForge



More information about the Fusionforge-commits mailing list