PDA

View Full Version : به جای کد کپچای تولید شده تو اون لحظه کپچای قبلی تو سشن خیره میشه



saeed-71
پنج شنبه 06 شهریور 1393, 10:03 صبح
سلام.
به جای کد کپچای تولید شده تو اون لحظه کپچای قبلی تو سشن خیره میشه
اون مقدار $text باید ذخیره بشه تو سشن اما اون کپتچا که ذخیره نمیشه کد بعدی که تولید میه ذخیره میشه!


<?php
require_once str_replace('\\', '/', dirname(__FILE__)) . '/config.php';
function AutoLoad($className) {
if(file_exists(ROOT . 'inc/class.' . $className . '.php')) {
require_once ROOT . 'inc/class.' . $className . '.php';
}
if(file_exists(ROOT . 'inc/interface.' . $className . '.php')) {
require_once ROOT . 'inc/interface.' . $className . '.php';
}
}
spl_autoload_register('AutoLoad');
header('Content-type:image/png');
$alphabet = array_merge(range('A', 'Z'), range(0, 9));
$text = '';
for($i = 0; $i < 6; $i++) {
$text .= $alphabet[rand(0, count($alphabet) - 1)];
};


$im = imagecreate(150, 40);
$backColor = imagecolorallocate($im, 227, 227, 227);
$font = 'font.ttf';
imagefill($im, 25, 100, $backColor);
$position = 5;
$space = 25;
for($i = 0; $i < 6; $i++) {
$rotate = rand(-5, 5);
$box = ImageTTFBBox(24, $rotate, $font, $text);
$font_size=20;
$foreColor = ImageColorAllocate($im, rand(0, 100), rand(0,100), rand(0, 100));
imagettftext($im, $font_size, $rotate, $position, (33 - $box[5]) / 2, $foreColor, $font, $text[$i]);
$position += $space;
}
for($i = 0; $i < 3; $i++) {
$maskColor = imagecolorallocate($im, rand(60, 100), rand(60, 100), rand(60, 100));
imageline($im, rand(0, 50), rand(10, 40), rand(150, 200), rand(10, 40), $maskColor);
imagearc($im, rand(0, 200), rand(0, 50), rand(10, 20), rand(10, 20), rand(0, 359), rand(0, 359), $maskColor);
}
imagepng($im);
$dbsh = new MySessionHandler();
$_SESSION['captcha'] = strtolower($text);
imagedestroy($im);
?>

prans.info
پنج شنبه 06 شهریور 1393, 10:41 صبح
قبل از ست کردن یه بار سشن رو حذف کنید .


$_SESSION['captcha'] = '';
$_SESSION['captcha'] = strtolower($text);

saeed-71
پنج شنبه 06 شهریور 1393, 10:56 صبح
مرسی ولی جواب نداد