วันจันทร์ที่ 29 ตุลาคม พ.ศ. 2555

[SMF] ข้อควรระวังก่อนการอัพเกรดเวอร์ชั่น


ข้อควรระวังก่อนการอัพเกรดเวอร์ชั่นจาก 1.10++ เป็นเวอร์ชั่น 2.0

วันก่อนนั่งอัพเกรอบอร์ดเวอร์ชั่น  1 เป็นเวอร์ชั่น 2.0.2 มั่นใจเต็มที่เพราะเคยอัพเกรดมาแล้วหลายต่อหลายครั้ง
ครั้งนี้เลยไม่คิดจะbackup ข้อมูลอะไรไว้ก่อนเลย

อัพเกรดครั้งแรก ..ไม่สำเร็จ
ครั้งที่สอง...เหมือนจะสำเร็จ
ครั้งที่สาม..ล้มเหลวเหมือนเดิม
ครั้งนี้ ผมเลยมานั่งหาสาเหตุ ... และก็พบสาเหตุ คือ มีmod บางตัวที่เข้าไปสร้างตารางไว้ในดาต้าเบสและเป็นตารางที่เวลาอัพเกรดแล้ว ไม่ยอมรับการเปลี่ยนแปลง พอระบบมาเจอตารางนี้เข้าก็หยุดทำงาน
ที่ถูกต้องเอา mod ทั้งหมดออกก่อน ก่อนทำการอัพเกรด แต่ครั้งนี้ผมถอดมอดไม่ทันแล้ว ต้องเดินหน้าต่อไป วิธีแก้คือ ลบตารางของมอดเจ้าปัญหาทั้งหมดออก!!

แล้วลองอัพเกรดใหม่..

ครั้งนี้..สำเร็จ แต่..ข้อมูลที่ดึงจากฐานข้อมูลเป็นตัวประหลาดหมดเลย!!

ทั้งๆที่เมนูต่างๆเป็นภาษาไทย แต่กระทู้ทั้งหมดกลายเป็นตัวประหลาด นั่งแก้ทั้งคืนก็ไม่หาย เลยต้องเข้านอนก่อนพรุ่งนี้ค่อยว่ากันใหม่

เช้าต่อมา นำดาต้าเบสข้างบนลงมาข้างล่างและลอง install ลงในเครื่องทุกอย่างปกติ ตัวหนังสือปกติ ..ผมค่อยใจชื้นขึ้นมาหน่อย
แต่ปัญหาที่ตามมาติดๆ  คือ ไม่สามารถเอาฐานข้อมูลจากเครื่องขึ้นไปข้างบนได้เลย!!

วิธีแก้ ดูจะง่อยไปหน่อย แต่เหมือนว่าจะเป็นวิธีสุดท้ายที่เหลืออยู่
ผมนั่ง dump ตารางของ smf ทุกตัว ซึ่งมี 63 ตารางลงมาข้างล่างก่อน แล้วค่อย import เข้าฐานข้อมูลผ่าน PHPMyAdmin ทีละตารางๆ

เรียบร้อยครับ บอร์ดผมมามีชีวิตและมีชาติไทยเหมือนเดิมแล้ว

ข้อควรระวังสำหรับเรื่องนี้ คือ ก่อนอัพเกรด ต้อง
1. เลือกธีมให้เป็นธีมdefault 
2. เลือกภาษาอังกฤษ
3. ถอด mod ทั้งหมดออกก่อน

วันพฤหัสบดีที่ 11 ตุลาคม พ.ศ. 2555

"เว็บดีไซน์" ควรคำนึงอะไรบ้าง??


ไม่ได้เขียนเองครับ ไปเจอบทความของฝรั่งมา เขาเขียนไว้เกี่ยวกับนักออกแบบเว็บว่าควรคำนึงอะไรบ้างในยุคปัจจุบัน ก่อนลงมือทำเว็บ
ม่ะ มาดูกัน


1. Responsive Design
ยุคนี้คงไม่พูดถึงไม่ได้แล้วว่าคนเข้าเว็บของเราจากช่องทางไหนบ้าง มันเข้ามาจากทุกช่องทาง นี่ถ้าตู้เย็นต่ออินเทอร์เนตได้ ก็คงจะมีคนเข้าเว็บเราจากตู้เย็น วิทยุ หรือหม้อหุงข้าว!!
Responsive คือ การออกแบบเว็บไซต์ให้แสดงผลได้ดีในทุกแฟลตฟอร์ม ไม่ว่าจะเป็นสมาร์ทโฟน ไอโฟน หรือเซ็กโฟน (อันหลังนี่ไม่ใช่นะครับ ไม่รู้จะตลกไปไหน)  ต้องให้เว็บดูดีทั้งใน PC , Notebook  และโทรศัพท์มือถือ

2. HTML5 & CSS3
เริ่มไม่ใหม่เท่าไรแล้วสำหรับ HTML5 & CSS3 เมื่อก่อนเรายังกล้าๆกลัว ๆ กั๊กๆ ไม่อยากใช้ เพราะมีบราวเซอร์รุ่นพ่อของพ่อของพ่อของพ่อของพ่อ ฯลฯ อย่างไออี6อยู่  แต่ปัจจุบันบราวเซอร์ที่ตอบสนองทุกท่วงท่าและลีลาอยาง Chrome , Firefox หรือ IE8 มีคนเริ่มใช้กันเยอะขึ้นมาก และทางเจ้าของเว็บไซต์ก็ไม่ค่อยแคร์ด้วยว่ายูเซอร์จะใช้ ie6 หรือไม่? ประมาณว่า ถ้ามึงจะเข้าเว็บกู อย่ามาด้วยie6  จะเข้าคฤหาสน์แต่ดันปั่นจักรยานมาใครจะให้เข้า!!

3. Minimalistic Design
ไปเจอคำจำกัดความของคำนี้ คือ "เรียบง่ายแต่ได้ประโยชน์มาก" ว่ากันว่าคนที่เข้ามาในเว็บเรานั้น เขาต้องการอ่านข้อมูลแบบสบายๆ ไม่ถูกบีบด้วยพื้นที่อันคับแคบ หรือดีไซน์ที่จัดจ้านจนอ่านลำบาก ดังนั้น การออกแบบที่เรียบง่า่ย แต่แฝงด้วยกึ๋นส์ จึงเป็นคำตอบสำหรับเว็บในปัจจุบัน

4. Content First Approach
เว็บในปัจจุับันเริ่มแข่งขันกันที่ content หรือเนื้อหาเป็นหลัก ดังนั้น เมื่อยูเซอร์คลิกเข้าเว็บมาแล้ว ต้องเสนอเนื้อหาให้อยู่ในระดับสายตาที่เห็นก่อน โดยไม่ต้องลากสโคลบาร์ลงล่าง หรือปิดโฆษณาก่อนถึงจะเห็นเนื้อหา มันจะทำให้หงุดหงิดใจเปล่าๆ


5. Rich Typography
การเลือกใช้ฟ้อนท์ ขนาด และสีที่อ่านง่ายเหมาะสมกับเว็บ ประเภทพื้นสีแดง ตัวหนังสือสีเหลือง ไม่ไหวนะครับ ตาจะบอด


6. Social Media Friendly
ทุกวันนี้คนเป็นประเภทพวกขี้อวด ขี้แบ่ง เจออะไรดีๆ (หรือไม่ดี) ไม่กดlike ก็ตกกด share ดังนั้น หาปุ่ม like หรือปุ่ม share ให้เขาหน่อย เผื่อเขาแบ่งไปยังเพื่อนๆของเขาแล้ว เพื่อนๆพวกนั้นจะช่วยแบ่งต่อไปอย่างไม่รู้จักสิ้น

ต้องขออภัยคนที่ต้องการเนื้อหาสาระแน่นๆนะครับ ผมเอาแค่หัวข้อของฝรั่งมา ส่วนรายละเอียดสรุปเอามาเีขียนใหม่ เพราะถ้าขืนแปลตามฝรั่งเขา คงออกทะเลจมน้ำตายไปแล้วครับ

อย่างไรก็ดี 6 ข้อนี้ ก็ควรระลึกถึงเสมอเมื่อจะออกแบบเว็บนะครับ

คลิกเข้าไปดูต้นฉบับเขาได้ที่ http://www.cssreflex.com/2012/08/consider-these-web-design-trends-in-your-next-project.html/

วันพุธที่ 10 ตุลาคม พ.ศ. 2555

ปัญหา fgetcsv กับ ภาษาไทย

เขียนโปรแกรมให้เขาupload ไฟล์ .csv แล้วบันทึกลง MySQL  ทดสอบในเครื่องก็ได้ทุกอย่าง แต่พอเอาขึ้นเซิฟเวอร์ ปรากฏว่าฟิลด์ที่เป็นภาษาไทย ใช้ไม่ได้เลย  งัดมาสารพัดวิธี ทั้ง iconv ทั้งแปลงไฟล์ให้เป็น utf-8 ก็ยังไม่ได้ สุดท้ายได้คำตอบจากคุณ เล็กน้ำ http://www.leknarm.com/2010/03/fgetcsv-php.html  ซึ่งมีใจความว่า..

เนื่องจากได้เขียน php โดยอ่านไฟล์จากไฟล์ csv ซึ่งมีข้อความภาษาไทยอยู่ โดยเมื่อทดสอบบนเครื่องตัวเองนั้นไม่มีปัญหาใดๆ ทั้งสิ้นแต่เมื่อ deploy ขึ้นไปบน server ดันเกิดปัญหาขึ้นโดย ภาษาไทยนั้นไม่แสดงผล

จากที่ลอง research ดูก็ไล่ไปเรื่อยๆ ตั้งแต่ check ว่าเปิดไฟล์ได้ไหม echo ภาษาไทยได้ไหม และก็มาเจอประเด็นที่ fgetcsv

จากที่อ่านใน http://php.net/manual/en/function.fgetcsv.php ซึ่งมีเขียนไว้ว่า

Note: Locale setting is taken into account by this function. If LANG is e.g. en_US.UTF-8, files in one-byte encoding are read wrong by this function.

แสดงว่าเราต้องทำการ set locale ให้กับ apache การแสดงผลจึงจะถูกต้องโดยใช้คำสั่ง


setlocale ( LC_ALL, 'en_US.UTF-8' );

แค่นี้ก้จะทำให้การ get csv ที่มีภาษาไทยภายในไฟล์แสดงผลได้ถูกต้องแล้วครับ

..

แต่มันก็ยังไม่หาย 100% คือเป็นภาษาไทยครับ แต่ทุกฟิลด์ที่เป็นภาษาไทย คำแรกจะหายไป เลยลองแก้จาก
setlocale ( LC_ALL, 'en_US.UTF-8' ); เป็น setlocale ( LC_ALL, 'Thai' );

ปรากฏว่าใช้ได้ครับ ..

ในวันที่ "แกมี" มา

ตั้งใจจะทำธีม SMF มาแจกเรื่อยๆ แต่ช่วงนี้ยุ่งเหลือเกินครับ
นานๆทีเข้ามาทักทาย ส่วนอีเมล์ที่สอบถามมาก็พยายามตอบไปเท่าที่จะตอบได้นะครับ

คำถามไหนที่เห็นว่าเป็นประโยชน์กับคนอื่นๆด้วย ผมจะเขียนเป็นบทความแทน

วันนี้มาสั้นๆ ลากันด้วยภาพขำๆ ภาพนี้ละกันครับ

ป.ล. กลัวเนื้อหาจะไม่เข้ากับชื่อ ขอพูดถึง "แกมี" สักหน่อย เพราะตอนนี้กำลังหวั่นเกรงว่าเจ้าแกมีจะเข้าประเทศ หลังจาก "แกมี" ผ่านมาแว่บๆ มีผลทำให้ฝนตกเกือบทุกวัน แต่ตอนนี้ "แกมี" เริ่มจากไปแล้วละ ทุกอย่างกำลังจะกลับสู่ภาวะปกติ โชคดีนะ "แกมี" แต่วันหลังไม่ต้องมา

กูเหนื่อยรถติด ~

วันเสาร์ที่ 29 กันยายน พ.ศ. 2555

[SMF]การปรับpermission หรือการอนุญาตในบอร์ด



โจทย์ คือ ต้องการให้สมาชิกบางกลุ่ม อ่านได้อย่างเดียวในบางบอร์ด

1. ล็อกอินเข้าระบบแอดมิน
2. ไปที่ ผู้ดูแล > ควบคุมสมาชิก > Permissions > Edit Profiles
3. ดูด้านล่างที่แทบ New Profile มี 2 ช่องในการสร้าง Profile ใหม่
    -  Profile Name:  ตั้งชื่อโปรไฟล์ใหม่
    - Copy Permissions From: เลือกโปรไฟล์ต้นแบบ
4. คลิกCreate

5. หลังจากสร้างแล้วเราจะได้ Profile ตัวใหม่ที่เกิดจากน้ำมือที่เราสร้างขึ้นมา คลิกไปที่โปรไฟล์ใหม่นั้นเลย
6. ระบบจะนำไปยังหน้าจัดการ 'การอนุญาต' ทีนี้เราจะกำหนดให้กลุ่มไหนทำอะไรได้ ก็กำหนดตรงนี้เลยให้เสร็จ  (อย่าลืมกำหนดให้อ่านได้อย่างเดียวด้วยตามโจทย์ที่ตั้งไว้)

7. จากนั้นไปที่เมนู Permission By Board
8. เราอยากให้บอร์ดไหนอ่านได้อย่างเดียว คลิกที่ชื่อบอร์ดนั้นเลย
9. หลังจากคลิกแล้ว ดูด้านล่าง เมนู Permission Profile:
 เลือกโปรไฟล์ที่เราได้สร้างไว้ในข้อที่ 3  แล้วคลิกปุ่ม แก้ไข
10. เสร็จพิธี

วันพฤหัสบดีที่ 30 สิงหาคม พ.ศ. 2555

[SMF] เพิ่ม thumbnail ในหน้ากระทู้รวม


วันนี้มานำเสนอไอเดีย การปรับแต่งบอร์ดให้มีความน่าสนใจมากขึ้น ด้วยการเพิ่ม thumbnail และหัวข้อกระทู้ในหน้ากระทู้รวม ตามภาพ


(ดูตัวอย่างจริงที่ http://phithan-toyota.com/forums/index.php/board,18.0.html)

ดูภาพประกอบคำอธิบายนะครับ
ผมดึงภาพเป็น thumbnail จากกระทู้โดยการสุ่ม ดึงมาแค่ 4 กระทู้และดึงสุ่มมาทุกครั้งที่แสดงพร้อมกับหัวข้อกระทู้ เพื่อเพิ่มความน่าสนใจกับบอร์ดมากขึ้น

ถัดลงมาจากนั้น จะเป็นกรอบและมีชื่อหมวดหมู่เว็บบอร์ด ภาพประจำหมวดหมู่ และคำอธิบายเว็บบอร์ดที่เพิ่มในหน้าแอดมิน ทั้งนี้เพื่อให้คนเข้าเว็บบอร์ดเมื่อคลิกมายังหน้ารวมแล้ว ไม่หลงทาง รู้ว่าตัวเองอยู่ห้องไหนอยู่

เป็นทิปสั้นๆนะครับ ลองเข้าไปปรับดูที่ไฟล์  MessageIndex.template.php ส่วนรายละเอียดว่าปรับยังไง ตรงจุดไหนบ้าง เดี๋ยวค่อยว่ากันต่อในบทความถัดไป

อันนี้แค่เกริ่นนำพอเป็นไอเดียก่อน

วันพุธที่ 29 สิงหาคม พ.ศ. 2555

SMF เวอร์ชั่นไหนดี??

เจอคำถามนี้ค่อนข้างบ่อย
จะใช้เวอร์ชั่นไหนดี 2 หรือ 1 ดี
เข้าไปดูในเว็บของ smf  เขาก็มีให้ดาวน์โหลดทุกเวอร์ชั่นที่ผ่านมาจนถึงเวอร์ชั่นล่าสุด ตามภาพ
ถ้าถามผมว่าเวอร์ชั่นไหนดี ก็คงต้องบอกอย่างนี้ครับ
สำหรับคนที่ทำบอร์ดใหม่ๆเลย เป็นบอร์ดเริ่มแรก ก็จัดเวอร์ชั่นใหม่ล่าสุดไปเลย คือ เวอร์ชั่น 2.0.1 

แต่สำหรับคนที่มีบอร์ดอยู่ก่อนแล้ว ต้องไปดูครับว่าบอร์ดของท่านเวอร์ชั่นไหน
ถ้าเป็นเวอร์ชั่น 1 ก็อัพเวอร์ชั่นให้ใหม่ที่สุดของเวอร์ชั่น 1  ก็คือ  1.1.16  
แต่ถ้าเป็นเวอร์ชั่น 2 ก็อัพเวอร์ชั่นให้ใหม่ที่สุดของเวอร์ชั่น 2 นั่นก็คือ 2.0.1 

แบบนี้ก็ได้เหมือนกัน
แต่บางท่านอยากอัพเวอร์ชั่นจาก 1 ไป 2 เลยแบบนี้ก็ได้ แต่ก็มีความเสี่ยงอย่างที่ผมเคยเขียนไว้แล้วในวิธีอัพเกรดเวอร์ชั่น (อ่านที่นี่ http://nevikup.blogspot.com/2011/08/smf-upgrade-smf-20.html)

คำถามต่อมาก็คือ เวอร์ชั่น 1 กับ 2 มันต่างกันยังไง และมีข้อดีข้อเสียอย่างไร?

จริงๆในเว็บของ smf เขาได้เขียนไว้ค่อนข้างละเอียดมากเรื่องความแตกต่างกันของ 2 เวอร์ชั่น แต่่ผมจะขอพูดถึงในส่วนที่เห็นชัดและเกี่ยวข้องกับเรา
ในแง่ของโค๊ดคำสั่งก็ต่างจากเดิมไปมากพอสมควร ดังนั้น mod ในเวอร์ชั่น 1 จึงใช้ไม่ได้ในเวอร์ชั่น 2 แน่นอน (นอกเสียจากเอามาโมดิฟายก่อน)

ส่วนเรื่องของโครงสร้าง เวอร์ชั่น 1 เน้นตารางเป็นหลัก แต่พอมาเป็นเวอร์ชั่น 2 ตารางเหลือน้อยจนแทบจะไม่มีแล้วครับ ใช้ div เป็นหลัก ซึ่งนั่นเป็นข้อดี เพราะจะทำให้เราออกแบบและปรับปรุงในเรื่องของหน้าตา ดีไซน์ได้ง่ายขึ้น

ข้อดีอีกอย่างของเวอร์ชั่น 2 คือ บอร์ดจะเร็วกว่าเวอร์ชั่น 1 ค่อนข้างเห็นได้ชัด
จริงๆมีมากกว่านี้ครับ แต่พอที่เราเห็นได้ด้วยตาเปล่าก็ประมาณนี้

่ส่วนข้อเสีย สแปมมีมั้ย? ก็มีพอๆกับเวอร์ชั่น 1 ครับ  แต่ก็มีตัวจัดการให้อยู่หมัดได้ ถ้าเป็นเวอร์ชั่น 1 ต้องลง mod ไว้ดักสแปม

สรุป  จัดเวอร์ชั่น 2 ไปเลยครับท่านมันส์กว่ากันเยอะ


วันพฤหัสบดีที่ 23 สิงหาคม พ.ศ. 2555

[SMF] Quick Post เติมเครื่องมือให้ตอบด่วน



เพิ่มเครื่องมือเครื่องไม้ให้เต็มสูบในช่อง Quick Post ประโยชน์คือทำให้ผู้ตอบกระทู้ไม่ต้องคลิก ตอบ เพื่อเปิดไปหน้าใหม่
แต่ให้สามารถโพสต์ในหน้านั้นได้เลย (ดูภาพ)


สะดวกต่อผู้ใช้ครับ อะไรที่ทำให้ผู้ใช้สะดวกและง่าย ถือเป็นสิ่งควรปฏิบัติครับ คลิกไปดูวิธีทำได้ที่ลิงค์ด้านล่างนี้นะ
http://nevikup.blogspot.com/2012/07/smf-quick-post-full-post.html

วันพุธที่ 1 สิงหาคม พ.ศ. 2555

[SMF] ตัวอย่างธีม SMFแสดงกระทู้เป็นลิสต์แบ่งเป็นห้อง

วันนี้หากินง่าย ๆ
เอาตัวอย่างเว็บบอร์ดของ smf มาให้ชมครับ
เป็นบอร์ดของเว็บที่เป็นdealer ของโตโยต้า

บอร์ดตัวนี้ใช้ Tab jQuery มาดึงกระทู้ล่าสุดของทุกห้องมาแสดง ห้องละ 5 กระทู้ แบ่งcontent เป็น 2 คอลัมน์ เนื้อหาหลักยังฝั่งซ้ายและมีเมนูย่อยอยู่ฝั่งขวา
ดูภาพตัวอย่างและดูของจริงกันเลยดีกว่าครับ

ดูตัวอย่างจริงที่ www.phithan-toyota.com/forums/

วันพฤหัสบดีที่ 26 กรกฎาคม พ.ศ. 2555

[SMF] ทำช่องตอบด่วน(Quick Post) ให้มีเครื่องมือและไอค่อนเหมือนตอบเต็ม (Full Post)

วันนี้ขอสั้นๆจริงๆ เพราะไม่ได้เขียนเองครับ
ไปเห็นบทความที่เขาเขียนไว้แล้วเกี่ยวกับการ ทำช่องตอบด่วน ให้มีเครื่องมือเครื่องไม้ รวมถึงไอค่อนต่างๆให้เหมือนตอบกระทู้แบบเต็มๆได้

เขาเขียนไว้ดีแล้วครับที่นี่ http://www.zone-it.com/stocks/data/90/90777.html 
จงไปเสพ ณ บัดนาว

หมายเหตุ : เนื่องจากกลัวกระทู้ดังกล่าวที่เขาเขียนไว้ จะหายไปตามกาลเวลา เลยขออนุญาตนำมาแปะไว้ที่นี่ด้วยละกันนะ

เปิดไฟล์ display.php
ยัดโค้ดนี่ลงไปก่อนบรรทัดสุดท้าย

// Show an enhanced quick reply box.
// NOTICE: With the exception of some edits, this code was copied from Subs-Post.php, which is the work of the SMF dev team. I only moved things around...so thank them, not me!
function theme_quickreply_box()
{

 
global $txt$modSettings$db_prefix;
 
global 
$context$settings$user_info;
 
// Switch between default images and back... mostly in case you don't have an PersonalMessage template, but do ahve a Post template.
 
if (isset(
$settings['use_default_images']) && $settings['use_default_images'] == 'defaults' && isset($settings['default_template']))
 
{
 
 
$temp1 $settings['theme_url'];
 
 
$settings['theme_url'] = $settings['default_theme_url'];
 
 
$temp2 $settings['images_url'];
 
 
$settings['images_url'] = $settings['default_images_url'];
 
 
$temp3 $settings['theme_dir'];
 
 
$settings['theme_dir'] = $settings['default_theme_dir'];
 
}
 
// Initialize smiley array...
 
$context['smileys'] = array(
 
 
'postform' => array(),
 
 
'popup' => array(),
 
);
 
// Load the Post language file for the color dropdown.
 
loadLanguage('Post');
 
// Load smileys - don't bother to run a query if we're not using the database's ones anyhow.
 
if (empty(
$modSettings['smiley_enable']) && $user_info['smiley_set'] != 'none')
 
 
$context['smileys']['postform'][] = array(
 
 
 
'smileys' => array(
 
 
 
 
array(
'code' => ':)''filename' => 'smiley.gif''description' => $txt[287]),
 
 
 
 
array(
'code' => ';)''filename' => 'wink.gif''description' => $txt[292]),
 
 
 
 
array(
'code' => ':D''filename' => 'cheesy.gif''description' => $txt[289]),
 
 
 
 
array(
'code' => ';D''filename' => 'grin.gif''description' => $txt[293]),
 
 
 
 
array(
'code' => '>:(''filename' => 'angry.gif''description' => $txt[288]),
 
 
 
 
array(
'code' => ':(''filename' => 'sad.gif''description' => $txt[291]),
 
 
 
 
array(
'code' => ':o''filename' => 'shocked.gif''description' => $txt[294]),
 
 
 
 
array(
'code' => '8)''filename' => 'cool.gif''description' => $txt[295]),
 
 
 
 
array(
'code' => '???''filename' => 'huh.gif''description' => $txt[296]),
 
 
 
 
array(
'code' => '::)''filename' => 'rolleyes.gif''description' => $txt[450]),
 
 
 
 
array(
'code' => ':P''filename' => 'tongue.gif''description' => $txt[451]),
 
 
 
 
array(
'code' => ':-[''filename' => 'embarrassed.gif''description' => $txt[526]),
 
 
 
 
array(
'code' => ':-X''filename' => 'lipsrsealed.gif''description' => $txt[527]),
 
 
 
 
array(
'code' => ':-\\''filename' => 'undecided.gif''description' => $txt[528]),
 
 
 
 
array(
'code' => ':-*''filename' => 'kiss.gif''description' => $txt[529]),
 
 
 
 
array(
'code' => ':\'(''filename' => 'cry.gif''description' => $txt[530])
 
 
 
),
 
 
 
'last' => true,
 
 
);
 
elseif (
$user_info['smiley_set'] != 'none')
 
{
 
 
if ((
$temp cache_get_data('posting_smileys'480)) == null)
 
 
{
 
 
 
$request db_query("
 
 
 
 
SELECT code, filename, description, smileyRow, hidden
 
 
 
 
FROM {$db_prefix}smileys
 
 
 
 
WHERE hidden IN (0, 2)
 
 
 
 
ORDER BY smileyRow, smileyOrder"
__FILE____LINE__);
 
 
 
while (
$row mysql_fetch_assoc($request))
 
 
 
{
 
 
 
 
$row['code'] = htmlspecialchars($row['code']);
 
 
 
 
$row['filename'] = htmlspecialchars($row['filename']);
 
 
 
 
$row['description'] = htmlspecialchars($row['description']);
 
 
 
 
$context['smileys'][empty($row['hidden']) ? 'postform' 'popup'][$row['smileyRow']]['smileys'][] = $row;
 
 
 
}
 
 
 
mysql_free_result($request);
 
 
 
cache_put_data('posting_smileys'$context['smileys'], 480);
 
 
}
 
 
else
 
 
 
$context['smileys'] = $temp;
 
}
 
// Clean house... add slashes to the code for javascript.
 
foreach (
array_keys($context['smileys']) as $location)
 
{
 
 
foreach (
$context['smileys'][$location] as $j => $row)
 
 
{
 
 
 
$n count($context['smileys'][$location][$j]['smileys']);
 
 
 
for (
$i 0$i $n$i++)
 
 
 
{
 
 
 
 
$context['smileys'][$location][$j]['smileys'][$i]['code'] = addslashes($context['smileys'][$location][$j]['smileys'][$i]['code']);
 
 
 
 
$context['smileys'][$location][$j]['smileys'][$i]['js_description'] = addslashes($context['smileys'][$location][$j]['smileys'][$i]['description']);
 
 
 
}
 
 
 
$context['smileys'][$location][$j]['smileys'][$n 1]['last'] = true;
 
 
}
 
 
if (!empty(
$context['smileys'][$location]))
 
 
 
$context['smileys'][$location][count($context['smileys'][$location]) - 1]['last'] = true;
 
}
 
$settings['smileys_url'] = $modSettings['smileys_url'] . '/' $user_info['smiley_set'];
 
// Set a flag so the sub template knows what to do...
 
$context['show_bbc'] = !empty($modSettings['enableBBC']) && !empty($settings['show_bbc']);
 
// Generate a list of buttons that shouldn't be shown - this should be the fastest way to do this.
 
if (!empty(
$modSettings['disabledBBC']))
 
{
 
 
$disabled_tags explode(','$modSettings['disabledBBC']);
 
 
foreach (
$disabled_tags as $tag)
 
 
 
$context['disabled_tags'][trim($tag)] = true;
 
}
 
// Go!  Supa-sub-template-smash!
 
template_quickreply_box();
 
// Switch the URLs back... now we're back to whatever the main sub template is.  (like folder in PersonalMessage.)
 
if (isset(
$settings['use_default_images']) && $settings['use_default_images'] == 'defaults' && isset($settings['default_template']))
 
{
 
 
$settings['theme_url'] = $temp1;
 
 
$settings['images_url'] = $temp2;
 
 
$settings['theme_dir'] = $temp3;
 
}
}

เปิดไฟล์ Display.template.php
ยัดโค้ดนี่ลงไปก่อนบรรทั้ดสุดท้ายเหมือนกัน

// This function displays all the stuff you'd expect to see with a message box, the box, BBC buttons and of course smileys.
// NOTICE: With the exception of some edits, this code was copied from Subs-Post.php, which is the work of the SMF dev team. I only moved things around...so thank them, not me!
function template_quickreply_box()
{

 
global $context$settings$options$txt$modSettings;
 
// Assuming BBC code is enabled then print the buttons and some javascript to handle it.
 
if (
$context['show_bbc'])
 
{
 
 
echo 
'
 
 
 
<script language="JavaScript" type="text/javascript"><!-- // -->
 
 
 
 
function bbc_highlight(something, mode)
 
 
 
 
{
 
 
 
 
 
something.style.backgroundImage = "url(" + smf_images_url + (mode ? "/bbc/bbc_hoverbg.gif)" : "/bbc/bbc_bg.gif)");
 
 
 
 
}
 
 
 
// ]]></script>'
;
 
 
// The below array makes it dead easy to add images to this page. Add it to the array and everything else is done for you!
 
 
$context['bbc_tags'] = array();
 
 
$context['bbc_tags'][] = array(
 
 
 
'bold' => array('code' => 'b''before' => '[b]''after' => '[/b]''description' => $txt[253]),
 
 
 
'italicize' => array('code' => 'i''before' => '[i]''after' => '[/i]''description' => $txt[254]),
 
 
 
'underline' => array('code' => 'u''before' => '[u]''after' => '[/u]''description' => $txt[255]),
 
 
 
'strike' => array('code' => 's''before' => '[s]''after' => '[/s]''description' => $txt[441]),
 
 
 
array(),
 
 
 
'glow' => array('code' => 'glow''before' => '[glow=red,2,300]''after' => '[/glow]''description' => $txt[442]),
 
 
 
'shadow' => array('code' => 'shadow''before' => '[shadow=red,left]''after' => '[/shadow]''description' => $txt[443]),
 
 
 
'move' => array('code' => 'move''before' => '[move]''after' => '[/move]''description' => $txt[439]),
 
 
 
array(),
 
 
 
'pre' => array('code' => 'pre''before' => '[pre]''after' => '[/pre]''description' => $txt[444]),
 
 
 
'left' => array('code' => 'left''before' => '[left]''after' => '[/left]''description' => $txt[445]),
 
 
 
'center' => array('code' => 'center''before' => '[center]''after' => '[/center]''description' => $txt[256]),
 
 
 
'right' => array('code' => 'right''before' => '[right]''after' => '[/right]''description' => $txt[446]),
 
 
 
array(),
 
 
 
'hr' => array('code' => 'hr''before' => '[hr]''description' => $txt[531]),
 
 
 
array(),
 
 
 
'size' => array('code' => 'size''before' => '[size=10pt]''after' => '[/size]''description' => $txt[532]),
 
 
 
'face' => array('code' => 'font''before' => '[font=Verdana]''after' => '[/font]''description' => $txt[533]),
 
 
);
 
 
$context['bbc_tags'][] = array(
 
 
 
'flash' => array('code' => 'flash''before' => '[flash=200,200]http://''after' => '[/flash]''description' => $txt[433]),
 
 
 
'img' => array('code' => 'img''before' => '[img]http://''after' => '[/img]''description' => $txt[435]),
 
 
 
'url' => array('code' => 'url''before' => '[url=http://''after' => ']''after' => '[/url]''description' => $txt[257]),
 
 
 
'email' => array('code' => 'email''before' => '[email]''after' => '[/email]''description' => $txt[258]),
 
 
 
'ftp' => array('code' => 'ftp''before' => '[ftp=ftp://''after' => ']''after' => '[/ftp]''description' => $txt[434]),
 
 
 
array(),
 
 
 
'table' => array('code' => 'table''before' => '[table][tr][td]''after' => '[/table]''description' => $txt[436]),
 
 
 
'tr' => array('code' => 'td''before' => '[table][tr][td]''after' => '[/td][/tr][/table]''description' => $txt[449]),
 
 
 
'td' => array('code' => 'td''before' => '[table][tr][td]''after' => '[/td][/tr][/table]''description' => $txt[437]),
 
 
 
array(),
 
 
 
'sup' => array('code' => 'sup''before' => '[sup]''after' => '[/sup]''description' => $txt[447]),
 
 
 
'sub' => array('code' => 'sub''before' => '[sub]''after' => '[/sub]''description' => $txt[448]),
 
 
 
'tele' => array('code' => 'tt''before' => '[tt]''after' => '[/tt]''description' => $txt[440]),
 
 
 
array(),
 
 
 
'code' => array('code' => 'code''before' => '[code]''after' => '[/code]''description' => $txt[259]),
 
 
 
'quote' => array('code' => 'quote''before' => '[quote]''after' => '[/quote]''description' => $txt[260]),
 
 
 
array(),
 
 
 
'list' => array('code' => 'list''before' => '[list]\n[list][li]''after' => '[/li][/list]\n[list][li][/li][/list]\n[/list]''description' => $txt[261]),
 
 
);
 
 
$found_button false;
 
 
// Here loop through the array, printing the images/rows/separators!
 
 
foreach (
$context['bbc_tags'][0] as $image => $tag)
 
 
{
 
 
 
// Is there a "before" part for this bbc button? If not, it can't be a button!!
 
 
 
if (isset(
$tag['before']))
 
 
 
{
 
 
 
 
// Is this tag disabled?
 
 
 
 
if (!empty(
$context['disabled_tags'][$tag['code']]))
 
 
 
 
 
continue;
 
 
 
 
$found_button true;
 
 
 
 
// If there's no after, we're just replacing the entire selection in the post box.
 
 
 
 
if (!isset(
$tag['after']))
 
 
 
 
 
echo 
'<a href="javascript:void(0);" onclick="replaceText(\''$tag['before'], '\', document.forms.postmodify.message); return false;">';
 
 
 
 
// On the other hand, if there is one we are surrounding the selection ;).
 
 
 
 
else
 
 
 
 
 
echo 
'<a href="javascript:void(0);" onclick="surroundText(\''$tag['before'], '\', \''$tag['after'], '\', document.forms.postmodify.message); return false;">';
 
 
 
 
// Okay... we have the link. Now for the image and the closing </a>!
 
 
 
 
echo 
'<img onmouseover="bbc_highlight(this, true);" onmouseout="if (window.bbc_highlight) bbc_highlight(this, false);" src="'$settings['images_url'], '/bbc/'$image'.gif" align="bottom" width="23" height="22" alt="'$tag['description'], '" title="'$tag['description'], '" style="background-image: url('$settings['images_url'], '/bbc/bbc_bg.gif); margin: 1px 2px 1px 1px;" /></a>';
 
 
 
}
 
 
 
// I guess it's a divider...
 
 
 
elseif (
$found_button)
 
 
 
{
 
 
 
 
echo 
'<img src="'$settings['images_url'], '/bbc/divider.gif" alt="|" style="margin: 0 3px 0 3px;" />';
 
 
 
 
$found_button false;
 
 
 
}
 
 
}
 
 
// Print a drop down list for all the colors we allow!
 
 
if (!isset(
$context['disabled_tags']['color']))
 
 
 
echo 
' <select onchange="surroundText(\'[color=\' + this.options[this.selectedIndex].value.toLowerCase() + \']\', \'[/color]\', document.forms.postmodify.message); this.selectedIndex = 0; document.forms.postmodify.message.focus(document.forms.postmodify.message.caretPos);" style="margin-bottom: 1ex;">
 
 
 
 
<option value="" selected="selected">'
$txt['change_color'], '</option>
 
 
 
 
<option value="Black">'
$txt[262], '</option>
 
 
 
 
<option value="Red">'
$txt[263], '</option>
 
 
 
 
<option value="Yellow">'
$txt[264], '</option>
 
 
 
 
<option value="Pink">'
$txt[265], '</option>
 
 
 
 
<option value="Green">'
$txt[266], '</option>
 
 
 
 
<option value="Orange">'
$txt[267], '</option>
 
 
 
 
<option value="Purple">'
$txt[268], '</option>
 
 
 
 
<option value="Blue">'
$txt[269], '</option>
 
 
 
 
<option value="Beige">'
$txt[270], '</option>
 
 
 
 
<option value="Brown">'
$txt[271], '</option>
 
 
 
 
<option value="Teal">'
$txt[272], '</option>
 
 
 
 
<option value="Navy">'
$txt[273], '</option>
 
 
 
 
<option value="Maroon">'
$txt[274], '</option>
 
 
 
 
<option value="LimeGreen">'
$txt[275], '</option>
 
 
 
</select>'
;
 
 
echo 
'<br />';
 
 
$found_button false;
 
 
// Print the buttom row of buttons!
 
 
foreach (
$context['bbc_tags'][1] as $image => $tag)
 
 
{
 
 
 
if (isset(
$tag['before']))
 
 
 
{
 
 
 
 
// Is this tag disabled?
 
 
 
 
if (!empty(
$context['disabled_tags'][$tag['code']]))
 
 
 
 
 
continue;
 
 
 
 
$found_button true;
 
 
 
 
// If there's no after, we're just replacing the entire selection in the post box.
 
 
 
 
if (!isset(
$tag['after']))
 
 
 
 
 
echo 
'<a href="javascript:void(0);" onclick="replaceText(\''$tag['before'], '\', document.forms.postmodify.message); return false;">';
 
 
 
 
// On the other hand, if there is one we are surrounding the selection ;).
 
 
 
 
else
 
 
 
 
 
echo 
'<a href="javascript:void(0);" onclick="surroundText(\''$tag['before'], '\', \''$tag['after'], '\', document.forms.postmodify.message); return false;">';
 
 
 
 
// Okay... we have the link. Now for the image and the closing </a>!
 
 
 
 
echo 
'<img onmouseover="bbc_highlight(this, true);" onmouseout="if (window.bbc_highlight) bbc_highlight(this, false);" src="'$settings['images_url'], '/bbc/'$image'.gif" align="bottom" width="23" height="22" alt="'$tag['description'], '" title="'$tag['description'], '" style="background-image: url('$settings['images_url'], '/bbc/bbc_bg.gif); margin: 1px 2px 1px 1px;" /></a>';
 
 
 
}
 
 
 
// I guess it's a divider...
 
 
 
elseif (
$found_button)
 
 
 
{
 
 
 
 
echo 
'<img src="'$settings['images_url'], '/bbc/divider.gif" alt="|" style="margin: 0 3px 0 3px;" />';
 
 
 
 
$found_button false;
 
 
 
}
 
 
}
 
}
 
// Now start printing all of the smileys.
 
if (!empty(
$context['smileys']['postform']))
 
{
 
 
echo 
'
 
 
 
<br />'
;
 
 
// Show each row of smileys ;).
 
 
foreach (
$context['smileys']['postform'] as $smiley_row)
 
 
{
 
 
 
foreach (
$smiley_row['smileys'] as $smiley)
 
 
 
 
echo 
'
 
 
 
<a href="javascript:void(0);" onclick="replaceText(\' '
$smiley['code'], '\', document.forms.postmodify.message); return false;"><img src="'$settings['smileys_url'], '/'$smiley['filename'], '" align="bottom" alt="'$smiley['description'], '" title="'$smiley['description'], '" /></a>';
 
 
 
// If this isn't the last row, show a break.
 
 
 
if (empty(
$smiley_row['last']))
 
 
 
 
echo 
'<br />';
 
 
}
 
 
// If the smileys popup is to be shown... show it!
 
 
if (!empty(
$context['smileys']['popup']))
 
 
 
echo 
'
 
 
 
<a href="javascript:moreSmileys();">['
$txt['more_smileys'], ']</a>';
 
}
 
// If there are additional smileys then ensure we provide the javascript for them.
 
if (!empty(
$context['smileys']['popup']))
 
{
 
 
echo 
'
 
 
 
<script language="JavaScript" type="text/javascript"><!-- // -->
 
 
 
 
var smileys = ['
;
 
 
foreach (
$context['smileys']['popup'] as $smiley_row)
 
 
{
 
 
 
echo 
'
 
 
 
 
 
['
;
 
 
 
foreach (
$smiley_row['smileys'] as $smiley)
 
 
 
{
 
 
 
 
echo 
'
 
 
 
 
 
 
["'
$smiley['code'], '","'$smiley['filename'], '","'$smiley['js_description'], '"]';
 
 
 
 
if (empty(
$smiley['last']))
 
 
 
 
 
echo 
',';
 
 
 
}
 
 
 
echo 
']';
 
 
 
if (empty(
$smiley_row['last']))
 
 
 
 
echo 
',';
 
 
}
 
 
echo 
'];
 
 
 
 
var smileyPopupWindow;

 
 
 
 
function moreSmileys()
 
 
 
 
{
 
 
 
 
 
var row, i;

 
 
 
 
 
if (smileyPopupWindow)
 
 
 
 
 
 
smileyPopupWindow.close();

 
 
 
 
 
smileyPopupWindow = window.open("", "add_smileys", "toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,width=480,height=220,resizable=yes");
 
 
 
 
 
smileyPopupWindow.document.write(\'\n<html>\');
 
 
 
 
 
smileyPopupWindow.document.write(\'\n\t<head>\n\t\t<title>'
$txt['more_smileys_title'], '</title>\n\t\t<link rel="stylesheet" type="text/css" href="'$settings['theme_url'], '/style.css" />\n\t</head>\');
 
 
 
 
 
smileyPopupWindow.document.write(\'\n\t<body style="margin: 1ex;">\n\t\t<table width="100%" cellpadding="5" cellspacing="0" border="0" class="tborder">\n\t\t\t<tr class="titlebg"><td align="left">'
$txt['more_smileys_pick'], '</td></tr>\n\t\t\t<tr class="windowbg"><td align="left">\');

 
 
 
 
 
for (row = 0; row < smileys.length; row++)
 
 
 
 
 
{
 
 
 
 
 
 
for (i = 0; i < smileys[row].length; i++)
 
 
 
 
 
 
{
 
 
 
 
 
 
 
smileys[row][i][2] = smileys[row][i][2].replace(/"/g, \'&quot;\');
 
 
 
 
 
 
 
smileyPopupWindow.document.write(\'<a href="javascript:void(0);" onclick="window.opener.replaceText(&quot; \' + smileys[row][i][0] + \'&quot;, window.opener.document.forms.postmodify.message); window.focus(); return false;"><img src="'
$settings['smileys_url'], '/\' + smileys[row][i][1] + \'" alt="\' + smileys[row][i][2] + \'" title="\' + smileys[row][i][2] + \'" style="padding: 4px;" border="0" /></a> \');
 
 
 
 
 
 
}
 
 
 
 
 
 
smileyPopupWindow.document.write("<br />");
 
 
 
 
 
}

 
 
 
 
 
smileyPopupWindow.document.write(\'</td></tr>\n\t\t\t<tr><td align="center" class="windowbg"><a href="javascript:window.close();\\">'
$txt['more_smileys_close_window'], '</a></td></tr>\n\t\t</table>\n\t</body>\n</html>\');
 
 
 
 
 
smileyPopupWindow.document.close();
 
 
 
 
}
 
 
 
// ]]></script>'
;
 
}
 
// Finally the most important bit - the actual text box to write in!
 
echo 
'
 
 
 
<textarea class="editor" cols="75" rows="7" style="width: 95%; height: 100px;" name="message" tabindex="1" onselect="storeCaret(this);" onclick="storeCaret(this);" onkeyup="storeCaret(this);" onchange="storeCaret(this);"></textarea>'
;
}

หาคำสั่งนี้

if ($context['can_reply'] && !empty($options['display_quick_reply']))
 
{
 
 
echo
<
a name="quickreply"></a>
<
table border="0" cellspacing="1" cellpadding="3" class="bordercolor" width="100%" style="clear: both;">
 
 
<
tr>
ไปจนถึง

<input type="button" value="', $txt['spell_check'], '" onclick="spellCheck(\'postmodify\', \'message\');" tabindex="5"/>';
 
 
echo '
 
 
 
 
<
input type="hidden" name="sc" value="' . $context['session_id'] . '" />
 
 
 
 
<
input type="hidden" name="seqnum" value="', $context['form_sequence_number'], '" />
 
 
 
</
form>
 
 
</
td>
 
</
tr>
</
table>;
 
}

แล้วแก้เป็นคำสั่งนี้แทน


 
// Show the quick reply box.
 
if (
$context['can_reply'] && !empty($options['display_quick_reply']))
 
{
 
 
echo 
'
<a name="quickreply"></a>
<div style="width: 100%;" align="center"><div class="tborder" style="width: 50%;" align="left">
 
<div class="catbg" style="padding: 4px;"><a href="javascript:swapQuickReply();"><img src="'
$settings['images_url'], '/'$options['display_quick_reply'] == 'collapse' 'expand''.gif" alt="+" id="quickReplyExpand" /></a> <a href="javascript:swapQuickReply();">'$txt['quick_reply_1'], '</a></div>
 
<div class="windowbg" id="quickReplyOptions" style="padding: 1ex;'
$options['display_quick_reply'] == '' ' display: none''">
 
 
'
$context['is_locked'] ? '<b>' $txt['quick_reply_warning'] . '</b><br /><br />' '''
 
 
<form action="'
$scripturl'?action=post2" method="post" accept-charset="'$context['character_set'], '" name="postmodify" id="postmodify" onsubmit="submitonce(this);" style="margin: 0;">
 
 
 
<input type="hidden" name="topic" value="' 
$context['current_topic'] . '" />
 
 
 
<input type="hidden" name="subject" value="' 
$context['response_prefix'] . $context['subject'] . '" />
 
 
 
<input type="hidden" name="icon" value="xx" />
 
 
 
<input type="hidden" name="notify" value="'
$context['is_marked_notify'] || !empty($options['auto_notify']) ? '1' '0''" />
 
 
 
<input type="hidden" name="goback" value="'
, empty($options['return_to_post']) ? '0' '1''" />
 
 
 
<input type="hidden" name="num_replies" value="'
$context['num_replies'], '" />';
 
 
// Here we show the actual post box with the smileys and BBCode..
 
 
theme_quickreply_box();
 
 
echo 
'
 
 
 
<br />
 
 
 
<input type="submit" name="post" value="' 
$txt[105] . '" onclick="return submitThisOnce(this);" accesskey="s" tabindex="2" />
 
 
 
<input type="submit" name="preview" value="' 
$txt[507] . '" onclick="return submitThisOnce(this);" accesskey="p" tabindex="4" />';
 
 
if (
$context['show_spellchecking'])
 
 
 
echo 
'
 
 
 
<input type="button" value="'
$txt['spell_check'], '" onclick="spellCheck(\'postmodify\', \'message\');" tabindex="5"/>';
 
 
echo 
'
 
 
 
<input type="hidden" name="sc" value="' 
$context['session_id'] . '" />
 
 
 
<input type="hidden" name="seqnum" value="'
$context['form_sequence_number'], '" />
 
 
</form>'
;
 
echo 
'
 
</div>
</div></div>'
;
 
}