Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP > PHP Forum > จะเปลี่ยน captcha ภาษาอังกฤษ ให้เป็นภาษาไทยทำไงค่ะ



 

จะเปลี่ยน captcha ภาษาอังกฤษ ให้เป็นภาษาไทยทำไงค่ะ

 



Topic : 054773

Guest




Code (PHP)
<?php
session_start();
// make a string with all the characters that we  
// want to use as the verification code 
//$alphanum  = "ABCDEFGHIJKLMNMPQRSTUVWXYZ4123456789"; 

$alphanum  = "กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรลวศษสหฬอฮ";



// generate the verication code  
$rand = substr(str_shuffle($alphanum), 0, 5); 

// choose one of four background images 
$bgNum = rand(1, 4); 

// create an image object using the chosen background 
$image = imagecreatefromjpeg("background$bgNum.jpg"); 

$textColor = imagecolorallocate ($image, 0, 0, 0);  

// write the code on the background image 
imagestring ($image, 5, 5, 8,  $rand, $textColor);  
     

$text_verify=md5($rand);
session_register("text_verify");
// create the hash for the verification code 
// and put it in the session 
$_SESSION['image_random_value'] = $text_verify; 
     
// send several headers to make sure the image is not cached     
// taken directly from the PHP Manual 
     
// Date in the past  
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");  

// always modified  
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");  

// HTTP/1.1  
header("Cache-Control: no-store, no-cache, must-revalidate");  
header("Cache-Control: post-check=0, pre-check=0", false);  

// HTTP/1.0  
header("Pragma: no-cache");      


// send the content type header so the image is displayed properly 
header('Content-type: image/jpeg'); 

// send the image to the browser 
imagejpeg($image); 

// destroy the image to free up the memory 
imagedestroy($image); 

?>




จาก code ข้างบนลองเปลี่ยนจากตัวภาษาอังกฤษให้เป็นภาษาไทย แล้วอัพขั้นเว็บ

มันไม่ขึ้ภาษาไทยให้ค่ะ แต่เป็นภาษาต่างด้าวแทนอ่ะค่ะ

ไม่รู้ว่าต้องทำยังไง ใครพอจะรู้บ้างค่ะ



Tag : PHP







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2011-01-20 10:33:12 By : กะเจี๊ยบซ่า View : 4157 Reply : 9
 

 

No. 1



โพสกระทู้ ( 681 )
บทความ ( 0 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter

ต้องเอา font ที่เป็นภาษาไทย ที่ใช้ใน captcha ลงไ้้ปด้วยนะ มันจึงจะได้






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-01-20 10:43:57 By : nottpoo
 


 

No. 2

Guest


ขอบคุณนะค่ะ nottpoo ตอนนี้ก็กำลังหาโหลด font อยู่

แต่ font captcah ภาษาไทยมันหายากมากเลยค่ะ

ใครรู้ช่วยบอกหน่อยได้มั้ยค่ะว่าต้องไปโหลดที่ไหน T^T
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-01-20 16:29:26 By : กะเจี๊ยบซ่า
 

 

No. 3

Guest


http://www.f0nt.com
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-01-20 16:33:23 By : i
 


 

No. 4

Guest


ขอ Code CaptCha ภาษาไทย หน่อยค่ะ

ใครพอจะมีบ้างคะ ^ ^
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-01-24 13:17:59 By : กะเจี๊ยบซ่า
 


 

No. 5

Guest


Code (PHP)
<?php 
session_start();
$characters = array(
"ก","ข","ค","ฆ","ง","จ","ฉ","ช","ซ","ช","ฌ","ญ","ฎ","ฏ","ฐ","ฑ","ฒ","ณ","ต","ถ","ท","ธ","น","บ","ป","ผ","พ","ภ","ม","ย","ร","ล","ว","ส","ห","ฬ","อ","ฮ","๑","๒","๓","๔","๕","๖","๗","๘","๙");
$keys = array();

while(count($keys) < 5) {
    $x = mt_rand(0, count($characters)-1);
    if(!in_array($x, $keys)) {
       $keys[] = $x;
    }
}

foreach($keys as $key){
   $random_chars .= $characters[$key];
}
//header ('Content-type: text/html; charset=utf-8'); 

$string=$random_chars;
$_SESSION['rand_code'] = $string;
$hashtext = md5($string);
setcookie('strSec', $hashtext, 0, '/');
$dir = '../balee/';
$image = imagecreatetruecolor(170, 60);
$black = imagecolorallocate($image, 0, 0, 0);
$color = imagecolorallocate($image, 200, 100, 90); // red
$white = imagecolorallocate($image, 255, 255, 255);

imagefilledrectangle($image,0,0,399,99,$white);
imagettftext ($image, 30, 0, 10, 40, $color, $dir."THCharmonmanBold.ttf", $_SESSION['rand_code']); //ห้ามใช้ชื่อว่าง เช่น TH Charmonman.ttf ต้องเปลี่ยนชื่อให้ติดกัน
    header("Content-Type: image/png");
imagepng($image);
imagedestroy($image);
?>

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-08-29 14:21:22 By : chin_ps
 


 

No. 6

Guest


Code (PHP)
หรือแสดงเป็นคำ...

<?php
ob_start();
session_start();
$chars = array("ทานมัย","สีลมัย","ภาวนามัย","ใจเกินร้อย","เซียงเหมี่ยง","ขุนเขา","โพธิสัตว์","โยมหญิง","โยมชาย","อุบาสก","อุบาสิกา","ไวยาวัจกร","ทหารหาญ","ปรินิพพาน","กอแก้ว","ดุจดิน","แผ่นดิน","ภูเสียดฟ้า","เหิรเวหา","กินนรี","บรรพต","ไพบูลย์","รุ่งเรือง","ขันธ์ห้า","วจีกรรม","กายกรรม","มโนกรรม","อินทรีย์","โพชฌงค์","นรกแตก","กรรมหนัก","ผู้ภักดี","คุณธรรม","นำสุขใจ","โลกธรรม","นิพพิทา","นิพพาน","สังวรธรรม","อิทธิบาท","มโนมยิทธิ","พิจารณา","โยนิโส","เบญจขันธ์","ศีลธรรม","มีสมาธิ","ทรงปัญญา","ช้างแก้ว","ไตรรัตน์","สามัคคี","ไร้ตน");
$keys = array();

while(count($keys) < 1) {
    $x = mt_rand(0, count($chars)-1);
    if(!in_array($x, $keys)) {
       $keys[] = $x;
    }
}

foreach($keys as $key){
   $random_chars .= $chars[$key];
}

header ('Content-type: text/html; charset=utf-8'); 
$textstr = $random_chars;
$_SESSION['rand_code']=$textstr;
$hashtext = md5($textstr);
setcookie('strSec', $hashtext, 0, '/');
if (produceCaptchaImage($textstr) != IMAGE_ERROR_SUCCESS) {
    // output header
    header( "Content-Type: image/gif" );

    header("Expires: Mon, 21 Jul 2010 05:00:00 GMT");
    header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
    header("Cache-Control: no-store, no-cache, must-revalidate");
    header("Cache-Control: post-check=0, pre-check=0", false);
    header("Pragma: no-cache" );

    // output error image
    //@readfile('captcha/captcha_error.gif');
}
ob_end_flush();


function produceCaptchaImage($text) {
    // constant values
    $backgroundSizeX = 2000;
    $backgroundSizeY = 350;
    $sizeX = 160;
    $sizeY = 60;
    $fontFile = "balee/THCharmonmanBold.ttf";
    $textLength = strlen($text);

    // generate random security values
    $backgroundOffsetX = rand(0, $backgroundSizeX - $sizeX - 1);
    $backgroundOffsetY = rand(0, $backgroundSizeY - $sizeY - 1);
    $angle = rand(-5, 5);
    $fontColorR = rand(0, 127);
    $fontColorG = rand(0, 127);
    $fontColorB = rand(0, 127);

    $fontSize = rand(26, 24);
    //$textX = rand(0, (int)($sizeX - 0.9 * $textLength * $fontSize)); // these coefficients are empiric
    //$textY = rand((int)(1.25 * $fontSize), (int)($sizeY - 0.2 * $fontSize)); // don't try to learn how they were taken out
    $textX = rand(5, 35); 
    $textY = rand((int)(1.25 * $fontSize), 55); 

    $gdInfoArray = gd_info();
    if (! $gdInfoArray['PNG Support'])
        return IMAGE_ERROR_GD_TYPE_NOT_SUPPORTED;

    // create image with background
    $src_im = imagecreatefrompng( "captcha/captcha/background.png");
    if (function_exists('imagecreatetruecolor')) {
        // this is more qualitative function, but it doesn't exist in old GD
        $dst_im = imagecreatetruecolor($sizeX, $sizeY);
        $resizeResult = imagecopyresampled($dst_im, $src_im, 0, 0, $backgroundOffsetX, $backgroundOffsetY, $sizeX, $sizeY, $sizeX, $sizeY);
    } else {
        // this is for old GD versions
        $dst_im = imagecreate( $sizeX, $sizeY );
        $resizeResult = imagecopyresized($dst_im, $src_im, 0, 0, $backgroundOffsetX, $backgroundOffsetY, $sizeX, $sizeY, $sizeX, $sizeY);
    }

    if (! $resizeResult)
        return IMAGE_ERROR_GD_RESIZE_ERROR;

    // write text on image
    if (! function_exists('imagettftext'))
        return IMAGE_ERROR_GD_TTF_NOT_SUPPORTED;
    $color = imagecolorallocate($dst_im, $fontColorR, $fontColorG, $fontColorB);
    imagettftext($dst_im, $fontSize, -$angle, $textX, $textY, $color, $fontFile, $text);

    // output header
    header("Content-Type: image/png");

    // output image
    imagepng($dst_im);

    // free memory
    imagedestroy($src_im);
    imagedestroy($dst_im);

    return IMAGE_ERROR_SUCCESS;
}

?>


หากจะหาไฟล์ background สามารถโหลดเอาได้ที่ต้นฉบับ
http://www.script-tutorials.com/demos/16/source.zip
ส่วนไฟล์ฟอนต์ ก็หาได้จากลิงค์ที่มีผู้วางไว้แล้ว พอดีทำเวบเกี่ยวกับบาลี เจอแสปมเยอะ ใช้ภาษาอังกฤษ ก็ยังป้องกันยาก เลยหาภาษาไทย ดัดแปรง ประยุกต์จนพอใช้งานได้
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-08-29 16:09:28 By : Balee
 


 

No. 7

Guest


ขอแก้คำว่า ดัดแปรง เป็น ดัดแปลง (เขียนไทยผิด แล้วไม่ได้แก้ไข รู้สึกไม่สบายใจ)
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-08-29 16:30:55 By : chin_ps
 


 

No. 8



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

กระทู้นี้ได้ครับ การแสดงผล Font ที่สร้างจาก PHP GD มันเกิดจากอะไรครับ , GD ภาษาไทย .. ตรงสระมันกระจายมั่วไปหมด
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-08-29 16:35:31 By : webmaster
 


 

No. 9

Guest


ขอบคุณค่ะ กำลังหาอยู่พอดีเลย
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-04-21 01:57:40 By : D
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : จะเปลี่ยน captcha ภาษาอังกฤษ ให้เป็นภาษาไทยทำไงค่ะ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 03
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่