Internet
You are currently browsing the articles from KomKid.Net matching the category Internet.
1.ดาวน์โหลดและติดตั้ง PHP SYSLOGVIEWER
1 2 3
| wget http://jaist.dl.sourceforge.net/sourceforge/phpsyslogviewer/phpsyslogviewer-7.2.1.tar.bz2
tar xjvf phpsyslogviewer-7.2.1.tar.bz2
cd phpsyslogviewer-7.2.1 |
2.สร้างฐานข้อมูล
1 2 3 4
| mysql -u root -p
mysql > create database syslogng;
mysql > exit;
mysql -u root -p syslogng < install/phpsyslogviewer.sql |
3.สร้างรายชื่อผู้ใช้
1 2 3
| vi install/newuser.sql.php
php install/newuser.sql.php (ถ้ายังไม่มี php-cli ต้องลงก่อน apt-get install php5-cli)
php install/newuser.sql.php | mysql -u root -p syslogng |
4.สร้างและตั้งค่าหน้าเว็บ
1 2 3 4
| cp -R htdocs /var/www/phpsyslogviewer
vi /var/www/phpsyslogviewer/config.php
chown root:www-data /var/www/phpsyslogviewer/config.php
chmod 440 /var/www/phpsyslogviewer/config.php |
5.ลองเข้าดูได้ที่ http://192.168.0.251/phpsyslogviewer
6.เพิ่มความเร็วให้การป้อนข้อมูลลง mysql
1 2 3 4 5 6 7 8 9 10
| wget http://jaist.dl.sourceforge.net/sourceforge/phpsyslogviewer/speedupd-7.3.2.tar.bz2
tar xjvf speedupd-7.3.2.tar.bz2
cd speedup-7.3.2ฝ
apt-get install debhelper cmake libdaemon-dev libconfuse-dev fakeroot
apt-get install build-essential libmysqlclient15-dev
dpkg-buildpackage -rfakeroot
cd ..
dpkg -i speedupd_7.3.0_i386.deb
vi /etc/speedupd.conf
/etc/init.d/speedupd start |
Written by Komkid on November 22nd, 2009 with no comments.
Read more articles on Admin and Internet and Networking and Ubuntu.
ติดตั้ง NTP (Network Time Protocol)
ตาม พรบ.ว่าด้วยการกระทำผิดเกี่ยวกับคอมพิวเตอร์ พ.ศ. 2550 กำหนดให้ ต้องตั้งนาฬิกาของอุปกรณ์บริการทุกชนิดให้ตรงกับเวลาอ้างอิงสากล (Stratum 0) โดยผิดพลาดไม่เกิน 10 มิลลิวินาที
1.ติดตั้ง apt-get install ntp (ที่ Log Server และ Server อื่น ๆ)
2.ตั้งค่า Log Server (/etc/ntp.conf)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| # /etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for help
driftfile /var/lib/ntp/ntp.drift
# Enable this if you want statistics to be logged.
#statsdir /var/log/ntpstats/
#statistics loopstats peerstats clockstats
#filegen loopstats file loopstats type day enable
#filegen peerstats file peerstats type day enable
#filegen clockstats file clockstats type day enable
# You do need to talk to an NTP server or two (or three).
server 203.185.69.60 dynamic
server time.navy.mi.th dynamic
server time.nist.gov dynamic
server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 10
broadcastdelay 0.008
keys /etc/ntp/keys
# Access control configuration; see /usr/share/doc/ntp-doc/html/accopt.html for
# details. The web page <http://support.ntp.org/bin/view/Support/AccessRestric$
# might also be helpful.
#
# Note that "restrict" applies to both servers and clients, so a configuration
# that might be intended to block requests from certain clients could also end
# up blocking replies from your own upstream servers.
# By default, exchange time with everybody, but don't allow configuration.
#restrict -4 default kod notrap nomodify nopeer noquery
restrict default kod notrap nomodify nopeer noquery
# Local users may interrogate the ntp server more closely.
restrict 127.0.0.1
#restrict ::1
# Clients from this (example!) subnet have unlimited access, but only if
# cryptographically authenticated.
restrict 192.168.0.0 mask 255.255.255.0 nomodify notrap
# If you want to provide time to your local subnet, change the next line.
# (Again, the address is an example only.)
#broadcast 192.168.123.255
# If you want to listen to time broadcasts on your local subnet, de-comment the
# next lines. Please do this only if you trust everybody on the network!
#disable auth
#broadcastclient |
3. ตั้งค่า Server อื่น ๆ ที่เป็น linux
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| # /etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for help
driftfile /var/lib/ntp/ntp.drift
# Enable this if you want statistics to be logged.
#statsdir /var/log/ntpstats/
#statistics loopstats peerstats clockstats
#filegen loopstats file loopstats type day enable
#filegen peerstats file peerstats type day enable
#filegen clockstats file clockstats type day enable
# You do need to talk to an NTP server or two (or three). (192.168.0.251 is Log Server)
server 192.168.0.251
# Access control configuration; see /usr/share/doc/ntp-doc/html/accopt.html for
# details. The web page <http://support.ntp.org/bin/view/Support/AccessRestrictions>
# might also be helpful.
#
# Note that "restrict" applies to both servers and clients, so a configuration
# that might be intended to block requests from certain clients could also end
# up blocking replies from your own upstream servers.
# By default, exchange time with everybody, but don't allow configuration.
#restrict -4 default kod notrap nomodify nopeer noquery
#restrict -6 default kod notrap nomodify nopeer noquery
restrict default ignore
# Local users may interrogate the ntp server more closely.
restrict 127.0.0.1
#restrict ::1
# Clients from this (example!) subnet have unlimited access, but only if
# cryptographically authenticated. (192.168.0.251 is Log Server)
restrict 192.168.0.251 mask 255.255.255.255 nomodify notrap noquery
# If you want to provide time to your local subnet, change the next line.
# (Again, the address is an example only.)
#broadcast 192.168.123.255
# If you want to listen to time broadcasts on your local subnet, de-comment the
# next lines. Please do this only if you trust everybody on the network!
#disable auth
#broadcastclient |
ทดสอบ
# ntpq -pn
# ntpdc
ntpdc>sysinfo
3. ตั้งค่าเครื่องอื่น ๆ ที่เป็น Windows โดยใช้ regedit.exe (save เป็น . reg แล้ว double click)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Config]
"AnnounceFlags"=dword:00000005
"MaxNegPhaseCorrection"=dword:00000e10
"MaxPosPhaseCorrection"=dword:00000e10
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Parameters]
"NtpServer"="192.168.0.251,0x1"
"Type"="NTP"
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpClient]
"SpecialPollInterval"=dword:00000384
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpServer]
"Enabled"=dword:00000001
|
restart service w32time
:\>net stop w32time
:\>net start w32time
ทดสอบ
:\>net time
:\>net time /querysntp
Written by Komkid on November 22nd, 2009 with no comments.
Read more articles on Admin and Internet and Networking and Ubuntu.
ทั้ง phpBB ของที่ทำงานและ wordpress ของที่นี่ ต่างก็ใช้ Syntax Hilight ของ GeSHi
โดย phpBB เป็น phpBB3.0.5 ติดตั้ง mod bbGeSHi 0.7.5
และ wordpress ใช้ plugin wp-syntax.0.9.8
เวลาใช้มักจะลืมตัวย่อของภาษาอยู่เรื่อย ก็เลยต้อง list ไว้กันลืมซะหน่อย
ABAP – abap
Actionscript – actionscript
ADA – ada
Apache Log – apache
AppleScript – applescript
APT sources.list –
ASM (m68k) – asm
ASM (pic16) – asm
ASM (x86) – asm
ASM (z80) – asm
ASP – asp
AutoIT – autoit
Backus-Naur form –
Bash – bash
Basic4GL –
BlitzBasic – blitzbasic
Brainfuck – bnf
C – c
C for Macs – c_mac
C# – cpp
C++ – csharp
C++ (with QT) – cpp-qt
CAD DCL – caddcl
CadLisp – cadlisp
CFDG – cfdg
CIL / MSIL –
COBOL –
ColdFusion – cfm
CSS – css
D – d
Delphi – delphi
Diff File Format – diff
DIV – div
DOS – dos
DOT language – dot
Eiffel – eiffel
Fortran – fortran
FourJ’s Genero – genero
FreeBasic – freebasic
GetText –
glSlang –
GML – gml
gnuplot –
Groovy – groovy
Haskell – haskell
HQ9+ –
HTML – html, html4strict
INI (Config Files) – ini
Inno – inno
INTERCAL –
IO – io
Java – java
Java 5 – java5
Javascript – javascript, js
KiXtart –
KLone C & C++ –
LaTeX – latex
Lisp – lisp
LOLcode –
LotusScript –
LScript –
Lua – lua
Make – m68k
mIRC – mirc
MXML –
MySQL – mysql
NSIS – nsis
Objective C – objc
OCaml – Ocaml-brief, ocaml
OpenOffice BASIC – oobas
Oracle 8 & 11 SQL – oracle8
Pascal – pascal
Perl – perl
PHP – Php-brief, php
Pixel Bender –
PL/SQL – plsql
POV-Ray –
PowerShell –
Progress (OpenEdge ABL) –
Prolog –
ProvideX –
Python – python
Q(uick)BASIC – qbasic
robots.txt – robots
Ruby – ruby
Ruby on Rails – rails
SAS – sas
Scala –
Scheme – scheme
Scilab –
SDLBasic – sdlbasic
Smalltalk – smalltalk
Smarty – smarty
SQL – sql
T-SQL – tsql
TCL – tcl
thinBasic – thinbasic
TypoScript –
Uno IDL –
VB.NET – vbnet
Verilog –
VHDL – vhdl
VIM Script –
Visual BASIC – vb
Visual Fox Pro – visualfoxpro
Visual Prolog –
Whitespace –
Winbatch – winbatch
Windows Registry Files – reg
X++ – xpp (มี X++ ของ Axapta ด้วย)
XML – xml, xsl
Xorg.conf –
Written by Komkid on October 4th, 2009 with no comments.
Read more articles on Admin and Internet.
มาต่อกันด้วยการส่งตรง Message ถึงเพื่อนที่เราต้องการ
URL: http://api.noknok.sanook.com/rest/direct_message_new
Format: xml
Method(s): POST
Parameters:
* authToken (required:GET)
* message (required:POST)
* message_to (required:POST)
Return:
* Sending status (true or false)
ก็เอา code เดิมมาแก้ไข form นิดหน่อย
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| $base = 'http://api.noknok.sanook.com/rest/auth';
$query_string = 'username=komkid&password=******';
$url = "$base?$query_string";
$xml = file_get_contents($url);
$dom = new DOMDocument ('1.0', 'UTF-8');
if ($dom->loadXML($xml) === false) {
die('Parsing failed');
}
$res = xml_to_result ($dom);
if($res["stat"] == "ok"){
$query_string = 'authToken='.$res["authToken"];
$str= " Send Direct Message <br>";
$str.= "<form method=\"post\" action=\"http://api.noknok.sanook.com/rest/direct_message_new?$query_string\">";
$str.= "message : <input type=\"text\" name=\"message\"><br>";
$str.= "send to : <input type=\"text\" name=\"message_to\"><br>";
$str.= "<input type=\"submit\" value=\"send\">";
$str.= "</form>";
echo $str;
} |
ได้ form ดังรูป

แล้วก็ได้ผลดังนี้

Written by Komkid on February 24th, 2009 with no comments.
Read more articles on Internet and Programming.
มาต่อกันด้วย การ Update Status ของเราด้วย
new
URL: http://api.noknok.sanook.com/rest/message_new
Format: XML
Method(s): GET, POST
Parameters:
* authToken (required:GET)
* message (required:POST)
Return
* Sending message data
(ผ่านไปไม่กี่วัน URL เปลี่ยนซะแล้ว จาก http://api.noknok.in.th/rest/ เป็น http://api.noknok.sanook.com/rest)
ซึ่งคราวนี้จะต้องส่งแบบ POST เพราะฉะันั้นก็ต้องสร้าง FORM ไว้ส่ง
ก็เอาแบบง่าย ๆ นะครับ
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| $base = 'http://api.noknok.sanook.com/rest/auth';
$query_string = 'username=komkid&password=******';
$url = $base.'?'.$query_string;
$xml = file_get_contents($url);
$dom = new DOMDocument ('1.0', 'UTF-8');
if ($dom->loadXML($xml) === false) {
die('Parsing failed');
}
$res = xml_to_result ($dom);
if($res[stat] == 'ok'){
$query_string = 'authToken='.$res[authToken ];
$str=<<<FORM
Update Status <br >
<form method ="post" action ="http://api.noknok.sanook.com/rest/message_new?$query_string">
message : <input type ="text" name ="message"><br >
<input type ="submit" value ="update">
</form >
FORM ;
echo $str;
} |

ได้ผลดังรูป

อ้อ อย่าลืมตั้งค่า Encoding เป็น UTF8 ด้วยนะครับ
Introduction
API Protocol
* Representational_State_Transfer(REST)
* HTTP Requests: Post and GET
Data Format
* XML, *Json, *RSS,*ATOM
Encoding
* UTF8
Written by Komkid on February 23rd, 2009 with no comments.
Read more articles on Internet and Programming.