Les modifications pour un captcha ?

Fermé
cyberien Messages postés 8 Date d'inscription samedi 3 mai 2008 Statut Membre Dernière intervention 4 mai 2008 - 3 mai 2008 à 21:47
cyberien Messages postés 8 Date d'inscription samedi 3 mai 2008 Statut Membre Dernière intervention 4 mai 2008 - 4 mai 2008 à 17:24
Bonjour,

Je souhaite mettre un captcha sur mon site, sur la page d'enregistrement. je ne connais pas grand chose en PHP, je me débrouille en m'aidant par le net. Mais sa fais plusieurs jours que je cherche et je ne trouve rien.

Donc pour mettre un captcha dans mon formulaire d'enregistrement.

J'ai un patch qui devrait faire ceci mais l'explication et pas clair, dumoins j'ai du mal a comprendre.

Si vous pouvez m'eclair voici le contenu du patch.

# Patch to add an anti-bot captcha in user registration
#
# you also need QuickCaptcha 1.0 for image creation, as well as PHP-GD (bundled)
# QuickCaptcha is available at https://www.web1consulting.com/
#
# GPL Code
#
diff -r templates/register.tpl.php.orig templates/register.tpl.php
30a31,36
>     <th align="left"><label for="captcha"><?php echo T_('Captcha');?></label></th>
>     <td><input MAXLENGTH=8 SIZE=8 name="imagepasswd" type="text" value="" class="required" /></td>
>     <td><img src="/imagebuilder.php" border="1" /></td>
> </tr>
> 
> <tr>
40c46
< ?>
\ Kein Zeilenumbruch am Dateiende.
---
> ?>
diff -r register.php.orig register.php
27a28,35
> // image verification
> 
> require ('captchasettings');
>     $imagestring = strtoupper($_SESSION['imagestring']);
>     $imagepasswd = strtoupper($_POST['imagepasswd']);
> 
> // end image verification
> 
46a55,59
>     // Check if captcha is ok 
>     } elseif (!($imagepasswd == $imagestring)) {
> 	$tplVars['error'] = T_('You entered the wrong code. Please try again!');
> 
> 





Voici le code original de Mes 2 fichier :

Le fichier register.tpl.php

<?php
$this->includeTemplate($GLOBALS['top_include']);
?>

<script type="text/javascript">
window.onload = function() {
    document.getElementById("username").focus();
}
</script>

<p><?php echo sprintf(T_('Sign up here to create a free %s account. All the information requested below is required'), $GLOBALS['sitename']); ?>.</p>

<form action="<?php echo $formaction; ?>" method="post">
<table>
<tr>
    <th align="left"><label for="username"><?php echo T_('Username'); ?></label></th>
    <td><input type="text" id="username" name="username" size="20" class="required" onkeyup="isAvailable(this, '')" /></td>
    <td id="availability"></td>
</tr>
<tr>
    <th align="left"><label for="password"><?php echo T_('Password'); ?></label></th>
    <td><input type="password" id="password" name="password" size="20" class="required" /></td>
    <td></td>
</tr>
<tr>
    <th align="left"><label for="email"><?php echo T_('E-mail'); ?></label></th>
    <td><input type="text" id="email" name="email" size="40" class="required" /></td>
    <td></td>
</tr>

<?php if(strlen($antispamQuestion)>0) {?>
<tr>
    <th align="left"><label for="question"><?php echo T_('Antispam question'); ?></label></th>
    <td><input type="text" id="antispamAnswer" name="antispamAnswer" size="40" class="required" value="<?php echo $antispamQuestion ?>"/></td>
    <td></td>
</tr>
<?php } ?>

<tr>
    <td></td>
    <td><input type="submit" name="submitted" value="<?php echo T_('Register'); ?>" /></td>
    <td></td>
</tr>
</table>
</form>

<?php
$this->includeTemplate($GLOBALS['bottom_include']);
?>


-----------------



Le fichier register.php

<?php

require_once('header.inc.php');
$userservice =& ServiceFactory::getServiceInstance('UserService');
$templateservice =& ServiceFactory::getServiceInstance('TemplateService');

$tplVars = array();

if ($_POST['submitted']) {
    $posteduser = trim(utf8_strtolower($_POST['username']));

    // Check if form is incomplete
    if (!($posteduser) || !($_POST['password']) || !($_POST['email'])) {
        $tplVars['error'] = T_('You <em>must</em> enter a username, password and e-mail address.');

    // Check if username is reserved
    } elseif ($userservice->isReserved($posteduser)) {
        $tplVars['error'] = T_('This username has been reserved, please make another choice.');

    // Check if username already exists
    } elseif ($userservice->getUserByUsername($posteduser)) {
        $tplVars['error'] = T_('This username already exists, please make another choice.');
    
    // Check if e-mail address is valid
    } elseif (!$userservice->isValidEmail($_POST['email'])) {
        $tplVars['error'] = T_('E-mail address is not valid. Please try again.');

    // Check if antispam answer is valid
    } elseif (strcmp($_POST['antispamAnswer'], $GLOBALS['antispamAnswer']) != 0) {
        $tplVars['error'] = T_('Antispam answer is not valid. Please try again.');

    // Register details
    } elseif ($userservice->addUser($posteduser, $_POST['password'], $_POST['email'])) {
        // Log in with new username
        $login = $userservice->login($posteduser, $_POST['password']);
        if ($login) {
            header('Location: '. createURL('bookmarks', $posteduser));
        }
        $tplVars['msg'] = T_('You have successfully registered. Enjoy!');
    } else {
        $tplVars['error'] = T_('Registration failed. Please try again.');
    }
}

$tplVars['antispamQuestion'] = $GLOBALS['antispamQuestion'];
$tplVars['loadjs']      = true;
$tplVars['subtitle']    = T_('Register');
$tplVars['formaction']  = createURL('register');
$templateservice->loadTemplate('register.tpl', $tplVars);
?>


En vous remerciant d'avance .

5 réponses

cyberien Messages postés 8 Date d'inscription samedi 3 mai 2008 Statut Membre Dernière intervention 4 mai 2008
3 mai 2008 à 22:43
personne n'a une idée ?
0
cyberien Messages postés 8 Date d'inscription samedi 3 mai 2008 Statut Membre Dernière intervention 4 mai 2008
4 mai 2008 à 02:05
bon je n'ai toujour pas trouvé grrrr
0
cyberien Messages postés 8 Date d'inscription samedi 3 mai 2008 Statut Membre Dernière intervention 4 mai 2008
4 mai 2008 à 11:42
Toujour rien c'est dommage
0
cyberien Messages postés 8 Date d'inscription samedi 3 mai 2008 Statut Membre Dernière intervention 4 mai 2008
4 mai 2008 à 13:50
Mon sujet à l'air d'interessé personne sur le forum.

Alors un peu de changement

J'ai mis dans register.tpl.php

ceci
<th align="left"><label for="captcha"><?php echo T_('Captcha');?></label></th>
<td><input MAXLENGTH=8 SIZE=8 name="imagepasswd" type="text" value="" class="required" /></td>
<td><img src="/imagebuilder.php" border="1" /></td>
</tr>

<tr>
par contre la balise ci dessous je sais pas si elle importante
< ?>
\ Kein Zeilenumbruch am Dateiende.



et dans register.php
j'ai mis ceci

// image verification

require ('captchasettings');
$imagestring = strtoupper($_SESSION['imagestring']);
$imagepasswd = strtoupper($_POST['imagepasswd']);

// end image verification


// Check if captcha is ok
} elseif (!($imagepasswd == $imagestring)) {
$tplVars['error'] = T_('You entered the wrong code. Please try again!');
</code>

mon captcha s'affiche dans le formulaire mais il me dit toujour que le code n'est pas correct.
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
cyberien Messages postés 8 Date d'inscription samedi 3 mai 2008 Statut Membre Dernière intervention 4 mai 2008
4 mai 2008 à 17:24
Heureusement que je suis là pour me répondre de temp en temp.

sur 32386 connectés personne ne peut m'aider.

alors je laisse tomber.
0