|
|
|
|
|
для: NoCash
(08.02.2010 в 07:21)
| | Попробуйте так
<?
// Выставляем уровень обработки ошибок
error_reporting(E_ALL & ~E_NOTICE);
// Ширина изображения
$width = 120;
// Высота изображения
$height = 50;
// Количество символов в коде
$sign = 1;
$sign1 =1;
$sign2=1;
// Защитный код
$code = "";
// Инициируем сессию
session_start();
// Символы, используемые в коде
$letters = array('0','1','2','3','4','5','6','7','8','9');
$letters1 = array('+');
$letters2=array('0','1','2','3','4','5','6','7','8','9');
// Компоненты для RGB-цвета
$figures = array('50','70','90','110',
'130','150','170','190','210');
// Создаем пустое изображение
$img = imagecreatetruecolor($width, $height);
// Заливаем фон белым цветом
$fon = imagecolorallocate($img, 230, 255, 255);
imagefill($img, 0, 0, $fon);
// Накладываем защитный код
for($i=0; $i<$sign; $i++)
{
//Ориентир
$h = 1;
$h1 = 2;
$h2=2;
$h3=3;
//Рисуем
$color = imagecolorallocatealpha(
$img,
$figures[rand(0,count($figures)-1)],
$figures[rand(0,count($figures)-1)],
$figures[rand(0,count($figures)-1)],
rand(10,30));
// Генерируем случайный символ
$letter1 = $letters[rand(0,sizeof($letters)-1)];
$letter2 = $letters1[rand(0,sizeof($letters1)-1)];
$letter3 = $letters2[rand(0,sizeof($letters2)-1)];
// Формируем координаты для вывода символа
if(empty($x)) $x = $width*0.08;
else $x = $x + ($width*0.8)/$sign+rand(0,$width*0.01);
if($h == rand(1,2)) $y = (($height*1)/4) + rand(0,$height*0.1);
else $y = (($height*1)/4) - rand(0,$height*0.1);
//1
if(empty($x1)) $x1 = $width*0.28;
else $x1 = $x1 + ($width*0.28)/$sign1+rand(0,$width*0.01);
if($h1 == rand(1,2)) $y1 = (($height*1)/4) + rand(0,$height*0.1);
else $y1 = (($height*1)/4) - rand(0,$height*0.1);
//2
if(empty($x2)) $x2 = $width*0.38;
else $x2 = $x2 + ($width*0.38)/$sign1+rand(0,$width*0.01);
if($h2 == rand(1,2)) $y2 = (($height*1)/4) + rand(0,$height*0.1);
else $y2 = (($height*1)/4) - rand(0,$height*0.1);
// Запоминаем символ в переменной $code
$code=$letter1+$letter2+$letter3;
// Изменяем регистр символа
if($h == rand(0,1)) $letter = strtoupper($letter1);
if($h1 == rand(0,1)) $letter2 = strtoupper($letter2);
if($h2 == rand(0,1)) $letter3 = strtoupper($letter3);
// Выводим символ на изображение
imagestring($img, 6 ,$x, $y, $letter1, $color);
imagestring($img, 6 ,$x1, $y1, $letter2, $color);
imagestring($img, 6 ,$x2, $y2, $letter3, $color);
}
// Помещаем защитный код в сессию
$_SESSION['code'] = $code;
// Выводим изображение
header ("Content-type: image/jpeg");
imagejpeg($img);
?>
|
| |
|
|
|
|
|
|
|
для: class
(08.02.2010 в 07:18)
| | пожалуйста
<?
// Выставляем уровень обработки ошибок
error_reporting(E_ALL & ~E_NOTICE);
// Ширина изображения
$width = 120;
// Высота изображения
$height = 50;
// Количество символов в коде
$sign = 1;
$sign1 =1;
$sign2=1;
// Защитный код
$code = "";
// Инициируем сессию
session_start();
// Символы, используемые в коде
$letters = array('0','1','2','3','4','5','6','7','8','9');
$letters1 = array('+');
$letters2=array('0','1','2','3','4','5','6','7','8','9');
// Компоненты для RGB-цвета
$figures = array('50','70','90','110',
'130','150','170','190','210');
// Создаем пустое изображение
$img = imagecreatetruecolor($width, $height);
// Заливаем фон белым цветом
$fon = imagecolorallocate($img, 230, 255, 255);
imagefill($img, 0, 0, $fon);
// Накладываем защитный код
for($i=0; $i<$sign; $i++)
{
//Ориентир
$h = 1;
$h2=2;
$h3=3;
//Рисуем
$color = imagecolorallocatealpha(
$img,
$figures[rand(0,count($figures)-1)],
$figures[rand(0,count($figures)-1)],
$figures[rand(0,count($figures)-1)],
rand(10,30));
// Генерируем случайный символ
$letter1 = $letters[rand(0,sizeof($letters)-1)];
$letter2 = $letters1[rand(0,sizeof($letters1)-1)];
$letter3 = $letters2[rand(0,sizeof($letters2)-1)];
// Формируем координаты для вывода символа
if(empty($x)) $x = $width*0.08;
else $x = $x + ($width*0.8)/$sign+rand(0,$width*0.01);
if($h == rand(1,2)) $y = (($height*1)/4) + rand(0,$height*0.1);
else $y = (($height*1)/4) - rand(0,$height*0.1);
//1
if(empty($x1)) $x1 = $width*0.28;
else $x1 = $x1 + ($width*0.28)/$sign1+rand(0,$width*0.01);
if($h1 == rand(1,2)) $y1 = (($height*1)/4) + rand(0,$height*0.1);
else $y1 = (($height*1)/4) - rand(0,$height*0.1);
//2
if(empty($x2)) $x2 = $width*0.38;
else $x2 = $x2 + ($width*0.38)/$sign1+rand(0,$width*0.01);
if($h2 == rand(1,2)) $y2 = (($height*1)/4) + rand(0,$height*0.1);
else $y2 = (($height*1)/4) - rand(0,$height*0.1);
// Запоминаем символ в переменной $code
$code=$letter1+$letter2+$letter3;
// Изменяем регистр символа
if($h == rand(0,1)) $letter = strtoupper($letter1);
if($h1 == rand(0,1)) $letter2 = strtoupper($letter2);
if($h2 == rand(0,1)) $letter3 = strtoupper($letter3);
// Выводим символ на изображение
imagestring($img, 6 ,$x, $y, $letter1, $color);
imagestring($img, 6 ,$x1, $y1, $letter2, $color);
imagestring($img, 6 ,$x2, $y2, $letter3, $color);
}
// Помещаем защитный код в сессию
$_SESSION['code'] = $code;
// Выводим изображение
header ("Content-type: image/jpeg");
imagejpeg($img);
?>
|
| |
|
|
|
|
|
|
|
для: NoCash
(08.02.2010 в 07:02)
| | Выложите файл captcha.php | |
|
|
|
|
|
|
| картинка на линуксе отображается на на виндоусе нет!!! у каво какие мысли??
<form method="post">
<img src="captcha.php" border="0" alt="Введите защитный код"><br>
<input type="text" name="code"><br>
<input class='button' type='submit' name='text' value="разместить" class='tbox' >
|
| |
|
|
| |
|