Archive

Archive for February, 2012

ฟังก์ชั่นเช็ค GIF ว่าเป็น Animation หรือไม่

February 16, 2012 Leave a comment

function is_ani($filename) {
$filecontents = file_get_contents($filename);

$str_loc = 0;
$count = 0;
while ($count < 2) { # There is no point in continuing after we find a 2nd frame
$where1 = strpos($filecontents, “\x00\x21\xF9\x04”, $str_loc);
if ($where1 === FALSE) {
break;
} else {
$str_loc = $where1 + 1;
$where2 = strpos($filecontents, “\x00\x2C”, $str_loc);
if ($where2 === FALSE) {
break;
} else {
if ($where1 + 8 == $where2) {
$count++;
}
$str_loc = $where2 + 1;
}
}
}

if ($count > 1) {
return(true);
} else {
return(false);
}
}

Categories: PHP Tags: , , ,

แก้ SSI ของ SMF ให้แสดงผลภาษาไทยไม่เพี้ยน

February 6, 2012 Leave a comment

เหตุเกิดจากตอนที่พยายามจะใช้ SSI ของ SMF ดึงรายการ Recent Topic แต่ปัญหาก็เกิด

คือภาษาไทยแสดงผลไม่ถูกต้อง เป็นเครื่องหมาย ????? ส่วนภาษาอังกฤษแสดงได้ปกติ

ทั้ง ๆ ที่ meta header ก็เป็น UTF8 อยู่แล้ว Database เช็คหมดแล้วก็เป็น UTF General CI

แล้วปัญหามาจากไหนล่ะ !!! สืบไปสืบมาได้เรื่องว่าเกิดจากตัว SSI นี่แหละ

วิธีแก้

1. เปิดไฟล์ SSI.php ขึ้นมา

2. ค้นหาข้อความ loadDatabase();

3. ใส่ mysql_query(‘set names utf8’, $db_connection); ลงในบรรทัดข้างล่าง ต่อจากข้อ 2

หมายเหตุ

1. ที่แก้เป็น SMF Version 2

2. เช็ค Header เว็บคุณว่าเป็น UTF8 แล้วหรือยัง

3. เช็ค Database ที่ prefix smf ว่าเป็น UTF8 แล้วหรือยัง (ถ้ายังต้องเปลี่ยนแล้วล้างข้อมูล SMF)