Sunday, May 30, 2010

ie iframe php session lost issues

Problem: IE lost ifrmae php page session when go to next page

Solution:
Add one line before session_start();


header('P3P: CP="CAO PSA OUR"');

session_start();

Friday, May 28, 2010

mount USB drive on linux

1, before connect USB do
[root@localhost intel]# fdisk -l

Disk /dev/sda: 80.0 GB, 80000000000 bytes
255 heads, 63 sectors/track, 9726 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 9726 78019672+ 8e Linux LVM

Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdb1 1 121601 976760001 83 Linux

2, after connect usa drive, do
[root@localhost intel]# fdisk -l

Disk /dev/sda: 80.0 GB, 80000000000 bytes
255 heads, 63 sectors/track, 9726 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 9726 78019672+ 8e Linux LVM

Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdb1 1 121601 976760001 83 Linux

Disk /dev/sdc: 2030 MB, 2030043136 bytes
63 heads, 62 sectors/track, 1015 cylinders
Units = cylinders of 3906 * 512 = 1999872 bytes

This doesn't look like a partition table
Probably you selected the wrong device.

Device Boot Start End Blocks Id System
/dev/sdc1 ? 773303 773432 253319 e4 SpeedStor
Partition 1 has different physical/logical beginnings (non-Linux?):
phys=(190, 120, 0) logical=(773302, 15, 51)
Partition 1 has different physical/logical endings:
phys=(544, 125, 44) logical=(773431, 60, 24)
Partition 1 does not end on cylinder boundary.
/dev/sdc2 ? 257697 766649 993984023 98 Unknown
Partition 2 has different physical/logical beginnings (non-Linux?):
phys=(1010, 16, 43) logical=(257696, 24, 10)
Partition 2 has different physical/logical endings:
phys=(205, 205, 22) logical=(766648, 48, 55)
Partition 2 does not end on cylinder boundary.
/dev/sdc3 ? 434364 925892 959953209 7d Unknown
Partition 3 has different physical/logical beginnings (non-Linux?):
phys=(252, 139, 46) logical=(434363, 62, 54)
Partition 3 has different physical/logical endings:
phys=(367, 195, 2) logical=(925891, 31, 25)
Partition 3 does not end on cylinder boundary.
/dev/sdc4 ? 1427 3557 4161536 0 Empty
Partition 4 has different physical/logical beginnings (non-Linux?):
phys=(0, 10, 0) logical=(1426, 9, 47)
Partition 4 has different physical/logical endings:
phys=(0, 0, 0) logical=(3556, 62, 52)
Partition 4 does not end on cylinder boundary.

Partition table entries are not in disk order

3,
mount /dev/sdc /flash/

Friday, May 21, 2010

mysql remove space, line break etc

select count(*) from compounds as c where 1=1 and c.CAS REGEXP '[0-9]-[0-9]{2}-[0-9]{1}';

update compounds set CAS=REPLACE(CAS, '\r','');

update compounds set CAS=REPLACE(CAS, '\r\n','');

mysql> update chemmolc_customer.compounds set CAS=TRIM(CAS);

mysql> update a.compounds as cc, b.compounds as bc set cc.CAS=bc.CAS where cc.mol_id=bc.mol_id;

linux REGEXP

mysql> select distinct(CAS) from compounds where CAS REGEXP '[0-9]-[0-9]-[0-9]' limit 1000;

Friday, May 14, 2010

mysql php support chinese

$host="localhost";
$usr="xxxxx";
$pwd="xxxxx";
$db="xxxxxx";
$link = mysql_connect($host, $usr, $pwd);

mysql_select_db($db);

mysql_query('SET NAMES "gb2312"');

if( mysql_error() ) { print "Database ERROR: " . mysql_error(); }

$query = "INSERT INTO ch VALUES ('034',convert('浏览器' using gb2312))";
 
mysql_query($query);

if (mysql_error()) { print "Database ERROR: " . mysql_error(); }


$query="SELECT * FROM ch";
$result=mysql_query($query);

while($row = mysql_fetch_array($result))
{
echo $row['ucs2'] . " || " . $row['gb2312'];
echo "
";
}

?>





php-mbstring

 1002  yum install php-mbstring
 1003  httpd -k restart
 1004  /etc/init.d/httpd -k restart
 1005  /etc/init.d/httpd -k stop
 1006  /etc/init.d/httpd stop
 1007  /etc/init.d/httpd start

ubuntu open iptables mysql port

 121  iptables -A INPUT -s x.x.x.x -p tcp --dport 3306 -j ACCEPT
  122  iptables -L
  123  iptables -A INPUT -j REJECT
  118  iptables -D INPUT 5

 2003  iptables -L INPUT
 2004  iptables -L INPUT
 2005  iptables -L INPUT 4
 2006  iptables -I INPUT 5 -s 71.26.22.12 -p tcp --dport 3306 -j ACCEPT
 2007  iptables -L INPUT 5
 2008  iptables -L INPUT
 2009  iptables -D INPUT 4
 2010  iptables -L INPUT


mysql add chinese support

mysql> alter table compounds add CNameCN varchar(255) CHARACTER SET gb2312 after CName;

Thursday, May 13, 2010

Block brute force attacks with iptables

    8  sudo iptables -D INPUT 1
    9  sudo iptables -L
   10  sudo iptables -D INPUT 1
   11  sudo iptables -L
   12  sudo iptables -A INPUT -i eth0 -p tcp --dport 22 -m state --state NEW -m recent --set --name SSH
   13  sudo iptables -L
   14  sudo iptables -A INPUT -i eth0 -p tcp --dport 22 -m state --state NEW -m recent --update --seconds 60 --hitcount 8 --rttl --name SSH -j DROP

apache support chinese charset

.htaccess

AddType text/html;charset=gb2312 html php

============
cg@SS$ sudo apt-get install xfonts-intl-chinese



centos chinese support

 1021  yum groupinstall "Chinese Support"