![Antiguo](http://static.forosdelweb.com/fdwtheme/images/statusicon/post_old.gif)
15/06/2009, 12:59
|
| | Fecha de Ingreso: mayo-2007
Mensajes: 135
Antigüedad: 17 años, 9 meses Puntos: 1 | |
no funsiona captcha !! (codigo de verficacion) Buenas gente, miren tengo una web, montada en mi PC
La estoy editando, y me he fijado que el capcha no funsiona
-al incicar sesion
-al regsitrarse como nuevo usuario
El codigo de verificacion en .PNG no aparece, y no tengo el codigo para poerlo en al darle en el "box" de vericacion , pues ovio que me dice que el codigo no es correcto Aqui esta el codigod el image.php
Código:
<?php
session_start();
// Juego de letras para usar
$letras = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
// Configuración tamaño imagen y tamaño fuente
$ancho_caja = 130;
$alto_caja = 60;
$tam_letra = 10;
$tam_letra_grande = 45;
// angulo máximo que rota (izq y der) cada letra
$angmax = 20;
// Establecer el tipo de contenido
header("Content-type: image/png");
// Creamos una imagen
$im = imagecreate($ancho_caja, $alto_caja);
// Creo el color del texto, del texto del fondo y del fondo de la imagen
$gris = ImageColorAllocate($im, 247, 247, 247);
$colorLetra = ImageColorAllocate($im, 105, 159, 189);
$colorLetraFondo = ImageColorAllocate($im, 247, 247, 247);
// tipo de letra obtenido en dafont.net
$fuente = './image2.ttf';
// Calculo el número de lÃ*neas que entran
$caja_texto = imagettfbbox($tam_letra, 0, $fuente , $letras);
$alto_linea = abs($caja_texto[7]-$caja_texto[1]);
$num_lineas = intval($alto_caja / $alto_linea)+1;
// Dibujo las letras del fondo
// Cada letra de escribe de una en una para poder
// darle una rotación independiente al resto
$pos = 0;
for ($i = 0; $i<$num_lineas; $i++) {
$x = 0;
for ($j = 0; $j<30; $j++) {
$texto_linea = $letras[rand(0, strlen($letras)-1)].' ';
$caja_texto = imagettfbbox($tam_letra, 0, $fuente , $texto_linea);
imagettftext($im, $tam_letra, rand(-$angmax, $angmax), $x, $alto_linea*$i, $colorLetraFondo, $fuente , $texto_linea);
// Posicion x de la siguiente letra
$x += $caja_texto[2] - $caja_texto[0];
}
}
// Escribo las tres letras del CAPTCHA
$res = $letras[rand(0, strlen($letras)-1)];
$ang1 = rand(-$angmax, $angmax);
$caja_texto = imagettfbbox($tam_letra_grande, $ang1, $fuente , $res);
$y1 = abs($caja_texto[7]-$caja_texto[1]);
$x1 = abs($caja_texto[2]-$caja_texto[0]);
$res .= $letras[rand(0, strlen($letras)-1)];
$ang2 = rand(-$angmax, $angmax);
$caja_texto = imagettfbbox($tam_letra_grande, $ang2, $fuente , $res[1]);
$y2 = abs($caja_texto[7]-$caja_texto[1]);
$x2 = abs($caja_texto[2]-$caja_texto[0]);
$res .= $letras[rand(0, strlen($letras)-1)];
$ang3 = rand(-$angmax, $angmax);
$caja_texto = imagettfbbox($tam_letra_grande, $ang3, $fuente , $res[2]);
$y3 = abs($caja_texto[7]-$caja_texto[1]);
$x3 = abs($caja_texto[2]-$caja_texto[0]);
imagettftext($im, $tam_letra_grande, $ang1, ($ancho_caja/2)-(($x1+$x2+$x3)/2), $y1+($alto_caja-$y1)/2, $colorLetra, $fuente , $res[0]);
imagettftext($im, $tam_letra_grande, $ang2, ($ancho_caja/2)-(($x1+$x2+$x3)/2)+($x1), $y2+($alto_caja-$y2)/2, $colorLetra, $fuente , $res[1]);
imagettftext($im, $tam_letra_grande, $ang3, ($ancho_caja/2)-(($x1+$x2+$x3)/2)+($x1+$x2), $y3+($alto_caja-$y3)/2, $colorLetra, $fuente , $res[2]);
imagepng($im);
imagedestroy($im);
imagedestroy($im2);
$_SESSION["texto"] = $res;
?>
y el codigo del login.php
Código:
<?
session_start();
if ($_POST['username']) {
if( strtolower($_POST['code'])!= strtolower($_SESSION['texto'])){
include('header.php');
echo "<br><br>SECURITY CODE ERROR... ";
include('footer.php');
exit();
}
//Comprobacion del envio del nombre de usuario y password
require('funciones.php');
$username=uc($_POST['username']);
$password=uc($_POST['password']);
if ($password==NULL) {
echo "La password no fue enviada";
}else{
require('config.php');
$query = mysql_query("SELECT username,password FROM tb_users WHERE username = '$username'") or die(mysql_error());
$data = mysql_fetch_array($query);
if($data['password'] != $password) {
echo "Login incorrecto";
}else{
$query = mysql_query("SELECT username,password FROM tb_users WHERE username = '$username'") or die(mysql_error());
$row = mysql_fetch_array($query);
mysql_close($con);
$nicke=$row['username'];
$passe=$row['password'];
//90 dias dura la cookie
setcookie("usNick",$nicke,time()+7776000);
setcookie("usPass",$passe,time()+7776000);
$lastlogdate=time();
$lastip = getRealIP();
require('config.php');
$querybt = "UPDATE tb_users SET lastlogdate='$lastlogdate', lastiplog='$lastip' WHERE username='$nicke'";
mysql_query($querybt) or die(mysql_error());
mysql_close($con);
?>
<META HTTP-EQUIV="REFRESH" CONTENT="0;URL=members.php">
<?
}
}
}else{
?>
<? include('header.php'); ?>
<h3>Login</h3>
<br />
<a href="register.php">New User Register Free Account</a>
<br>
<a href="recoverpwd.php">Lost password?</a>
<br><br>
<div align="center"><div id="form">
<fieldset>
<legend>Login</legend>
<form action='login.php' method='POST'>
<table width="400" border="0" align="center">
<tr>
<td width="150" align="left"><p><label>Username</label></p></td>
<td width="250" align="left"><input type='text' size='15' maxlength='25' name='username' autocomplete="off"value="" tabindex="1" /></td>
</tr>
<tr>
<td width="150" align="left"><p><label>Password</label></p></td>
<td width="250" align="left"><input type='password' size='15' maxlength='25' name='password' autocomplete="off" value="" tabindex="2" /></td>
</tr>
<tr>
<td width="150" align="left"><p><label>Security Code </label></p></td>
<td width="250" align="left"><input type='text' size='3' maxlength='3' name='code' autocomplete="off" class="securitycode" value="" tabindex="3" /></td>
</tr>
<tr>
<td width="150" align="left"> </td>
<td width="250" align="left"><img src="image.php?<?php echo $res; ?>" /></td>
</tr>
<tr>
<td width="150" align="left"> </td>
<td width="250" align="right"><input type="submit" value="Enter" class="submit" tabindex="4" />
</td>
</tr>
</table>
</form>
</fieldset>
</div></div>
<? include('footer.php'); ?>
<?
}
?>
y CREO QUE EL register.php tambien tengo que tocarlo, pero eso yo lo ago despues
espero me ayuden con esto
.
Última edición por mario_64k; 15/06/2009 a las 13:13 |