| Autor | Zpráva | ||
|---|---|---|---|
| tpilar Profil |
#1 · Zasláno: 24. 1. 2013, 11:29:13 · Upravil/a: Moderátor (editace znemožněna) 24. 1. 2013, 18:16:33
www.rexonz.cz
<?php
$width = 100;
$height = 38;
$length = 5;
$font = 'verdana.ttf';
$font_size = 12;
$bg_color = array(255, 173, 91);
$chars = 'ABCDEFGHKMNPQRSTUVWXYZ23456789';
session_start();
putenv('GDFONTPATH=' . realpath('.'));
$img = imagecreatetruecolor($width, $height);
$bkgr = imagecolorallocate($img, $bg_color[0], $bg_color[1], $bg_color[2]);
imagefilledrectangle($img, 0, 0, $width, $height, $bkgr);
$code = '';
for($i = 0; $i < $length; $i++)
{
$code .= $chr = $chars[mt_rand(0, strlen($chars)-1)];
$r = rand(0, 192);
$g = rand(0, 192);
$b = rand(0, 192);
$color = imagecolorallocate($img, $r, $g, $b);
$rotation = rand(-35, 35);
$x = 5+$i*(4/3*$font_size+2);
$y = rand(4/3*$font_size, $height-(4/3*$font_size)/2);
imagettftext($img, $font_size, $rotation, $x, $y, $color, $font, $chr);
}
$_SESSION['random_txt'] = md5($code);
header("Content-type: image/png");
header("Expires: Mon, 01 Jul 1998 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
imagepng($img);
imagedestroy($img);
?> HTML uvedu také ale snažil jsem se to zjednodušit, viz odkaz na stránku : <?php
session_start();
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
if (isset($_POST['captcha_code'],$_SESSION['random_txt']) && md5($_POST['captcha_code']) == $_SESSION['random_txt'])
{
unset($_POST['captcha_code'],$_SESSION['random_txt']);
}
else
{
echo '<b>The entered code was wrong.</b><br>';
echo '<a href="javascript:history.back()">Go Back</a>';
exit;
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "[url=http://www.w3.org/TR/html4/loose.dtd]http://www.w3.org/TR/html4/loose.dtd[/url]">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Untitled Page</title>
<meta name="generator" content="WYSIWYG Web Builder - [url=http://www.wysiwygwebbuilder.com]http://www.wysiwygwebbuilder.com[/url]">
<style type="text/css">
div#container
{
position: absolute;
left: 50%;
top: 50%;
width: 650px;
height: 460px;
margin-top: -230px;
margin-left: -325px;
}
</style>
<style type="text/css">
body
{
background-color: #FFFFFF;
color: #000000;
}
</style>
</head>
<body>
<div id="container">
<div id="wb_Image1" style="position:absolute;left:30px;top:19px;width:592px;height:423px;z-index:0;" align="left">
<img src="images/pozadibezove.jpg" id="Image1" alt="" align="top" border="0" style="width:592px;height:423px;"></div>
<div id="wb_Captcha1" style="position:absolute;left:143px;top:140px;width:296px;height:68px;z-index:1;" align="left">
<img src="captcha1.php" alt="Click for new image" title="Click for new image" style="cursor:pointer;width:100px;height:38px;" onclick="this.src='captcha1.php?'+Math.random()">
<input type="text" id="Captcha1Edit" style="position:absolute;left:106px;top:18px;width:196px;height:18px;border:1px #C0C0C0 solid;font-family:Courier New;font-size:13px;" name="captcha_code" value=""></div>
</div>
</body>
</html> Předem díky. |
||
|
Časová prodleva: 13 let
|
|||
0