MediaWiki:Tuning

Z ωικι.matfyz.cz
Přejít na: navigace, hledání

Captcha

These are captcha patches to MediaWiki 1.4.5 used on this site.


extensions/authimage-inc/

http://dev.wp-plugins.org/wiki/AuthImage


extensions/authimage-inc/veriword.ini

...
randomword_length = 
...


extensions/authimage-inc/words/words.txt

Tip: Create your own captcha word dictionary!


extensions/authimage.php

<?php
/*
Plugin Name: AuthImage
Plugin URI: http://www.gudlyf.com/index.php?p=376
Description: Creates an authentication image to help combat spam in comments.
Version: 3.0
Author: Keith McDuffee
Author URI: http://www.gudlyf.com/

Modified by miEro
*/

$sess_key_name = "veriword"; // Don't change this
$authimage = "/extensions/authimage-inc/image.veriword.php";

function checkAICode($code)
{
  global $sess_key_name;

  require_once("authimage-inc/class.verificator.php");
  $veri = new VeriFicator($code);
  $verified = $veri->verified();

  $return = ($verified == 1) ? 1 : 0;
  if(!isset($_SESSION[$sess_key_name])) {
    $return = 0;
  } else {
    unset($_SESSION[$sess_key_name]);
  }

  return $return;
}

?>

includes/EditPage.php

$ diff -u EditPage.php.old EditPage.php
--- EditPage.php.old    2005-05-27 13:18:20.000000000 +0200
+++ EditPage.php        2005-11-14 12:33:34.000000000 +0100
@@ -65,7 +65,10 @@
                        return;
                }
                if ( $this->save ) {
-                       $this->editForm( 'save' );
+                       if ( checkAICode($_POST['code']) || $wgUser->isSysop() )
+                               $this->editForm( 'save' );
+                       else
+                               $this->editForm( 'edit' );
                } else if ( $this->preview ) {
                        $this->editForm( 'preview' );
                } else { # First time through
@@ -150,6 +153,7 @@
        }

        function submit() {
+
                $this->edit();
        }

@@ -170,7 +174,7 @@
                global $wgWhitelistEdit;
                global $wgSpamRegex, $wgFilterCallback;
                global $wgUseLatin1;
-
+
                $sk = $wgUser->getSkin();
                $isConflict = false;
                // css / js subpages of user pages get a special treatment
@@ -535,11 +539,18 @@
 {$commentsubject}
 <textarea tabindex='1' accesskey=\",\" name=\"wpTextbox1\" rows='{$rows}'
 cols='{$cols}'{$ew}>" .
-htmlspecialchars( $wgContLang->recodeForEdit( $this->textbox1 ) ) .
-"
+htmlspecialchars( $wgContLang->recodeForEdit( $this->textbox1 ) ) . "
 </textarea>
-<br />{$editsummary}
+<table><tr><td>
+{$editsummary}
 {$checkboxhtml}
+<p>
+<label for=\"code\">Enter phrase from image (or skip for another): </label>
+<input type=\"text\" name=\"code\" id=\"code\" value=\"\" size=\"20\" tabindex=\"4\"/>
+</p>
+</td><td valign=\"bottom\">
+<img style=\"border:1px solid black\" src=\"$GLOBALS[authimage]\" alt=\"authimage\"/><br/>
+</td></tr></table>
 <input tabindex='5' id='wpSave' type='submit' value=\"{$save}\" name=\"wpSave\" accesskey=\"".wfMsg('accesskey-save')."\"".
 " title=\"".wfMsg('tooltip-save')."\"/>
 <input tabindex='6' id='wpPreview' type='submit' value=\"{$prev}\" name=\"wpPreview\" accesskey=\"".wfMsg('accesskey-preview')."\"".

includes/SpecialUserlogin.php

$ diff -u SpecialUserlogin.php.old SpecialUserlogin.php
--- SpecialUserlogin.php.old    2005-04-25 05:17:58.000000000 +0200
+++ SpecialUserlogin.php        2005-11-11 19:47:38.000000000 +0100
@@ -51,6 +51,7 @@
                $this->mLoginattempt = $request->getCheck( 'wpLoginattempt' );
                $this->mAction = $request->getVal( 'action' );
                $this->mRemember = $request->getCheck( 'wpRemember' );
+               $this->mCode = $request->getVal( 'wpCode' );

                if( $wgEnableEmail ) {
                        $this->mEmail = $request->getText( 'wpEmail' );
@@ -74,14 +75,18 @@
                        $this->onCookieRedirectCheck( $this->mCookieCheck );
                        return;
                } else if( $this->mPosted ) {
-                       if( $this->mCreateaccount ) {
+                       $ok = -1;
+                       if( $this->mCreateaccount && ($ok = checkAICode($this->mCode)) ) {
                                return $this->addNewAccount();
-                       } else if ( $this->mCreateaccountMail ) {
+                       } else if ( $this->mCreateaccountMail && ($ok = checkAICode($this->mCode))) {
                                return $this->addNewAccountMailPassword();
-                       } else if ( $this->mMailmypassword ) {
+                       } else if ( $this->mMailmypassword && ($ok = checkAICode($this->mCode))) {
                                return $this->mailPassword();
                        } else if ( ( 'submitlogin' == $this->mAction ) || $this->mLoginattempt ) {
-                               return $this->processLogin();
+                               if ($ok !== -1)
+                                       return $this->mainLoginForm( 'Incorrect phrase from image. Please, try again with another image.' );
+                               else
+                                       return $this->processLogin();
                        }
                }
                $this->mainLoginForm( '' );

includes/templates/Userlogin.php

$ diff -u Userlogin.php.old Userlogin.php
--- Userlogin.php.old   2005-03-27 18:11:26.000000000 +0200
+++ Userlogin.php       2005-11-11 19:30:41.000000000 +0100
@@ -65,16 +65,24 @@
                                        <input tabindex='7' type='text' name="wpEmail" id="wpEmail"
                                                value="<?php $this->text('email') ?>" size='20' />
                                </td>
+                               <td rowspan="2"><img src="<?php print $GLOBALS['authimage'] ?>" alt="authimage"/></td>
                        <?php } ?>
                        <?php if( $this->data['userealname'] ) { ?>
-                               </tr>
-                               <tr>
+               </tr>
+               <tr>
                                        <td align='right'><label for='wpRealName'><?php $this->msg('yourrealname') ?>:</label></td>
                                        <td align='left'>
                                                <input tabindex='8' type='text' name="wpRealName" id="wpRealName"
                                                        value="<?php $this->text('realname') ?>" size='20' />
                                        </td>
                        <?php } ?>
+               </tr>
+               <tr>
+                               <td align='right'><label for='wpCode'>Enter phrase from image:</label></td>
+                               <td align='left'>
+                                       <input tabindex='7' type='text' name="wpCode" id="wpCode"
+                                               value="" size='20' />
+                               </td>
                        <td align='left'>
                                <input tabindex='9' type='submit' name="wpCreateaccount"
                                        value="<?php $this->msg('createaccount') ?>" />

Other mediawiki customizations

http://www.fxparlant.net/Category:Mediawiki