Файл: system/connections/captcha.php
Строк: 77
<?php
/*
--------------------
Совсем простая капча
--------------------
*/
$captha_length = 5;
$captcha_random_seed = "152639487";
IF (ISSET($_REQUEST['image'])) {
FUNCTION write_image_number($num_c) {
$number_c = "R0lGODlhCgAMAIABAFNTU////yH5BAEAAAEALAAAAAAKAAwAAAI";
IF ($num_c == "0") { $len_c = "63"; $number_c.="WjIFgi6e+QpMP0jin1bfv2nFaBlJaAQA7";}
IF ($num_c == "1") { $len_c = "61"; $number_c.="UjA1wG8noXlJsUnlrXhE/+DXb0RUAOw==";}
IF ($num_c == "2") { $len_c = "64"; $number_c.="XjIFgi6e+QpMPRlbjvFtnfFnchyVJUAAAOw==";}
IF ($num_c == "3") { $len_c = "64"; $number_c.="XjIFgi6e+Qovs0RkTzXbj+3yTJnUlVgAAOw==";}
IF ($num_c == "4") { $len_c = "64"; $number_c.="XjA9wG8mWFIty0amczbVJDVHg9oSlZxQAOw==";}
IF ($num_c == "5") { $len_c = "63"; $number_c.="WTIAJdsuPHovSKGoprhs67mzaJypMAQA7";}
IF ($num_c == "6") { $len_c = "63"; $number_c.="WjIFoB6vxmFw0pfpihI3jOW1at3FRAQA7";}
IF ($num_c == "7") { $len_c = "61"; $number_c.="UDI4Xy6vtAIzTyPpg1ndu9oEdNxUAOw==";}
IF ($num_c == "8") { $len_c = "63"; $number_c.="WjIFgi6e+QpMP2slSpJbn7mFeWDlYAQA7";}
IF ($num_c == "9") { $len_c = "64"; $number_c.="XjIFgi6e+QpMP0jinvbT2FGGPxmlkohUAOw==";}
HEADER("Content-type: image/gif");
HEADER("Content-length: $len_c");
ECHO BASE64_DECODE($number_c);
}
// Вывод закодированных изображений на экран
IF (ARRAY_KEY_EXISTS('image', $_REQUEST)) {
$num_c = $_REQUEST['image'];
FOR ($i = 0; $i < 10; $i++) {
IF (MD5($i + $captcha_random_seed) == $num_c) {
write_image_number($i);
EXIT;
}
}
}
EXIT;
}
$captcha_key = '';
/*
--------------------
Функция вывода капчи
--------------------
*/
FUNCTION CAPTCHA($title, $class) {
//$title - заголовок капчи
//$class - стиль поля ввода чисел с картинки
GLOBAL $captha_length, $captcha_random_seed, $captcha_key;
ECHO "<b>".LG($title).":</b> ";
ECHO "<span class='captcha'>";
FOR ($i = 0; $i < $captha_length; $i++) {
$snum = MT_RAND(0,9);
$psnum = MD5($snum + $captcha_random_seed);
ECHO '<img src="'.PHP_SELF.'?image='.$psnum.'">';
$captcha_key .= $snum;
}
ECHO "</span><br /><br />";
$captcha_key = MD5($captcha_key + $captcha_random_seed);
ECHO "<input name='captcha_key' type='hidden' value='$captcha_key'>";
ECHO "<input placeholder='".LG('Числа')."' name='captcha' class='".$class."' type='text' maxlength='$captha_length' size='$captha_length'><br /><br />";
}
?>