Tuesday, November 27, 2007

UNIX - uname : print name of current system

`uname` - Print certain system information. With no OPTION, same as -s.


Usage
uname [OPTION]


DESCRIPTION
The uname utility prints information about the current system on the standard output. When options are specified, symbols representing one or more system characteristics will be written to the standard output. If no options are specified, uname prints the current operating system's name. The options print selected information returned by uname(2), sysinfo(2), or both.

OPTION
-a, --all print all information, in the following order:
-s, --kernel-name print the kernel name
-n, --nodename print the network node hostname
-r, --kernel-release print the kernel release
-v, --kernel-version print the kernel version
-m, --machine print the machine hardware name
-p, --processor print the processor type
-i, --hardware-platform print the hardware platform
-o, --operating-system print the operating system
--help display this help and exit
--version output version information and exit


EXAMPLE

[root@server root]# uname -a
Linux admincmd.blogspot.com 2.4.21-4.ELsmp #1 SMP Fri Nov 14 12:52:56 EDT 2002 i686 i686 i386 GNU/Linux


.

Friday, November 23, 2007

PHP The $_POST variable

`PHP $_POST`

The $_POST variable is used to collect values from a form with method="post".

The $_POST variable is used to collect values from a form with method="post". Information sent from a form with the POST method is invisible to others and has no limits on the amount of information to send.

Example

HTML: test.html









When the user clicks the "Submit" button, the URL will not contain
any form data, and will look something like this:
 http://admincmd.blogspot.com/login.php

The "login.php" file can now use the $_POST variable to catch the form data (notice that the names of the form fields will automatically be the ID keys in the $_POST array):

PHP: login.php

< ?php
echo "Your name is ".$_POST["name"]
;

echo "Your password is ".$_POST["pass"];

?>

Why use $_POST?

  • Variables sent with HTTP POST are not shown in the URL
  • Variables have no length limit

However, because the variables are not displayed in the URL, it is not possible to bookmark the page.

Thursday, November 22, 2007

UNIX - df [disk space]

`df` - report filesystem disk space usage

USAGE
df [OPTION]... [FILE]...

The df command displays the amount of disk space occupied by mounted or unmounted file systems, the amount of used and available space, and how much of the file system's total
capacity has been used. The file system is specified by dev ice, or by referring to a file or directory on the specified file system.

Used without operands or options, df reports on all mounted file systems.

df may not be supported for all FSTypes.

If df is run on a networked mount point that the automounter has not yet mounted, the file system size will be reported as zero. As soon as the automounter mounts the file system,
the sizes will be reported correctly.

OPTIONS
Show information about the filesystem on which each FILE resides, or all filesystems by default.
Mandatory arguments to long options are mandatory for short options too.

-a, --all
include filesystems having 0 blocks

-B, --block-size=SIZE use SIZE-byte blocks

-h, --human-readable
print sizes in human readable format (e.g., 1K 234M 2G)

-H, --si
likewise, but use powers of 1000 not 1024

-i, --inodes
list inode information instead of block usage

-k like --block-size=1K

-l, --local
limit listing to local filesystems

--no-sync
do not invoke sync before getting usage info (default)

-P, --portability
use the POSIX output format

--sync invoke sync before getting usage info

-t, --type=TYPE
limit listing to filesystems of type TYPE

-T, --print-type
print filesystem type

-x, --exclude-type=TYPE
limit listing to filesystems not of type TYPE

-v (ignored)

--help display this help and exit

--version
output version information and exit

EXAMPLE

banner

`banner` - make posters

DESCRIPTION
banner prints its arguments (each up to 10 characters long) in large letters on the standard output.

EXAMPLE
root@server # banner test








root@server #

Tuesday, October 2, 2007

diplay domain name.

`domainname` - set or display name of the current domain.

USAGE:
domainname [ name-of-domain ]

DESCRIPTION:
Without an argument, domainname displays the name of the current domain, which typically encompasses a group of hosts or passwd entries under the same administration.The domainname command is used by various components of Solaris to resolve names for types such as passwd, hosts and aliases.By default, various naming services such as NIS, NIS+, the
Internet Domain Name Service (DNS) and sendmail(1M) use this domainname to resolve names. The domainname is normally a valid Internet domain name.

The domainname for various naming services can also be set by other means. For example, ypinit can be used to specify a different domain for all NIS calls. The file /etc/resolv.conf can be used to specify a different domain for DNS lookups. For sendmail, the domainname can be specified through the sendmail_vars entry in the /etc/nsswitch.conf file, or through the /etc/mail/sendmail.cf file. Only the superuser can set the name of the domain by specifying the new domainname as an argument. The domain name of the machine is usually set during boot-time through the domainname command in the /etc/init.d/inetinit file. If the new domain name is not saved in the /etc/defaultdomain file, the machine will revert back to the old domain after rebooting.

EXAMPLE:
[root@server root]# domainname
(none)

print name of host.

`hostname` - set or print name of current host system.

DESCRIPTION:
The hostname command prints the name of the current host, as given before the login prompt. The super-user can set the hostname by giving an argument.

When called without any arguments, the program displays the current names.

USAGE:

[root@server root]# hostname
file.server.co.th



DOS - Starts app.

`start` - Starts a separate window to run a specified program or command.
USAGE:
START ["title"] [/Dpath] [/I] [/MIN] [/MAX] [/SEPARATE | /SHARED]
[/LOW | /NORMAL | /HIGH | /REALTIME | /ABOVENORMAL | /BELOWNORMAL]
[/WAIT] [/B] [command/program]
[parameters]

"title" Title to display in window title bar.
path Starting directory
B Start application without creating a new window. The application has ^C handling ignored. Unless the application enables ^C processing, ^Break is the only way to interrupt the application
I The new environment will be the original environment passed to the cmd.exe and not the current environment.
MIN Start window minimized
MAX Start window maximized
SEPARATE Start 16-bit Windows program in separate memory space
SHARED Start 16-bit Windows program in shared memory space
LOW Start application in the IDLE priority class
NORMAL Start application in the NORMAL priority class
HIGH Start application in the HIGH priority class
REALTIME Start application in the REALTIME priority class
ABOVENORMAL Start application in the ABOVENORMAL priority class
BELOWNORMAL Start application in the BELOWNORMAL priority class
WAIT Start application and wait for it to terminate command/program
If it is an internal cmd command or a batch file then the command processor is run with the /K switch to cmd.exe. This means that the window will remain after the command has been run.

If it is not an internal cmd command or batch file then it is a program and will run as either a windowed application or a console application.

parameters These are the parameters passed to the command/program


If Command Extensions are enabled, external command invocation through the command line or the START command changes as follows:

non-executable files may be invoked through their file association just by typing the name of the file as a command. (e.g. WORD.DOC would launch the application associated with the .DOC file extension). See the ASSOC and FTYPE commands for how to create these associations from within a command script.

When executing an application that is a 32-bit GUI application, CMD.EXE does not wait for the application to terminate before returning to the command prompt. This new behavior does NOT occur if executing within a command script.

When executing a command line whose first token is the string "CMD " without an extension or path qualifier, then "CMD" is replaced with the value of the COMSPEC variable. This prevents picking up CMD.EXE from the current directory.

When executing a command line whose first token does NOT contain an extension, then CMD.EXE uses the value of the PATHEXT environment variable to determine which extensions to look for and in what order. The default value for the PATHEXT variable is:

.COM;.EXE;.BAT;.CMD

Notice the syntax is the same as the PATH variable, with semicolons separating the different elements.

When searching for an executable, if there is no match on any extension,then looks to see if the name matches a directory name. If it does, the START command launches the Explorer on that path. If done from the command line, it is the equivalent to doing a CD /D to that path.

EXAMPLE:

C:\>start notepad

Thursday, September 13, 2007

UNIX - determine file type

`file` - determine file type

USAGE:
file [ -h ] [ -m mfile ] [ -f ffile ] file ...

file [ -h ] [ -m mfile ] -f ffile

file -c [ -m mfile ]

DESCRIPTION:
The file utility performs a series of tests on each file supplied by file and, optionally, on each file listed in ffile in an attempt to classify it. If the file is not a regular file, its file type is identified. The file types directory, FIFO, block special, and character special are
identified as such. If the file is a regular file and the file is zero-length, it is identified as an empty file.

If file appears to be a text file, file examines the first 512 bytes and tries to determine its programming language. If file is an executable a.out, file prints the version stamp, provided it is greater than 0. If file is a symbolic link, by default the link is followed and file tests the file to which the symbolic link refers.

By default, file will try to use the localized magic file /usr/lib/locale/locale/LC_MESSAGES/magic, if it exists, to identify files that have a magic number. For example, in the Japanese locale, file will try to use /usr/lib/locale/ja/LC_MESSAGES/magic. If a localized magic file does not exist, file will utilize /etc/magic. A magic number is a numeric or string constant that indicates the
file type. See magic(4) for an explanation of the format of /etc/magic.

If file does not exist, cannot be read, or its file status could not be determined, it is not considered an error that affects the exit status. The output will indicate that the
file was processed, but that its type could not be deter mined.

OPTIONS:
The following options are supported:

-c Check the magic file for format errors. For reasons of
efficiency, this validation is normally not carried
out.
-h Do not follow symbolic links.
-f ffile

EXAMPLES:
[root@server root]# file *
3c2000.tar.gz: gzip compressed data, from Unix
DriverInstall: directory
fw_script.sh: Bourne shell script text executable
install.log: ASCII text
[root@serverroot]#

UNIX - change login password

`passwd` - change login password and password attributes.

Usage:
passwd [OPTION...]

OPTION:
-k, --keep-tokens keep non-expired authentication tokens
-d, --delete delete the password for the named account (root only)
-l, --lock lock the named account (root only)
-u, --unlock unlock the named account (root only)
-f, --force force operation

-x, --maximum=DAYS maximum password lifetime (root only)
-n, --minimum=DAYS minimum password lifetime (root only)
-w, --warning=DAYS number of days warning users receives before
password expiration (root only)
-i, --inactive=DAYS number of days after password expiration when an
account becomes disabled (root only)
-S, --status report password status on the named account (root
only)
--stdin read new tokens from stdin (root only)


EXAMPLE:

[root@server root]# passwd smith
Changing password for user smith.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

***

Friday, August 31, 2007

Add a Mailbox to an Existing User Account in Exchange 2003 Server

Add a Mailbox to an Existing User Account

1. Click Start, point to Programs, point to Microsoft Exchange, and then click Active Directory Users and Computers.

2. Expand the domain, and then click the Users folder.
3. In the right pane, right-click the user's name, and then click Exchange Tasks to start the Exchange Task Wizard.
4. In the Welcome dialog box, click Next.
If you want to skip the Welcome screen in the future, you can click to select the Do Not Show This Welcome Page Again check box.



5. Under Select a task to perform, click Create Mailbox.


6. By default, the alias is set to the logon name. If you want to change this value, type a new alias.



7. If multiple Exchange Server computers are configured with an information store, click an entry in the Server list to specify the server where you want the mailbox to be stored.

Caution: In Exchange Server mixed-mode operations, you cannot move mailboxes from a server in one administrative group to a server in another administrative group.
8. If multiple mailbox stores are configured, click an entry in the Mailbox Store list to specify the mailbox store to use.

9. Click Next, and then click Finish.

Thursday, August 30, 2007

Unix - change working directory

`cd` - change working directory.

The cd utility will change the working directory of the current shell execution environment. When invoked with no operands, and the HOME environment variable is set to a non-empty value, the directory named in the HOME environment variable will become the new working directory.

EXAMPLE:

[root@server log]# pwd
/var/log
[root@server log]# cd ..
[root@server var]# pwd
/var
[root@server var]# cd /var/mail
[root@server mail]# pwd
/var/mail
[root@server mail]# cd /
[root@server /]# pwd
/
[root@server /]# cd
[root@server root]# pwd
/root

Unix - print name of working directory

`pwd` - print name of current/working directory,return working directory name.

Usage:
pwd [OPTION]

Print the full filename of the current working directory.
pwd writes an absolute path name of the current working directory to standard output.


EXAMPLE:

root@server# pwd
/

------------------------------
trigger@server:/stdisk001/home/trigger>pwd
/stdisk001/home/trigger

------------------------------

[root@server log]# pwd
/var/log

Linux - list loaded modules.

`lsmod` - list loaded modules.

lsmod shows information about all loaded modules.

The format is name, size, use count, list of referring modules. The information displayed is identical to that available from /proc/modules.

If the module controls its own unloading via a can_unload routine then the user count displayed by lsmod is always -1, irrespective of the real use count.

EXAMPLE:

[root@server root]# lsmod
Module Size Used by Not tainted
nfsd 86960 8 (autoclean)
lockd 60656 1 (autoclean) [nfsd]
sunrpc 92124 1 (autoclean) [nfsd lockd]
parport_pc 19204 1 (autoclean)
lp 9220 0 (autoclean)
floppy 59056 0 (autoclean)
microcode 5248 0 (autoclean)
keybdev 2976 0 (unused)
mousedev 5688 0 (unused)
hid 22404 0 (unused)
input 6208 0 [keybdev mousedev hid]
ehci-hcd 20904 0 (unused)
usb-uhci 27532 0 (unused)
usbcore 83168 1 [hid ehci-hcd usb-uhci]
ext3 95784 5
jbd 56856 5 [ext3]
......
..


Tuesday, August 28, 2007

DOS - `dir`

`dir` - Displays a list of files and subdirectories in a directory.

Usage:
DIR [drive:][path][filename] [/A[[:]attributes]] [/B] [/C] [/D] [/L] [/N]
[/O[[:]sortorder]] [/P] [/Q] [/S] [/T[[:]timefield]] [/W] [/X] [/4]

[drive:][path][filename]
Specifies drive, directory, and/or files to list.

/A Displays files with specified attributes.
attributes D Directories R Read-only files
H Hidden files A Files ready for archiving
S System files - Prefix meaning not
/B Uses bare format (no heading information or summary).
/C Display the thousand separator in file sizes. This is the
default. Use /-C to disable display of separator.
/D Same as wide but files are list sorted by column.
/L Uses lowercase.
/N New long list format where filenames are on the far right.
/O List by files in sorted order.
sortorder N By name (alphabetic) S By size (smallest first)
E By extension (alphabetic) D By date/time (oldest first)
G Group directories first - Prefix to reverse order
/P Pauses after each screenful of information.
/Q Display the owner of the file.
/S Displays files in specified directory and all subdirectories.
/T Controls which time field displayed or used for sorting
timefield C Creation
A Last Access
W Last Written
/W Uses wide list format.
/X This displays the short names generated for non-8dot3 file
names. The format is that of /N with the short name inserted
before the long name. If no short name is present, blanks are
displayed in its place.
/4 Displays four-digit years

Switches may be preset in the DIRCMD environment variable. Override
preset switches by prefixing any switch with - (hyphen)--for example, /-W.

EXAMPLE:

C:\>dir /A
Volume in drive C is SYSTEM
Volume Serial Number is NRF9-8T9A

Directory of C:\

01/12/2007 02:12 PM 332 001.sql
04/26/2006 10:58 AM 0 AUTOEXEC.BAT
08/24/2005 04:18 PM 194 boot.ini
04/26/2005 10:58 AM 0 CONFIG.SYS
07/17/2004 04:03 PM dir Document
04/26/2007 11:03 AM dir Documents and Settings
02/13/2005 01:09 PM 561 INSTALL.LOG
01/26/2007 10:58 AM 0 IO.SYS
01/26/2007 10:58 AM 0 MSDOS.SYS
06/26/2002 02:19 AM 45,124 NTDETECT.COM
06/26/2002 02:19 AM 222,368 ntldr
02/10/2007 09:22 AM 399,491,072 pagefile.sys
04/20/2005 09:09 AM dir Program Files
04/26/2006 12:19 PM dir RECYCLER
02/22/2007 11:03 AM dir System Volume Information
03/23/2007 10:29 AM dir TMP
06/11/1985 05:34 PM 128,000 UNWISE.EXE
06/22/2007 05:55 PM dir WINDOWS
10 File(s) 400,158,372 bytes
8 Dir(s) 24,543,551,488 bytes free

C:\>

DOS - change console foreground and background colors

[WINDOWS XP - DOS]
`color`
- Sets the default console foreground and background colors.

Usage:
COLOR [attr]

attr Specifies color attribute of console output

Color attributes are specified by TWO hex digits -- the first corresponds to the background; the second the foreground.
Each digit can be any of the following values:

0 = Black
1 = Blue
2 = Green
3 = Aqua
4 = Red
5 = Purple
6 = Yellow
7 = White
8 = Gray
9 = Light Blue
A = Light Green
B = Light Aqua
C = Light Red
D = Light Purple
E = Light Yellow
F = Bright White

If no argument is given, this command restores the color to what it was
when CMD.EXE started. This value either comes from the current console
window, the /T command line switch or from the DefaultColor registry
value.

The COLOR command sets ERRORLEVEL to 1 if an attempt is made to execute
the COLOR command with a foreground and background color that are the
same.

Example:

"COLOR fc" produces light red on bright white
C:\>color fc



Monday, August 27, 2007

DOS - `vol`

`vol` - Displays the disk volume label and serial number, if they exist.

Usage:
VOL [drive:]

Example:

C:\>vol
Volume in drive C is SYSTEM
Volume Serial Number is PCD4-4R59

Friday, August 24, 2007

Disk Defragmenter tool

Disk Defragmenter
How to Defragment Your Disk Drive Volumes in Windows XP ^_^

You can use the Disk Defragmenter tool to increase the speed of programs on your computer. When a program is installed on your computer, the program's files may be broken up over multiple locations on your hard disk. This is called fragmentation. If fragmentation occurs on your hard disk, the performance of programs on your computer is slower. The Disk Defragmenter tool optimizes the performance of your computer by reorganizing the files on your hard disk into contiguous blocks. When the Disk Defragmenter tool completes the defragmentation of files on your hard disk, the performance of your programs is faster because the files are arranged closer together.



To start the Disk Defragmenter tool, use the following steps:
(1)
(2)



(3)

สาเหตุที่ต้องมีการจัดเรียงไฟล์ต่าง ๆ ในฮาร์ดดิสก์ เนื่องจากเมื่อมีการบันทึกข้อมูลลงในฮาร์ดดิสก์ ตัว Microsoft Windows จะเขียน file แบบสุ่มโดยไม่สนใจว่าจะเขียนลง ณ ตำแหน่งใด ๆของฮาร์ดดิสก์ หรือเมื่อมีการติดตั้งโปรแกรมใช้งานต่าง ๆ จะทำให้เนื้อที่ฮาร์ดดิสก์ถูกใช้งานเพิ่มมากขึ้น จึงส่งผลกระทบต่อการเรียกใช้งานคอมพิวเตอร์

How often should I run Disk Defragmenter?
A hard drive should be defragmented once a month as a good preventative maintenance.


.

Unix - ` print `

`print`- shell built-in function to output characters to the screen or window

OPTIONS:
The following options are supported:
-n suppresses new-line from being added to the output.
-R
-r (raw mode) ignore the escape conventions of echo. The -R option will print all subsequent arguments and options other than -n.
-p causes the arguments to be written onto the pipe of the process spawned with & instead of standard output.
-s causes the arguments to be written onto the history file instead of standard output.
-u [ n ] flag can be used to specify a one digit file descriptor unit number n on which the output will be placed. The default is 1.

EXIT STATUS
The following exit values are returned:
0 Successful operation.
>0 Output file is not open for writing.

EXAMPLE:

tprint.ksh
-----------------------
#!/bin/ksh
$word="Hello world!";
print $word;
exit 0;



Thursday, August 23, 2007

DOS - `SYSTEMINFO`

`SYSTEMINFO` [/S system [/U username [/P [password]]]] [/FO format] [/NH]

Description:
This command line tool enables an administrator to query for basic
system configuration information.

Parameter List:
/S system Specifies the remote system to connect to.

/U [domain\]user Specifies the user context under which
the command should execute.

/P [password] Specifies the password for the given
user context. Prompts for input if omitted.

/FO format Specifies the format in which the output
is to be displayed.
Valid values: "TABLE", "LIST", "CSV".

/NH Specifies that the "Column Header" should
not be displayed in the output.
Valid only for "TABLE" and "CSV" formats.

/? Displays this help/usage.

Examples:
SYSTEMINFO
SYSTEMINFO /?
SYSTEMINFO /S system
SYSTEMINFO /S system /U user
SYSTEMINFO /S system /U domain\user /P password /FO TABLE
SYSTEMINFO /S system /FO LIST
SYSTEMINFO /S system /FO CSV /NH

C:\>systeminfo
Host Name: XXXXXXXXXXXXXXX

Name: Microsoft Windows XP ProfessionalOS
Version: X.X.2X00 Build 2XX0OS
Manufacturer: Microsoft CorporationOS
Configuration: Standalone WorkstationOS Build
Type: XXXXXXXXXXXXXXXXX
Owner: XXXXXXXXXXx
Registered Organization: XXXXXx
Product ID: XXXXX-XVM-0XXX1G3-0GHN2
Original Install Date: 1/26/2000, 11:02:06 AM
System Up Time: 100 Days, 1 Hours, 55 Minutes, 59 Seconds
System Manufacturer: XXXXXXXXXXXXXXXx
System Model: XXXXXXXXXXX
System type: X86-based PC
Processor(s): 12 Processor(s) Installed.
[01]: XXXXXXXXXXXXXXXXXXXXXXXXXX
BIOS Version: XXXX - 6
Windows Directory: C:\WINDOWS
System Directory: C:\WINDOWS\System32
Boot Device: \Device\HarddiskVolume1
.................
....

Monday, August 20, 2007

JS - `onMouseOver`


onMouseOver

ข้อความที่ต้องการ

<a onmouseover="alert('YOUR MESSAGE');return true;" href="#">ข้อความที่ต้องการ</a>
////////
<script language="Javascript">
<!--// please keep these lines on when you copy the sourcehttp://admincmd.blogspot.com
alert ("This is a Javascript Alert")//-->
</script>

PHP - Session variable

session : An abstract concept to represent a series of HTTP requests and responses exchanged between a specific Web browser and a specific Web server. Session concept is very useful for Web based applications to pass and share information from one Web page (request) to another Web page (request).
Since the current design of HTTP protocol does not support session concept, all Web server side scripting technologies, including PHP, have designed their own way to support session concept. The key design element of session support is about how to identify a session and how to maintain the session ID (identification). One common way to maintain the session ID is use the cookie technology. The following diagram shows you how to do this:

Server Browser
ID created <-- Request #1 ---
<--- Response #1 --> ID kept as cookie
<-- Request #2 ---> ID send back to server
<--- Response #2 -->
<-- Request #3 --- >ID send back to server
<--- Response #3 -->
......

The session concept should be managed by the server. When the first request comes from a browser on a client host, the server should create a new session, and assigns a new session ID. The session ID will be then send back to the same browser as a cookie. The browser will remember this ID, and send the ID back to the server in the subsequent requests. When the server receives a request with a session ID in them, it knows this is a continuation of an existing session.
When the server receives a request from a browser on a new client host (request without a session ID), the server should not only create a new session ID, it should also create a new session object associated with the new session ID. This session object should become the storage place for different requests of the same session to store and share information.
If there is no subsequent request coming back for a long time for a particular session ID, that session should be timed out. After the session has been timed out, if the browser comes back again with the associated session ID, the server should give an invalid session error.

EXAMPLE:

/* Create new session */
session_start();

/*set session parameter */
session_register("var");
$_SESSION["var"]="test session";

echo $_SESSION["var"];
test session

/*clear session */
session_unregister("var");
unset($_SESSION);
session_destroy();

Unix - `echo`


`echo` - display a line of text

your shell may have its own version of echo which will supercede the version described here. Please refer to your shell’s documentation for details about the options it supports.

Echo the STRING(s) to standard output.
-n do not output the trailing newline
-e enable interpretation of the backslash-escaped characters listed below
-E disable interpretation of those sequences in STRINGs

Without -E, the following sequences are recognized and interpolated:
\NNN the character whose ASCII code is NNN (octal)
\\ backslash
\a alert (BEL)
\b backspace
\c suppress trailing newline
\f form feed
\n new line
\r carriage return
\t horizontal tab
\v vertical tab

Sunday, August 19, 2007

PHP - Convert digit to thai word

thaimoney_convert.php
============================

<<

function convert($number){

$txtnum1 = array('ศูนย์','หนึ่ง','สอง','สาม','สี่','ห้า','หก','เจ็ด','แปด','เก้า','สิบ');
$txtnum2 = array('','สิบ','ร้อย','พัน','หมื่น','แสน','ล้าน'); $number = str_replace(",","",$number);
$number = str_replace(" ","",$number); $number = str_replace("บาท","",$number);
$number = explode(".",$number);
if(sizeof($number)>2){
return 'ทศนิยมหลายตัวนะจ๊ะ';
exit;
}

$strlen = strlen($number[0]);
$convert = '';

for($i=0;$i<$strlen;$i++){

$n = substr($number[0], $i,1);

if($n!=0){
if($i==($strlen-1) AND $n==1){ $convert .= 'เอ็ด'; }
elseif($i==($strlen-2) AND $n==2){ $convert .= 'ยี่'; }
elseif($i==($strlen-2) AND $n==1){ $convert .= ''; }
else{ $convert .= $txtnum1[$n]; }
$convert .= $txtnum2[$strlen-$i-1];
}
}

$convert .= 'บาท';
if($number[1]=='0' OR $number[1]=='00' OR $number[1]==''){ $convert .= 'ถ้วน'; }
else{ $strlen = strlen($number[1]);
for($i=0;$i<$strlen;$i++){
$n = substr($number[1], $i,1);
if($n!=0){
if($i==($strlen-1) AND $n==1){$convert .= 'เอ็ด';}
elseif($i==($strlen-2) AND $n==2){$convert .= 'ยี่';}
elseif($i==($strlen-2) AND $n==1){$convert .= '';}
else{ $convert .= $txtnum1[$n];}
$convert .= $txtnum2[$strlen-$i-1];
}
}
$convert .= 'สตางค์';
}
return $convert;
}
$x = '5,121.10 บาท';

echo $x.' => '.convert($x);

?>


Friday, August 17, 2007

DOS - `bootcfg`

`bootcfg`
This command line tool can be used to configure, query, change or delete the boot entry settings in the BOOT.INI file.

Usage:
BOOTCFG /parameter [arguments]

Parameter List:
/Copy Makes a copy of an existing boot entry [operating systems] section for which you can add OS options to.
/Delete Deletes an existing boot entry in the [operating systems] section of the BOOT.INI file. You must specify the entry# to delete.
/Query Displays the current boot entries and their settings.
/Raw Allows the user to specify any switch options to be added for a specified boot entry.
/Timeout Allows the user to change the Timeout value.
/Default Allows the user to change the Default boot entry.
/EMS Allows the user to configure the /redirect switch for headless support for a boot entry.
/Debug Allows the user to specify the port and baudrate for remote debugging for a specified boot entry.
/Addsw Allows the user to add predefined switches for a specific boot entry.
/Rmsw Allows the user to remove predefined switches for a specific boot entry.
/Dbg1394 Allows the user to configure 1394 port debugging for a specified boot entry.
/? Displays this help/usage.


Examples:

BOOTCFG /Copy /?
BOOTCFG /Delete /?
BOOTCFG /Query /?
BOOTCFG /Raw /?
BOOTCFG /Timeout /?
BOOTCFG /EMS /?
BOOTCFG /Debug /?
BOOTCFG /Addsw /?
BOOTCFG /Rmsw /?
BOOTCFG /Dbg1394 /?
BOOTCFG /Default /?
BOOTCFG /?

C:\>bootcfg
Boot Loader Settings

--------------------
timeout: 30
default: multi(0)disk(0)rdisk(0)partition(1)\WINDOWS

Boot Entries
------------
Boot entry ID: 1
Friendly Name: "Microsoft Windows XP Professional"
Path: multi(0)disk(0)rdisk(0)partition(1)\WINDOWSOS Load Options: /fastdetect

DOS - `CD`

`CD` - Displays the name of or changes the current directory.

EXALPLE:

C:\>cd
C:\

.......

C:\>cd WINDOWS
C:\WINDOWS>

C:\WINDOWS>cd ..
C:\>



.....

DOS - `LABEL`

`LABEL` - Creates, changes, or deletes the volume label of a disk.

EXAMPLE:

C:\>label
Volume in drive C: is SYSTEM
Volume Serial Number is RHF4-4T59
Volume label (ENTER for none)?
Delete current volume label (Y/N)? n



DOS-Defragment disk


`defrag` - Windows Disk Defragmenter

Usage:
defrag [-a] [-f] [-v] [-?]
volume drive letter or mount point (d: or d:\vol\mountpoint)
-a Analyze only
-f Force defragmentation even if free space is low
-v Verbose output
-? Display this help text


EXAMPLE:

C:\>defrag c:
Windows Disk Defragmenter
Copyright (c) 2003 Microsoft Corp. and Executive Software International, Inc.
Analysis Report 16.00 GB Total, 8.11 GB (50%) Free, 9% Fragmented (17% file fragmentation)Defragmentation Report 16.00 GB Total, 8.11 GB (50%) Free, 9% Fragmented (16% file fragmentation)

C:\>defrag -a c:
Windows Disk Defragmenter
Copyright (c) 2001 Microsoft Corp. and Executive Software International, Inc.
Analysis Report

37.24 GB Total, 9.70 GB (26%) Free, 8% Fragmented (15% file fragmentation)

Unix - `history`

Unix command.

`history` - process command history list

csh history [ -hr ] [ n ]

The command history list references commands by number. The first number in the list is selected arbitrarily. The rela- tionship of a number to its command will not change except when the user logs in and no other process is accessing the list, at which time the system may reset the numbering to start the oldest retained command at another number (usually 1). When the number reaches the value in HISTSIZE or 128 (whichever is greater), the shell may wrap the numbers, starting the next command with a lower number (usually 1). However, despite this optional wrapping of numbers, fc will maintain the time-ordering sequence of the commands. For example, if four commands in sequence are given the numbers 32766, 32767, 1 (wrapped), and 2 as they are executed, com- mand 32767 is considered the command previous to 1, even though its number is higher.


csh
Display the history list; if n is given, display only the n most recent events.
-r Reverse the order of printout to be most recent first rather than oldest first.
-h Display the history list without leading numbers. This is used to produce files suitable for sourcing using the -h option to the csh built-in command, source(1).

Thursday, August 16, 2007

Unix - `typeset`

Unix command.

`typeset` - shell built-in functions to set/get attributes and values for shell variables and functions

typeset sets attributes and values for shell variables and functions. When typeset is invoked inside a function, a new instance of the variables name is created. The variables value and type are restored when the function completes. The following list of attributes may be specified:

-H This flag provides UNIX to host-name file mapping on non-UNIX machines.
-L Left justify and remove leading blanks from value. If n is non-zero it defines the width of the field; otherwise, it is determined by the width of the value of first assignment. When the variable is assigned to, it is filled on the right with blanks or truncated, if necessary, to fit into the field. Leading zeros are removed if the -Z flag is also set. The -R flag is turned off.
-R Right justify and fill with leading blanks. If n is non-zero it defines the width of the field, otherwise it is determined by the width of the value of first assignment. The field is left filled with blanks or truncated from the end if the variable is reassigned. The -L flag is turned off.
-Z Right justify and fill with leading zeros if the first non-blank character is a digit and the -L flag has not been set. If n is non-zero it defines the width of the field; otherwise, it is determined by the width of the value of first assignment.
-f The names refer to function names rather than variable names. No assignments can be made and the only other valid flags are -t, -u and -x. The flag -t turns on execution tracing for this function. The flag -u causes this function to be marked undefined. The FPATH variable will be searched to find the function definition when the function is referenced. The flag -x allows the function definition to remain in effect across shell procedures invoked by name.

-i Parameter is an integer. This makes arithmetic fas- ter. If n is non-zero it defines the output arithmetic base; otherwise, the first assignment determines the output base.
-l All upper-case characters are converted to lower-case. The upper-case flag, -u is turned off.
-r The given names are marked readonly and these names cannot be changed by subsequent assignment.
-t Tags the variables. Tags are user definable and have no special meaning to the shell.
-u All lower-case characters are converted to upper-case characters. The lower-case flag, -l is turned off.
-x The given names are marked for automatic export to the environment of subsequently-executed commands.


EXAMPLE:

$ a="907b67"
$ typeset -R3 a
$ echo $a
b67


Unix - `mkdir`

Unix command.

`mkdir` - make directories
Create the DIRECTORY(ies), if they do not already exist.

Usage:
mkdir [-m mode] [-p] dirname ...

OPTIONS:
The following options are supported:
-m --mode This option allows users to specify the mode to be used for new directories. Choices for modes can be found in chmod(1).
-p --parents With this option, mkdir creates dir by creating all the non-existing parent directories first. The mode given to intermediate directories will be the difference between 777 and the bits set in the file mode creation mask. The difference, however, must be at least 300 (write and executepermission for the user).
-v --verbose print a message for each created directory


EXAMPLES:
The following example:

1--------
[root@server tmp]# mkdir -m777 xxx
[root@server tmp]# ls -l
drwxrwxrwx 2 root root 4096 Feb 8 14:15 xxx

2--------
[root@server root]# mkdir -p /tmp/source/test
creates the subdirectory structure /tmp/source/test.

3--------
[root@ims tmp]# mkdir -v xxx
mkdir: created directory `xxx'



Wednesday, August 15, 2007

Unix - `rm,rmdir`

Unix command.

`rm` - remove files or directories

Usage:
rm [OPTION]... FILE...

OPTIONS:
Remove (unlink) the FILE(s).
-d, --directory unlink FILE, even if it is a non-empty directory (super-user only)
-f, --force ignore nonexistent files, never prompt
-i, --interactive prompt before any removal
-r, -R, --recursive remove the contents of directories recursively

Example:
delete non-empty directory.
....
[root@server /]# rm -rf /tmp
[root@server /]#
....
----------------------------------------------------------------------

`rmdir` - remove empty directories
Remove the DIRECTORY(ies), if they are empty.

Example:
[root@server /]# rmdir /tmp
rmdir: `/tmp': Directory not empty

......
Make empty directory and use this command again.
........
[root@server /]# mkdir newdir
[root@server /]# rmdir newdir
....

Tuesday, August 14, 2007

Unix - `basename` & `dirname`

Unix command.

`basename` - strip directory and suffix from filenames

Print NAME with any leading directory components removed. If specified, also remove a trailing SUFFIX.
The basename utility deletes any prefix ending in / and the suffix (if present in string) from string, and prints the result on the standard output. It is normally used inside substitution marks (``) within shell procedures.

`dirname` - deliver portions of path names strip non-directory suffix from file name.
Print NAME with its trailing /component removed; if NAME contains no /’s, output ‘.’ (meaning the current directory).



EXAMPLES:

Example 1: Examples of the basename command.
...
bash-2.03$ NAME=`basename $HOME/personal/mail`;
bash-2.03$ echo $NAME;
bash-2.03$ mail
......

Example 2: Examples of the dirname command.
...
bash-2.03$ DIRNAME=`dirname $HOME/personal/mail`;
bash-2.03$ echo $DIRNAME;
bash-2.03$ $HOME/personal

......

Friday, August 10, 2007

JS - protect your site

Using this script protect your site. ~_~

protect.js
///////////////////////////NO RIGHT CLICK ///////////////////////
var message="";
function clickIE() {
if (document.all) {(message);return false;}
}
function clickNS(e) {
if(document.layers(document.getElementById && !document.all)) {if (e.which==2e.which==3) {(message);return false;}}}
if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS;
}else{
document.onmouseup=clickNS;
document.oncontextmenu=clickIE;
}
document.oncontextmenu=new Function("return false");

////////////////////////
//////////////NOT ALLOW DRAG/////////////////
function disableselect(e){ return false }
function reEnable(){ return true } //if IE4+ document.onselectstart=new Function ("return false") //if NS6 if (window.sidebar){ document.onmousedown=disableselect document.onclick=reEnable }



Usage:
include this script into your code.
...

<HTML>
<head><tile>........</title>
<script language="'javascript'" src="'protect.js'" type="text/javascript"></script>
</head>
<BODY>
...
...
</BODY>
</HTML>
....

Unix - `touch`,`settime`

Unix,Linux command.

`touch, settime` - change file access and modification times

touch [ -acm ] [ -r ref_file -t time ] file ...
touch [ -acm ] [ date_time ] file ...
settime [ -f ref_file ] file ...

The touch utility sets the access and modification times of each file. The file operand is created if it does not already exist.
The time used can be specified by -t time, by the corresponding time fields of the file referenced by -r ref_file, or by the date_time operand. If none of these are specified, touch uses the current time (the value returned by the time(2) function).
If neither the -a nor -m options are specified, touch updates both the modification and access times.
The settime utility is equivalent to touch -c.
OPTIONS touch The following options are supported for the touch utility:
-a Change the access time of file. Do not change the modification time unless -m is also specified.
-c Do not create a specified file if it does not exist. Do not write any diagnostic messages concerning this condition.
-m Change the modification time of file. Do not change the access time unless -a is also specified.
-r ref_file Use the corresponding times of the file named by ref_file instead of the current time.
-t time Use the specified time instead of the current time. time will be a decimal number of the form:
[[CC]YY]MMDDhhmm [.SS]



Example:

bash-2.03$ ls -l
-rw-rw-r-- 1 root other 18 Aug 10 05:55 test_touch.txt
bash-2.03$ touch test_touch.txt
bash-2.03$ ls -l
-rw-rw-r-- 1 root other 18 Aug 10 10:47 test_touch.txt


^_^

Thursday, August 9, 2007

PHP - get client ip address

Function can get client ip address using this function :)

//-----------------------------------------------

function getIP() {
$ip;
if (getenv("HTTP_CLIENT_IP"))
$ip = getenv("HTTP_CLIENT_IP");
else if(getenv("HTTP_X_FORWARDED_FOR"))
$ip = getenv("HTTP_X_FORWARDED_FOR");
else if(getenv("REMOTE_ADDR"))
$ip = getenv("REMOTE_ADDR");
else
$ip = "UNKNOWN";
return $ip;


}

//-----------------------------------------------

Usage:
<

$client_ip=getIP();
echo "Your IP :".$client_ip;
?>

//--------------------------------------------


Unix - `cal`

Unix,Linux command.

` cal` - displays a calendar

Usage: cal [-smjy13] [[month] year]

DESCRIPTION
Cal displays a simple calendar. If arguments are not specified, the cur- rent month is displayed. The options are as follows:
-1 Display single month output. (This is the default.)
-3 Display prev/current/next month output.
-s Display Sunday as the first day of the week. (This is the default.)
-m Display Monday as the first day of the week.
-j Display Julian dates (days one-based, numbered from January 1).
-y Display a calendar for the current year.

Example:

[root@server]# cal

October

Su Mo Tu We Th Fr Sa

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

DOS - ipconfig

USAGE: ipconfig [/? /all /renew [adapter] /release [adapter]
/flushdns /displaydns /registerdns
/showclassid adapter
/setclassid adapter [classid] ]

Options:
/? Display this help message
/all Display full configuration information.
/release Release the IP address for the specified adapter.
/renew Renew the IP address for the specified adapter.
/flushdns Purges the DNS Resolver cache.
/registerdns Refreshes all DHCP leases and re-registers DNS names
/displaydns Display the contents of the DNS Resolver Cache.
/showclassid Displays all the dhcp class IDs allowed for adapter.
/setclassid Modifies the dhcp class id.
The default is to display only the IP address, subnet mask anddefault gateway for each adapter bound to TCP/IP.
For Release and Renew, if no adapter name is specified, then the IP addressleases for all adapters bound to TCP/IP will be released or renewed.
For Setclassid, if no ClassId is specified, then the ClassId is removed.

Examples:
> ipconfig /all ... Show detailed information
Windows IP Configuration
Host Name . . . . . . . . . . . . : Sample Machine

Primary Dns Suffix . . . . . . . :
Node Type . . . . . . . . . . . . : Unknown
IP Routing Enabled. . . . . . . . : Yes
WINS Proxy Enabled. . . . . . . . : No
Ethernet adapter Local Area Connection:
Connection-specific DNS Suffix . :

Description . . . . . . . . . . . : Intel(R) PRO/1000 MT Network Connection
Physical Address. . . . . . . . . : B9-09-99-99-99-1A
Dhcp Enabled. . . . . . . . . . . : No
IP Address. . . . . . . . . . . . : 1.24.196.102
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 1.24.196.71
DNS Servers . . . . . . . . . . . : 1.24.196.9

-----------------------------------
> ipconfig /release *Con* ... release all matching connections,
Windows IP Configuration
Ethernet adapter Local Area Connection:
Connection-specific DNS Suffix . :

IP Address. . . . . . . . . . . . : 0.0.0.0
Subnet Mask . . . . . . . . . . . : 0.0.0.0
Default Gateway . . . . . . . . . : 0.0.0.0
-------------------------------------
> ipconfig /renew ... renew all adapters
> ipconfig /renew EL* ... renew any connection that has its name starting with EL

Unix command `ls`

Linux,Unix command.
`ls` : list contents of directory
feature : [ -aAbcCdfFgilLmnopqrRstux1 ] [ file ... ]
For each file that is a directory, ls lists the contents of the directory; for each file that is an ordinary file, ls repeats its name and any other information requested. The output is sorted alphabetically by default. When no argument is given, the current directory is listed. When several arguments are given, the arguments are first sorted appropriately, but file arguments appear before directories and their contents.
How to use the features
[root@server tmp]# ls -l
-rw------- 1 apache apache 92 Aug 1 10:08 sess_276
-rw------- 1 apache apache 450 Aug 2 11:29 ess_730701

Features means
-a Lists all entries, including those that begin with a dot (.), which are normally not listed.
-A Lists all entries, including those that begin with a dot (.), with the exception of the working directory (.) and the parent directory (..).
-b Forces printing of non-printable characters to be in the octal \ddd notation.
-c Uses time of last modification of the i-node (file created, mode changed, and so forth) for sorting (-t) or printing (-l or -n).
-C Multi-column output with entries sorted down the columns. This is the default output format.
-d If an argument is a directory, lists only its name (not its contents); often used with -l to get the status of a directory.
-f Forces each argument to be interpreted as a directory and list the name found in each slot. This option turns off -l, -t, -s, and -r, and turns on -a; the order is the order in which entries appear in the directory.
-F Marks directories with a trailing slash (/), doors with a trailing greater-than sign (>), executable files with a trailing asterisk (*), FIFOs with a trailing vertical bar (), symbolic links with a trailing at-sign (@), and AF_UNIX address family sock- ets with a trailing equals sign (=).
-g The same as -l, except that the owner is not printed.
-i For each file, prints the i-node number in the first column of the report.
-l Lists in long format, giving mode, ACL indication, number of links, owner, group, size in bytes, and time of last modification for each file (see above). If the file is a special file, the size field instead con- tains the major and minor device numbers. If the time of last modification is greater than six months ago, it is shown in the format `month date year' for the POSIX locale. When the LC_TIME locale category is not set to the POSIX locale, a different format of the time field may be used. Files modified within six months show `month date time'. If the file is a sym- bolic link, the filename is printed followed by "->" and the path name of the referenced file.
-L If an argument is a symbolic link, lists the file or directory the link references rather than the link itself.
-m Streams output format; files are listed across the page, separated by commas.
-n The same as -l, except that the owner's UID and group's GID numbers are printed, rather than the asso- ciated character strings.
-o The same as -l, except that the group is not printed.
-p Puts a slash (/) after each filename if the file is a directory.
-q Forces printing of non-printable characters in file names as the character question mark (?).
-r Reverses the order of sort to get reverse alphabetic
-R Recursively lists subdirectories encountered.
-s Gives size in blocks, including indirect blocks, for each entry.
-t Sorts by time stamp (latest first) instead of by name. The default is the last modification time. (See -u and -c.)
-u Uses time of last access instead of last modification for sorting (with the -t option) or printing (with the -l option).
-x Multi-column output with entries sorted across rather than down the page.
-1 Prints one entry per line of output.