12/14/2012

How to set ICS Proxy


How to set ICS Proxy

How to set ICS Proxy?

Not that difficult if you know where to click :)

 Click on Wi-Fi
 Click on your selected WIFI and hold. Select Modify network config.

 Check [Show advanced options]
Tadaaaaaa.... put in your proxy server here.... you dont have to root to do this :)

Thank ! for web http://jjpda.blogspot.com/2012/05/how-to-set-ics-proxy.html

9/24/2012

PHP fopen(),fwrite() เป็น Function ใช้ในการเขียนไฟล์ (Write File)

mode
- r อ่านอย่างเดียว
- w สร้างไฟล์โดยถ้ามีไฟล์เดิมอยู่แล้วจะทำการลบทิ้งและสร้างไฟล์ขึ้นมาใหม่
- a กรณีที่มีไฟล์อยู่แล้วจะทำการเขียนไฟล์ต่อจากที่มีอยู่


<html>
<head>
<title>Test PHP & writefile</title>
</head>
<body>
<?
$strFileName = "Test.txt";
$objFopen = fopen($strFileName, 'w');
$strText1 = "123 Line1\r\n";
fwrite($objFopen, $strText1);
$strText2 = "234 Line2\r\n";
fwrite($objFopen, $strText2);
$strText3 = "345 Line3\r\n";
fwrite($objFopen, $strText3);

if($objFopen)
{
 echo "File writed.";
}
else
{
 echo "File can not write";
}

fclose($objFopen);
?>
</body>
</html>

8/29/2012

I mobile Q2 ปรับเสียงลำโพงให้ดังมากกว่าเดิม

**ใครจะปรับเพิ่มตัว เลือกอื่นก็ได้นะ แต่ย้ำว่าให้จดของเดิมไว้ก่อน 
เข้า  engineermode
กดเบอร์ แล้วโทรออก
*#*#2584560#*#*
เลือก Audio
Normal Mode
type เลือก Media
Level เลือก level 6
value is 160 กด set -->  OK
max vol 160 กด set -->  OK

LoudSpeaker Mode
type เลือก ring
Level เลือก level 6
value is 255 กด set -->  OK
max vol 160 กด set -->  OK

type เลือก Media
Level เลือก level 6
value is 255 กด set -->  OK
max vol 160 กด set   -->  OK

ค่าเดิมเผื่อต้องการทำกลับมาให้เหมือนเดิม
เข้า
engineermode
*#*#2584560#*#*
เลือก Audio
Normal Mode
type เลือก Media
Level เลือก level 1
value is 128 กด set --> ok
max vol 96 กด set --> ok

LoudSpeaker Mode
type เลือก ring
Level เลือก level 0
value is 0 กด set --> ok
max vol 160 กด set --> ok

type เลือก Media
Level เลือก level 0
value is 0 กด set --> ok
max vol 160 กด set --> ok

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


ขอบคุณ luxdee แห่ง pdamobiz ครับ
http://pdamobiz.com/forum/forum_posts.asp?TID=572903&PN=0&TPN=18

8/09/2012

Thunderbird : read receipts mail thunderbird.

วิธีตั้งค่า ให้รู้ว่าผู้รับอีเมลปลายทางเปิดเมลที่เราส่งไป ของโปรแกรม Thunderbird

1. คลิกที่เมนู Tools >คลิกเลือกที่ Account Settings...

2.คลิกที่เมนู Return Receipts > คลิกเลือกที่ Customize return receipts ... > คลิกเครื่องหมายถูกที่ When sending messages... > และคลิกที่ปุ่ม OK ก็เป็นอันเสร็จขั้นตอน

3. เมื่อผู้รับปลายทางเปิดเมล์ ที่เราส่งไปจะมีเมลแจ้งกลับมาตามรูปด้านล่างโดยระบุ Subject ที่เราส่งไปและในเนื้อเมลจะแสดงอีเมลปลายทาง

ทีมา http://support2.truecorp.co.th/detail.aspx?document_id=263

8/05/2012

วิธีย้าย app ไปที่ external SD 8G ของ i-style Q2 ต้อง root นะครับ


i-style Q2 ต้อง root ก่อนน่ะครับ ตามนี้ 
http://porpramarn.blogspot.com/2012/08/ubuntu-root-i-mobile-i-style-q2.html หรือ
http://www.pex.in.th/2012/07/how-to-root-i-mobile-i-style-q2-on.html#comment-form

***ผมไม่รับรองกับความเสียหายที่จะเกิดขึ้นกับเครื่อง น่ะครับแต่เครื่องผม ทำได้ตามนี้ครับ

เมื่อเสร็จแล้วหากต้องการเปลี่ยนที่สำหรับลงโปรแกรมจากเดิมที่ลงใน SDCard  ของเครื่องมาเป็น External SDCard 8G ให้แก้ /system/etc/vold.fstab



โดยใช้โปรแกรม Root Explorer ที่จะมีให้เมื่อ root เสร็จแล้ว
เข้าไปตาม Part /system/etc/vold.fstab ติ๊กข้างบนโปรแกรมตรง Mount R/W ให้เป็น Mount R/O แล้วแก้
*** แนะนำน่ะครับก่อนแก้ ควรเป็นอย่างยิ่ง Copy ไฟล์ vold.fstab อันเดิมไว้ก่อน เผื่อผิดพลาดหรืออยากกลับมาใช้เหมือนเดิม จะได้แำก้ชื่อไฟล์แล้วใช้ได้เลย ครับ
พร้อมแล้วแก้ตามนี้เลยครับ

dev_mount sdcard /mnt/sdcard2 emmc@fat /devices/platform/goldfish_mmc.0 /devices/platform/mtk-sd.0/mmc_host

dev_mount sdcard /mnt/sdcard auto /devices/platform/goldfish_mmc.1 /devices/platform/mtk-sd.1/mmc_host

จากนั้น download link2sd จาก Google Play 

เสร็จแล้วปิดเครื่อง ถอดแบตร ถอด SD Gard 8G ออก ใส่เข้าไปใหม่
วิธีทำตามนี้คือ เปลี่ยน จาก SD 8G ให้เป็น SD Phone แทน เท่านี้ก็สามารถย้าย App ไปใช้ SD 8G ได้อย่างเต็มที่แล้วครับ

ส่วน SD ของเครื่องที่มีประมาณ 1.5 G ก็เอาไว้เก็บเพลง กับ อะไรเล็ก ๆ น้อย ๆ ก็ได้ครับ

****
เผื่อใครพลาด บอกก็บอกว่าให้ copy ไว้ก่อน มีปัญหาจะได้เอามาใช้ได้ ก็ยังมีคนพลาด โหลดไฟล์ vold.fstab
 แล้ว ต่อสาย usb copy วางใน SD เครื่องก่อน แล้วใช้ Root Explorer Copy ไปวางไว้ใน /system/etc/  ที่เดิมมัน ครับ (ไฟล์นี้ผมแก้ให้เห็น SDCard 8G แล้วน่ะครับไม่ต้องทำอะไร)
เสร็จแล้วปิดเครื่อง ถอดแบตร ถอด SD Gard 8G ออก ใส่เข้าไปใหม่ 

ส่วนอันนี้เป็นไฟล์ เดิม ๆ ครับที่ยังไม่ได้แก้ไข  vold.fstab
 http://www.mediafire.com/?hrrv0sp1v51ttsa

ที่มา http://pdamobiz.com/forum/forum_posts.asp?TID=575104&PN=1

Ubuntu : root i-mobile i-Style Q2


How to root i-mobile i-Style Q2 (On Linux only) 

** การ root ทำให้หมดประกันกับทาง I-mobile น่ะครับ ต้องมีความรู้เกี่ยวกับการใช้คำสั่งใน Ubuntu พอสมควร ผมไม่รับรองกับความเสียหายที่จะเกิดขึ้นกับเครื่อง น่ะครับแต่เครื่องผม ทำได้ตามนี้ครับ

สำหรับตอนนี้เท่านั้นนะครับ เพราะยังไม่มีไดรเวอร์ ADB (Android Debugging) บน Windows ทำให้ไม่สามารถใช้ได้ หลัก ๆ เลยคือต้องใช้ ADB ในการจัดการครับ ซึ่งเครื่องที่ยังไม่ root จะไม่สามารถใช้งาน Terminal Emulator ทั้งหลายบนโทรศัพท์ได้ ดังนั้น จึงต้องใช้งานผ่าน Desktop เพียงอย่างเดียวครับ บน Linux นั้นไม่ต้องมีไดรเวอร์ของ ADB เพียงแค่รู้รหัส OEM ก็พอครับ ทีละขั้นตอนเลยนะครับ

1. ต้องมี Linux ก่อน จะเป็นดิสโทรอะไรก็ได้ตามสะดวก แนะนำ Ubuntu ครับ ติดตั้งง่าย แนะนำว่าติดตั้งจริง ๆ ดีที่สุดครับ หรือถ้าติดตั้บบน Virtual Machine ทั้งหลายก็ต้องตั้งค่าสาย USB ให้ดี ใครถนัดวิธีไหนก็ตามสะดวกครับ (ไม่แนะนำ WUBI นะครับ ปัญหาเยอะ)

2. ติดตั้ง JAVA จะเป็นเวอร์ชั่นล่าสุด ถ้าเอาง่าย ๆ ใน Repository จะมี OpenJDK Runtime อยู่ ใชัตัวนี้ได้เลยครับ ถ้าเป็น Ubuntu ก็เปิด Ubuntu Software Centre หา Java ในนั้น หรือ Distro อื่ นๆ ก็ตามวิธีครับ แต่มี OpenJDK เหมือนกันแน่นอน

**สำหรับคนที่ติดตั้ง Linux แบบ 64bit ต้องติดตั้ง ia32-libs ด้วยนะครับ**

3. เมื่อติดตั้ง JAVA เรียบร้อยแล้ว ไปดาวน์โหลด Android SDK สำหรับ Linux ที่ http://developer.android.com/sdk/index.html โดยเลือกของ Linux ถ้าลงแบบ 64 bit ก็ไม่ต้องสนใจครับ ใช้ตัว i386 นั่นแหละ ดาวน์โหลดเสร็จแล้วแตกไฟล์ไว้ที่ Home ก็ได้ครับ เวลาใช้งานผ่าน Terminal จะได้ง่าย

4. เปิด Terminal ขึ้นมา (อาจชื่อ GNOME Terminal ตัวไหนก็ได้) มันจะพร้อมอยู่ที่ HOME folder เป็นเรื่องปกติ ก็พิพม์ cd android-sdk-linux เมื่อเข้าไปในนั้นแล้วก็สั่งคำสั่งนี้ครับ  tools/android update sdk --no-ui  ถ้าไม่มีอะไรผิดพลาดมันจะค่อย ๆ โหลดทุกอย่างมาครับ ทุกอย่างตามความเร็วเน็ต

5. เมื่อดาวน์โหลดจนเสร็จเรียบร้อย ลองกลับไปดูที่โฟลเดอร์ android-sdk-linux/platform-tools ครับ ในนั้นจะมีไฟล์ชื่อ adb แสดงว่าเรียบร้อยแล้ว

6. ที่โทรศัพท์ ไปที่ Settings > Development Options  ดูที่ USB Debugging ถ้ายังไม่ได้ติ๊กก็ติ๊กด้วยครับ

7. เชื่อมต่อโทรศัพท์เข้ากับคอมพิวเตอร์ เปิด Terminal แล้วพิมพ์ lsusb กด Enter จะมีรายการ USB ต่าง ๆ ขึ้นมา ให้หาบรรทัดที่เขียนว่า High Tech Computer ครับ ในบรรทัดนั้นก่อนหน้าชื่อที่บอกไปจะมีเลข xxxx:xxxx อยู่ 4 ตัวหน้าคือรหัส OEM ของเครื่อง และ 4 ตัวหลังคือรหัสรุ่นครับ ในที่นี้เราจะ root เจ้า Q2 ถ้าเปิด USB Debugging แล้วเลขที่ได้ไม่น่าจะต่างกัน จะต้องเป็นเลข 0bb4:0c03 ครับ

8. จาก Terminal พิมพ์ sudo gedit /etc/udev/rules.d/50-android.rules กด Enter จะขึ้นหน้าต่าง text editor ขึ้นมา หรือจะใช้ text editor ตัวอื่นก็ได้ตามถนัด พิมพ์ตามนี้ครับ SUBSYSTEMS==”usb”, ATTRS{idVendor}==”0bb4″, ATTRS{idProduct}==”0c03″, MODE=”0666″ จากนั้นเซฟไฟล์ได้เลย (ซึ่งการเพิ่มแบบนี้จะเพิ่มได้เรื่อย ๆ หากคุณมี Android เครื่องอื่นก็สามารถสร้างไฟล์ 51,52,53 ต่อไปได้เรื่อย ๆ แล้วเปลี่ยนเลขให้ตรงกับรุ่นครับ)

9. เรียบร้อยแล้วก็กลับมาที่ Terminal พิมพ์ cd android-sdk-linux/platform-tools สั่ง ./adb devices จะต้องขึ้นเลขชุดนึงขึ้นมา และต่อท้ายด้วย device ประมาณนี้

0123456789ABCDEF    device

แต่ถ้าขึ้นเป็น ????????????????    no permissions ให้ทำดังนี้ครับ ใน Terminal ตรงพาร์ทนั้นครับไม่ต้องเปลี่ยน พิมพ์

sudo su
./adb kill-server
./adb start-server

จากนั้นถอดสาย USB ออกจากโทรศัพท์ เสียบใหม่อีกครั้ง แล้วสั่ง ./adb devices จะเห็นเลขเป็นชุด ๆ อย่างข้างบนครับ

................

เมื่อสามารถใช้งาน ADB ได้แล้ว ต่อไปคือการ root ครับ สำคัญที่ไฟล์นี้ โหลดเลยครับ root mt6575.rar

แตกไฟล์ทั้งหมดใส่ในโฟลเดอร์ platform-tools ครับ เพราะเราจะ ADB จากในนั้น เรียบร้อยแล้วทำตามนี้ครับ (หรือจะเปิดไฟล์ .bat แล้วทำตามวิธีในนั้นก็ได้ ผมก็ทำตามในนั้น แต่เอามาเรียบเรียงให้ง่าย ๆ ตรงนี้แล้วกันนะครับ)

**ปิดเครื่อง ถอดแบตออก ใส่ใหม่ กด Vol Down + Power พร้อมกัน เข้า Factory Test Mode แล้วค่อยเชื่อมต่อกับคอมพิวเตอร์ครับ ไม่งั้นจะเจอ Permission Denied ครับ**

Step 1
./adb shell mv /data/local/tmp /data/local/tmp.bak
./adb shell ln -s /data /data/local/tmp
./adb reboot


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

Step2
./adb shell rm /data/local.prop > nul
./adb shell "echo \"ro.kernel.qemu=1\" > /data/local.prop"
./adb reboot



Step3
./adb shell id

ตรงนี้ถ้าขึ้นประมาณ "the id is 0 / root" แสดงว่ามาถูกทางแล้วครับ ถ้าไม่ใช่ทำใหม่ตั้งแต่ต้นเลยครับ

ในกรณีสำเร็จนะครับ ทำต่อไปดังนี้

./adb remount
./adb push su /system/bin/su
./adb shell chown 0.0 /system/bin/su
./adb shell chmod 06755 /system/bin/su
./adb push busybox /system/bin/busybox
./adb shell chown 0.0 /system/bin/busybox
./adb shell chmod 0755 /system/bin/busybox
./adb push Superuser.apk /system/app/Superuser.apk
./adb shell chown 0.0 /system/app/Superuser.apk
./adb shell chmod 0644 /system/app/Superuser.apk
./adb push RootExplorer.apk /system/app/RootExplorer.apk
./adb shell chown 0.0 /system/app/RootExplorer.apk
./adb shell chmod 0644 /system/app/RootExplorer.apk

./adb shell rm /data/local.prop
./adb shell rm /data/local/tmp
./adb shell mv /data/local/tmp.bak /data/local/tmp
./adb reboot


เปิดเครื่องอีกครั้ง จะเห็นไอคอน Super User และสามารถให้ Permission กับแอพที่ต้องการสิทธิ์ root เช่น Titanium Backup ได้ครับ ลองดู

unroot 

"unroot ไปลบ File 
/system/bin/su
/system/app/superuser
/system/app/rootexplorer 
โดยใช้ rootexplorer ลบนะครับ"

ขอบคุณที่มา
http://www.pex.in.th/2012/07/how-to-root-i-mobile-i-style-q2-on.html#comment-form

7/24/2012

Default printer troubles with Thunderbird

ตั้ง Printer ให้โปรแกรม Thunderbird แล้วไม่จำค่า Printer Default ที่เราตั้งไว้

If you can't print from Thunderbird, or if Thunderbird won't recognize the computer's default printer:

1. In Thunderbird, go to Tools - Options.
2. Under Advanced, on the General tab, click on the Config Editor button.
3. Scroll down to the line starting with print.print_printer. If you don't have that line, then everything should already be set correctly.
4. Right-click on the print.print_printer line & choose Reset.
5. Close the configuration window, then click OK to close the Options window.
6. Close Thunderbird.
7. Make sure that the correct default printer is selected. To do so, go to Start - Settings - Printers and Faxes. The one with the small checkmark is the default. To set a different printer as the default, right-click on it & choose Set as Default Printer.
8. Reopen Thunderbird.


ที่มา
http://arstechnica.com/civis/viewtopic.php?f=11&t=224248

7/10/2012

Linux Mint 13 Maya : sources.list

Although I posted linux mint ‘sources.list’ for my own reference, it is 
the most viewed content on this site. So I will continue to post the 
‘sources.list’. The upcoming Linux Mint 13 Maya ‘sources.list’ will 
probably look the following.
 
sudo nano /etc/apt/sources.list
 
deb http://packages.linuxmint.com/ maya main upstream import
deb http://archive.ubuntu.com/ubuntu/ precise main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ precise-updates main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu/ precise-security main restricted universe multiverse
deb http://archive.canonical.com/ubuntu/ precise partner
deb http://packages.medibuntu.org/ precise free non-free

# deb http://archive.getdeb.net/ubuntu precise-getdeb apps
# deb http://archive.getdeb.net/ubuntu precise-getdeb games

Linux :Mount partition on startup.

สามารถ Mount Partition ที่เป็น NTFS ตอน boot หรือ Partition ext3, ext4 อื่น ๆ ได้โดย
1.ใช้ ntfs-3g (ถ้ายังไม่มีก็ติดตั้งได้เลยด้วย apt-get)
2.แก้ไข /etc/fstab ป้อนข้อมูลลักษณะดังตัวอย่าง


  1. # <file system>   <dir>     <type>    <options>             <dump>  <pass>
  2. /dev/<NTFS-part>  /mnt/windows  ntfs-3g   defaults        0       0
2.1 (ต้องสร้าง Directory /home/name/DATA ได้ก่อน) หรือที่อื่น ๆก็ได้
2.2 ใช้ UUID เผื่อกรณีที่มีการสลับ Hard disk แล้วลำดับเปลี่ยน (ใช้คำสั่ง blkid เรียกดู)
2.3 ใช้คำสั่ง sudo nano /etc/fstab  เพื่อเพิ่ม Partition ที่จะให้ StartUp

เพิ่ม Partition ที่เรารู้ UUID แล้วเข้าไป เช่น

# Auto Mount Drive Data
UUID=3be91762-2823-4bf5-86ac-5f12ba53220c /home/suwit/DATA     ext4    defaults  0       0

 
หรือ Ntfs ก็เปลี่ยน Type เป็น
  ntfs-3g defaults        0       0    เป็นต้น

เท่านี้เวลาเปิดเครื่อง Partition ก็จะถูกเปิดขึ้นมา Auto แล้วครับ

6/28/2012

Ubuntu : CHOMD ที่ควรรู้จัก


<< CHMOD >>
CHMOD คือ ค่า Permission ครับ หรือธิบายเป็นไทยคือ ค่าของความมีสิทธิ์ในการเข้าถึงและใช้งาน File หรือ Directory นั้น ๆ ซึ่งจะมีค่าต่าง ๆ แบ่งเป็นตัวเลข 3 หลัก เช่น 755, 777 เป็นต้น ในความหมายของเลขแต่ละหลักทั้ง 3 หลัก จะมีความหมายดังนี้
Execute คือ การสั่งให้ทำงาน  Write คือ การเขียนFile หรือ Directory  Read คือ การอ่าน File หรือ Directory
* การที่จะได้เลขหลักใด ๆ มา ก็คือการนำเอาเลขในกลุ่มสิทธิ์นั้น ๆ มาบวกกัน ตัวอย่างเลข 6 จะได้มาจาก การนำเอาเลข 4 กับ 2 มาบวกกัน (Execute+Write)
เลขในหลักแรก -> เจ้าของไฟล์/directory (Owner)
ตัวเลขในหลักแรก จะแสดงถึงสิทธิ์ในการเข้าถึงไฟล์ของผู้เป็นเจ้าของไฟล์ หรือ Dir นั้น ๆ ถ้า ตัวเลขหลักแรกเป็นเลข 
4 จะหมายความว่า เจ้าของ (Owner) ไฟล์นั้น มีสิทธิ์ในการสั่งให้ไฟล์นั้นทำงาน เพียงอย่างเดียว แต่ไม่มีสิทธิ์ เขียน หรือ อ่าน ไฟล์นั้น 
6 จะหมายความว่า เจ้าของ (Owner) ไฟล์นั้น มีสิทธิ์ในการสั่งให้ไฟล์นั้นทำงาน และมีสิทธิ์ในการเขียนไฟล์นั้นเพียงอย่างเดียว แต่ไม่มีสิทธิ์อ่านไฟล์นั้น (4+2)
7 จะหมายความว่า เจ้าของ (Owner) ไฟล์นั้น มีสิทธิ์ในการสั่งให้ไฟล์นั้นทำงาน และมีสิทธิ์ เขียน หรือ อ่าน ไฟล์นั้น (4+2+1)
(ดูค่าตามตาราง ประกอบ)

เลขในหลักที่สอง -> ผู้ใช้กลุ่มเดียวกับเจ้าของไฟล์/directory (Group)
เลขในหลักที่สอง จะแสดงถึงสิทธิ์ในการเข้าถึงไฟล์ของผู้ใช้กลุ่มเดียวกับเจ้าของไฟล์ (Group) หรือ Dir นั้น ๆ ถ้า ตัวเลขหลักที่สองเป็นเลข 
4 จะหมายความว่า ผู้ใช้ในกลุ่มเดียวกับเจ้าของ (Group) ไฟล์นั้น มีสิทธิ์ในการสั่งให้ไฟล์นั้นทำงาน เพียงอย่างเดียว แต่ไม่มีสิทธิ์ เขียน หรือ อ่าน ไฟล์นั้น
6 จะหมายความว่า ผู้ใช้ในกลุ่มเดียวกับเจ้าของ (Group)ไฟล์นั้น มีสิทธิ์ในการสั่งให้ไฟล์นั้นทำงาน และมีสิทธิ์ในการเขียนไฟล์นั้นเพียงอย่างเดียว แต่ไม่มีสิทธิ์อ่านไฟล์นั้น (4+2)
7 จะหมายความว่า ผู้ใช้ในกลุ่มเดียวกับเจ้าของ (Group) ไฟล์นั้น มีสิทธิ์ในการสั่งให้ไฟล์นั้นทำงาน และมีสิทธิ์ เขียน หรือ อ่าน ไฟล์นั้น (4+2+1)
(ดูค่าตามตาราง ประกอบ)

เลขในหลักที่สาม -> ผู้ใช้ในอื่น ๆ (Others)

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

ตัวอย่างเลข 777 จะหมายความว่า ผู้ใช้ในทุกกลุ่ม ไม่ว่าจะเป็นเจ้าของไฟล์ / กลุ่มเดียวกับเจ้าของ / ผู้ใช้อื่น ๆ ทุกกลุ่มที่กล่าวมา มีสิทธิ์ในการกระทำทุกสิ่งกับไฟล์ที่มีค่า CHMOD เป็น 777 เป็นต้น
ตัวอย่างการใช้งานเช่น ในไฟล์ TEXT ของโปรแกรมเรา อย่างเช่นโปรแกรม COUNTER ที่จะต้องมีการ สั่งให้ทำงาน อ่าน และเขียน อยู่ทุก ๆ ครั้งที่มีการเรียกใช้งานเว็บเพจที่มีการติดตั้งโปรแกรมดังกล่าว ไฟล์ TEXT นั้น จะต้องมีการเปลี่ยนค่า CHMOD เป็น 777 เพื่อให้มีการเขียนไฟล์ได้จากผู้ใช้อื่น ๆ เป็นต้น


6/20/2012

PHP : อย่าง งง กับ CHECKBOX

1. ต้องการให้ Checkbox ตรวจสอบค่า Text และส่ง ค่าใน Text1 ไปยัง Text2
2. ถ้าไม่ ติ๊ก ให้ Text2 ว่าง
3. เก็บค่า 0 , 1 เข้า Database
4. เรียกข้อมูลเดิมมาดูให้แสดง ติ๊ก ไม่ติ๊ก ตาม DataBase ที่ Select มาได้

1, 2 :
    input type="checkbox" name="checkbox" id="checkbox" onclick="if(this.checked){this.form.Name Text2.value = this.form.Name Text1.value}else{this.form.Name Text2.value = '';}" />
3 :
ส่งค่าไปอีกไฟล์ PHP รับค่า $_POST เพื่อทำการ SAVE
เช็คว่าว่างหรือไม่ว่าง แล้วเก็บค่าไว้ในตัวแปร ค่อยไปยัดใส่ Database

    if(!empty($emp_address_check)){
        $emp_address_check = 1;
    }else{
        $emp_address_check = 0;
    }
4 :
 เช็คค่า ที่ Select มาจาก Database ว่าว่าง หรือ เท่ากับ 0 หรือไม่ ให้เก็บค่าใส่ตัวแปรว่า checked='checked' แล้วค่อยไป echo

        if(empty($emp_address_check) || $emp_address_check = 0){
            $checked = "";
        } else {
            $checked = "checked='checked'";
        }
ส่วนแสดงผล
    input type="checkbox" name="checkbox" id="checkbox" onclick="if(this.checked){this.form.Name Text2.value = this.form.Name Text1.value}else{this.form.Name Text2.value = '';}" <?php echo $checked ?> />

6/14/2012

PHP Upload and Resize Image

phpUploadResize.html

<html>
<head>
<title>ThaiCreate.Com PHP Upload Resize</title>
</head>
<body>
<form action="phpUploadResize.php" method="post" enctype="multipart/form-data" name="frmMain">
<table width="343" border="1">
<tr>
<td>Upload</td>
<td><input name="fileUpload" type="file"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
</form>
</body>
</html>

phpUploadResize.php

<html>
<head>
<title>ThaiCreate.Com PHP Upload Resize</title>
</head>
<body>
<?
 if(trim($_FILES["fileUpload"]["tmp_name"]) != "")
 {
  $images = $_FILES["fileUpload"]["tmp_name"];
  $new_images = "Thumbnails_".$_FILES["fileUpload"]["name"];
  copy($_FILES["fileUpload"]["tmp_name"],"MyResize/".$_FILES["fileUpload"]["name"]);
  $width=100; //*** Fix Width & Heigh (Autu caculate) ***//
  $size=GetimageSize($images);
  $height=round($width*$size[1]/$size[0]);
  $images_orig = ImageCreateFromJPEG($images);
  $photoX = ImagesX($images_orig);
  $photoY = ImagesY($images_orig);
  $images_fin = ImageCreateTrueColor($width, $height);
  ImageCopyResampled($images_fin, $images_orig, 0, 0, 0, 0, $width+1, $height+1, $photoX, $photoY);
  ImageJPEG($images_fin,"MyResize/".$new_images);
  ImageDestroy($images_orig);
  ImageDestroy($images_fin);
 }
?>
<b>Original Size</b><br>
<img src="<?="MyResize/".$_FILES["fileUpload"]["name"];?>">
<hr>
<b>New Resize</b><br>
<img src="<?="MyResize/".$new_images;?>">
</body>
</html>

ที่มา http://www.thaicreate.com/php/php-upload-resize-image.html

แสดงรูป
<?="MyResize/NameFile.jpg"; ?>

6/12/2012

การเปิดหน้าต่างใหม่ - onClick="javascript:window.open()"

เปิดหน้าต่าง ใหม่และย่อขนาดให้เล็กลง PHP

<script language="javascript">
var win = null;

function NewWindow(mypage,myname,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
win = window.open(mypage,myname,settings)
}
</script>


[ <a href="function_query_repor_print.php" onClick="NewWindow(this.href,'name','800','600','yes');return false">คลิก</a> ]







////////////////////////////////// หรือ //////////////////////////////////////////////


onClick="popWin()";

function popWin(){
window.open('keycalen.php' , 'mypopup' , 'nenuber=no,toorlbar=no,location=no,scrollbars=no, status=no,resizable=no,width=180,height=180,top=220,left=650 ' )";
mypopup.focus();
}





ที่มา http://www.thaicreate.com/php/forum/025196.html

5/31/2012

Axapta X++ : ย่อขาย Forms ตามความต้องการ


การสร้าง Axapta ให้ย่อและขยาย Forms ที่มี Grid อยู่ข้างใน

1. ที่ Design ของ Form  ที่ properties ตั้งค่า WindowsResize เป็น Dynamic
2. จะย่อขยายได้ ต้องสร้าง Tap ข้างในด้วย ก่อนใส่ Grid โดยสร้าง Tab และ TabPage แล้วค่อยสร้าง Grid ข้างใน
3. ตั้งค่า Properties ของ Tab ตรง Width เป็น Column width และ Height เป็น Column height
4. ตั้งค่า Properties ของ Grid ตรง Width เป็น Column width และ Height เป็น Column height

เท่านี้ก็จะสามารถย่อขาย Form ที่มี Grid ได้ตามที่เราต้องการ

ตัวอย่างที่ Form ---> AssemblyDescription

5/29/2012

วิธีตั้งค่าให้ Gmail Notifier เช็ดเมล์ของ google ได้บน linux


ผมก็หามานานครับสำหรับ mail notifier ที่ไว้สำหรับตรวจสอบเมล์ของบริษัท (ใช้ของ google apps ครับ) ผมบน linux หรือ ubuntu นั่นเอง คือสิ่งที่ผมอย่างได้ก็แค่ให้มันเตือนว่ามีเมล์ใหม่เข้ามา และต้องการโปรแกรมที่ไม่ใหญ่มาก ทำงานบน tray icon ก็พอแล้ว ซึ่ง Gmail Notifier ตอบโจทย์ผมได้อย่างดีที่สุด
ตามจริงเจ้าตัว Gmail Notifier มันไว้สำหรับ check gmail แค่นั้น แต่เราต้องมีการปรับแต่งนิดหน่อยเพื่อให้มัน check สำหรับคนที่ใช้บริการ google apps ได้ด้วย โดยให้เราติดตั้ง Gmail Notifier ก่อน
sudo aptitude install gmail-notify
หลังจากติดตั้งเสร็จแล้วเข้าไปปรับแต่งกันเลยดีกว่า
cd /usr/lib/gmail-notify
sudo gedit notifier.py
หาบรรทัด
def gotourl( self, wg=None):
print "----------"
print "launching browser "+self.options['browserpath']+" http://mail.google.com/" os.system(self.options['browserpath']+" http://mail.google.com/ &")
แก้เป็น โดย SITE.COM ให้แก้เป็น domain ที่ใช้บริการ google apps อยู่
def gotourl( self, wg=None):
print "----------"
print "launching browser "+self.options['browserpath']+" https://mail.google.com/a/SITE.COM" os.system(self.options['browserpath']+" https://mail.google.com/a/SITE.COM &")
จากนั้นไป set gmail notifier config ตามรูป

ที่มา http://snappytux.com/content99-linux

5/15/2012

วิธีแก้ Windows 7 32bit ให้เห็นmemory มากกว่า 4GB จนสูงสุดถึง128GB!!

1. Download ตัวโปรแกรมPatchที่ชื่อ RAMFix มา โดยโหลดได้ ที่นี่ หรือ Download mediafire แล้วพอเปิดที่ตัวโปรแกรมนี้ขึ้นมา จะมีโปรแกรมเด้งขึ้นมา สองหน้าต่างคือ Winzip กับ DOS (ไม่ต้องไปสนใจหรือคลิกอะไรในตัว Winzip)
 2. กด Enter เพื่อเริ่มการแก้ไขวินโดว์ (แนะนำให้ปิดโปรแกรม Antivirus และโปรแกรมอื่นๆ)
3. จะมีโปรแกรมเด้งขึ้นมาเป็นภาษารัสเซีย ให้กดปุ่มใหญ่ๆตรงกลาง 1ที
4.จะมีหน้าต่างภาษารัสเซียโผล่มาอีกตัว ให้กด OK
5. ต่อไป ใน DOS จะถาม Y=Yes/N=No ให้เรากด Y แล้ว Enter
6. เมื่อเครื่องให้กด Enter to exit เราก็กด Enter ตามที่เขาสั่ง
7.หลังจากเสร็จแล้ว เครื่องจะรอให้เรา Restart เราก็กด Enter เพื่อ restart เครื่องได้เลย

เมื่อเปิดเครื่องขึ้นมาจะมี Manu List ให้เลือก 2 อัน ให้เลือกอันบน 

5/09/2012

วิธีแก้ปลดล็อค Hidden Folder ไม่ได้เพราะโดนไวรัส ซ่อน Folder

วิธีแก้ปลดล็อค Hidden Folder ไม่ได้เพราะโดนไวรัส ซ่อน Folder 2 วิธีคือ

1. ถ้าอยู่ใน HDD ที่สามารถใช้ CMD เข้าไปใน Drive ได้ไวรัสกับแฟลชไดร์ฟมักจะเป็นของคู่กันเสมอโดยเฉพาะคนที่ใช้แฟลชไดร์ฟโดยไม่ระวังเสียไปทั่วก็เสี่ยงที่จะติดไวรัสสูง เมื่อแฟลชไดร์ฟโดนไวรัส กำจัดไวรัสไปได้แล้ว แต่ โฟลเดรอ์ต่างๆ ยังคงถูกซ่อนไว้ ได้กำหนด Folder Options ให้ View แบบ Show hidden files and folders แล้ว ก็ไม่สามารถกำหนด Properties เพื่อแก้ hidden ออกได้ แม้ว่าจะพยายามปลดล็อค Hidden Folder ยังไงก็ไม่ได้ยอม แต่ผมมีวิธีแก้ไขง่ายๆ ด้วยคำสั่ง dos เพียงไม่กี่คำสั่ง

วิธีแก้ปลดล็อค Hidden Folder ไม่ได้เพราะโดนไวรัส ซ่อน Folder ด้วยคำสั่ง DOS มีดังนี้

    คลิก start –> run
    พิมพ์คำสั่ง cmd แล้วกด enter หรือคลิก OK
    พิมพ์ K: (เมื่อ แฟลชไดร์ฟ เป็นไดร์ K: ถ้าของคุณเป็นไดร์ฟไหนก็พิมพ์ไดร์ฟนั้นโดยดูใน My computer)
    พิมพ์คำสั่ง attrib -s -h -r /S /D   ซึ่งเป็นคำสั่งยกเลิกการซ่อนโฟลเดอร์ทั้งหมด

2. ถ้าอยู่ใน USB และใช้คำสั่ง CMD เข้าใน USB ไม่ได้ แก้โดย
2.1. ดาวโหลดตัวนี้มา [url]http://www.mediafire.com/?ak8d895xll6k5ia[/url]

โปรแกรมนี้สามารถทำให้เราไปเซ็ทค่า Attribute ต่างๆได้ครับ  เมื่อเราติดตั้งแล้ว ให้คลิกขวาที่โฟลเดอร์เป้าหมายที่ถูกไวรัสซ่อนไว้และมี Hiddenสีเทาๆ  จะมีเมนูขึ้นมาให้เซ็ทครับ  เราแค่เอาเครื่องหมายถูกออก ตรง Hiidden กับ System ก็เรียบร้อยแล้วครับ
2.2. ติดตั้งโปรแกรม Next ---> Next ไปเรื่อย ๆ เสร็จแล้ว
2.3. โชว์ Hidden เข้าไปที่ Menu Tool  ---> Folder Options ครับ เลือก View แล้วเลือก Show Hidden File  แล้วมาติ้กเอาเครื่องหมายถูก หน้า Hide extension กับ Hide Protect เอาออกไปซะ ตามรูป แล้วจะมีกรอบขึ้นมาถามเรา ให้ตอบ Yes เลยครับ เสร็จแล้วกด OK เลยครับ
2.4 เปิด USB ดูข้อมูลที่อยู่ใน USB อันไหนที่ไม่ใช่ข้อมูลของเราถ้ามั่นใจแล้วให้ลบออกได้เลย เช่น ไฟล์ .exe ที่ไม่ต้องการ, ไฟล์ .vob และอื่น ๆ ที่คาดว่าจะเป็นไวรัสซึ่งไม่ใช่งานเรา ให้ลบออก
2.5 คลิกขวาที่ไฟล์ที่งานที่ถูกซ่อน เลือก Properties เลือก Change Attributes แล้วติ๊กเครื่องหมายถูกออกตามรูป


กด Apply แล้วกด OK เลยครับ เป็นอันเสร็จครับ

การลบไฟล์ และ ไดเรกทอรี บน ubuntu (remove file and directory on Ubuntu...rm command)


#ลบไฟล์

rm ชื่อไฟล์
rm -i ชื่อไฟล์
rm -f ชื่อไฟล์

#ไดเรกทอรี แบบทั้งหมดหายเกลี้ยง

rm -rf ชื่อไดเรคทอรี่

4/24/2012

Setup ระบบ Openfire Messaging on Ubuntu

เพื่อง่าย ให้ ssh เข้าไป code จะได้ copy ได้
1.ติดตั้ง Package ที่จำเป็น (นำมาจาก testExtranet ตัวเดิมบางอันลงไว้แล้ว)
  1.    apt-get install apache2
  2.     apt-get install php5 libapache2-mod-php5
  3.     apt-get install mysql-server
  4.     apt-get install libapache2-mod-auth-mysql php5-mysql phpmyadmin
  5.  
2.Download ไฟล์ติดตั้งจาก http://www.igniterealtime.org เลือกเอาที่เป็น .tra.gz
3. Copy ไว้ที่เครื่องที่มี Apache ใน WWW แล้ว ทำการ Copy ไปเครื่อง testExtranet โดย
  1. cd /opt/
  1. wget http://localhost/openfire_3_7_1.tar.gz
4. แตกไฟล์ใน opt โดยใช้
  1. tar -zxvf openfire_3_7_1.tar.gz
5. ทดลอง start และเช็ค status ดู โดยใช้
  1. /opt/oprnfire/bin/openfire start
  1. /opt/oprnfire/bin/openfire status
6. สร้าง script สำหรับ openfire ให้ Start เองตอนเปิดเครื่อง (เพราะไม่ได้ติดตั้งผ่าน .deb จึงต้องทำขึ้นเอง)
  1. nano /etc/init.d/openfire
แล้ว copy code นี้วางแทนที่ทั้งหมดเลย
  1.    #! /bin/sh
  2.     # /etc/init.d/openfire
  3.     #
  4.      
  5.     # Some things that run always
  6.     #touch /var/lock/openfire
  7.      
  8.     # Carry out specific functions when asked to by the system
  9.     case "$1" in
  10.       start)
  11.         #echo "Starting openfire "
  12.         /opt/openfire/bin/openfire start
  13.         ;;
  14.       stop)
  15.         #echo "Stopping openfire"
  16.         /opt/openfire/bin/openfire stop
  17.         ;;
  18.       status)
  19.         #echo "Checking openfire"
  20.         /opt/openfire/bin/openfire status
  21.         ;;
  22.       *)
  23.         echo "Usage: /etc/init.d/openfire {start|stop|status}"
  24.         exit 1
  25.         ;;
  26.     esac
  27.      
  28.     exit 0

7. ฝังให้ run ตอน boot ด้วยคำสั่ง
  1.    chmod 755 /etc/init.d/openfire
  2.     update-rc.d openfire defaults

8. เข้าไป Setup โดยใช้ port 9090 เช่http://localhost:9090
Language : English
Domain: server0.sci.com
Admin Console Port: 9090
Secure Admin Console Port: 9091

Database Settings : Standard Database Connection
Database Driver Presets: MySQL
JDBC Driver Class: com.mysql.jdbc.Driver
Database URL: jdbc:mysql://localhost:3306/openfire (ต้องสร้างฐานข้อมูลไว้ก่อน เลือก Collation เป็น unicode)

Profile Settings : Directory Server (LDAP)
Server Type: Active Directory
Host: server4.sci.com
Port: 389
Base DN : DC=SCI,DC=COM
Administrator DN: CN=Administrator,CN=Users,DC=SCI,DC=COM

Username Field: sAMAccountName
Name : {cn}
User Filter : (objectClass=organizationalPerson) (จะกำหนดเงื่อนไขเพิ่มก็ได้ เช่น &(objectClass=organizationalPerson)(department=IF-IT))
Email : {mail}
Full Name : {displayName}

Group Field: cn
Member Field: member
Description Field: description
Group Filter : (objectClass=group) (จะกำหนดเงื่อนไขเพิ่มก็ได้ เช่น &(objectClass=group)(name=IM))

9.Add Administrator แล้วลอง test ดู ใส่เป็นชื่อ เช่น suwit_j

10.ทดลอง Login เข้าใช้งาน http://localhost:9090/login.jsp?url=%2Findex.jsp โดย User : suwit_j Password ใน Domain

11. การตั้งค่าโปรแกรมเช่น Pidgin Set ที่ Account Connect Server : 192.168.0.9 , Connect Port : 5222 , User : suwit_j , Domain : sci.net
password : ใชัตัวเดียวกับ Domain
หมายเหตุ : การ upgrade version สามารถ download .deb มาแล้วติดตั้งซ้ำได้เลย

syslog ส่ง Log จากเครื่องหนึ่งไปเก็บอีกเครื่องหนึ่ง

การส่ง Log จากเครื่องตัวเองหรือจาก SERVER ตัวอื่น เพื่อไปเก็บไว้ที่ SERVER Log ตัวเดียว
เช่น การเก็บ Log จาก SERVER ต่าง ๆ ใน SCI เพื่อไปรวมที่ SERVER ตัวเดียวคือ LogSERVER (192.168.0.251)

1. ติดตั้งโปรแกรม พื้นฐานที่จำเป็นต้องใช้ในเครื่อง ตัวเอง
- apt-get install apache2 ติดตั้ง Apache
- apt-get install Mysql-server ติดตั้ง Mysql-server
- apt-get install phpmyadmin ติดตั้ง phpmyadmin

2. ติดตั้ง syslog
โดยทำตาม ขั้นตอนนี้
http://porpramarn.blogspot.com/2012/04/ubuntu-centralized-log-with-logzilla.html

*** สำคัญมาก คือ 3.ติดตั้ง Package อื่น ๆ ที่จำเป็น ต้อง ติดตั้งทีละ แถว ให้ครบทุกตัวไม่งั้นจะไม่เก็บ Log


3. แก้ไขไฟล์ Config เพิ่มเติมที่เครื่องเราเอง
- nano /etc/syslog-ng/syslog-ng.conf
  1. destination d_logserver { tcp("192.168.0.9" port(514)); };
  2.  

ไว้ล่าง ### Destinations ###
และเพิ่ม 
  1. #get s_apache locolhost
  2. log {
  3.    source(s_apache_access);
  4.    destination(d_logzilla);
  5. };
  6.  
  7. log {
  8.    source(s_apache_access);
  9.    destination(d_logserver);
  10. };
  11.  


ไว้ล่าง ### Logs ###

ตัวอย่าง จาก Sources ที่แก้เพิ่มเติม จาก http://porpramarn.blogspot.com/2012/04/ubuntu-install-serverextranet.html
  1. ### Sources ###
  2. source s_local {
  3. internal();
  4. # standard Linux log source (this is the default place for the syslog()
  5. # function to send logs to)
  6. unix-stream("/dev/log");
  7. # messages from the kernel
  8. file("/proc/kmsg" program_override("kernel: "));
  9. };
  10.  
  11. source s_apache_access {
  12.     file("/var/log/apache2/access.log");
  13. };
  14.  
  15. ### Destinations ###
  16. destination d_logzilla {
  17.   program("/var/www/logzilla/scripts/db_insert.pl"
  18.   template("$HOST\t$FACILITY\t$PRIORITY\t$LEVEL\t$TAG\t$YEAR-$MONTH-$DAY\t$HOUR:$MIN:$SEC\t$PROGRAM\t$MSG\n")
  19.   );
  20. };
  21. destination d_logserver { tcp("192.168.0.9" port(514)); };
  22.  
  23. ### Logs ###
  24. #get s_local
  25. log {
  26.    source(s_local);
  27.    destination(d_logzilla);
  28. };
  29.  
  30. #get s_apache locolhost
  31. log {
  32.    source(s_apache_access);
  33.    destination(d_logzilla);
  34. };
  35.  
  36. log {
  37.    source(s_apache_access);
  38.    destination(d_logserver);
  39. };
  40.  
  41.  


*** อธิบาย Code
ไฟล์ syslog-ng.conf จะประกอบด้วย 3 ส่วนคือ
ส่วนที่ 1. Source บอกถึงเราจะเก็บอะไรบ้าง ใส่ตัวแปร เช่น เก็บทั้งหมด, เก็บ Apacher, เก็บ Squid หรืออื่น ๆ
  1. source s_apache_access {
  2.     file("/var/log/apache2/access.log");
  3. };
  4.  


ส่วนที่ 2. Destination คือส่วนที่ประกาศตัวแปรเรียกใช้โปรแกรมเพื่อเก็บลง ฐานข้อมูลของ Log ตามตัวแปรที่มีการตั้งชื่อไว้
และเป็นส่วนที่ใช้ในการ ส่ง ข้อมูล Log ไปอีก SERVER ตัวอื่น 
  1. destination d_logzilla {
  2.   program("/var/www/logzilla/scripts/db_insert.pl"  #เรียกใช้ไฟล์คำสั่งนี้
  3.   template("$HOST\t$FACILITY\t$PRIORITY\t$LEVEL\t$TAG\t$YEAR-$MONTH-$DAY\t$HOUR:$MIN:$SEC\t$PROGRAM\t$MSG\n")
  4.   );   # เก็บตัวแปรเหล่านี้เข้าไปเก็บ
  5. };
  6. destination d_logserver { tcp("192.168.0.9" port(514)); };  # ส่วนที่ส่ง ข้อมูลไป SERVER อื่น


ส่วนที่ 3. Log คือส่วนที่เรา ใช้ในการส่ง log ว่าจะเก็บส่วนไหนบ้างและส่งไปโดยใช้ตัวแปรไหนบ้าง เช่น
  1. log {
  2.    source(s_local);
  3.    destination(d_logzilla);
  4. };  
เก็บเฉพาะ Log ข้องเครื่องตัวเอง ใช้ตัวแปร s_local และส่งโดยใช้ destination ของตัวแปร d_logzilla

  1. log {
  2.    source(s_apache_access);
  3.    destination(d_logzilla);
  4. };
เก็บ เฉพาะ log ส่วนที่ทำงานเกี่ยวกับ apache โดยใช้ source s_apache_access และส่งโดยใช้ destination ชื่อ d_logzilla

  1. log {
  2.    source(s_apache_access);
  3.    destination(d_logserver);
  4. };
เก็บ เฉพาะ log ส่วนที่ทำงานเกี่ยวกับ apache โดยใช้ source s_apache_access และส่งโดยใช้ destination ชื่อ d_logserver
ซึ่งชุดคำสั่งในตัวแปร d_logserver คือจะส่งไปเก็บอีก SERVER หนึ่งผ่าน port 514

4. การตั้งค่า ไฟล์ syslog-ng.conf ที่ SERVER ฝั่งที่เป็นเครื่องรับ
- nano /etc/syslog-ng/syslog-ng.conf
เพิ่มในส่วนของ Source
  1. source s_net {
  2.    udp(ip(0.0.0.0) port(514));
  3.    tcp(ip(0.0.0.0) port(514) keep-alive(yes) max-connections(300));
  4. };


เพิ่มในส่วนของ log
  1. ### Logs ###
  2. log {
  3.    source(s_net);
  4.    destination(d_logzilla);
  5. };
  6.  


ตัวอย่าง Source
  1. ### Sources ###
  2. source s_local {
  3. # message generated by Syslog-NG
  4. internal();
  5. # standard Linux log source (this is the default place for the syslog()
  6. # function to send logs to)
  7. unix-stream("/dev/log");
  8. # messages from the kernel
  9. file("/proc/kmsg" log_prefix("kernel: "));
  10. };
  11.  
  12. source s_net {
  13.    udp(ip(0.0.0.0) port(514));
  14.    tcp(ip(0.0.0.0) port(514) keep-alive(yes) max-connections(300));
  15. };
  16.  
  17.  
  18. ### Destinations ###
  19. destination d_logzilla {
  20.   program("/var/www/logzilla/scripts/db_insert.pl"
  21.   template("$HOST\t$FACILITY\t$PRIORITY\t$LEVEL\t$TAG\t$YEAR-$MONTH-$DAY\t$HOUR:$MIN:$SEC\t$PROGRAM\t$MSG\n")
  22.   );
  23. };
  24.  
  25. ### Logs ###
  26. log {
  27.    source(s_local);
  28.    source(s_net);
  29.    destination(d_logzilla);
  30. };
  31.  

ความหมายคือ
source s_local เป็นตัวรับค่าจาก เครื่องตัวเอง
source s_net เป็นตัวที่ใช้รับค่าจากการส่งค่าจาก เครื่องอื่นมา
แล้วเก็บใส่ log โดยนำ source ต่าง ๆ มาส่งเก็บเข้าฐานข้อมูลของ log โดดยใช้ destination d_logzilla

Ubuntu : Centralized Log with LogZilla

Centralized Log with LogZilla
1. ดาวน์โหลดและติดตั้ง LogZilla
  1. sudo su -
  2. cd /var/www
  3. wget http://php-syslog-ng.googlecode.com/files/logzilla_v2.9.9o.tgz
  4. tar xzvf logzilla_v2.9.9o.tgz
  5. mv php-syslog-ng logzilla
  6.  

2.ติดตั้ง และ config syslog-ng
  1. aptitude install syslog-ng

แก้ไข /etc/syslog-ng/syslog-ng.conf
  1. options {
  2.       long_hostnames(off);
  3.       # doesn't actually help on Solaris, log(3) truncates at 1024 chars
  4.       log_msg_size(8192);
  5.       # buffer just a little for performance
  6.       # sync(1); <- Deprecated - use flush_lines() instead
  7.       flush_lines(1);
  8.       # memory is cheap, buffer messages unable to write (like to loghost)
  9.       log_fifo_size(16384);
  10.       # Hosts we don't want syslog from
  11.       #bad_hostname("^(ctld.|cmd|tmd|last)$");
  12.       # The time to wait before a dead connection is reestablished (seconds)
  13.       time_reopen(60);
  14.       #Use DNS so that our good names are used, not hostnames
  15.       use_dns(yes);
  16.       dns_cache(yes);
  17.       #Use the whole DNS name
  18.       use_fqdn(yes);
  19.       keep_hostname(yes);
  20.       chain_hostnames(no);
  21.       #Read permission for everyone
  22.       perm(0644);
  23.       # The default action of syslog-ng 1.6.0 is to log a STATS line
  24.       # to the file every 10 minutes.  That's pretty ugly after a while.
  25.       # Change it to every 12 hours so you get a nice daily update of
  26.       # # how many messages syslog-ng missed (0).
  27.       # stats(43200);
  28.   };
  29.  
  30. ### Sources ###
  31. source s_net {
  32. udp(ip(0.0.0.0) port(514));
  33. tcp(ip(0.0.0.0) port(514) keep-alive(yes) max-connections(300));
  34. };
  35.  
  36. source s_local {
  37. # message generated by Syslog-NG
  38. internal();
  39. # standard Linux log source (this is the default place for the syslog()
  40. # function to send logs to)
  41. unix-stream("/dev/log");
  42. # messages from the kernel
  43. file("/proc/kmsg" log_prefix("kernel: "));
  44. };
  45.  
  46. ### Destinations ###
  47. destination d_messages { file("/var/log/messages"); };
  48.  
  49. destination d_logzilla {
  50.   program("/var/www/logzilla/scripts/db_insert.pl"
  51.   template("$HOST\t$FACILITY\t$PRIORITY\t$LEVEL\t$TAG\t$YEAR-$MONTH-$DAY\t$HOUR:$MIN:$SEC\t$PROGRAM\t$MSG\n")
  52.   );
  53. };
  54.  
  55. ### Logs ###
  56. log {
  57. source(s_local);
  58. destination(d_messages);
  59. };
  60.  
  61. log {
  62.    source(s_local);
  63.    source(s_net);
  64.    destination(d_logzilla);
  65. };

3.ติดตั้ง Package อื่น ๆ ที่จำเป็น
  1. aptitude install apache2 php5 php5-gd php5-cli php5-mysql mysql-server msttcorefonts build-essential
  2. cpan Text::LevenshteinXS
  3. cpan -i Digest::SHA1
  4. cpan -i Net::MySQL


4.Config Apache กับ PHP
  1. nano /etc/php5/apache2/php.ini
  1. nano /etc/php5/cli/php.ini

แก้ไขให้เป็น
  1. memory_limit = 128M
  2. max_execution_time = 300
  3.  
  1. nano /etc/apache2/conf.d/logzilla
  1. Alias /logs "/var/www/logzilla/html/"
  2.    <Directory "/var/www/logzilla/html/">
  3.        Options Indexes MultiViews FollowSymLinks
  4.        AllowOverride All
  5.    Order allow,deny
  6.    Allow from all
  7.    </Directory>
  8.  
restart apache
  1. /etc/init.d/apache2 restart
  2. chown -R www-data:www-data /var/www/logzilla/html


5.Logrotate
  1. mkdir -p /var/log/logzilla
  2. nano /etc/logrotate.conf
  1. /var/log/logzilla/*.log {
  2.   missingok
  3.   compress
  4.   rotate 5
  5.   daily
  6.   postrotate
  7.   /etc/init.d/syslog-ng reload > /dev/null 2>&1 || true
  8.   endscript
  9. }

ตั้งเวลา
  1. crontab -e
  1. @daily php /var/www/logzilla/scripts/logrotate.php >> /var/log/logzilla/logrotate.log
  2. @daily find /var/www/logzilla/html/jpcache/ -atime 1 -exec rm -f '{}' ';'
  3. 0,5,10,15,20,25,30,35,40,45,50,55 * * * * php /var/www/logzilla/scripts/reloadcache.php >> /var/log/logzilla/reloadcache.log
6.Setup LogZilla
  1. cd /var/www/logzilla/html
  2. chmod 777 ./config/config.php
  3. chmod 777 ./config
  4. chmod 777 ./jpcache
  5. touch lpd_graph.jpeg
  6. chmod 777 lpd_graph.jpeg

เข้าไปที่ http://server/logs แล้วทำตามขั้นตอนไปเรื่อย ๆ
step 1 ป้อนแค่รหัสผ่าน mysql ของ root อย่างอื่นปล่อยเป็น default ไว้
step 3 ตรง site url ใส่ /logs/ ตามที่ตั้งค่า apache ไว้ แล้วใส่ email กับตั้งรหัสผ่านของ admin
step 4 คลิก Install CEMDB (Cisco Error Message Database) แล้วก็ Import จนเสร็จ
เข้าไปแก้ไข path ต่าง ๆ โดยใช้ script
  1. cd /var/www/logzilla/scripts
  2. ./fixpaths.sh
  3.  

Ubuntu : Install : ServerExtranet

1. Install Ubuntu 10.04 Server by select guide Install and set software openssh-server
2. Edit sources list new
http://porpramarn.blogspot.com/2012/04/ubuntu-update-sources-list.html
3. Install apache2 use code apt-get install apache2
4. Setting Vbox ---> Network Adapter1 : Bridged Adapter for get ip real.
5. in ubuntu use command in terminal ifconfig for looking ip for network.
6. Test Apache by open browser and insert address ip in (5.) if browser show It Works. it ok.
7. Set ip new in network. by use command nano /etc/network/interfaces
edit dhcp to static and remote look server2 file nano /etc/network/interfaces or use command
  1.  
  2. iface eth0 inet static
  3.         address 192.168.0.9
  4.         netmask 255.255.255.0
  5.         network 192.168.0.0
  6.         broadcast 192.168.0.255
  7.         gateway 192.168.0.2
  8.  

8. restart network by use command /etc/init.d/networking restart
9. Test apache by (6.) . by use new ip.
10. if (9.) not work. use command check LAN (
  1. mii-tool
) or (
  1. ifconfig
for look etc and use
  1. ifconfig eth0 up
and restart networking) .
if it ready not use command in (10).
11. install MySql-server by use command (
  1. apt-get install mysql-server
and set password root) step install select apache2 and set password 3 times
12. Test phpmyadmin by open browser get address IP/phpmyadmin and insert user and password
13. Copy file backup for server and extract and create new database in phpmyadmin is name same database real.
14. import database
15. Install webmin by copy file backup to server2/var/www/cc. by use ftp in ubuntu or other method.
16. use code in terminal for servertest (
) for download file insert home for server test. Or use method other by computer is install apache it can shared file for other computer download. by paste in var/www/cc.
17. install webmin by use command (
  1. dpkg -i webmin_1.580_......name file
).step install you must set password for sa. if step install error some packet. so use command (
  1. apt-get install -f
). And test webmin by open browser insert address IP:10000 (https)
After install webmin finish. you can use webmin upload file or delete file and extract file in program webmin. by insert menu other and select file manager. or you can use command
18. copy file for web to servertest. by copy file extarnet.tar.gz and paste in cc for computer is run apache example paste in server2/var/www/cc by use ftp for ubuntu or use upload file in webmin.
19. use command in terminal for servertest (
) for download file paste in home for servertest.
20. extract file in home by use command (
  1. tar -zxvf extranet....file name
)
21. enter in var and www by use command cd var, cd www
22. move all file in folder to /var/www/ by use command (
  1. mv * /var/www/
)
24. delete file index.html in program webmin in folder /var/www/ and test run web by enter ip.
25. if web not run or error. you must install packet by use command (
  1. apt-get install php5-sybase
) and test run web
26. edit file getNews.php by change split to explode.

Finished install web Extranet and phpmyadmin

Install syslog
1. install ntp by use command (
  1. apt-get install ntp
)
2. edit server (
  1. nano /etc/ntp.conf)
change server to 192.168.0.252 << NTP Server IP
use ssh enter to ip. for copy command in blog paste so not typing.
by run terminal in ubuntu computer and use command
  1. ssh sa@IP
insert password of servertest
And see this blog. Method install syslog
http://porpramarn.blogspot.com/2012/04/ubuntu-centralized-log-with-logzilla.html
1. step difference.
in 1.
if you copy file logzilla_v2...file name to server2/var/www/cc you can use command
in 1.
  1. mv php-syslog-ng logzilla
you must move to file /var/www/
2. difference step 2.Edit /etc/syslog-ng/syslog-ng.conf . by copy เฉพาะ Code ตรง ส่วน ### Sources ### ไปวางต่อท้าย ไฟล์ดังกล่าว ไม่ต้องทับหมด

  1. ### Sources ###
  2. source s_local {
  3. # message generated by Syslog-NG
  4. internal();
  5. # standard Linux log source (this is the default place for the syslog()
  6. # function to send logs to)
  7. unix-stream("/dev/log");
  8. # messages from the kernel
  9. file("/proc/kmsg" log_prefix("kernel: "));
  10. };
  11.  
  12. ### Destinations ###
  13. destination d_logzilla {
  14.   program("/var/www/logzilla/scripts/db_insert.pl"
  15.   template("$HOST\t$FACILITY\t$PRIORITY\t$LEVEL\t$TAG\t$YEAR-$MONTH-$DAY\t$HOUR:$MIN:$SEC\t$PROGRAM\t$MSG\n")
  16.   );
  17. };
  18.  
  19. ### Logs ###
  20. log {
  21.    source(s_local);
  22.    destination(d_logzilla);
  23. };
  24.  

3. difference step 3.

  1. cpan Text::LevenshteinXS
in step install you must answer ok and yes
And install

  1. packed cpan -i YAML
after install fist command.
4. difference step 5. set time

  1. crontab -e
you mush select 2 and enter.
5. difference step 6. step install LogZilla setup is not font red in page. if have font red you must edit file.

  1. nano /etc/php5/apache2/php.ini
  2. nano /etc/php5/cli/php.ini

ตาม error นั้น ค้นหาและ แก้ไฟล์ save

Ubuntu Update Sources list

- After install Ubuntu finish
1. Use command nano /etc/apt/sources.list Enter
2. Edit file by Ctrl+w and typing "th.archive.ubunt.com" and Ctrl+r
3. Typing "192.168.0.252:9999" Enter and typing a Enter
4. Ctrl+w and typing "security.ubuntu.com" and Ctrl+r
5. Insert data same number 3.
6. press Ctrl+x and Ctrl+y Enter
7. use command apt-get update
8. After apt-get update finish. Use command apt-get upgrade

PHP : ความแตกต่างของฟังก์ชั่น empty()และ isset() ใน PHP

ความแตกต่างของฟังก์ชั่น empty()และ isset() ใน PHP
มาดูความแตกต่างระหว่างฟังก์ชั่น empty() และ ฟังก์ชั่น isset() กันค่ะ ว่าแตกต่างกันยังไง และใช้งานกันยังไงบ้าง
ฟังก์ชั่น empty() ทำหน้าที่ตรวจสอบว่าตัวแปลที่เรากำหนดไว้มีค่าอยู่ในตัวแปลนั้นหรือไม่
ส่วน
ฟังก์ชั่น isset() จะทำหน้าที่ตรวจสอบว่ตัวแปรนั้นมีอยู่จริงหรือไม่
การใช้ isset จะไม่เหมาะกับพวกการรับข้อมูลเช่น GET POST
ยกตัวอย่าง ถ้ามีคนเรียกแบบนี้ download.php?id=
ถ้าใช้ empty($_GET['id']) มันจะคืน true แปลว่าตัวแปรนั้นว่าง
แต่ถ้า isset($_GET['id']) มันจะคืน true แปลว่าตัวแปรนั้นมี แต่เราไม่รู้ว่ามันว่างหรือไม่
ดังนั้นการใช้ empty จะชัวร์กว่า ในเรื่องตัวแปรนั้นๆ มีข้อมูลมาจริงๆ

View source
<? if(!$table || !$params) return false; ?>

เวลาจะเช็คตัวแปร แนะนำใช้ empty ดีกว่า

View source
<? if(empty($table) || empty($params)) return false; ?>

ตัวอย่างการใช้ isset ตรวจสอบว่าตัวแปรนั้นมีอยู่จริงหรือไม่

View source
<? if (isset($p_edit)) {
 
 $sql = "SELECT * FROM $tb_pc WHERE id_com = '$p_edit' ";
 
 $query =mysql_query($sql);
 
 $show = mysql_fetch_array($query);}?>

PHP : ส่งค่าผ่าน From โดยไม่ต้องแสดงผล

ส่งผ่าน hidden
ความต้องการคื่อในหน้า PHP นั้น ๆ ไม่อยากให้แสดงข้อมูล หรือไม่ได้เก็บใส่ Taxt แต่ต้องการค่า
จากหน้าหนึ่งไปยังอีกหน้าหนึ่ง

<input type="hidden" name="hdnName" value="<?=$x;?>">


รับค่าก็เป็น
$hidden = $_GET[hdnName];