Je me doute que je ne dois pas être le premier à demander ce type d'aide, mais j'ai eu beau chercher parmi les posts anciens, je n'ai pas vraiment trouvé mon bonheur...
Alors voilà :
L'accès à mon site se fait par une page "index.php" sur laquelle les utilisateurs doivent se connecter par un login et un mdp. Je souhaite sécuriser cette entrée par un captcha et voici le script d'un captcha récupéré sur le net en enregistré dans un fichier "captcha.php" :
Code : Tout sélectionner
<?php
$width=110;
$height=40;
$image=imagecreatetruecolor($width,$height);
$couleur1 = imagecolorallocate($image, $rouge=rand(0,255), $vert=rand(0,255), $bleu=rand(0,255));
imagefill($image,0,0,$couleur1);
$couleur2= imagecolorallocate($image,255-$rouge,255-$vert,255-$bleu);
$nbr_caractere=rand(5,7);
$taille_char_min=14;
$taille_char_max=18;
$char_autorise = 'ABCDEFGHKLMNPRTWXYZ234569';
$x = 4;
$inter_space = 18;
$i=0;
while($i<$nbr_caractere)
{
$caractere_setting[$i]['caractere']=$char_autorise{rand(0,strlen($char_autorise)-1)};
$caractere_setting[$i]['taille']=rand($taille_char_min, $taille_char_max);
$caractere_setting[$i]['angle']=rand(-20,20);
imagettftext($image,$caractere_setting[$i]['taille'],$caractere_setting[$i]['angle'],$x,30,$couleur2,'ELECHA.TTF',$caractere_setting[$i]['caractere']);
$x+=$inter_space;
$i++;
}
imagepng($image, "captcha.png");
?>Code : Tout sélectionner
<html>
<HEAD>
<title><?php echo TITRE; ?></title>
<link rel="stylesheet" type="text/css" href="css/styles.css" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.Style1 {font-size: xx-small}
-->
</style>
</HEAD>
<BODY onLoad="document.entree.login.focus();">
<br/>
<div id="conteneur">
<div id="titre">
<?php echo TITRE; ?>
</div>
<div id="page">
<br />
<form action="accueil.php" method="post" name="entree" id="entree">
<table border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="4" height="4" background="img/cadre/hg.gif"></td>
<td height="4" background="img/cadre/h.gif"></td>
<td width="4" height="4" background="img/cadre/hd.gif"></td>
</tr>
<tr>
<td width="4" background="img/cadre/g.gif"></td>
<td>
<table border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="4" height="4"></td>
<td height="4"></td>
<td width="4" height="4"></td>
</tr>
<tr>
<td width="4"></td>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="3" class="tabtitre">Accès restreint</td>
</tr>
<tr>
<td height="10" colspan="2" class="tabtit"> </td>
<td class="simple"> </td>
</tr>
<tr>
<td class="tabtitd">Identifiant :</td>
<td width="10" class="tabtit"> </td>
<td class="simpleg"><input name="login" type="text" style="simpled"></td>
</tr>
<tr>
<td class="tabtit"> </td>
<td class="tabtit"> </td>
<td class="tabtit"> </td>
</tr>
<tr>
<td class="tabtitd">Mot de passe :</td>
<td> </td>
<td class="simple"><input name="mdp" type="password"></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td colspan="3" class="ligne"></td>
</tr>
//C'est à cet endroit que j'aimerais un captcha...
<tr>
<td colspan="3" class="ligne"></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td colspan="3" class="tabtit"><input type="submit" name="button" id="button" value="Valider la saisie et accéder au <?php echo LOGO; ?>">
<input name="envoi" type="hidden" value="oui"> </td>
</tr>
</table>
</td>
<td width="4"></td>
</tr>
<tr>
<td width="4" height="4"></td>
<td height="4"></td>
<td width="4" height="4"></td>
</tr>
</table>
</td>
<td width="4" background="img/cadre/d.gif"></td>
</tr>
<tr>
<td width="4" height="4" background="img/cadre/bg.gif"></td>
<td height="4" background="img/cadre/b.gif"></td>
<td width="4" height="4" background="img/cadre/bd.gif"></td>
</tr>
</table>
</form>
<p class="simplec"><?php echo LOGO; ?>. Version 1.1</p>
</div>
<div id="pied">
</body>
</html>