From 9d35f9b000bf1cafcb35f6be573185d1af58afc9 Mon Sep 17 00:00:00 2001 From: rurban Date: Sat, 29 Oct 2005 07:37:56 +0000 Subject: [PATCH] USE_CAPTCHA_RANDOM_WORD by Dan Frankowski git-svn-id: svn://svn.code.sf.net/p/phpwiki/code/trunk@4919 96ab9672-09ca-45d6-a79d-3d69d39ca109 --- config/config-default.ini | 3 ++- config/config-dist.ini | 9 ++++++++- lib/Captcha.php | 39 +++++++++++++++++++++++++++++++++++++-- 3 files changed, 47 insertions(+), 4 deletions(-) diff --git a/config/config-default.ini b/config/config-default.ini index b984fa485..c5d6d0ad7 100644 --- a/config/config-default.ini +++ b/config/config-default.ini @@ -1,4 +1,4 @@ -; $Id: config-default.ini,v 1.41 2005-10-13 06:12:56 rurban Exp $ +; $Id: config-default.ini,v 1.42 2005-10-29 07:37:56 rurban Exp $ ; This is the default PhpWiki configuration for undefined config.ini entries. ; recent development and debugging features: @@ -17,6 +17,7 @@ GOOGLE_LINKS_NOFOLLOW = true USE_SAFE_DBSESSION = false ENABLE_DISCUSSION_LINK = false ENABLE_CAPTCHA = false +USE_CAPTCHA_RANDOM_WORD = false ENABLE_ACDROPDOWN = false ; deprecated ENABLE_LIVESEARCH = false diff --git a/config/config-dist.ini b/config/config-dist.ini index 0a0295637..2334c81e2 100644 --- a/config/config-dist.ini +++ b/config/config-dist.ini @@ -56,6 +56,10 @@ ; Optionally define BABYCART_PATH. Default: /usr/local/bin/babycart ;ENABLE_SPAMASSASSIN = true +; Check external links on edit against domains blocked by surbl.org and +; bl.spamcop.net +ENABLE_SPAMBLOCKLIST = true + ; If more than this number of external links appear on non-authenticated ; edits it will be rejected as spam. ;NUM_SPAM_LINKS = 20 @@ -81,13 +85,16 @@ ;ENABLE_ACDROPDOWN = true ; Experimental WikiPedia feature: Force Discussion/Article link at the topnavbar. -; This does not work yet. ;ENABLE_DISCUSSION_LINK = true ; If set to true, add some anti-spam countermeasures based on captcha ; tests. See http://www.captcha.net/ for more information on captcha. ;ENABLE_CAPTCHA = true +; If USE_CAPTCHA_RANDOM_WORD is set to true, +; Captcha will use a random word, otherwise a disctionary word. +;USE_CAPTCHA_RANDOM_WORD = false + ; USE_SAFE_DBSESSION should be enabled, if you encounter session problems, with ; duplicate INSERT sess_id warnings at the bottom of the page. Reason is a ; unreliable affected_rows implementation() in the sql backend. diff --git a/lib/Captcha.php b/lib/Captcha.php index bf5dae163..90d62f643 100644 --- a/lib/Captcha.php +++ b/lib/Captcha.php @@ -1,8 +1,10 @@ Modified by Benjamin Drieu - 2005 for PhpWiki + get_captcha_random_word() contributed by Dan Frankowski 2005 for PhpWiki This File is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,7 +22,14 @@ */ -function get_captcha_word () { +function get_captcha_word () { + if (USE_CAPTCHA_RANDOM_WORD) + return get_captcha_dictionary_word(); + else + return get_captcha_random_word(); +} + +function get_captcha_dictionary_word () { // Load In the Word List $fp = fopen(FindFile("lib/captcha/dictionary"), "r"); while ( !feof($fp) ) @@ -35,6 +44,20 @@ function get_captcha_word () { } } +/* by Dan Frankowski. + */ +function get_captcha_random_word () { + // Pick a few random letters or numbers + $word = ""; + // Don't use 1 <=> l or 0 (for o), because they're hard to read + $letters = "abcdefghijkmnopqrstuvwxyzABCDEFGHIJKMNOPQRSTUVWXYZ23456789"; + $letter_len = strlen($letters); + for ($i=0; $i<4; $i++) { + $word .= $letters[mt_rand(0, $letter_len-1)]; + } + return $word; +} + // Draw the Spiral function spiral( &$im, $origin_x = 100, $origin_y = 100, $r = 0, $g = 0, $b = 0 ) { $theta = 1; @@ -79,7 +102,9 @@ function captcha_image ( $word ) { $y = rand(25, 50); $x = rand(10, $width-100); - imagettftext($jpg, $size, $angle, $x, $y, $tx, realpath(FindFile("lib/captcha/Vera.ttf")), $word); + imagettftext($jpg, $size, $angle, $x, $y, $tx, + realpath(FindFile("lib/captcha/Vera.ttf")), + $word); $x = rand(0, 280); $y = rand(0, 115); @@ -93,4 +118,14 @@ function captcha_image ( $word ) { header("Content-type: image/jpeg"); ImageJpeg($jpg); } + +// $Log: not supported by cvs2svn $ + +// Local Variables: +// mode: php +// tab-width: 8 +// c-basic-offset: 4 +// c-hanging-comment-ender-p: nil +// indent-tabs-mode: nil +// End: ?> \ No newline at end of file -- 2.45.0