beh3000
پنج شنبه 27 آذر 1393, 21:12 عصر
سلام
من از کپچایی که استاد شهرکی توی یکی از پست هاشون گذاشته بودن استفاده میکنم کار هم میکنه خیلی وقته ... یعنی کار میکرد الام که سیستم رو روشن کردم دیدم کار نمیکنه ... روی تصویر کپچا کلیک کردم و new tab باز کردم دیدم این خطا رو میده
CDbException
CDbConnection failed to open the DB connection.
کد کپچا :
<?php
$yii = dirname(__FILE__) . '/../../framework/yii.php';
$config = dirname(__FILE__) . '/../protected/config/main_cnfg.php';
require_once ($yii);
Yii::createWebApplication($config);
$height = 34;
$width = 100;
$length = 4;
$minLength=4;
$maxLength=5;
$lineCount = 3;
$circleCount = 2;
$maxRadius = 50;
$space = 15;
$length = mt_rand($minLength,$maxLength);
$alpha = range('A', 'Z');
$string = '';
for($i = 0; $i < $length; $i++)
$string .= substr(str_shuffle("0123456789"), 0, 1);
Yii::app()->session->open();
Yii::app()->session->add('captcha', strtolower($string));
header('Content-type: image/png');
$im = imagecreate($width, $height);
$backColor = imagecolorallocate($im, 255, 255, 255);
$font = './BYekan.ttf';
$fontsize = $height * 0.75;
$box = imagettfbbox($fontsize, 0, $font, $string);
$positionX = (($width - $space * $length) / 2)-10;
$direction = 1;
imagefill($im, $width / 2, $height / 2, $backColor);
for($i = 0; $i < $length; $i++) {
$char = substr($string, $i, 1);
$angle = rand(-20, 20);
$s=rand(1,2);
if($s==1)
$textColor = imagecolorallocate($im, 17,162,78);
elseif($s==2)
$textColor = imagecolorallocate($im, 34,34,34);
$xx1=rand(0,100);
$xx2=rand(0,100);
$yy1=rand(0,40);
$yy2=rand(0,40);
imageline($im, $xx1, $xx2, $yy1, $yy2, $textColor);
$xx1=rand(0,100);
$xx2=rand(0,100);
$yy1=rand(0,40);
$yy2=rand(0,40);
imageline($im, $xx1, $xx2, $yy1, $yy2, $textColor);
imagettftext($im, $fontsize, $angle, $positionX, ($height - $box [5]) / 2, $textColor, $font, $char);
$direction = -$direction;
$positionX += $space;
}
imagepng($im);
imagedestroy($im);
?>
من از کپچایی که استاد شهرکی توی یکی از پست هاشون گذاشته بودن استفاده میکنم کار هم میکنه خیلی وقته ... یعنی کار میکرد الام که سیستم رو روشن کردم دیدم کار نمیکنه ... روی تصویر کپچا کلیک کردم و new tab باز کردم دیدم این خطا رو میده
CDbException
CDbConnection failed to open the DB connection.
کد کپچا :
<?php
$yii = dirname(__FILE__) . '/../../framework/yii.php';
$config = dirname(__FILE__) . '/../protected/config/main_cnfg.php';
require_once ($yii);
Yii::createWebApplication($config);
$height = 34;
$width = 100;
$length = 4;
$minLength=4;
$maxLength=5;
$lineCount = 3;
$circleCount = 2;
$maxRadius = 50;
$space = 15;
$length = mt_rand($minLength,$maxLength);
$alpha = range('A', 'Z');
$string = '';
for($i = 0; $i < $length; $i++)
$string .= substr(str_shuffle("0123456789"), 0, 1);
Yii::app()->session->open();
Yii::app()->session->add('captcha', strtolower($string));
header('Content-type: image/png');
$im = imagecreate($width, $height);
$backColor = imagecolorallocate($im, 255, 255, 255);
$font = './BYekan.ttf';
$fontsize = $height * 0.75;
$box = imagettfbbox($fontsize, 0, $font, $string);
$positionX = (($width - $space * $length) / 2)-10;
$direction = 1;
imagefill($im, $width / 2, $height / 2, $backColor);
for($i = 0; $i < $length; $i++) {
$char = substr($string, $i, 1);
$angle = rand(-20, 20);
$s=rand(1,2);
if($s==1)
$textColor = imagecolorallocate($im, 17,162,78);
elseif($s==2)
$textColor = imagecolorallocate($im, 34,34,34);
$xx1=rand(0,100);
$xx2=rand(0,100);
$yy1=rand(0,40);
$yy2=rand(0,40);
imageline($im, $xx1, $xx2, $yy1, $yy2, $textColor);
$xx1=rand(0,100);
$xx2=rand(0,100);
$yy1=rand(0,40);
$yy2=rand(0,40);
imageline($im, $xx1, $xx2, $yy1, $yy2, $textColor);
imagettftext($im, $fontsize, $angle, $positionX, ($height - $box [5]) / 2, $textColor, $font, $char);
$direction = -$direction;
$positionX += $space;
}
imagepng($im);
imagedestroy($im);
?>