script antibot image

Répondre


Cette question est un moyen d’empêcher des soumissions automatisées de formulaires par des robots.
Smileys
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: =D> #-o =P~ :^o :non: :priere: 8-|
Voir plus de smileys
  Revue du sujet
 

  Étendre la vue Revue du sujet : script antibot image

par scorpion » 16 avr. 2007, 10:55

Ok donc j'ai mit le bout de code ci dessous au debut de ma page et cela ne change rien.
<?php
session_start();
?>

par titerm » 15 avr. 2007, 22:20

Comme cela t'as été déjà dis , au début de ta page, tu utilises $_SESSION alors qu'aucun session_start() n'as été effectué. Met donc ton session_start() au début de ta page,après si cela ne marche pas, on pourra toujours chercher plus avant, mais pour l'instant, cela ne sert a rien car cela ne peut pas fonctionner dans l'état

par scorpion » 15 avr. 2007, 21:17

$_SESSION['ident'] et pour ce code ci :

<img src="http://www.performant-heberg.com/crypt/ ... e=[b]ident[/b]"</center></font></td> <td><input type="text" name="code"></td>

en faite j'ai besoin de 2 verifications :

1. Quand on se connecte avec son login et son passe (verifie si il existe)
2. Verifie si le code et bon

par Truc » 15 avr. 2007, 11:48

Cette seconde page intervient ici je suppose :
 if ($_SESSION["logged_status"]!=0)
        header("location: gestion_adherents.php");
il y a un session_start() au début ?
je ne pense pas puisque tu en à un autre un peu plus bas :
session_start();
                        if(isset($_POST['submit']))
                        {
                        if ($_SESSION['ident'] == $_POST['code']) 
où tu ne devrais pas te retrouver si la redirection est OK.

$_SESSION['ident'] vient d'où ?

Des points de départs...

par Cyrano » 15 avr. 2007, 11:43

Je n,ai pas regardé le code en détail.
Principe général : lorsque tu crées ton image, enregistres les caractères utilisés dans une variable de session. Ensuite lors de la validation, compare la saisie avec le contenu de cette variable de session. Il ne peux dans ce cas pas y avoir d'erreur.

Donc dans ton code, ta page doit également commencer par un session_start() qui te permettra de conserver la variable de session créée et de la récupérer pour le contrôle de validation. Ce session_start() est absent du code que tu as montré.

par scorpion » 15 avr. 2007, 11:30

voila j'espere que sa ira

Re: script antibot image

par Cyrano » 15 avr. 2007, 08:31

jusqu'a la tout se deroule bien l'image s'affiche mais du moment que je veut ecrire le chiffre je peut ecrire n'importe quoi il m'accepte quand meme il em retourne aucune erreur et me laisse passer sur la seconde page qui pourrait m'aider je vous montre ma page
Dis-moi, est-ce que ce serait trop te damander d'utiliser une ponctuation dans tes phrases histoire de rendre tout ça intelligible ? :?

script antibot image

par scorpion » 15 avr. 2007, 01:14

bonsoir a tous j'ai un petit problème que j'arrive pas a resoudre le problème, je vient d'installer se code ci dessous

http://www.phpcs.com/code.aspx?ID=38969#infocode

jusqu'a la tout se deroule bien, l'image s'affiche bien. Quand je veut ecrire le chiffre que l'image me donne je peut ecrire les chiffres different de l'image, il m'accepte quand meme il me retourne aucune erreur et me laisse passer sur la seconde page qui pourrait m'aider je vous montre ma page.
<?php

/* index.php
 * - Identification
 * Copyright (c) 2003 Frédéric Jacquot
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 */
 
	include("includes/config.inc.php"); 
	include(WEB_ROOT."includes/database.inc.php"); 
	include(WEB_ROOT."includes/functions.inc.php"); 
	include(WEB_ROOT."includes/lang.inc.php"); 
	include(WEB_ROOT."includes/session.inc.php"); 
	 
	if (isset($_POST["ident"])) 
	{	
		if ($_POST["login"]==PREF_ADMIN_LOGIN && $_POST["password"]==PREF_ADMIN_PASS)
		{
			$_SESSION["logged_status"]=1;
			$_SESSION["admin_status"]=1;
			$_SESSION["logged_username"]=$_POST["login"];
			$_SESSION["logged_nom_adh"]=_T("Administrateur");
			dblog(_T("Identification"));
		}
		else
		{
			$requete = "SELECT id_adh, bool_admin_adh, nom_adh, prenom_adh
					FROM ".PREFIX_DB."adherents
									WHERE login_adh=" . txt_sqls($_POST["login"]) . "
									AND activite_adh='1'
									AND mdp_adh=" . txt_sqls($_POST["password"]);
			$resultat = &$DB->Execute($requete);
			if (!$resultat->EOF)
			{
				if ($resultat->fields[1]=="1")
					$_SESSION["admin_status"]=1;
				$_SESSION["logged_id_adh"]=$resultat->fields[0];
				$_SESSION["logged_status"]=1;
				$_SESSION["logged_nom_adh"]=strtoupper($resultat->fields[2]) . " " . strtolower($resultat->fields[3]);
				dblog(_T("Identification"));
			}
			else
				dblog(_T("Echec authentification. Login :")." \"" . $_POST["login"] . "\"");
		}
	}
	
    if ($_SESSION["logged_status"]!=0)
		header("location: gestion_adherents.php");
	else
	{ 
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 
<html>
<head>
<title>Performant-Heberg : Espace clients</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Language" content="fr">
<meta name="description" content="Performant-Hosting : Espace clients">
<meta name="keywords" content="Performant-Heberg, heberg, performant, hebergement, bande passante, windows, debian, html, php, perl, mysql, backup, allopass, directadmin, ftp, apache">
<meta http-equiv="identifier-url" name="Identifier-URL" content="">
<meta http-equiv="revisit-after" name="Revisit-after" content="7 days">
<meta http-equiv="robots" name="Robots" content="all">
<meta name="robots" content="INDEX|FOLLOW">
<link href="http://www.performant-heberg.com/style.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.Style8 {color: #000000}
.Style10 {color: #09BAB2}
.Style12 {
	color: #09BAB2;
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-weight: bold;
	font-size: 10px;
}
-->
</style>
</head>
<body bgcolor="#FFFFFF">
<table width="760" height="80" align="center">
  <tr> 
    <td>
	<img border="0" src="http://www.performant-heberg.com/images/logo.gif" width="844" height="112"></td>
  </tr>
</table>
<br>
<table width="835" align="center">
  <tr> 
    <td width="130" valign="top"> 
      <table width="173" border="0" cellpadding="0" cellspacing="0">
                    <tr>
                      <td width="173">
                        <img src="http://www.performant-heberg.com/images/gestion.jpg" width="186" height="50" alt="" />
                        </td>
                    </tr>
                    <tr>
                      <td align="center" valign="middle" background="http://www.performant-heberg.com/images/left_nav_bg.gif">
						<table border="0" align="center" cellpadding="2" cellspacing="0" width="149">
                          <tr valign="top">
                            <td width="5" valign="middle"> <img src="http://www.performant-heberg.com/images/puce.jpg" width="5" height="8" alt="" border="0" /></td>
                            <td width="136" align="left" valign="middle"> 
							<font color="#999999"><b class="Style1">
							<a href="http://www.performant-heberg.com/clients/">
							Panneau de gestion</a></b></font></td>
                          </tr>
                        </table>
                        <table width="173" border="0" cellpadding="0" cellspacing="0">
                    <tr>
                      <td width="173">
                        <img src="http://www.performant-heberg.com/images/paiment.jpg" width="186" height="50" alt="" />
                        </td>
                    </tr>
                    <tr>
                      <td align="center" valign="middle" background="http://www.performant-heberg.com/images/left_nav_bg.gif"><table border="0" align="center" cellpadding="2" cellspacing="0">
                          <tr valign="top">
                            <td width="5" valign="middle"> <img src="http://www.performant-heberg.com/images/puce.jpg" width="5" height="8" alt="" border="0" /></td>
                            <td width="132" align="left" valign="middle"> 
							<b class="Style1">
							<a href="http://www.performant-heberg.com/renouvellement.php">
							Renouvellement</a></b></td>
                          </tr>
                        </table>
                          </td>
                    </tr>
                  </table>
                          </td>
                    </tr>
                  </table>
                  <br>
      <br>
    <td valign="top">

<table width="95%" align="center">

        <td align="center">
			<br><p align="center"><font face="Tahoma" size="3"><b>Espace de votre compte sur Performant-Heberg<br></b></font></p>
			<form action="http://www.performant-heberg.com/clients/interface.php" method="post"> 
				<font face="Tahoma" size="2"><b>Identification</b></font><br>
				<br>
				<table style="height: 65%;" border="1" bordercolor="#3c5f7c" width="60%"> 
				<tbody><tr>
				<td align="center">
				<table> 
					<tbody><tr> 
						<td><font face="Tahoma" size="2">Identifiant :</font></td>
						<td><input name="login" type="text"></td> 
					</tr> 
					<tr> 
						<td><font face="Tahoma" size="2">Mot de passe :</font></td> 
						<td><input name="password" type="password"></td> 
					</tr>
					
					<tr>
						<td><font face="Tahoma" size="2"><center>
						<?
                        session_start();
                        if(isset($_POST['submit']))
                        {
                        if ($_SESSION['ident'] == $_POST['code'])
                        {
                        echo'le code entré est bon';
                        }
                        else
                        {
                        echo' le code entré n\'est pas bon';
                        }
                        }
                        else
                        {
						?>
						<img src="http://www.performant-heberg.com/crypt/anti_spam.php?strlen=4&name=ident"</center></font></td> 
						<td><input type="text" name="code"></td>
					</tr>
					
					
				</tbody></table>
				<br><input name="ident" value="Identification" type="submit"><br>
				</td>
				</tr>
				</tbody></table>
				<br><a href="http://www.performant-heberg.com/clients/lostpasswd.php"><font face="Tahoma" size="2">Mot de passe perdu ?</font></a><br><br><br>
			</form>
		</td>

      </table></td>
    <td width="5">&nbsp;</td>
    </table>
<br>
<table width="760" height="33" align="center" cellpadding="3">
  <tr> 
    <td valign="top" class="txtb" bgcolor="#CCCCCC"><center>© 2007 - 2008, Performant-Herberg.com.</center></td>

  </tr>
</table>
</body>
</html>

<?
	}
?>
<?
	}
?>
et voici le script de mon image (chez un ami il fonctionne tres bien donc a mon avis c'est ma page qui et au dessus)
<?php
session_start();
// type de flood
$name = $_GET['name'];
// nb de caractères
$strlen = (int) $_GET['strlen'];
// taille de l'image ( width )
$width = $strlen * 25 + 20;
$height = 30;
// création
$img = imagecreatetruecolor( $width, $height );
// antialising, c'est plus bô! :-)
imageantialias( $img, 1 );
// chaine
$string = '123456789';
$chaine = '';
for( $i = 0; $i < $strlen; $i++ )
	$chaine .= $string[ mt_rand( 0, 8 ) ];
$_SESSION[ $name ] = $chaine;
// couleur de départ
$c1 = array( mt_rand( 200, 255), mt_rand( 200, 255), mt_rand( 200, 255) );
// couleur finale
$c2 = array( mt_rand( 150, 200), mt_rand( 150, 200), mt_rand( 150, 200) );
$colors = array( imagecolorallocate( $img, 70, 130, 255 ) , imagecolorallocate( $img, 255, 237, 175 ), imagecolorallocate( $img, 166, 250, 186 ), imagecolorallocate( $img, 253, 188, 251 ), imagecolorallocate( $img, 255, 255, 255 ) );
// création de l'image
for( $i = 0; $i < $width; $i++ )
{
	$r = $c1[0] + $i * ( $c2[0] - $c1[0] ) / $width;
	$v = $c1[1] + $i * ( $c2[1] - $c1[1] ) / $width;
	$b = $c1[2] + $i * ( $c2[2] - $c1[2] ) / $width;
	$color = imagecolorallocate( $img, $r, $v, $b );
	imageline( $img, $i, 0, $i, $height, $color );
}
// caractères
for( $i = 0; $i < $strlen; $i++ )
{
	$col = imagecolorallocate( $img, mt_rand( 0, 120 ), mt_rand( 0, 120 ), mt_rand( 0, 120 ) );
	imagettftext( $img, mt_rand( 20, 15 ), mt_rand( 0, 0 ), 10 + $i * 30, 25, $col, 'comic.ttf', $chaine[ $i ] );
}
// quelques lignes qui embêtent
for( $i = 0; $i < 8; $i++ )
{
	imageline( $img, mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $height), $colors[mt_rand( 0, 4 )] );
}
$noir = imagecolorallocate( $img, 0, 0, 0 );
// bordure
imageline( $img, 0, 0, $width, 0, $noir );
imageline( $img, 0, 0, 0, $height, $noir );
imageline( $img, $width - 1, 0, $width - 1, $height, $noir );
// header: image
header("Content-type: image/png");
imagepng( $img ); 
imagedestroy( $img );
?>

merci a vous de votre aide ;)