Ideas for improved versions.
[toast/cookiecaptcha.git] / CookieCaptcha.class.php
1 <?php
2
3 class CookieCaptcha extends SimpleCaptcha {
4         // Check whether the cookie is present
5         function keyMatch($answer, $info) {
6                 global $wgCaptchaCookieName;
7                 if (isset($_COOKIE[$wgCaptchaCookieName])) {
8                         wfDebug( "CookieCaptcha: Found cookie\n" );
9                         return parent::keyMatch($answer, $info);
10                 } else {
11                         wfDebug( "CookieCaptcha: Didn't find cookie...\n" );
12                         return false;
13                 }
14         }
15
16
17         function getForm() {
18                 global $wgCaptchaCookieName, $wgCaptchaCookieImage, $wgCaptchaCookieAlt, $wgCaptchaCookieStyle;
19                 return parent::getForm() . "<p>" .
20                         Html::element( 'img', array(
21                                 'src'    => $wgCaptchaCookieImage,
22                                 'alt'    => $wgCaptchaCookieAlt,
23                                 'style'  => $wgCaptchaCookieStyle ) ) .
24                         "</p>\n";
25         }
26
27 }