PDA

View Full Version : نمایش کد کپچا؟



nemo php
دوشنبه 21 مرداد 1392, 08:14 صبح
سلام من کد کپچایی نوشتم که توی یک صفحه عادی نمایش داده میشه اما وقتی به صفحه سایت اصلی اضافش میکنم
به جای تصویر، حروف عجیبی نمایش میده و صفحه پر میشه از اون حروف عجیب؟ کد های صفحه اصلی شامل کد های htmlوphpهستش؟

titreaval
دوشنبه 21 مرداد 1392, 08:32 صبح
جنس صفحه ات تصویر نیست



header("Content-type: application/jpeg");



بعد برای گرفتن داده و اعتبار سنجی باید هر دو جا از شروع سیشن استفاده کنی

من تا الان 20 نوع کپچا درست کردم
فارسی عددی متنی
با فونت . بی فونت

اگه نشد بزار اینجا بهت بگم

nemo php
دوشنبه 21 مرداد 1392, 12:42 عصر
ممنون اما همه این کارا رو انجام دادم
ولی صفحه اصلیم یک تگ متا داره که تو اونجا نوع صفحه رو مشخص مردم وتوی فابل کد کپچا هم نوع عکسو مشخص کردم .
باشه کدشو واستون میزارم .
اما مشکل از قسمت html نیست که تگ متا رو تعریف کردم.

qartalonline
دوشنبه 21 مرداد 1392, 12:53 عصر
کدتون رو قرار بدین.

nemo php
سه شنبه 22 مرداد 1392, 09:07 صبح
این کد کپچاست :


<?php
session_start();
function random_string($len=5, $str='')
{ for($i=1; $i<=$len; $i++ )
{ //generates a random number that will be the ASCII code of the character.
//We only want numbers (ascii code from 48 to 57) and caps letters.
$ord=rand(48, 90);
if((($ord >= 48) && ($ord <= 57)) || (($ord >= 65) && ($ord<= 90)))
$str.=chr($ord); //If the number is not good we generate another one
else
$str.=random_string(1);
} return $str;}
//create the random string using the upper function
//(if you want more than 5 characters just modify the parameter)
$rand_str=random_string(5);
// جدا کردن رشته به صورت 5 کاراکتر
$letter1=substr($rand_str,0,1);
$letter2=substr($rand_str,1,1);
$letter3=substr($rand_str,2,1);
$letter4=substr($rand_str,3,1);
$letter5=substr($rand_str,4,1);
//Creates an image from a png file. If you want to use gif or jpg images,
//just use the coresponding functions: imagecreatefromjpeg and imagecreatefromgif.
$image=imagecreatefrompng("images/verify.png");
//Get a random angle for each letter to be rotated with.
// تعیین زاویه نمایش کاراکترها
$angle1 = rand(-30, 30);
$angle2 = rand(-30, 30);
$angle3 = rand(-30, 30);
$angle4 = rand(-30, 30);
$angle5 = rand(-30, 30);
//Get a random font. (In this examples, the fonts are located in "fonts" directory and named from 1.ttf to 10.ttf)
// تعیین فونت برای نمایش هر یک از کاراکترها
$font1 = 'font/'.rand(1,5).'.ttf';
$font2 = 'font/'.rand(1,5).'.ttf';
$font3 = 'font/'.rand(1,5).'.ttf';
$font4 = 'font/'.rand(1,5).'.ttf';
$font5 = 'font/'.rand(1,5).'.ttf';

//Define a table with colors (the values are the RGB components for each color).

//Get a random color for each letter.
// تعیین رنگ برای هر یک از کاراکتر ها
$color1=rand(0,255);
$color2=rand(0,255);
$color3=rand(0,255);
$color4=rand(0,255);
$color5=rand(0,255);
//Allocate colors for letters.
$textColor1 = imagecolorallocate ($image, $color1,10, $color3);
$textColor2 = imagecolorallocate ($image, $color4,40, $color2);
$textColor3 = imagecolorallocate ($image, $color2,60, $color1);
$textColor4 = imagecolorallocate ($image, $color3,110, $color5);
$textColor5 = imagecolorallocate ($image, $color5,120, $color4);

//Write text to the image using TrueType fonts.
// تعیین سایز برای هر یک از کاراکترها
$size1 = rand(17,23);
$size2 = rand(17,23);
$size3 = rand(17,23);
$size4 = rand(17,23);
$size5 = rand(17,23);
// تعیین موقعیت نمایش برای هر کدام از کاراکترها
$y_pos1 = rand(27,40);
$y_pos2 = rand(27,40);
$y_pos3 = rand(27,40);
$y_pos4 = rand(27,40);
$y_pos5 = rand(27,40);

imagettftext($image, $size1, $angle1, 12, $y_pos1, $textColor1, $font1, $letter1);
imagettftext($image, $size2, $angle2, 40, $y_pos2, $textColor2, $font2, $letter2);
imagettftext($image, $size3, $angle3, 70, $y_pos3, $textColor3, $font3, $letter3);
imagettftext($image, $size4, $angle4, 100, $y_pos4, $textColor4, $font4, $letter4);
imagettftext($image, $size5, $angle5, 130, $y_pos5, $textColor5, $font5, $letter5);

$_SESSION['image_verification'] = $rand_str;

header('Content-type: image/png');
//Output image to browser
//imagejpeg($image);
imagepng($image);
//Destroys the
imagedestroy($image);



?>








اینم کد صفحه:




<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>پروفایل مدیریت</title>
<link href="css/head.css" rel="stylesheet" type="text/css" />
<link href="../../SpryAssets/SpryValidationPassword.css" rel="stylesheet" type="text/css" />
<link href="../../SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
<link href="../../SpryAssets/SpryValidationConfirm.css" rel="stylesheet" type="text/css" />
<script src="../../SpryAssets/SpryValidationPassword.js" type="text/javascript"></script>
<script src="../../SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<script src="../../SpryAssets/SpryValidationConfirm.js" type="text/javascript"></script>
</head>

<body>
<div class="head">
<span>

</span>
</div>
<div align="center">
<div class="divmenu">

<table border="0">
<tr>
<td width="128">پروفایل مدیریت</td>
</tr>
<tr>
<td>مدیریت کاربران</td>
</tr>
<tr>
<td>وضعیت فروش </td>
</tr>
<tr>
<td>مدیریت منو ها</td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td>اضافه کردن صفحه</td>
</tr>
<tr>
<td>تنظیمات کتاب</td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td>تنظیمات سایت</td>
</tr>
<tr>
<td>مسدود کردن سایت</td>
</tr>
<tr>
<td>راهنما</td>
</tr>
<tr>
<td>تنضیمات سرور</td>
</tr>
<tr>
<td>نمایش سایت</td>
</tr>
<tr>
<td>خروج</td>
</tr>
</table>

</div>

<div class="divrightmanager">
<form method="post" action="<?php $_SERVER['HTTP_HOST'] ?>" >
<div align="left">
<fieldset style="text-align:left; width:350px"><legend >مشخصات مدیر</legend>
<p><label for="fullname">نام:</label>
<input type="text" name="fullname " id="fullname" class="txt" />

</p>
<p>
<label for="lastname">نام خانوادگی : </label>
<input type="text" name="lastname " id="lastname" class="txt" />

</p>
<p>
<label for="tel">تلفن: </label>
<input type="text" name="tel " id="tel" class="txt" />

</p>
<p>
<label for="address">آدرس :</label>
<input type="text" name="address " id="address" class="txt" />

</p>
<p> <label for="fax">فکس :</label>
<input type="text" name="fax" id="fax" class="txt" />

</p>
<p>
<label for="lastname">تلفکس :</label>
<input type="text" name="telfax" id="telfax" class="txt" />

</p>
<p>
<label for="email">ایمیل:</label>
<input type="text" name="email" id="email" class="txt" />
</p>
<p>
<input name=" managersave" type="submit" value="ذخیره تغییرات"/>
</p>
</fieldset>
</div>
</form>
<form method="post" action="">
<div align="right" style="position: absolute; top: 1px; left: 386px; width: 519px; height: 319px;">

<fieldset style="text-align: left; width: 532px; position: absolute; left: 10px; top: 2px; height: 334px;"><legend >تغییر رمز</legend>
<p>
<span id="sprytextfield1">
<label for="name">نام کاربری:</label>
<input type="text" name="text1" id="text1" class="txt" />
<span class="textfieldRequiredMsg">نام کاربری را وارد کنید</span></span>
</p>
<p>

<span id="sprypassword1">
<label for="password1">رمز قبلی : </label>
<input type="password" name="password1" id="password1" class="txt" />
<span class="passwordRequiredMsg">لظفا رمز را وارد نمایید</span></span>

</p>
<p>
<label for="newpass">رمز جدید: </label>
<input type="text" name="newpass " id="newpass" class="txt" />

</p>
<p>
<label for="re-pass">تکرار رمز جدید :</label>
<span id="spryconfirm1">
<input type="text" name="re-pass " id="re-pass" class="txt" />
<span class="confirmRequiredMsg">پسورد صحیح نیست</span><span class="confirmInvalidMsg">The values don't match.</span></span></p>
<p>
<label for="captcha"> <?php echo "<a href=managerprofile.php>بازسازی</a><br>\n"; ?> </label>


<?php
require_once("captcha.php");

?>


</p>
<p>
<label for="captcha"> کد تصویر :</label>
<input type="text" name="captcha" id="captcha" class="txt" />

</p>
<p>


</p>
</fieldset>
<input name="savepass" type="submit" class="btn" value="دخیره تغییرات" />

</div>
</form>
</div>
<script type="text/javascript">
var sprypassword1 = new Spry.Widget.ValidationPassword("sprypassword1", {validateOn:["blur", "change"]});
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", "none", {validateOn:["blur", "change"]});
var spryconfirm1 = new Spry.Widget.ValidationConfirm("spryconfirm1", "newpass", {validateOn:["blur", "change"]});
</script>
</body>
</html>

qartalonline
سه شنبه 22 مرداد 1392, 09:18 صبح
شما باید از تصویر کپچا بصورت زیر در صفحه html استفاده کنید:

<img src="captcha.php" >

nemo php
سه شنبه 22 مرداد 1392, 09:38 صبح
ببخش اما اگه در مورد رسم نمودار ها مثل pchart یا غیره اطلاعاتی دارین میشه لطف کنید آموزششو بگید اگه انگلیسیم باشه مهم نیست.ممنون

qartalonline
سه شنبه 22 مرداد 1392, 09:48 صبح
منظورتون رسم خط تو تصویر کپچا هستش؟

nemo php
چهارشنبه 23 مرداد 1392, 08:35 صبح
نه رمسم نمودار آماری توی سایت!

qartalonline
چهارشنبه 23 مرداد 1392, 08:50 صبح
لینک زیر رو ببینید:
http://pchart.sourceforge.net/documentation.php?topic=exemple1