Text_CAPTCHA (Previous) (Next) Text_Figlet

View this page in Last updated: Sun, 28 Sep 2008
English | French | German | Hungarian | Japanese | Polish | Spanish | Plain HTML

Text_CAPTCHA_Numeral

Implémentation des CAPTCHA (Completely Automated Public Turing tests to tell Computers and Humans Apart) par opérations mathématiques.

Introduction

Ce paquet fourni le nécéssaire pour créer des CAPTCHA numériques (Completely Automated Public Turing tests to tell Computers and Humans Apart). Cela comprend les fonctionnalités suivantes:

Ce paquet crée des CAPTCHAs numériques; étant donné la nature sans état du protocole HTTP, la logique pour sécuriser une page utilisant ce paquet doit être specifically implémentée. Regardez l'exemple d'utilisation pour des informations détaillées.

Exemple

L'exemple suivant implémente l'utilisation classique d'un CAPTCHA: Les données d'un formulaire soumis ne sont prise en considération que quand le CAPTCHA a correctement été résolu.

Exemple 64-4. Protéger un forumlaire avec un CAPTCHA numérique

Cet exemple vous présente comment protéger un formulaire en utilisant un CAPTCHA numérique. On génère une opération arithmétique et on conserve la réponse dans une variable de session


<?php
require_once 'Text/CAPTCHA/Numeral.php';
$numcap = new Text_CAPTCHA_Numeral;

if (isset($_POST['captcha']) && isset($_SESSION['answer'])) {
    if ($_POST['captcha'] == $_SESSION['answer']) {
        $errors[] = 'Ok.. Vous êtes probablement un humain..';
    } else {
        $errors[] = 'Soit vous êtes maladroit, soit vous n\'êtes pas humain';
    }
}
    if (!empty($errors)) {
        foreach ($errors as $error) {
            print "<h1><font color='red'>$error</font></h1><br />";
        }
    }


    print '
        <form name="capter" action="index.php?page=liveExample" method="post">
         <table>
          <tr>
           <th>What is this result pilgrim?: '.$numcap->getOperation().'</th>
           <td><input type="text" value="" name="captcha" /></td>
          </tr>
          <tr>
           <th/>
           <td><input type="submit" value="Laissez moi vous prouver que je suis un humain!" /></td>
          </tr>
        </form>
    ';
    $_SESSION['answer'] = $numcap->getAnswer();
?>

Text_CAPTCHA (Previous) (Next) Text_Figlet

Download Documentation Last updated: Sun, 28 Sep 2008
Do you think that something on this page is wrong? Please file a bug report or add a note.
User Notes:
There are no user contributed notes for this page.