From 5e372578a7839eac6a37d7ca8a4c0f8579a80698 Mon Sep 17 00:00:00 2001 From: Philipp Spitzer Date: Tue, 27 Nov 2012 23:41:47 +0100 Subject: [PATCH 1/1] Proof of concept. --- CookieCaptcha.class.php | 56 +++++++---------------------------------- 1 file changed, 9 insertions(+), 47 deletions(-) diff --git a/CookieCaptcha.class.php b/CookieCaptcha.class.php index 1ab2879..a859736 100644 --- a/CookieCaptcha.class.php +++ b/CookieCaptcha.class.php @@ -9,22 +9,19 @@ class CookieCaptcha extends SimpleCaptcha { * @param array $info * @return bool */ - /* function keyMatch( $answer, $info ) { - global $wgCaptchaSecret; - - $digest = $wgCaptchaSecret . $info['salt'] . $answer . $wgCaptchaSecret . $info['salt']; - $answerHash = substr( md5( $digest ), 0, 16 ); - - if ( $answerHash == $info['hash'] ) { - wfDebug( "FancyCaptcha: answer hash matches expected {$info['hash']}\n" ); + if (isset($_COOKIE['cookiecaptcha'])) { + wfDebug( "CookieCaptcha: Found cookie\n" ); return true; } else { - wfDebug( "FancyCaptcha: answer hashes to $answerHash, expected {$info['hash']}\n" ); + wfDebug( "CookieCaptcha: Didn't find cookie...\n" ); return false; } } - */ + + function retrieveCaptcha() { + return true; + } /* function addCaptchaAPI( &$resultArr ) { @@ -45,49 +42,14 @@ class CookieCaptcha extends SimpleCaptcha { /** * Insert the captcha prompt into the edit form. */ - /* function getForm() { - $info = $this->pickImage(); - if ( !$info ) { - throw new MWException( "Ran out of captcha images" ); - } - - // Generate a random key for use of this captcha image in this session. - // This is needed so multiple edits in separate tabs or windows can - // go through without extra pain. - $index = $this->storeCaptcha( $info ); - - wfDebug( "Captcha id $index using hash ${info['hash']}, salt ${info['salt']}.\n" ); - - $title = SpecialPage::getTitleFor( 'Captcha', 'image' ); - + global $wgLogo; return "

" . Html::element( 'img', array( - 'src' => $title->getLocalUrl( 'wpCaptchaId=' . urlencode( $index ) ), - 'width' => $info['width'], - 'height' => $info['height'], + 'src' => $wgLogo, 'alt' => '' ) ) . - "

\n" . - Html::element( 'input', array( - 'type' => 'hidden', - 'name' => 'wpCaptchaId', - 'id' => 'wpCaptchaId', - 'value' => $index ) ) . - '

' . - Html::element( 'label', array( - 'for' => 'wpCaptchaWord', - ), parent::getMessage( 'label' ) . wfMessage( 'colon-separator' )->text() ) . - Html::element( 'input', array( - 'name' => 'wpCaptchaWord', - 'id' => 'wpCaptchaWord', - 'type' => 'text', - 'autocorrect' => 'off', - 'autocapitalize' => 'off', - 'required' => 'required', - 'tabindex' => 1 ) ) . // tab in before the edit textarea "

\n"; } - */ /** * Show a message asking the user to enter a captcha on edit -- 2.30.2