2010/12/25

「做工」的問題及想法

工作的公司是傳統產業的公司,員工不像電子廠有著高學歷的員工,
通常這些員工都從青少年時期學藝而成的,也有從職訓班或是職校出來的。

但不論如何,我總是稱呼他為「師傅」,這是對於這些員工的一種尊稱。當然這也被電視廣告當成創造台灣奇蹟的無名英雄。

若以高科技產業和傳統產業的員工薪水相較,員工薪水傳統產業通常來得較高,且因為工作有時並不是那麼的多,通常都以日薪來作計算。

通常台灣以中小企業為主,再傳統中小企業產業員工大多分成三個等級,

有經驗,成熟做事有效率的老師傅。通常年歲約 45 ~ 65 之間 ,且身體狀況都保持的非常的好,不抽煙,不吃檳榔,作息很正常。

年輕剛出社會不到幾年的小伙子,年輕氣盛通常技術還可以。有的有菸,酒,檳榔再身上。遇到這種我竟可能不用,因為他闖的禍或造成的失誤可能比他賺的多。

第三種就是一直再換工作,對自己沒有信心。表現的結果也令人沒有信心,這也就是台灣失業率的來源。但是通常傳統產業比較缺員工,大部份只要差不多,不要太差勁就可以進去。薪水給的也不錯,因為是勞力工作應徵的人實在太少了......

台灣這幾年嚴重的輕視技職教育,造成人才嚴重的缺乏頭殼比較清楚的人都跑到所謂的高科技業。反倒變成職訓中心是最大的技術工作人員養成場所,這台彎的社會真令人擔憂呀!!

但我覺得好處是,傳統產業工作講求日清日結,再工作時間內把今天的工作做完,上班時間就發揮最高的工作效率,回家就好好的休息。這樣比現在長工時效率低來的有用多了.......

但效率的定義各公司不同..........但可確定的是獨裁的體系是最有效率的。

One-way Web Hacking

One-way Web Hacking

前陣子追一個入侵的事件,找到的相關資料....

http://net-square.com/papers/one_way/one_way.html
http://blog.aggregatedintelligence.com/2010/02/dotnetnuke-version-zero-day.html
http://www.foofus.net/~jmk/iis.html

用 tftp 配合 dhcp 使用於網路開機 (tftpd32)

tftp server + dhcpd server on windows

http://tftpd32.jounin.net/

配合 iscsi boot
gpxe
pxe
很方便的

當然用來當作 switch or route 的備份設定檔伺服器也應該很方便。

作業--Huffman Decoder and encoded

/*-------------------------------------------------------
PROGRAM: DEHUFF.C
USAGE : dehuff encoded.file decoded_file
PURPOSE: Huffman Decoder
Created by barkly 06/11/03
Finish Tested by mtchang
--------------------------------------------------------*/
/* Error codes returned to the caller */
#define NO_ERROR 0
#define BAD_FILE_NAME 1
#define BAD_ARGUMENT 2
#define BAD_MEM_ALLOC 3

#include <stdio.h>
#include <io.h>
#include <fcntl.h>
#include <values.h>

/* Global variables */
FILE *source_file,*dest_file;

/*int main(void);*/
void help(void);
void pass1(void);
void get_min2(int,int*,int*);
void pass2(void);
int get_bit(void);

typedef struct
{
float frequency;
int Lchild;
int Rchild;
int parent;
} NODE;

NODE table[256+255]; /*CONVERSION TABLE�RECORD��511*/
long total_bytes;
int tail;

/***************/
int main(argc,argv)
/* Returned parameters: Returns an error code (0=None)
Action: Main procedure
Errors: Detected, handled and an error code is returned, if any
*/
int argc;
char *argv[];
{ if (argc!=3)
{ help();
exit(BAD_ARGUMENT);
}
else if ((source_file=fopen(argv[1],"rb"))==NULL)
{ help();
exit(BAD_FILE_NAME);
}
else if ((dest_file=fopen(argv[2],"wb"))==NULL)
{ help();
exit(BAD_FILE_NAME);
}
else {
pass1();
/* fseek(source_file,0L,SEEK_SET);
rewind(source_file); */
pass2();
fclose(source_file);
fclose(dest_file);
}
printf("Execution of decode huffman completed.\n");
return (NO_ERROR);
}

/***************/
void pass1(void)
{
int i,m0,m1;
long total;

fread(&total_bytes,4,1,source_file); /*������串�度*/
for (i=0; i<256; i++)
fread(&table[i].frequency,4,1,source_file); /*�����素� {頻�*/

i = 256;
get_min2(256,&m0,&m1); /*以���建CONVERSION TABLE� {�*/
while (table[m1].frequency <= 1.0)
{
table[i].frequency = table[m0].frequency+table[m1].frequency;
table[i].Lchild = m0;
table[i].Rchild = m1;
table[m0].frequency = 2.0;
table[m1].frequency = 2.0;
table[m0].parent = i;
table[m1].parent = i;
i++;
get_min2(i,&m0,&m1);
}
table[i-1].parent = 0;
tail = i-1; /*tail��ROOT NODE*/
}

/***************/
void get_min2(int total, int *m0, int *m1)
{
int i;

if (table[1].frequency > table[0].frequency)
{
*m0 = 0;
*m1 = 1;
}
else
{
*m0 = 1;
*m1 = 0;
}
for (i=2; i<total; i++)
{
if (table[i].frequency < table[*m0].frequency)
{
*m1 = *m0;
*m0 = i;
}
else if (table[i].frequency < table[*m1].frequency)
*m1 = i;
}
}

/************/
void pass2(void)
{
int ptr;
long count=0L;

while (count < total_bytes)
{
ptr = tail; /*�ROOT NODE }�traverse down*/
while ((table[ptr].Lchild != 0) || (table[ptr].Rchild != 0))
{ /*��NODE�Lchild�Rchild�����0�*/
if (get_bit() == 0) /*�繼�traverse down */
ptr = table[ptr].Lchild;
else
ptr = table[ptr].Rchild;
}
fputc(ptr,dest_file); /*����TERMINAL NODE��*/
count++; /*����該NODE�ASCII碼�*/
} /*並�已�解碼�byte� [1�*/
}

/****************/
int get_bit(void)
{
static bit_count = 0;
static bit_buf;
int x;

if (bit_count == 0)
{
bit_buf = fgetc(source_file);
bit_count = 8;
}
x = bit_buf & 0x80;
bit_buf = bit_buf << 1;
bit_count--;

return x;
}

void help()
{
printf("\nUse: dehuff source target\n");
printf("source: Name of the file to compress\n");
printf("target: Name of the compressed file\n");
}

Ubuntu Enterprise Cloud 安裝方式

關於Ubuntu Enterprise Cloud

可以提供虛擬機器的服務,還有網頁的管理界面。

中文翻譯的版本
http://kadok0520.pixnet.net/blog/post/25483674

原始文件
https://help.ubuntu.com/community/UEC/CDInstall


有做過但沒成功...等下次有空再來玩玩看

使用 usb 安裝 fedora or centos

使用 usb 安裝 fedora or centos

http://unetbootin.sourceforge.net/

但是好像 RHEL6 還不支援。

用 tftp 配合 dhcp 使用於網路開機 (tftpd32)

tftp server + dhcpd server on windows

http://tftpd32.jounin.net/

配合 iscsi boot
gpxe
pxe
很方便的

當然用來當作 switch or route 的備份設定檔伺服器也應該很方便。

Windows Server 如何防毒?

「Server 防啥毒.... 都擺在機房沒人去動怎麼會中毒....」

通常Windows Server 會中毒原因都不是很單純, 就我曾遇過得經驗來說windows server裝防毒軟體沒有用的通常有裝得都有中毒,沒裝的人反倒是中的少。這原因很簡單,因為通常server一定是提供網路上的服務,不會有人用server做pc的工作(但看過不少笨蛋是這樣做的....),除了windows server系統本身有 windows update 每月定時會更新系統的漏洞,沒更新則是一定會中獎的。

server版的防毒軟體--不錢的
* http://www.clamwin.com
* http://www.safer-networking.org/ct/index.html
其他都是要錢的
且不一定有用基本上我都是用
netstat -anp 看目前有哪些人連到你的機器
tcpview 也是一樣的功能,但是更細
svhost viewwe 看有沒有奇怪的程式被載入

簡單的解毒方式:
先掃毒
* http://www.clamwin.com
* http://www.safer-networking.org/ct/index.html
分析中毒原因:通常是木馬,或是網路攻擊

所以整理歸納幾個實用的防毒防入侵手段:
(1)別把server當PC用,讓他的工作單純化.
(2)記得安裝防火牆,系統有漏洞一定要修補。因為server中毒通常由本機提供的網路服務循標準管道入侵的。
(3)目前看到比較多的漏洞是 m$-sql or asp 的漏洞,通常是程式或是伺服器的權限設定的太過寬鬆造成的。

2010/12/19

Adobe Flash for X86_64 64bit on RHEL/CentOS

簡單的說就是 64bit 的flash player
官方網站的連結很不友善,幾乎就是不支援的樣子
曾經是出過,後來又說不支援...
我找了半天才找到下載點....

下載點:
http://download.macromedia.com/pub/labs/flashplayer10/flashplayer_square_p2_64bit_linux_092710.tar.gz

然後把壓縮檔解開,放到 /usr/lib64/mozilla/plugs/  目錄內
$ tar zxvf flashplayer_square_p2_64bit_linux_092710.tar.gz
$ cd flashplayer_square_p2_64bit_linux_092710.tar.gz
$ chown root.root libflashplayer.so
$ mv libflashplayer.so /usr/lib64/mozilla/plugins/libflashplayer.so

2010/12/07

某單位借用教室程式表示流程圖

#!/bin/bash
# Program:
# 某單位借用教室程式表示流程圖  
# History:
# 2010.12.07
# 對話開始
for (( i=1; i<=10次; i=i+1 ))
do
     echo '生:12/x Rxxxx 教室有空嗎?'+" $各種可能的嘗試語句與理由 "
     echo '工:沒有,有人上課'; 
done

# 等待兩分鐘後
sleep 2   


# 對話開始2,和上面一樣沒變
for (( i=1; i<=10次; i=i+1 ))
do
     echo '生:12/x Rxxxx 教室有空嗎?'+" $各種可能的嘗試語句與理由 "
     echo '工:沒有,有人上課'; 
done

......自此陷入無限循環......
# 幹!!!

2010/12/06

12/6 google 日曆有錯誤,錯誤示意圖

Google 日曆嵌入頁面的顯示,產生錯誤。
之前沒發生問題,但是現在發生了。
很多人昨天就發現問題的,請幫忙解決巴!!!!
http://www.google.com/support/forum/p/other/thread?tid=41fefbef78762fee&hl=zh-TW

看起來是嵌入網頁版本的日曆套表套錯表格了。
登入後的版本顯示為星期一開始 <---- 正確
網頁版本的顯示為星期日開始 <--- 顯示差一天
煩請修正一下巴!! 否則我老闆會跑錯行程拉!!!


請看起來是 12/4 日動了程式碼後,才發生問題的
http://www.google.com/support/forum/p/other/thread?tid=13089896f160c732&hl=zh-TW

2010/12/04

中山大學EMBA及IBMBA聯合招生說明會

說明會報名網站 QRCODE  可以手機線上報名


IBMBA文宣海報,這個正妹叫做 patty 目前在德國交換....maybe,高雄市公車後面的海報都是他,我沒有MSN....




中山IBMBA 2010法國巴黎交換經驗分享 更多 http://ibmba.nsysu.edu.tw (有full hd畫質,希望他不會來信問候我......)

但我覺得他講的很好呀!!人又很正.....












100年度招生說明會(立即報名)

地區時間活動地點
台北2010/12/09(四) 19:00-21:00福華國際文教會館 201室
(台北市新生南路三段30號)
新竹2010/12/09(四) 12:00-14:00新竹科技園區科技生活館 207 室
(新竹市科學園區工業東二路1號)
台中2010/12/08 (三) 19:00-21:00全國大飯店 (B館 東京廳)
(台中市台中港路一段257號)
台南2010/12/01(三) 12:30-13:30南科同業公會南部園區辦事處R202
(台南縣新市鄉南科三路26號2F )
2010/12/01(三) 19:00-21:00香格里拉台南遠東國際大飯店 9F
(台南市大學路西段89號)
高雄2010/12/18(六) 10:00-12:00中山大學管理學院2樓2037室



2010/11/30

台客舞教學影片下載 -- 參考台客舞萬年

2009 年高雄左營萬年季,「台客舞萬年」活動高雄市政府配合活動重新將目前流行的舞蹈動作結合傳統抬轎人員的「七星步」台客舞。
http://cabu.kcg.gov.tw/ks2009/activity08.html

也就是目前在電視上看到的廣告,「我們都是高雄人」跳的這個舞蹈



這個看起來好像是配樂的作者
節錄歌詞如下:
In the Sun I see your shinning smile
Everyday will be a perfect day
It's your love that takes my breath away
It's the place we wanna stay

Share your love with everyone around
That's the treasure which you've never found
It's our home that keeps us safe and sound
Take me to the future all we want

當然如果尾牙或有活動要表演的話,在是市政府網站有完整。示範影片提供下載,還有分段動作教學勒....

本站分流
1.台客舞萬年舞蹈示範教學 .mp4下載
2.台客舞流程分析-前奏動作 .mp4下載
3.台客舞流程分析-主動作 .mp4下載
4.台客舞流程分析-間奏動作 .mp4下載
5.台客舞背景音樂下載 .mp3下載

立即 youtube 上觀看








2010/11/22

OMR 系統 - 自動閱卷,只需要軟體就可以搞定

早期聯招考試都用答案卡劃線的方式作答
但是答案卡和試卷分開,有時後會不小心劃錯位置
且題目的呈現需要和試卷結合,會有不小的問題。

目前電腦問卷系統已經很成熟了, limesurvey 是套很成熟的問卷軟體
http://www.limesurvey.org/
目前 google form 也可以提供很方便的問卷。
但這網路化結果,通常是要上網才可以填,但常常造成施測不易。

所以兩者各有優缺點。

但如果可以改善傳統的問卷方式,以較低成本的方式提供問卷服務。
那不就可以減少很多無謂的困擾。傳統上目前已經有用應用程式的方式
提供這樣的服務,如果可以以網站的方式,呈現這樣的結果不就更方便了。

參考:
http://www.alldala.com/
http://www.dartgoal.com.tw/main/index.php?module=product&func=list&sid=36

答案卡範例:
http://www.marks.com.tw/downloads/answersheet/a5_80.pdf

「經典必看」3 IDIOTS



幾天前在youtube 上亂逛看到一則有趣的影片
一開始是被他的教考卷及NASA鉛筆的笑話吸引,後來又多看了幾則簡短相關的影片。
很有料.....




內容根本合影片的簡單介紹差很多,網路上心得文太多了,想要先看劇情的搜尋應該有一堆
http://s24280.pixnet.net/blog/post/25298455


土豆網 印度喜劇電影《三個白痴》英語中文字幕 3 Idiots 三傻大鬧寶萊塢

2010/11/12

RedHat正式釋出RHEL6,並且改變認證考試RHCT成為RHCSA,RHCE認證將有大變動



Red Hat Enterprise Linux 這幾天也為免變化太大了,都快追不上了.

RedHat正式釋出RHEL6,並且改變認證考試RHCT成為RHCSA,RHCE認證將有大變動

引用自 RELEASE-NOTES-zh-TW.html


比較大的改變:

檔案系統​​​預​​​設​​​值​​​變更為 ext4 檔​​​案​​​系​​​統。

Red Hat Enterprise Linux 6 提​​​供​​​了​​​ Intelligent Input Bus(IBus)為​​​預​​​設​​​的​​​亞​​​洲​​​語​​​言​​​輸​​​入​​​法​​​框​​​架​​​。​​​

Red Hat Enterprise Linux 6 已​​​支​​​援​​​作​​​為​​​ x86 與​​​ AMD 64 以​​​及​​​ Intel 64 架​​​構​​​的​​​ Xen 客​​​座​​​端​​​。​
Red Hat Enterprise Linux 6 不​​​支​​​援​​​作​​​為​​​ Xen 主​​​機​​​。​​​


xen不支援那該怎麼辦?

還好有新工具 virt-v2v
Red Hat Enterprise Linux 6 包​​​含​​​了​​​新​​​的​​​ virt-v2v 工​​​具​​​,並​​​能​​​讓​​​系​​​統​​​管​​​理​​​員​​​轉​​​換​​​和​​​匯​​​入​​​他​​​們​​​在​​​其​​​它​​​系​​​統​​​(例​​​如​​​ Xen 和​​​ VMware ESX)上​​​所​​​建​​​立​​​的​​​虛​​​擬​​​機​​​器​​​。​​​virt-v2v 為​​​ Red Hat Enterprise Linux 5 hypervisor 上​​​執​​​行​​​的​​​ Xen 客​​​座​​​端​​​提​​​供​​​了​​​遷​​​移​​​路​​​徑​​​。​​​



Red Hat Certified System Administrator (RHCSA)


RHCT 認證更動為 RHCSA(原文) RHCE考試又要大變動。

關於 RHCSA 的經常問題回答

RHCSA Exam Objectives 考試目標

2010年11月,紅帽RHCE認證的升級版RHEL 6正式出現預計2011.3開始教授新的認證課程。2011.3月,舊版RHEL 5.4的認證課程將全面退出培訓。新版的RHCT認證將更名為 RHCSA(Redhat Certified System Administrator),考試代號為EX200。

新版的RHCE,必須先通過RHCSA認證,才可以參加RHCE考試(EX300)證書有效期變為三年。

這就是說,新版RHCE的難度將大幅度加大,考試的次數將變為二次,考試的時間將由現在半天,延長為一天(又改一天...XD),上午考RHCSA,下午考RHCE。

結論是,要考趁三月前快點考,否則剛出來的RHEL 6 認證一定是最難的狀況。

2010/11/04

debian/ubuntu 安裝 logwatch 系統記錄分析及報告工具

如果一台 linux 機器放在實體的網路上,通常會有來自於各地的攻擊訊息
如果你不是一個勤勞的管理者,每天都有去看 log 檔的紀錄根本不會知道發生什麼事。
於是 logwatch 就是幫我門分析在系統的紀錄中,哪些疑似有問題的,每天回報給
管理者,管理人員透過回報的紀錄就會知道最近的伺服器狀況是如何,不用每天登入機器去關心。

office site
http://sourceforge.net/projects/logwatch/files/

* 安裝 logwatch
apt-get install logwatch

* 通常安莊程式會寫一個 script 到 /etc/cron.daily 內,讓他每天可以執行。如果應試要測試的話可以直接執行以做測試
/etc/cron.daily/00logwatch

執行完成後,分析的 email 會寄到 root 管理者的信箱。

如果要改變信箱,請使用標準的作法修改 /etc/aliases 檔案

root@ubuntu:~# nano /etc/aliases
# 詳細說明可以觀看 man 5 aliases for format
# 請在最底下加入
root: mtchang@xxx.jangmt.com
這樣會把 root 所有的信件轉到 mtchang@xxx.jangmt.com 的信箱。
管理人員收信就可以知道狀況了。

信件內容長的大概如下....

################### Logwatch 7.3.6 (05/19/07) ####################
Processing Initiated: Thu Nov  4 11:22:26 2010
Date Range Processed: yesterday
( 2010-Nov-03 )
Period is day.
Detail Level of Output: 0
Type of Output/Format: mail / text
Logfiles for Host: ubuntu
##################################################################

--------------------- dpkg status changes Begin ------------------------

Upgraded:
ttf-symbol-replacement-wine1.3 1.3.5-0ubuntu1~lucidppa1 => 1.3.6-0ubuntu1~lucidppa1
wine1.3 1.3.5-0ubuntu1~lucidppa1 => 1.3.6-0ubuntu1~lucidppa1

---------------------- dpkg status changes End -------------------------


--------------------- pam_unix Begin ------------------------

sesman:
Unknown Entries:
authentication failure; logname= uid=0 euid=0 tty= ruser= rhost= : 7 Time(s)
check pass; user unknown: 7 Time(s)

su:
Sessions Opened:
root -> root: 1 Time(s)


---------------------- pam_unix End -------------------------

--------------------- SSHD Begin ------------------------


Refused incoming connections:
189.20.68.59 (189.20.68.59): 1 Time(s)
203.116.55.140 (203.116.55.140): 2 Time(s)
customer-200-79-53-211.uninet-ide.com.mx (200.79.53.211): 1 Time(s)
mail.cipi.tj (79.170.186.119): 1 Time(s)
mail.ncku.edu.tw (140.116.229.2): 2 Time(s)

---------------------- SSHD End -------------------------

2010/11/03

CentOS/RHEL 安裝 rar 程式

rar 不是GPL的程式,所以沒有被打包在套件包中。
但是很多人就是喜歡用他,遇到 .rar 的壓縮檔在 linux 中出現也很麻煩。

rar for linux 下載 http://www.rarsoft.com/download.htm


* 32bit 的 rar安裝流程,請依你的需求安裝(載點在上面的 link )
[root@cicsrv ~]# wget http://www.rarsoft.com/rar/rarlinux-3.9.3.tar.gz
[root@cicsrv ~]# tar zxvf rarlinux-3.9.3.tar.gz
[root@cicsrv ~]# cd rar
[root@cicsrv rar]# make install
mkdir -p /usr/local/bin
mkdir -p /usr/local/lib
cp rar unrar /usr/local/bin
cp rarfiles.lst /etc
cp default.sfx /usr/local/lib


我推薦有GPL授權,且具有 rar 壓縮比的壓縮工具 7zip or bzip 這兩支工具程式
7zip
http://www.7-zip.org/download.html
現在在 windows 底下我都用這套,連寫 windows 的備份程式 dos script 也用這個做壓縮的動作,簡單有好用

bzip 通常 linux 預設就會安裝,但是在 windows 底下使用比較麻煩
http://gnuwin32.sourceforge.net/packages/bzip2.htm
尤其是使用 command mode 的時候,因為他很多的 lib 所以不適合做 portable 的壓縮 script
但是壓縮比來說,是很不錯的。

2010/11/01

Fail2ban 杜絕很煩人的 bot-net 攻擊

fail2ban 是一個針對 log 檔案中密碼輸入錯誤的紀錄,然後更新防火牆規則
進行 ban ip 動作的服務,可以有效的對付 bot-net 的惡意掃瞄程式

在 rhel/centos 的版本中如果要安裝需要安裝 EPEL 的套件

下載:
http://www.fail2ban.org/wiki/index.php/Downloads

EPEL 是針對 fedora 中沒有被收錄在 rhel 的套件,做打包彙整。提供給 rhel 使用的套件。
如果要安裝 EPEL 套件來源方法很簡單,請在系統的 /etc/yum.repos.d/ 目錄建立一個檔案 epel.repo
並且放入底下的內容,皆下來安裝軟體的時候就會更新了。底下是以 5 版 x86_64 為安裝來源
如果你的版本比較新,請觀看官方網站找比較新的安裝來源。
http://fedoraproject.org/wiki/EPEL
[root@lab yum.repos.d]# nano epel.repo
[epel5]
enabled = 1
name = epel 5
baseurl = http://mirror01.idc.hinet.net/EPEL/5/x86_64/
gpgcheck = 0

[epel5Server]
enabled = 1
name = epel 5Server
baseurl = http://mirror01.idc.hinet.net/EPEL/5Server/x86_64/
gpgcheck = 0

[epel5Client]
enabled = 1
name = epel 5Client
baseurl = http://mirror01.idc.hinet.net/EPEL/5Client/x86_64/
gpgcheck = 0

* 安裝好後,就可以透過 yum 安裝 fail2ban 軟體
# 安莊 fail2ban
[root@lab ~]# yum install fail2ban
# 因為他是各服務,需要重新啟動
[root@lab ~]# /etc/init.d/fail2ban restart

* 驗證看有沒有在跑 ps -auxww
root 11384 0.0 0.7 175836 4920 ? Sl 14:49 0:00
/usr/bin/python /usr/bin/fail2ban-server -b -s /var/run/fail2ban/fail2ban.sock -x

系統服務設定檔 /etc/fail2ban/fail2ban.conf

服務監控的設定檔 /etc/fail2ban/jail.conf 格式類似底下這樣,需要啟動的服務把 enabled 設定為 true 即可
[ssh-iptables]

enabled = true
filter = sshd
action = iptables[name=SSH, port=ssh, protocol=tcp]
sendmail-whois[name=SSH, dest=root, sender=fail2ban@mail.com]
logpath = /var/log/secure
maxretry = 5

2010/10/31

IEEE OUI and Company_id Assignments (有 MAC find)

ieee  管理網卡 mac 發放的組織
http://standards.ieee.org/regauth/oui/index.shtml

找尋你的網卡 mac 的前三碼是屬於哪各公司製造的
eth0 Link encap:Ethernet HWaddr 00:26:2D:29:36:F0
inet addr:192.168.3.193 Bcast:192.168.3.255 Mask:255.255.255.0
inet6 addr: fe80::226:2dff:fe29:36f0/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:5362381 errors:0 dropped:0 overruns:0 frame:0
TX packets:2854706 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:7721273209 (7.1 GiB) TX bytes:207441338 (197.8 MiB)
Interrupt:177 Memory:febf0000-fec00000
搜尋方式:填入你的mac前六個字元 00262d 為範例
下列就會列出屬於誰的資訊
http://standards.ieee.org/cgi-bin/ouisearch?00262D

00-26-2D   (hex)  Wistron Corporation
00262D     (base 16)  Wistron Corporation
    21F, 88, Sec.1, Hsin Tai Wu Rd., Hsichih,
    Taipei Hsien Taiwan 221
    TAIWAN, REPUBLIC OF CHINA
看樣子很明顯是中國代工的 dell 電腦


列表:
http://www.iana.org/assignments/ethernet-numbers

2010/10/29

netstat 指令用法,及狀態說明

netstat 指令

netstat是一個可以查詢本機網路和外界網路連線的指令,可以透過這個指令的查詢得知有沒有奇怪的連線在你的機器中連線,也可透過此指令瞭解電腦連線的狀況
這個指令windows 上也有,Linux上也有,但在參數與用法有一些不同。
Windows 上得說明可以參考 m$ 的 netstat 說明
節錄及翻譯如下:
語法:
netstat [-a] [-e] [-n] [-o] [-p Protocol] [-r] [-s] [Interval]

參數:
-a : 顯示所有活動中的 TCP 連線,及 TCP and UDP ports 上聆聽中的資訊。

-e : 顯示網路的統計資訊,如 bytes 數和封包發送和接收的數量.這參數通常和 -s 並用。

-n : 顯示活動的TCP連線,但是 ip address和port編號沒有被解釋翻譯成為名稱說明。(通常可以加速顯示的速度因為反解通常需要查詢 dns 的時間)

-o : 顯示活動的 TCP 連線並且包含每個連線程序的 ID 編號(PID).你能夠找到應用程式的程序的PID資訊,在 windows 的工作管理員。這個參數通常和 -a, -n, and -p 混合使用.

-p 通訊協定 : 顯示指連線的通訊協定.預設的狀況這個通訊協定包含 tcp, udp, tcpv6, or udpv6. 如果配合 -s 參數則是可以顯示統計數量。

-s : 顯示統計資訊。預設顯示 TCP, UDP, ICMP, and IP 通訊協定. 如果 IPv6 protocol for Windows XP 被安裝的話, 統計資料顯示 TCP over IPv6, UDP over IPv6, ICMPv6, and IPv6 protocols.

-r : 顯示 IP 路由表的內容. 相當於 route print 命令.

Interval : 每隔幾秒重新顯示資訊. 按 CTRL+C 可以停止顯示. 如果省略則只顯示一次。

/? : 此說明

netstat -e



netstat -n

netstat -o

netstat -on 5

在這些資訊中,必須要先瞭解關於TCP 連線的的溝通方式。看起來才不會覺得怪怪的一直看不懂...

Protocol的執行過程描述:

下圖描述為一張簡化的TCP狀態圖,更詳細可以看這份文件(TCP EFSM diagram)



引用自 http://en.wikipedia.org/wiki/Transmission_Control_Protocol


TCP通訊過程可分為三個階段。且必須正確建立連接在一個很多步驟的交握處理(handshake process)然後才進入建立連接(connection establishment),再進入資料傳輸(data transfer) 階段。資料傳輸完成後,最後連接終止(connection termination)建立的虛擬通道關閉並釋放所有分配的資源。

一個TCP連接是由OS管理,TCP連線基本上經歷底下這些變化:

 1. LISTEN:如果是服務程式的話,指的是等待連接請求從任何遠端的客戶端。
 2. SYN-SENT:等待遠端點對點發回一個 TCP segment 並帶有 SYN 和 ACK flag。通常做這件事的為TCP客戶端。
 3. SYN-RECEIVED:等待遠端通道的另一端發回一個確認後發回確認連接到遠程節點。通常做這件事的為TCP服務端。
 4. ESTABLISHED: port 準備好接收/及發送數據從到遠端節點。
 5. FIN-WAIT-1
 6. FIN-WAIT-2
 7. CLOSE-WAIT
 8. CLOSING
 9. LAST-ACK
10. TIME-WAIT:指等待足夠的時間,以確保通過遠端對等機器收到確認其連接終止請求。根據 RFC 793中的連接可以等到最久為四分鐘。
11. CLOSED

詳細網路協定可以參考:市面上的TCP/IP 書籍

底下這是 Linux man netstat 對於狀態的解釋

netstat 的狀態

   State
       The  state  of  the socket. Since there are no states in raw mode and usually no states used in UDP, this column
       may be left blank. Normally this can be one of several values:

       ESTABLISHED
              The socket has an established connection.

       SYN_SENT
              The socket is actively attempting to establish a connection.

       SYN_RECV
              A connection request has been received from the network.

       FIN_WAIT1
              The socket is closed, and the connection is shutting down.

       FIN_WAIT2
              Connection is closed, and the socket is waiting for a shutdown from the remote end.

       TIME_WAIT
              The socket is waiting after close to handle packets still in the network.

       CLOSE  The socket is not being used.

       CLOSE_WAIT
              The remote end has shut down, waiting for the socket to close.

       LAST_ACK
              The remote end has shut down, and the socket is closed. Waiting for acknowledgement.

       LISTEN The socket is listening for incoming connections.  Such sockets are not included in the output unless you
              specify the --listening (-l) or --all (-a) option.

       CLOSING
              Both sockets are shut down but we still don't have all our data sent.

       UNKNOWN
              The state of the socket is unknown.
             
          
Linux 上的 netstat 套件在 net-tools 上面,如果缺少可以使用 yum install net-tools -y 安裝
$ rpm -qf /usr/bin/netstat   (查詢 netstat 指令套件名稱)
net-tools-2.0-0.17.20131004git.el7.x86_64

在 Linux 上有幾種特殊的用法
引用自 http://www.hkcode.com/linux-bsd-notes/559


以下是一些實用的 netstat 語法,可以檢查主機的連線數量:

netstat -na
顯示主機上所有已建立的連線。

netstat -an | grep :80 | sort
顯示所有 port 80 的連線,並把結果排序。

netstat -n -p|grep SYN_REC | wc -l
列出主機上有多少個 SYNC_REC,一般上這個數字應該相當低。

netstat -n -p | grep SYN_REC | sort -u
同樣是列出 SYNC_REC,但不只列出數字,而是將每個 SYNC_REC 的連線列出。

netstat -n -p | grep SYN_REC | awk ‘{print $5}’ | awk -F: ‘{print $1}’
列出發送 SYNC_REC 的所有 ip 地址。

netstat -ntu | awk ‘{print $5}’ | cut -d: -f1 | sort | uniq -c | sort -n
計算每一個 ip 在主機上建立的連線數量。

netstat -anp |grep ‘tcp\|udp’ | awk ‘{print $5}’ | cut -d: -f1 | sort | uniq -c | sort -n
列出從 TCP 或 UDP 連線到主機的 ip 的數量。

netstat -ntu | grep ESTAB | awk ‘{print $5}’ | cut -d: -f1 | sort | uniq -c | sort -nr
列出每個 ip 建立的 ESTABLISHED 連線數量。

netstat -plan|grep :80|awk {’print $5′}|cut -d: -f 1|sort|uniq -c|sort -nk 1
列出每個 ip 建立的 port 80 連線數量。

Linux netstat 使用範例:
netstat -alp 列出連線的協定及使用的應用程式

2010/10/26

windows XP 使用 iscsi 遠端無碟啟動 remote boot

維基上的介紹:

iSCSI又稱為IP-SAN,是一種基於網際網路SCSI-3協議下的存儲技術,由IETF提出,並於2003年2月11日成為正式的標準。與傳統的SCSI技術比較起來,iSCSI技術有以下三個革命性的變化:
  1. 把原來只用於本機的SCSI協同透過TCP/IP網路傳送,使連接距離可作無限的地域延伸;
  2. 連接的伺服器數量無限(原來的SCSI-3的上限是15);
  3. 由於是伺服器架構,因此也可以實現在線擴容以至動態部署。


iscsi使用前要先認識兩個名詞:

* iscsi target (儲存裝置目的端,用來當遠端網路硬碟使用)

你可以透過 ubuntu 安裝 iscsi 的 target 來提供 iscsi 網路硬碟的服務。

* 安裝過程
# ubuntu 軟體安裝
apt-get install iscsitarget

# use dd 指令建立1個 20G 的檔案,用這個 20 G檔案當成網路硬碟。
 dd if=/dev/zero of=/backup/iscsi/LUN0 bs=1024 count=20480000

# 修改設定檔, /etc/ietd.conf 加入
vim /etc/ietd.conf
# 設定檔的最底下加入
Target iqn.2010-10.com.ec:storage.data1t.iscsi.data01
        #IncomingUser trysoft trysoft
        #OutgoingUser trysoft trysoft
        Lun 0 Path=/backup/iscsi/LUN0,Type=fileio
        Alias iSCSI for ec
        MaxConnections          2
        InitialR2T              Yes
        ImmediateData           Yes

# 加入允許連線的範圍
# vim /etc/initiators.allow
ALL 140.117.69.0/24

# 設定啟動
vim /etc/default/iscsitarget
ISCSITARGET_ENABLE=true

# 重新啟動所有的 iscsi target 設定
/etc/init.d/iscsitarget restart

# 驗證是否該 port 有被開啟
root@ec:~# netstat -an | grep 3260
tcp        0      0 0.0.0.0:3260            0.0.0.0:*               LISTEN  
tcp6       0      0 :::3260                 :::*                    LISTEN  

* 對於 iscsi target 服務設定不清楚可以參考
# http://www.ichiayi.com/wiki/tech/centos_iscsi
# http://ubuntuforums.org/showthread.php?t=1210576

--------------------------------
接就是要驗證 iscsi initiator 的部分,這個是用來連接 iscsi target 的工具程式

* iscsi initiator 微軟出的
http://www.microsoft.com/downloads/en/details.aspx?familyid=12cb3c1a-15d6-4585-b385-befd1319f825&displaylang=en

你可以安裝完這套軟體後,先用圖形界面設定驗證看看,看看是否可以正常工作,可以工作後再繼續下一步。







 設定完成,請選 LogON 啟用,皆下來到管理電腦,磁碟管理應該就會看到一個新的硬碟了。


以上為 iscsi  initiator 的部分
不清楚的話請看微軟 msdn 說明

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

接下來就是把這個 iscsi 裝置裝上 windows XP ,很可惜XP 先天沒有支援iscsi 所以必須要改很多才可以達到目的。

先找一台電腦安裝好 windows xp 並且更新到最新的 update ,但是為了快速起見,建議把分割區切 8G 就好,這樣再把硬碟做成影像檔的時候,速度會比較快。


裝好後請加裝  iscsi 在 windows上得支援套件
請參考:http://www.etherboot.org/wiki/sanboot/winnt_iscsi
也就是下載這兩個檔案安裝:

然後你如果是要用 iscsi 開機請再加裝 sanboot driver
http://www.etherboot.org/wiki/sanboot/winnt_sanbootconf
這是 etherboot 這個專案為了這個開發的設定工具。

 不過既然都裝到這裡了,一併連 AOE support 也裝上去好了
http://www.etherboot.org/wiki/sanboot/winnt_aoe

皆下來就是把這個 XP的影像檔,做到 iscsi 當成 image 檔案
方法請參照:http://www.etherboot.org/wiki/sanboot/transfer

然後最後如果你的網卡不是 iscsi 可以開機的網卡,必須要使用 gpxe 光碟片開機,
gpxe 光碟片支援很多種的開機型態,但是要搭配 dhcp server 來指定參數。
詳細請看這篇 http://www.etherboot.org/wiki/sanboot/iscsi_boot

最後記得拔除原本的 HD 然後重新開機,就可以遠端網路iscsi 開機了。

過程真的很瑣碎,以後再把圖補上。

參考:
http://www.ichiayi.com/wiki/tech/centos_iscsi
http://etherboot.org/wiki/index.php
http://www.libthomas.org/~thomas/wp/?p=158
http://blog.hfu.edu.tw/blog/FOOL/archives/1421
http://afterainblog.spaces.live.com/blog/cns!BC6BD653C5FCF7A6!325.entry
http://jackden-diary.blogspot.com/2010/03/freenas-iscsi-in-ubuntu-904-mount-log.html
http://www.cyberciti.biz/faq/howto-setup-debian-ubuntu-linux-iscsi-initiator/
http://wiki.debian.org/iSCSI/iscsitarget

2010/10/25

php list 的 url cache 及 footer 問題

php list 中可以插入遠端的 URL 當作郵件內容,但是內容只要輸入後會被 cache 在 mysql 資料庫中
資料表示 url_cache 如果想立即生效可以從 sql 中刪除被 cache 的 web url 文件
,但是 url cache refetch time 是可以設定的,預設是 3600 秒,只要修改
phplist 目錄中 config/config.php 檔案中的這一段就可以達成
# send a webpage. You can send the contents of a webpage, by adding
# [URL:http://website/file.html] as the content of a message. This can also be personalised
# for users by using eg
# [URL:http://website/file.html?email=[email]]
# the timeout for refetching a URL can be defined here. When the last time a URL has been
# fetched exceeds this time, the URL will be refetched. This is in seconds, 3600 is an hour
# this only affects sending within the same "process queue". If a new process queue is started
# the URL will be fetched the first time anyway. Therefore this is only useful is processing
# your queue takes longer than the time identified here.
define('REMOTE_URL_REFETCH_TIMEOUT',300);

另外在系統中,會自動增加 phplist 的廣告及 footer 訂閱的連結,如果想拿掉可以
修改 admin/sendemaillis.php 其中程式碼為

$url = getConfig("subscribeurl");$sep = ereg('\?',$url)?'&':'?';
$html["subscribe"] = sprintf('<a href="%s">%s</a>',$url,$strThisLink);
$text["subscribe"] = sprintf('%s',$url);
$html["subscribeurl"] = sprintf('%s',$url);
$text["subscribeurl"] = sprintf('%s',$url);
#?mid=1&id=1&uid=a9f35f130593a3d6b89cfe5cfb32a0d8&p=forward&email=michiel%40tincan.co.uk&
$url = getConfig("forwardurl");$sep = ereg('\?',$url)?'&':'?';
$html["forward"] = sprintf('<a href="%s%suid=%s&mid=%d">%s</a>',$url,$sep,$hash,$messageid,$strThisLink);
$text["forward"] = sprintf('%s%suid=%s&mid=%d',$url,$sep,$hash,$messageid);
$html["forwardurl"] = sprintf('%s%suid=%s&mid=%d',$url,$sep,$hash,$messageid);
$text["forwardurl"] = $text["forward"];
$url = getConfig("forwardurl");
# make sure there are no newlines, otherwise they get turned into <br/>s
$html["forwardform"] = sprintf('<form method="get" action="%s" name="forwardform" class="forwardform"><input type=hidden name="uid" value="%s" /><input type=hidden name="mid" value="%d" /><input type=hidden name="p" value="forward" /><input type=text name="email" value="" class="forwardinput" /><input name="Send" type="submit" value="%s" class="forwardsubmit"/></form>',$url,$hash,$messageid,$GLOBALS['strForward']);
// $text["signature"] = "\n\n--\nPowered by PHPlist, www.phplist.com --\n\n";
// skip by mtchang 2010.7.14
$text["signature"] = 'mtchang';



/* skip by mtchang 2010.7.14
if (!EMAILTEXTCREDITS) {
$html["signature"] = $PoweredByImage;#'
<div align="center" id="signature">
<a href="http://www.phplist.com/"><img alt="Powered by PHPlist" border="0" height="31" src="powerphplist.png" title="Powered by PHPlist" width="88" /></a></div>
';
# oops, accidentally became spyware, never intended that, so take it out again :-)
$html["signature"] = preg_replace('/src=".*power-phplist.png"/','src="powerphplist.png"',$html["signature"]);
} else {
$html["signature"] = $PoweredByText;
}
*/
$html["signature"] = '';



在 footer 產生訂閱連結的部分,可以修改

$text["footer"] = eregi_replace("\[SUBSCRIBE\]",$text["subscribe"],$text['footer']);
$html["footer"] = eregi_replace("\[SUBSCRIBE\]",$html["subscribe"],$html['footer']);
$text["footer"] = eregi_replace("\[PREFERENCES\]",$text["preferences"],$text["footer"]);
$html["footer"] = eregi_replace("\[PREFERENCES\]",$html["preferences"],$html["footer"]);
$text["footer"] = eregi_replace("\[FORWARD\]",$text["forward"],$text["footer"]);
$html["footer"] = eregi_replace("\[FORWARD\]",$html["forward"],$html["footer"]);
$html["footer"] = eregi_replace("\[FORWARDFORM\]",$html["forwardform"],$html["footer"]);
$text["footer"] = eregi_replace("\[BLACKLIST\]",$text["blacklist"],$text['footer']);
$html["footer"] = eregi_replace("\[BLACKLIST\]",$html["blacklist"],$html['footer']);
if (sizeof($forwardedby) && isset($forwardedby['email'])) {
$htmlmessage = eregi_replace("\[FORWARDEDBY]",$forwardedby["email"],$htmlmessage);
$textmessage = eregi_replace("\[FORWARDEDBY]",$forwardedby["email"],$textmessage);
$html["footer"] = eregi_replace("\[FORWARDEDBY]",$forwardedby["email"],$html["footer"]);
$text["footer"] = eregi_replace("\[FORWARDEDBY]",$forwardedby["email"],$text["footer"]);
$text["footer"] = eregi_replace("\[UNSUBSCRIBE\]",$text["blacklist"],$text['footer']);
$html["footer"] = eregi_replace("\[UNSUBSCRIBE\]",$html["blacklist"],$html['footer']);
} else {
$text["footer"] = eregi_replace("\[UNSUBSCRIBE\]",$text["unsubscribe"],$text['footer']);
$html["footer"] = eregi_replace("\[UNSUBSCRIBE\]",$html["unsubscribe"],$html['footer']);
}

$html["footer"] = '<div class="emailfooter">'.nl2br($html["footer"]).'</div>';
// skip footer by mtchang 2010.10.25
$html["footer"] = '';

雲端運算 Cloud Computing 相關資料

聽六先生說雲端...
http://mr6.cc/?p=2281 

國際研究暨顧問機構Gartner 說明雲端
http://www.computerworld.com/s/article/9115904/Cloud_computing_hype_spurs_confusion_Gartner_says

我所認識的雲端運算:
主要分成兩種,一種為雲端服務,類似 SaaS (Software as a Service) ,透過網路使用網路服務公司提供的網路服務,例如:Google APP , Amanzon EC2 and S3 ,  虛擬主機商提供的虛擬空間或是DNS代管等.....透過這些服務,改變簡化工作流程並節省企業的成本。
另外一種為雲端技術,透過一群電腦協同合作達成高速的運算。例如:MIT的尋找外星人,基因定序等需要很多運算時脈的。

http://zh.wikipedia.org/zh-tw/%E9%9B%B2%E7%AB%AF%E9%81%8B%E7%AE%97

CIO 及 CFO 該如何評估雲端運算導入的考量?
CIO:
1.現有公司服務須分成可導入的部份,及公司核心價值或有機密性不可導入的部份。
2.導入後是否可改善簡化工作流程,對企業有正面效益?
3.導入期間所需花費時間,服務周邊相關人員對於導入的接受度?
 CFO:
1.導入後可以節省多少直接或間接成本?
2.對於公司財務負擔一次性支出,及經常性支出的風險評估?

企業如果採用雲端運算可能造成營運危機有哪些?
假設是一間小型購物網站,將其網站及資料全部導入 Amanzon S3的儲存服務 and EC2 所提供的虛擬主機服務。
營運危機的可能有:
1.Amanzon S3 or EC2暫停服務所造成的營運損失
2.資料被竊取或無故消失,並且找不到可能消失的原因。
3.系統管理者如惡意離職,沒有交接或沒有備份突然失去管理權的損失。

2010/10/17

「推薦」注音符號教學網

首推注音符號筆順教學

http://163.24.106.140/resorceclass/online/work/wri--all.html

用上衣  中間  褲子 表達的注音符號,並付念法
http://163.24.106.140/resorceclass/online/work2/fullscreen1.htm

這是用來教小孩的拉,因為我門「之吃私」發音都不是很正確

有著濃濃的高雄台語腔,這甲是愛呆丸拉!!!!


推薦 我們都是高雄人!!!!! http://www.youtube.com/watch?v=Nj6VLRxFG3c

Unix Like 系統上面 2038年問題

因為UNIX的日期當初在定義的時候以 1970.1.1起的時間秒來算
但是當初設計的時候,因為變數表達長度的關係,如果是32bit只能表達到
在2038年1月19日3時14分07秒 ,所以就會出現類似百年序或是千年蟲的問題

wiki上面的圖片可以很清楚的表達這件事
 http://zh.wikipedia.org/zh-tw/2038%E5%B9%B4%E9%97%AE%E9%A2%98

2010/10/09

EzGo 8 下載分流

EzGo 8 下載分流,因為原始連結還滿不穩定的,且速度真的不快。

關於下一個版本 EzGo8 我有意見
http://wekey.westart.tw/Ezgo8_suggestion

分流
http://jangmt.com/ezgo/

英文版 http://jangmt.com/ezgo/ezgo8_en.iso

RC中文版 http://jangmt.com/ezgo/ezgo8_rc.iso

這看起來是官方網站 http://ezgo.westart.tw/

引用自 http://news.ossacc.org/ezgo6_readme_linux/ezgo.html
什麼是EzGo:
◎EzGo的設計理念
EzGo並不是Linux,相信Linux已經夠多了,不需要再多一套EzGo Linux來湊熱鬧,EzGo只是一張想要把超讚的自由軟體用最感動的方式跟您分享的光碟片!!

EzGo的設計理念聚焦在視窗環境下的自由軟體應用,相信不管是哪一套Linux,都會有視窗環境X Window系統,而現在比較常見的桌面環境GNOME和KDE等也都是以X Window系統為基礎建構而成的,然而不管是GNOME、KDE或其它桌面環境,相信一般的使用習慣,一定還是以系統下的應用軟體為主,在微軟Windows下,您可能會透過「開始功能表」的選單按鈕來啟動應用軟體,而在Linux下也有類似「開始功能表」的選單按鈕,它的名稱叫作「應用程式」,您可以透過「應用程式」選單按鈕,開始體驗自由軟體中豐富多元的應用軟體!!

EZGO資源


資訊論理


電子賀卡製作

  • 範例觀賞:


其實我是拿來教自己的小孩啦!!真的很好用...

2010/10/03

Apache 限制下載流量與連線數 in debian

這個模組不是官方釋出的模組,所以如果要用的話請自行衡量
開發者的網站:http://dominia.org/djao/limitipconn2.html

debian 的安裝擋下載
http://elonen.iki.fi/code/unofficial-debs/mod-limitipconn/

安裝:
# 抓檔案
$ wget http://elonen.iki.fi/code/unofficial-debs/mod-limitipconn/apache2-mod-
limitipconn_0.22-2_amd64.deb

# 安裝
$ sudo dpkg -i apache2-mod-limitipconn_0.22-2_amd64.deb

# 進入模組目錄
$ cd /etc/apache2/mods-available/

# 啓動模組
$ sudo a2enmod limitipconn

# 重新載入模組
$ sudo /etc/init.d/apache2 restart

# 修改設定檔
$ sudo vim /etc/apache2/sites-enabled/jangmt
# jangmt是我的virtualhost設定檔請在設定檔內加入類似下面的限制


MaxConnPerIP 3




# 底下是模組的預設值,無須更動可以參考修改
$ cat /etc/apache2/mods-available/limitipconn.load
ExtendedStatus On
LoadModule limitipconn_module /usr/lib/apache2/modules/mod_limitipconn.so

$ cat /etc/apache2/mods-available/limitipconn.conf
# Example config for limitipconn


MaxConnPerIP 5
# exempting images from the connection limit is often a good
# idea if your web page has lots of inline images, since these
# pages often generate a flurry of concurrent image requests
NoIPLimit image/*




* 置於有沒有有用可以看紀錄檔的變化
$ netstat -an | grep EST
tcp 0 0 140.117.69.15:22 140.117.69.182:3349 ESTABLISHED
tcp 0 0 140.117.69.15:22 115.165.192.55:61735 ESTABLISHED
tcp6 0 36400 140.117.69.15:80 123.4.205.188:50018 ESTABLISHED
tcp6 0 0 140.117.69.15:445 140.117.69.183:1047 ESTABLISHED
tcp6 0 12726 140.117.69.15:80 114.243.88.195:65100 ESTABLISHED
tcp6 0 0 140.117.69.15:445 140.117.69.182:3311 ESTABLISHED
tcp6 0 51800 140.117.69.15:80 123.4.205.188:50120 ESTABLISHED
tcp6 0 12960 140.117.69.15:80 175.17.194.177:36633 ESTABLISHED

$ sudo tail /var/log/apache2/access.log
.... skip

$ sudo tail /var/log/apache2/error.log
[Sun Oct 03 16:35:54 2010] [error] [client 175.17.194.177] Rejecting client at 175.17.194.177
[Sun Oct 03 16:35:55 2010] [error] [client 114.243.88.195] Rejecting client at 114.243.88.195
[Sun Oct 03 16:36:04 2010] [error] [client 175.17.194.177] Rejecting client at 175.17.194.177
[Sun Oct 03 16:36:05 2010] [error] [client 175.17.194.177] Rejecting client at 175.17.194.177
[Sun Oct 03 16:36:10 2010] [error] [client 175.17.194.177] Rejecting client at 175.17.194.177
[Sun Oct 03 16:36:27 2010] [error] [client 175.17.194.177] Rejecting client at 175.17.194.177
[Sun Oct 03 16:36:29 2010] [error] [client 175.17.194.177] Rejecting client at 175.17.194.177
[Sun Oct 03 16:36:29 2010] [error] [client 175.17.194.177] Rejecting client at 175.17.194.177



* 更多請參考官方的說明
http://dominia.org/djao/limitipconn-README
mod_limitipconn.c
David Jao
Proxy tracking by Jonathan J. Miner

Apache C module to limit the maximum number of simultaneous connections
per IP address. Allows inclusion and exclusion of files based on MIME
type.

Example configuration:

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

ExtendedStatus On

# Only needed if the module is compiled as a DSO
LoadModule limitipconn_module lib/apache/mod_limitipconn.so
AddModule mod_limitipconn.c



MaxConnPerIP 3
# exempting images from the connection limit is often a good
# idea if your web page has lots of inline images, since these
# pages often generate a flurry of concurrent image requests
NoIPLimit image/*



MaxConnPerIP 1
# In this case, all MIME types other than audio/mpeg and video*
# are exempt from the limit check
OnlyIPLimit audio/mpeg video



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

Notes:

This module will not function unless mod_status is loaded and the
"ExtendedStatus On" directive is set.

The limits defined by mod_limitipconn.c apply to all IP addresses
connecting to your Apache server. Currently there is no way to set
different limits for different IP addresses.

Connections in excess of the limit result in a stock 503 Service
Temporarily Unavailable response. The job of returning a more useful
error message to the client is left as an exercise for the reader.

mod_limitipconn sets the LIMITIP environment variable to 1 whenever a
download is denied on the basis of too high an IP count. You can use
this variable to distinguish accesses that have been denied by this
module. For example, a line like

CustomLog /var/log/httpd/access_log common env=!LIMITIP

in httpd.conf can be used to suppress logging of denied connections
from /var/log/httpd/access_log. (Note that, if you want to do this,
you'll probably also want to comment out the ap_log lines from
mod_limitipconn.c to suppress error_log lines as well.)

Proxy client tracking

By default, all clients behind a proxy are treated as coming from the
proxy server's IP address. If you patch Apache with the included patch
and configure with --with-forward and rebuild, the real IP addresses
of clients behind proxies are correctly detected. You will need to
either compile statically or compile with -DRECORD_FORWARD.

If you don't patch the server, DO NOT compile with RECORD_FORWARD
defined. The module will still function, but it will not recognize
clients behind proxies.


picasa movie maker 將照片轉換成為視訊檔案,免費的且很簡單作

office 2010 ppt 增加了好用的功能就是可以方便的把 ppt 播放檔轉換成為視訊檔案

但是 office 2010 要錢,否則就是要另外買 PowerVideoMaker 把 ppt 轉成影像檔

但那些全部都是要錢的...

現在 picasa 提供了一個 movie maker 的功能,可以直接讓你把照片加上文字加上背景音樂

加上轉場特效,再來把他轉換成為 視訊檔案 .wmv or .mov 這些....全都不用錢啦!!

http://picasa.google.com/support/bin/answer.py?hl=b5&answer=19533

這功能實在太方便了,對於要製作宣傳影片的使用者真是一大幅音,不用在影像軟體中編個老半天,

然後只是為了個簡單的功能。

介紹影片:




More DIY videos at 5min.com

2010/09/29

Google Spreadsheet 的應用 query filter 及簡單的 API

Google 有個 Google Live Form 的表單可以快速建立讓使用者輸入的表單。後端資料儲存在 spreadsheets,但是資料通常是一個很大的 table 不能只秀出我們要得資料。



通常這功能用來做訂便當系統是很方便的。






透過 publish to web  可以將網頁的內容輸出到網頁,讓使用者可以透過網頁觀看結果。但資料會太多,所以需要過 filter 的功能。



但現在有了 spreadsheets 有了 sql query 的功能可以讓我們自訂撈出想要的資料即可。

 Google Spreadsheet  提供類似 SQL query  的查詢工具,可以透過簡單的 SQL 語法撈出我門想要的資料。 他是透過 Google Visualization API Query Language.  的語法來做簡單的影用,在 youtube 上面有影片介紹如何使用:
 

http://docs.google.com/support/bin/answer.py?hl=en&answer=159999

範例:
Full example: =QUERY(A1:E6, "select avg(A) pivot B")
說明:
A1:E5 表示資料蘭範圍,"select avg(A) pivot B" 是 sql select 查詢句, from 預設值為 A1:E5 當然也可以指定不同的 sheets 來做查詢。

Select語法說明如下,和標準的 sql 很雷同:
http://code.google.com/intl/zh-TW/apis/visualization/documentation/querylanguage.html#Setting_the_Query_in_the_Data_Source_URL


看裡面的 select 及 where 兩個部份的 example 說明

於是我開了一個新的 sheet R0033 並作成這樣的查詢句
 其中 week_check_list 指的是表單 sheet 名稱,week_check_list!A:S 是說
這個表單的A~S欄位為資料來源。

select * 這裡代表顯示所有的欄為,當然也可以單獨指令欄為 ex: select B,C,D

where D like 'R0033' 指的是 D欄位的字串符合 R0033 的顯示出來

order by A desc 資料依照 A 欄位的排序,新的在上面

於是這段 sql query 我寫在 R0033 這個 sheet 內,就顯示了這樣的內容....

所以擴大輸出 all sheets 到 web 就變成這樣,使用者點選上面的編號就可以依照 sql 查詢句工作撈出的結果顯示在 web 上面。



如果還要進一步的運用資料,可以參考關於 Setting the Query from JavaScript

這裡直接提供一個 code sample 可以直接修改並且線上測試
http://code.google.com/apis/ajax/playground/?type=visualization#using_the_query_language

首先要餵給它 data source : Setting the Query in the Data Source URL

這裡用它原始的 data source 測試,我把它改成 table 的格式,可以讓每個人只要換 key 就可以套用。

測試網址(純html可以下載使用):http://code.jangmt.com/googleapi/test.html



詳細請看 google 說明: http://code.google.com/intl/zh-TW/apis/visualization/documentation/reference.html#queryobjects
 參考:http://blog.ericsk.org/archives/1417

補充說明:
剛剛測試完成後,本來可以的表單功能,送出竟然出現錯誤....^^!!!! 這是 bug 呀....google 你出來公塊賣...

2010/09/28

PHPLIST 使用及設定 - 發信設定

phplist 是一套功能很強大的發信工具,但他的製報功能不是很強.....
http://www.phplist.com/

這是他的特色(官方網站說明)
  • phplist is a one-way email announcement delivery system. It is great for newsletters, publicity lists, notifications, and many other uses. (It is different from group mailing list systems like mailman.)
  • The Web Interface lets you write and send messages, and manage phplist over the internet.
  • phplist keeps sending messages from your web server, even after you shut down your computer.
  • 100 000 + subscribers. phplist is designed to manage mailing lists with hundreds of thousands of subscribers. phplist is excellent with smaller lists too!
  • No duplicate messages. No 'forgotten' messages. phplist manages message delivery with a message queue, ensuring that every subscriber gets the email message, and that no subscribers receive two copies, even if they're subscribed to more than one list!
  • Open/View Tracking tells you how many users opened your email message. This provides a minimum statistic, as many email clients with privacy or security policies block images (gmail, thunderbird, and others).
  • Click Tracking tracks links and URLs. Statistics can be viewed by message, URL or subscriber.
  • Multiple Subscribe Pages allow you to choose many different combinations of templates, languages, user attributes and lists.
  • Templates are completely customizable, and make site integration a breeze.
  • Multiple Templates on different subscribe pages can integrate phplist with several different web sites.
  • Subscriber Attributes like 'name', 'country', and other personal information, are completely customizable. You can specify what information you need to get from users when they subscribe.
  • User Specific Content. You can use Subscriber Attributes in message content to make each and every email message personalized with the subscribers name, country, or any other attribute.
  • HTML email messages. Subscribers can be given the choice between text or html email messages. You decide whether subscribers can choose, what the default choice is, and what format a message is sent in: text only, html only, or both!
  • The HTML Editor allows you to edit html messages from phplist using FCKeditor. TinyMCE is also available.
  • Internationalization. phplist is available in English, French, German, Spanish, Portuguese, Traditional Chinese, Dutch, Vietname and Japanese and translation work is in progress for other languages.
  • Easy Install via Fantastico, FTP upload, or SSH.
  • Multiple List Administrators. The super-admin can assign lists to List Managers, who can manage their users and lists. The super-admin user can 'prepare' messages that can be sent by list managers to their lists.
  • Subscriber Preferences. Every email message contains personalized URLs for subscribers to update their preferences or unsubscribe. Subscribers can update their own information and keep your database up to date. Unlike most other mailing list managers, in phplist subscribers can change their email address.
  • The User Management tools are excellent to manage and maintain large databases of subscribers.
  • Bounce Processing keeps your database clean of unused and non-existent email addresses.
  • Advanced Bounce handling let's you teach phplist to distinguish between permanent and temporary message-delivery errors. You can define automated actions on receipt of bounce messages according to matches with your regular expressions.
  • CSV Import and Export. Use CSV and tab delimited files to import your existing list of users or to export the users on the phplist system for use in your in-house database. phplist's database has a 'foreign key' to help keep multiple copies of databases synchronized without duplicating users.
  • Attachments can be uploaded and included in messages for download.
  • Send a Web page. Tell phplist the URL of a web page you want to send to your users, and phplist will fetch it and send it. You can even put subscriber-specific parameters in the URL.
  • RSS feeds can be automatically sent to a mailing list weekly, daily, or monthly.
  • PDF messages can be automatically created and sent as attachments to ensure that your message is seen the way it was designed by all your subscribers, regardless of their email message reader.
  • Batch Processing is useful in shared hosting environments. Set the maximum number of sent messages in a given time period.
  • Throttling can limit the load on your server so it doesn't overload.
  • Domain Throttling limits the number of emails to specific domains to keep on the friendly side of their system administrators.
  • Scheduled Sending let's you tell phplist when the message is to be sent.
  • Repetition. A message can be repeated automatically to send updated dynamic content and attachments.
  • Text from HTML. Text email messages are managed fluently in phplist. phplist will automatically create a text version of an html message. Optionally the message composer can create it manually.
  • PGP signing and encrypting (soon).
    Send your message digitally signed or encrypted, or both.
  • Email to Fax (soon).
    Configure the details of your favourite email 2 fax gateway and phplist will send the HTML version of the message as a PDF attachment to your fax gateway. The fax will include the images in the HTML.
  • Integration with other tools. Several systems exist on the internet that integrate phplist with your favourite CMS or blogging tool. Check out the Documentation for a list.

連台大的的電子發報平台都是用它改寫的
http://epaper.ntu.edu.tw/


他的安裝請參考官方網站的說明,中文有空我在來寫
http://docs.phplist.com/PhplistInstallation

我要備註的是這一段,關於 README.commandline 的設定方式
官方的文件是這樣寫的
Running PHPlist from the commandline

Commandline processing requires PHP 4.3.0 or higher

A few pages in the PHPlist system can now, as of version 2.7.0 be run with
a simple command from the commandline.

the script to use is called "phplist" in the "bin" directory. You will have to edit
this script to fit your system

The normal PHPlist access restrictions are bypassed, but the Unix users who are
allowed to run the script should be mentioned in the "commandline_users" config
variable. The identity of a user is determined by the USER environment variable, which
may not always match your system.

The "p" parameter is the page that needs to be run.
Currently you can use "send", "processqueue" and "processbounces"

phplist -psend

This will require some more arguments:

-l list
-s subject
[-f from]

and you need to "pipe" the message into the script.

The -l parameter can have two types of values, the name of the list or the number of the list.
You can added multiple lists or multiple -l parameters
The subject can have spaces
The from is optional. It will default to the system administrator as set up in your config.

So the full "send" command line would be:

phplist -psend -s This is the subject -l test 1 2 3 -f me@server.com < messagefile




* 於是我在我的命令列下這樣的指令 /bin/phplist -p processqueue (處理電子報queue 的信件),它執行了一段時間,因為我設定發 300 封信後,需要休息 300 秒才可以繼續在工作,免得被當成廣告信件。如果這個動作在網頁上執行,它就會把該網頁綁住,然後一直的用 javascript 跑一個執行寄信的畫面,並且鎖住 browser 避免你關掉。但是如果可以把這一段寫成 cron(排成) 放在系統中讓他自己跑就會方便許多了。
epaper@www:~$ /home/epaper/bin/phplist -p processqueue
PHPlist version 2.10.12 (c) 2000-2010 Tincan Ltd, http://www.phplist.com
Started
Sending in batches of 300 emails
Script stage: 6
Finished, Nothing to do
Finished, All done
epaper@www:~$ /home/epaper/bin/phplist -p processqueue
PHPlist version 2.10.12 (c) 2000-2010 Tincan Ltd, http://www.phplist.com
Started
Sending in batches of 300 emails
Processing has started, 1 message(s) to process.
Processing message 66
Looking for users
Found them: 778 to process
batch limit reached: 300 (300)
Script stage: 5
300 messages sent in 335.89 seconds (3215 msgs/hr)
1 invalid emails
Finished this run
Reload required
You have mail in /var/mail/epaper

* 但是有想到另外一個問題,就是當一個發信的工作跑了很久可能需超過 24 hr 以上的時間發信,系統的處理是等待.....,所以這樣就不會有搶工作佇列的問題。
epaper@www:~$ /home/epaper/bin/phplist -p processqueue
PHPlist version 2.10.12 (c) 2000-2010 Tincan Ltd, http://www.phplist.com
A process for this page is already running and it was still alive 1 seconds ago
Running commandline, quitting. We'll find out what to do in the next run.

* 所以如果第二次發信的時候,phplist 會把剛剛發過得扣除,然後在發一次然後在等待 300 秒才會結束程式。所以看起來如果要自動跑的話寫 5min 跑一次,看起來是可以接受的。
epaper@www:~$ /home/epaper/bin/phplist -p processqueue
PHPlist version 2.10.12 (c) 2000-2010 Tincan Ltd, http://www.phplist.com
Started
Sending in batches of 300 emails
Processing has started, 1 message(s) to process.
Processing message 66
Looking for users
Found them: 477 to process

* 如果你有設定好的話,它應該會發一封信到你的信箱去,告訴你大概做了什事....
To: epaper@epaper.cm.nsysu.edu.tw
Subject: PHPlist Maillist Processing info
Recieved:
From: EpaperWebmaster
X-MessageID: systemmessage
X-ListMember: epaper@epaper.jangmt.com
X-UID: 4790


Started
Sending in batches of 300 emails
Processing has started, 1 message(s) to process.
Processing message 66
Looking for users
Found them: 778 to process
batch limit reached: 300 (300)
Script stage: 5
300 messages sent in 335.89 seconds (3215 msgs/hr)
1 invalid emails


* 但是你知道發信總是有人的 email 會是錯誤的,所以要定時的收取退件清單。這些清單會被收進系統的資料庫內,並且予以紀錄。只要修正這些原始的資料,就可以排除了
epaper@www:~$ /home/epaper/bin/phplist -p processbounces
PHPlist version 2.10.12 (c) 2000-2010 Tincan Ltd, http://www.phplist.com
110 bounces to fetch from the mailbox
Please do not interrupt this process
25 done
50 done
75 done
100 done
Closing mailbox, and purging messages
Identifying consecutive bounces
Identifying consecutive bounces
0 of 355 users processed
Identifying consecutive bounces
10 of 355 users processed
Identifying consecutive bounces

* 於是乎加上了排成,我寫成這樣的方式,使用這 epaper 使用 crontab -e 編輯 crontab ,每 20 min 收一次退信,每 5 min 處理信件佇列。
# m h dom mon dow command
*/5 * * * * /home/epaper/bin/phplist -p processbounces
*/20 * * * * /home/epaper/bin/phplist -p processqueue

* BUT 人生就是因為有那麼多的 but 才顯得有趣,系統會告訴你某個變數沒有定義,不讓你跑....錯誤訊息如下
Error: USER environment variable is not defined, cannot do access check. Please make sure USER is defined.
PHPlist version 2.10.12 (c) 2000-2010 Tincan Ltd, http://www.phplist.com

* 那怎麼辦勒,只好自己手工產生變數了...於是我修改了 cron 並自己改寫了一個 shell script
epaper@www:~$ vim epaper_cron.sh
#!/bin/bash
# 手工把變數輸出,應該只是要 USER 這個變數而已...
SHELL=/bin/bash
USER=epaper
MAIL=/var/mail/epaper
PATH=/home/epaper/bin:/usr/local/bin:/usr/bin:/bin:/usr/games
PWD=/home/epaper
LANG=zh_TW.UTF-8
HOME=/home/epaper
LANGUAGE=zh_TW:zh
LOGNAME=epaper
export SHELL
export USER
export MAIL
export PATH
export PWD
export LANG
export HOME
export LANGUAGE
export LOGNAME
/home/epaper/bin/phplist -p processbounces
/home/epaper/bin/phplist -p processqueue

* 排成改了變成這樣
epaper@www:~$ crontab -e
m h dom mon dow command
*/5 * * * * /home/epaper/epaper_cron.sh >> /home/epaper/epaper_cron.log
* 然後就一切正常了, 可以到 /home/epaper/epaper_cron.log 看系統產生的 log


* 另外系統為了避免你一直 try 錯誤的信箱,於是有個文件 README.bounces 可以設定當遇到多少次退信後就不再嘗試寄信了。
In the admin pages, you can now load the bounces in the PHPlist database. Some bounces are not
always really bounces, but they can be "Message delayed" or "Out of Office" messages. Therefore
PHPlist will not immediately unsubscribe a user when a message has bounces, but it will determine
a treshold of messages which will identify a bounce.

You set the threshold with the variable

$bounce_unsubscribe_treshold = 3;

This variable will be used to returns of normal messages. If "systemmessages" return, a user will
be unsubscribed immediately. Unsubscribed means that their email will be marked unconfirmed, which
will cause the system to stop sending emails to this user.

In the future it will become possible to "probe" the unconfirmed emails with a renewed request for
confirmation, which will be dealt with seperately, most likely by simply deleting the user.

If a message to a user bounces, the threshold will be used to determine the previous number of
message that have bounced. A user will only be marked unconfirmed once a row of consecutive messages
as many as your threshold have occurred.

If you run in TEST mode, the emails in the bounce system will not be deleted from the mailbox. If you
have set TEST to 0, it will delete the emails it has dealt with, according to the settings

$bounce_mailbox_purge = 1;
and
$bounce_mailbox_purge_unprocessed = 1;

$bounce_mailbox_purge can be 1 or 0, and 1 means that messages that have been processed and identified
will be delete from the mailbox. $bounce_mailbox_purge_unprocessed can be 1 or 0 as well, and
1 means that also unprocessed messages, which are messages that could not be matched with a user in
the system, will be deleted. This is fairly safe, because you can still look at the messages
in PHPlist.
.

* 關於 bounces 的處理,需要建立一個帳號,來收取信件處理。設定檔一樣在 config.php 內
=========================================================================

Settings for handling bounces

=========================================================================

*/

# Message envelope. This is the email that system messages come from
# it is useful to make this one where you can process the bounces on
# you will probably get a X-Authentication-Warning in your message
# when using this with sendmail
# NOTE: this is *very* different from the From: line in a message
# to use this feature, uncomment the following line, and change the email address
# to some existing account on your system
# requires PHP version > "4.0.5" and "4.3.1+" without safe_mode
$message_envelope = 'listbounces@epaper.jangmt.com';

# Handling bounces. Check README.bounces for more info
# This can be 'pop' or 'mbox'
$bounce_protocol = 'pop';

# set this to 0, if you set up a cron to download bounces regularly by using the
# commandline option. If this is 0, users cannot run the page from the web
# frontend. Read README.commandline to find out how to set it up on the
# commandline
define ("MANUALLY_PROCESS_BOUNCES",1);

# when the protocol is pop, specify these three
$bounce_mailbox_host = 'epaper.jangmt.com';
$bounce_mailbox_user = 'listbounces';
$bounce_mailbox_password = '1234567890xxxxxx';

# the "port" is the remote port of the connection to retrieve the emails
# the default should be fine but if it doesn't work, you can try the second
# one. To do that, add a # before the first line and take off the one before the
# second line

$bounce_mailbox_port = "110/pop3/notls";
#$bounce_mailbox_port = "110/pop3";

# when the protocol is mbox specify this one
# it needs to be a local file in mbox format, accessible to your webserver user
$bounce_mailbox = '/var/spool/mail/listbounces';

# set this to 0 if you want to keep your messages in the mailbox. this is potentially
# a problem, because bounces will be counted multiple times, so only do this if you are
# testing things.
$bounce_mailbox_purge = 1;

# set this to 0 if you want to keep unprocessed messages in the mailbox. Unprocessed
# messages are messages that could not be matched with a user in the system
# messages are still downloaded into PHPlist, so it is safe to delete them from
# the mailbox and view them in PHPlist
$bounce_mailbox_purge_unprocessed = 1;

# how many bounces in a row need to have occurred for a user to be marked unconfirmed
$bounce_unsubscribe_threshold = 5;

* 關於批次處理信件的設定,在設定檔 epaper@www:~/public_html/lists/config$ vim config.php ,可以避免你發信太快被人一直退信或當成垃圾。
# batch processing
# if you are on a shared host, it will probably be appreciated if you don't send
# out loads of emails in one go. To do this, you can configure batch processing.
# Please note, the following two values can be overridden by your ISP by using
# a server wide configuration. So if you notice these values to be different
# in reality, that may be the case

# define the amount of emails you want to send per period. If 0, batch processing
# is disabled and messages are sent out as fast as possible
# define("MAILQUEUE_BATCH_SIZE",0);
define("MAILQUEUE_BATCH_SIZE",300);

# define the length of one batch processing period, in seconds (3600 is an hour)
# define("MAILQUEUE_BATCH_PERIOD",3600);
define("MAILQUEUE_BATCH_PERIOD",300);