X-Git-Url: https://git.toastfreeware.priv.at/toast/cookiecaptcha.git/blobdiff_plain/da07c3eb19e055101497090bddbf1b6e9c489b38..3d581df3947eb43713d41f798c4b7106586ff88c:/FancyCaptcha.php
diff --git a/FancyCaptcha.php b/FancyCaptcha.php
index 7cacd23..c2a6cc3 100644
--- a/FancyCaptcha.php
+++ b/FancyCaptcha.php
@@ -1,115 +1,41 @@
+ * http://www.mediawiki.org/
+ *
+ * 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 2 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, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @addtogroup Extensions
+ */
-if ( defined( 'MEDIAWIKI' ) ) {
+if ( !defined( 'MEDIAWIKI' ) ) {
+ exit;
+}
global $wgCaptchaDirectory;
$wgCaptchaDirectory = "$wgUploadDirectory/captcha"; // bad default :D
+global $wgCaptchaDirectoryLevels;
+$wgCaptchaDirectoryLevels = 0; // To break into subdirectories
+
global $wgCaptchaSecret;
$wgCaptchaSecret = "CHANGE_THIS_SECRET!";
-
-class FancyCaptcha extends SimpleCaptcha {
- function keyMatch() {
- global $wgRequest, $wgCaptchaSecret;
-
- if( !isset( $_SESSION['ceAnswerVar'] ) ) {
- wfDebug( "FancyCaptcha: no session captcha key set, this is new visitor.\n" );
- return false;
- }
-
- $var = $_SESSION['ceAnswerVar'];
- $salt = $_SESSION['captchaSalt'];
- $hash = $_SESSION['captchaHash'];
-
- $answer = $wgRequest->getVal( $var );
- $digest = $wgCaptchaSecret . $salt . $answer . $wgCaptchaSecret . $salt;
- $answerHash = substr( md5( $digest ), 0, 16 );
-
- if( $answerHash == $hash ) {
- wfDebug( "FancyCaptcha: answer hash matches expected $hash\n" );
- return true;
- } else {
- wfDebug( "FancyCaptcha: answer hashes to $answerHash, expected $hash\n" );
- return false;
- }
- }
-
- function formCallback( &$out ) {
- $dest = 'wpCaptchaWord' . mt_rand();
-
- $img = $this->pickImage();
- if( !$img ) {
- die( 'aaargh' );
- }
-
- $_SESSION['ceAnswerVar'] = $dest;
- $_SESSION['captchaHash'] = $img['hash'];
- $_SESSION['captchaSalt'] = $img['salt'];
- $_SESSION['captchaViewed'] = false;
- wfDebug( "Picked captcha with hash ${img['hash']}, salt ${img['salt']}.\n" );
-
- $title = Title::makeTitle( NS_SPECIAL, 'Captcha/image' );
- $url = $title->getLocalUrl();
-
-
- $out->addWikiText( wfMsg( "captcha-short" ) );
- $out->addHTML( <<