Capcha image php
Fermé
Bonjour,
pouvez m'aider, j'aimerai faire un système de contrôle lors de l'envois de commentaire comme celui de ce site https://www.ebookuri.ro?id=528&reb=infographie-livre vue que je reçois beaucoup de message dibon, j'ai esseyer quelque code source mais j'y arrive pas, merci d'avance
pouvez m'aider, j'aimerai faire un système de contrôle lors de l'envois de commentaire comme celui de ce site https://www.ebookuri.ro?id=528&reb=infographie-livre vue que je reçois beaucoup de message dibon, j'ai esseyer quelque code source mais j'y arrive pas, merci d'avance
A voir également:
- Capcha image php
- Image iso - Guide
- Acronis true image - Télécharger - Sauvegarde
- Image iso windows 10 - Guide
- Légender une image - Guide
- Faststone image viewer - Télécharger - Visionnage & Diaporama
1 réponse
j'ai esseyer ce code sur ma machine ça marche mais quand je met le site sur le serveur l'image ne s'affiche
<?php
session_start();
// type de flood
$name = $_GET['name'];
// nb de caractères
$strlen = (int) $_GET['strlen'];
// taille de l'image ( width )
$width = $strlen * 30 + 20;
$height = 60;
// création
$img = imagecreatetruecolor( $width, $height );
// antialising, c'est plus bô! :-)
imageantialias( $img, 1 );
// chaine
$string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
$chaine = '';
for( $i = 0; $i < $strlen; $i++ )
$chaine .= $string[ mt_rand( 0, 35 ) ];
$_SESSION['afficheval'] = $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, 25 ),
mt_rand( -30, 30 ),
10 + $i * 30, 35,
$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 );
?>
<?php
session_start();
// type de flood
$name = $_GET['name'];
// nb de caractères
$strlen = (int) $_GET['strlen'];
// taille de l'image ( width )
$width = $strlen * 30 + 20;
$height = 60;
// création
$img = imagecreatetruecolor( $width, $height );
// antialising, c'est plus bô! :-)
imageantialias( $img, 1 );
// chaine
$string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
$chaine = '';
for( $i = 0; $i < $strlen; $i++ )
$chaine .= $string[ mt_rand( 0, 35 ) ];
$_SESSION['afficheval'] = $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, 25 ),
mt_rand( -30, 30 ),
10 + $i * 30, 35,
$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 );
?>