2008年8月20日 星期三

現代人的愛情觀

class love {
var $sex;
var $height;
var $weight;
var $money;
var $cup=NULL;
var $id;
var $sexfriends=0;

function love() {}

function man($height,$weight,$money,$id) {
$this- >sex="男";
$this- >height=$height;
$this- >weight=$weight;
$this- >money=$money;
$this- >id=$id;
}

function find($query) {
include_once "worldbase.class.pHp";
$_conn=new worldbase($this- >sex,$this- >height,$this- >weight,$this- >money,$this- >cup,$this- >id);
$this- >sexfriend=$conn->query($query);
}

function getsexfriends() {return $this- >sexfriends;}

function woman($height,$weight,$money,$cup,$id) {
$this- >sex="女";
$this- >height=$height;
$this- >weight=$weight;
$this- >money=$money;
$this- >cup=$cup;
$this- >id=$id;
}

function happyending() {return "Get true love";}

function badending() {return "I am single";}

function god ($height,$weight,$cup=NULL) {
if ($this- >money >66000) {
$this- >sex=$sex;
$this- >height=$height;
$this- >weight=$weight;
$this- >money-=66000;
$this- >cup=$cup;
return "show your identity";
} else return "Get out";
}
}

$a=new love();
$a- >man(156,70,200000,"normal");
$b=new love();
$b- >man(188,120,12,"normal");
$c=new love();
$c- >man(170,50,1200,"normal");
$d=new love();
$d- >man(165,62,33000,"normal");

$w=new love();
$w- >woman(170,90,200000,"G","normal");
$x=new love();
$x- >woman(155,120,18,"A","normal");
$y=new love();
$y- >woman(166,42,44000,"B","normal");
$z=new love();
$z- >woman(167,60,38000,"C","normal");

$a- >find("select woman from Taiwan where (height >150 and height<170)>36 and weight<46) and cup="E";");
$b- >find("select woman from Japan where (height >166 and height<170)>36 and weight<47) and cup="G";");
$c- >find("select woman from Taiwan where (height >166 and height<176)>36 and weight<48) and cup="F";");
$d- >find("select woman from Taiwan where (height >155 and height<165)>36 and weight<52) and cup="B";");

$w- >find("select man from USA where (height >177 and height<200)>70 and weight<90)>400000000;");
$x- >find("select man from France where (height >182 and height<198)>72 and weight<86)>700000000;");
$y- >find("select man from UK where (height >188 and height<200)>70 and weight<90)>350000000;");
$z- >find("select man from Japan where (height >180 and height<190)>70 and weight<90)>370000000;");

if (($a- >getsexfriends())<1)
($a- >god(180,70)=="Get out")? $a- >badending() : else $a- >happyending();
else $a- >happyending();
if (($b- >getsexfriends())<1)
($b- >god(180,70)=="Get out")? $b- >badending() : $b- >happyending();
else $b- >happyending();
if (($c- >getsexfriends())<1)
($c- >god(180,70)=="Get out")? $c- >badending() : $c- >happyending();
else $c- >happyending();
if (($d- >getsexfriends())<1)
($d- >god(180,70)=="Get out")? $d- >badending() : $d- >happyending();
else $d- >happyending();

if (($w- >getsexfriends())<1)
($w- >god(168,42,"C")=="Get out")? $w- >badending() : $w- >happyending();
else $w- >happyending();
if (($x- >getsexfriends())<1)
($x- >god(180,70)=="Get out")? $x- >badending() : $x- >happyending();
else $x- >happyending();
if (($y- >getsexfriends())<1)
($y- >god(180,70)=="Get out")? $y- >badending() : $y- >happyending();
else $y- >happyending();
if (($z- >getsexfriends())<1)
($z- >god(180,70)=="Get out")? $z- >badending() : $z- >happyending();
else $z- >happyending();

女人的年齡是秘密

function Woman_age(CoolMan) {var age=30;return CoolMan?age-10:age+10;}

2008年7月20日 星期日

設定簡易防火牆規則

環境:
Server IP:192.168.0.1

設定:

#規則初始化
iptables --flush

#隱形掃瞄攻擊防範
iptables -A INPUT -p tcp --tcp-flags ALL NONE -j DROP
iptables -A FORWARD -p tcp --tcp-flags ALL NONE -j DROP
iptables -A INPUT -p tcp --tcp-flags SYN,FIN SYN,FIN -j DROP
iptables -A FORWARD -p tcp --tcp-flags SYN,FIN SYN,FIN -j DROP
iptables -A INPUT -p tcp --tcp-flags SYN,RST SYN,RST -j DROP
iptables -A FORWARD -p tcp --tcp-flags SYN,RST SYN,RST -j DROP
iptables -A INPUT -p tcp --tcp-flags FIN,RST FIN,RST -j DROP
iptables -A FORWARD -p tcp --tcp-flags FIN,RST FIN,RST -j DROP
iptables -A INPUT -p tcp --tcp-flags ACK,FIN FIN -j DROP
iptables -A FORWARD -p tcp --tcp-flags ACK,FIN FIN -j DROP
iptables -A INPUT -p tcp --tcp-flags ACK,URG URG -j DROP
iptables -A FORWARD -p tcp --tcp-flags ACK,URG URG -j DROP

#非法位址篩選
iptables -A INPUT -i eth0 -s 0.0.0.0/8 -j DROP
iptables -A FORWARD -i eth0 -s 0.0.0.0/8 -j DROP
iptables -A INPUT -i eth0 -s 10.0.0.0/8 -j DROP
iptables -A FORWARD -i eth0 -s 10.0.0.0/8 -j DROP
iptables -A INPUT -i lo -s 127.0.0.0/8 -j DROP
iptables -A FORWARD -i lo -s 127.0.0.0/8 -j DROP
iptables -A INPUT -i eth0 -s 169.254.0.0/16 -j DROP
iptables -A FORWARD -i eth0 -s 169.254.0.0/16 -j DROP
iptables -A INPUT -i eth0 -s 172.16.0.0/12 -j DROP
iptables -A FORWARD -i eth0 -s 172.16.0.0/12 -j DROP
iptables -A INPUT -i eth0 -s 192.168.0.0/16 -j DROP
iptables -A FORWARD -i eth0 -s 192.168.0.0/16 -j DROP
iptables -A INPUT -i eth0 -s 192.168.2.0/24 -j DROP
iptables -A FORWARD -i eth0 -s 192.168.2.0/24 -j DROP
iptables -A INPUT -i eth0 -s 224.0.0.0/4 -j DROP
iptables -A FORWARD -i eth0 -s 224.0.0.0/4 -j DROP
iptables -A INPUT -i eth0 -s 240.0.0.0/5 -j DROP
iptables -A FORWARD -i eth0 -s 240.0.0.0/5 -j DROP
iptables -A INPUT -i eth0 -s 255.255.255.255 -j DROP
iptables -A FORWARD -i eth0 -s 255.255.255.255 -j DROP


iptables-save

2008年7月19日 星期六

架設Webmin

環境:
Server IP:192.168.0.1

設定:

vi /etc/apt/sources.list

Add

deb http://download.webmin.com/download/repository sarge contrib


apt-get update
apt-get install webmin

接下來就可以透過瀏覽器進入https://192.168.0.1:10000來管理伺服器囉

架設Samba

環境:
Server IP:192.168.0.1
Networks:192.168.0.0/255.255.255.0


設定:

vi /etc/samba/smb.conf

全數清空,改為以下

#======================= Global Settings =======================
[global]
log file = /var/log/samba/log.%m #記錄檔存放點
display charset = utf8 #顯示之字碼為utf-8
passwd chat = *Enter\snew\sUNIX\spassword:* %n\n *Retype\snew\sUNIX\spassword:* %n\n .
socket options = TCP_NODELAY SO_SNDBUF=8192 SO_RCVBUF=8192 #Socket
obey pam restrictions = Yes
encrypt passwords = True
domain master = Yes #設為DMB
local master = Yes #設為LMB
preferred master = Yes #設為PDC
interfaces = eth0 #負責的網卡
hosts allow = 192.168.0.0/255.255.255.0 #允許的主機
passdb backend = tdbsam
passwd program = /usr/bin/passwd %u
template shell = /bin/false
wins support = true #將主機設為Wins
dns proxy = no
netbios name = teed7334.idv.tw #主機名稱
netbios aliases = teed7334.idv.tw #主機別名
server string = %h server
invalid users = root #禁止進入的使用者
dos charset = cp950
workgroup = WORKGROUP #使用的工作群組
os level = 255 #0~255,數值越大,越優先成為LMB、DMB
syslog = 0
security = user
unix charset = utf8
panic action = /usr/share/samba/panic-action %d
max log size = 1000

#======================= Share Definitions =======================

[homes] #使用者家目錄
comment = Home Directories #分享的資料夾別名
create mode = 700 #新增檔案預設權限
directory mode = 600 #新增資料夾預設權限
valid users = %S
writeable = yes #預設可寫入
public = yes #公開

[Temp] #資料暫存區
comment = Temp #分享的資料夾別名
create mode = 777 #新增檔案預設權限
directory mode = 777 #新增資料夾預設權限
writeable = yes #預設可寫入
public = yes #公開
path = /tmp #分享資料夾系統路徑

[Game] #分享資料夾
comment = Game Directories #分享的資料夾別名
create mode = 777 #新增檔案預設權限
directory mode = 777 #新增資料夾預設權限
path = /mnt/hdb/game #分享資料夾系統路徑
write list = a1,a2,a3 #分享資料夾系統路徑

/etc/init.d/samba restart

架設Bind

環境:
僅設定為forward only的DNS,轉向HiNet DNS–168.95.1.1

設定:
apt-get install bind

vi /etc/bind/named.conf.options

add

forward only;
forwarders {
168.95.1.1;
};


/etc/init.d/bind restart

架設Apache2+PHP5+MySQL5

設定:
apt-get install apache2.2-common apache2-utils apache2-mpm-prefork libapache2-mod-php5 php5-mysql

apt-get install mysql-server-5.0 mysql-client-5.0