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 6234bd3d4f92e1c384bfa93b30b4d7e632bb4e8f (commit) from 8cafd03c719b83cbcd4b2709e29c1b165f8552ed (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 ----------------------------------------------------------------- https://scm.fusionforge.org/anonscm/gitweb/?p=fusionforge/fusionforge.git;a=commitdiff;h=6234bd3d4f92e1c384bfa93b30b4d7e632bb4e8f commit 6234bd3d4f92e1c384bfa93b30b4d7e632bb4e8f Author: Franck Villaume <franck.villa...@trivialdev.com> Date: Thu Aug 10 12:26:42 2017 +0000 new plugin phptextcaptcha: implement captcha hooks using standard pear lib: php-text-captcha diff --git a/autoinstall/install-src.sh b/autoinstall/install-src.sh index a987f18..22dcbb4 100755 --- a/autoinstall/install-src.sh +++ b/autoinstall/install-src.sh @@ -29,14 +29,15 @@ if [ -e /etc/debian_version ]; then export DEBIAN_FRONTEND=noninteractive backports_deb apt-get update - apt-get install -y make gettext php5-cli php5-pgsql php-htmlpurifier php-http \ + apt-get install -y make gettext php5-cli php5-pgsql php-htmlpurifier php-http php-text-captcha \ libapache2-mpm-itk libapache2-mod-svn \ libapache2-mod-php5 \ apache2 postgresql postgresql-contrib libnss-pgsql2 unscd \ cvs subversion viewvc python-pycurl git mercurial xinetd \ python-moinmoin libapache2-mod-wsgi python-psycopg2 \ unoconv poppler-utils dpkg-dev \ - vsftpd + vsftpd \ + fonts-dejavu-core if ! dpkg-vendor --is Ubuntu; then apt-get install locales-all # https://bugs.launchpad.net/ubuntu/+source/glibc/+bug/1394929 fi @@ -60,13 +61,14 @@ else yum install -y make tar backports_rpm yum --enablerepo=epel install -y httpd-itk - yum install -y gettext php-cli php-pgsql php-process php-mbstring php-pear-HTTP \ + yum install -y gettext php-cli php-pgsql php-process php-mbstring php-pear-HTTP php-pear-Text-CAPTCHA \ httpd mod_dav_svn mod_ssl postgresql-server postgresql-contrib nscd \ cvs subversion viewvc python-pycurl git gitweb mercurial xinetd \ moin mod_wsgi python-psycopg2 \ unoconv poppler-utils libreoffice-headless \ mediawiki php-markdown \ - vsftpd + vsftpd \ + dejavu-fonts-common fi ( @@ -76,9 +78,12 @@ fi install-plugin-scmcvs install-plugin-scmsvn install-plugin-scmgit install-plugin-scmhg \ install-plugin-blocks install-plugin-moinmoin \ install-plugin-taskboard install-plugin-message \ - install-plugin-repositoryapi + install-plugin-repositoryapi if [ -e /etc/centos-release ]; then make install-plugin-mediawiki fi + if [ -e /etc/centos-release -o -e /etc/debian-release ]; then + make install-plugin-phptextcaptcha + fi make post-install ) diff --git a/src/plugins/phptextcaptcha/GNUmakefile b/src/plugins/phptextcaptcha/GNUmakefile new file mode 100644 index 0000000..74236a8 --- /dev/null +++ b/src/plugins/phptextcaptcha/GNUmakefile @@ -0,0 +1,7 @@ +include ../../GNUmakefile.defaults + +all: + @echo "No default action" + +install: + install -d -m 755 $(DESTDIR)$(data_path)/plugins/phptextcaptcha diff --git a/src/plugins/phptextcaptcha/bin/install.sh b/src/plugins/phptextcaptcha/bin/install.sh new file mode 100755 index 0000000..cf1e938 --- /dev/null +++ b/src/plugins/phptextcaptcha/bin/install.sh @@ -0,0 +1,19 @@ +#!/bin/bash -e +# phptextcaptcha post-install + +source $(forge_get_config source_path)/post-install.d/common/service.inc + +datadir=$(forge_get_config data_path)/plugins/phptextcaptcha +apache_user=$(forge_get_config apache_user) + +case "$1" in + configure) + chown $apache_user: $datadir + ;; + remove) + find $datadir -type l -print0 | xargs -r0 rm + ;; + *) + echo "Usage: $0 {configure|remove}" + exit 1 +esac diff --git a/src/plugins/phptextcaptcha/common/phptextcaptchaPlugin.class.php b/src/plugins/phptextcaptcha/common/phptextcaptchaPlugin.class.php new file mode 100644 index 0000000..fd3b35a --- /dev/null +++ b/src/plugins/phptextcaptcha/common/phptextcaptchaPlugin.class.php @@ -0,0 +1,102 @@ +<?php +/** + * phptextcaptchaPlugin Class + * + * Copyright 2017, 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 phptextcaptchaPlugin extends Plugin { + + var $pngdir = ''; + + function __construct() { + parent::__construct(); + $this->name = 'phptextcaptcha'; + $this->text = _('Enable use of php-text-captcha (more information http://pear.php.net/manual/en/package.text.text-captcha.php)'); + $this->_addHook('captcha_check'); + $this->_addHook('captcha_form'); + $this->pngdir = forge_get_config('data_path').'/plugins/'.$this->name; + } + + function captcha_check($params) { + session_start(); + if (isset($_POST['captcha_code']) && is_string($_POST['captcha_code']) + && isset($_SESSION['captcha_code']) + && strlen($_POST['captcha_code']) > 0 && strlen($_SESSION['captcha_code']) > 0 + && $_POST['captcha_code'] == $_SESSION['captcha_code'] + ) { + unset($_SESSION['captcha_code']); + } else { + $params['valide'] = 0; + $params['warning_msg'] = _('Wrong captcha code'); + } + @unlink($this->pngdir.'/'.sha1(session_id()) . '.png'); + } + + function captcha_form(&$html) { + require_once 'Text/CAPTCHA.php'; + + // Set CAPTCHA image options (font must exist!) + if (is_file('/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf')) { + //Debian-like + $font_path = '/usr/share/fonts/truetype/dejavu/'; + } else { + //CentOS + $font_path = '/usr/share/fonts/dejavu/'; + } + $imageOptions = array( + 'font_size' => 24, + 'font_path' => $font_path, + 'font_file' => 'DejaVuSansMono.ttf', + 'text_color' => '#DDFF99', + 'lines_color' => '#CCEEDD', + 'background_color' => '#555555' + ); + + // Set CAPTCHA options + $options = array( + 'width' => 200, + 'height' => 80, + 'output' => 'png', + 'imageOptions' => $imageOptions + ); + + // Generate a new Text_CAPTCHA object, Image driver + $c = Text_CAPTCHA::factory('Image'); + $c->init($options); + + // Get CAPTCHA secret passphrase + $_SESSION['captcha_code'] = $c->getPhrase(); + + // Get CAPTCHA image (as PNG) + $png = $c->getCAPTCHA(); + + $pngfile = sha1(session_id()).'.png'; + if (is_file($this->pngdir.'/'.$pngfile)) { + unlink($this->pngdir.'/'.$pngfile); + } + file_put_contents($this->pngdir.'/'.$pngfile, $png); + $html = '<p>'; + $html .= '<img src="/plugins/'.$this->name.'/'.$pngfile.'?'.time().'" />'; + $html .= _('Write captcha here')._(': ').'<br />'; + $html .= '<input type="text" name="captcha_code" size="10" maxlength="8" required="required" />'; + $html .= '</p>'; + return $html; + } +} diff --git a/src/plugins/phptextcaptcha/etc/httpd.conf.d/plugin-phptextcaptcha.inc b/src/plugins/phptextcaptcha/etc/httpd.conf.d/plugin-phptextcaptcha.inc new file mode 100644 index 0000000..ee128e3 --- /dev/null +++ b/src/plugins/phptextcaptcha/etc/httpd.conf.d/plugin-phptextcaptcha.inc @@ -0,0 +1,5 @@ +Alias /plugins/phptextcaptcha ${FF__core__data_path}/plugins/phptextcaptcha +<Directory ${FF__core__data_path}/plugins/phptextcaptcha > + Include ${FF__core__config_path}/httpd.conf.d/auth-main.inc +</Directory> + diff --git a/src/plugins/phptextcaptcha/etc/phptextcaptcha.ini b/src/plugins/phptextcaptcha/etc/phptextcaptcha.ini new file mode 100644 index 0000000..ba64237 --- /dev/null +++ b/src/plugins/phptextcaptcha/etc/phptextcaptcha.ini @@ -0,0 +1,7 @@ +[phptextcaptcha] +; plugin_status is a string. +; valid means : production ready. +; Any other strings means it's under work or broken and plugin +; is available in installation_environment = development only. +plugin_status = 'valid' + ----------------------------------------------------------------------- Summary of changes: autoinstall/install-src.sh | 15 ++- src/plugins/{scmsvn => phptextcaptcha}/GNUmakefile | 3 +- src/plugins/phptextcaptcha/bin/install.sh | 19 ++++ .../common/phptextcaptchaPlugin.class.php | 102 +++++++++++++++++++++ .../etc/httpd.conf.d/plugin-phptextcaptcha.inc | 5 + .../etc/phptextcaptcha.ini} | 4 +- 6 files changed, 139 insertions(+), 9 deletions(-) copy src/plugins/{scmsvn => phptextcaptcha}/GNUmakefile (55%) create mode 100755 src/plugins/phptextcaptcha/bin/install.sh create mode 100644 src/plugins/phptextcaptcha/common/phptextcaptchaPlugin.class.php create mode 100644 src/plugins/phptextcaptcha/etc/httpd.conf.d/plugin-phptextcaptcha.inc copy src/plugins/{globalactivity/etc/globalactivity.ini => phptextcaptcha/etc/phptextcaptcha.ini} (92%) hooks/post-receive -- FusionForge _______________________________________________ Fusionforge-commits mailing list Fusionforge-commits@lists.fusionforge.org http://lists.fusionforge.org/cgi-bin/mailman/listinfo/fusionforge-commits