最近眼睛右眼看東西, 正中間都有一團黑影 , 導致東西都看不清楚 ,
至醫院檢查 , 發現是視網膜病變所引起 , 需要長期休息及作進一步檢查.
原因可能是愛情動作片看太多了 , ㄚ~ 不是啦 , 醫生說應該是壓力大 , 且
太長時間看電腦螢幕所引起的 .
目前正在家休養中 , 可能會休息一兩個月吧~~ 大家努力
工作之餘 , 更要保重身體啊~~
星期五, 9月 02, 2005
在asp.net中處理意外情況
於Global.asax 中的 Application_Error 事件加上以下的內容 , 如此
當系統發生意外情況時 , 則會將錯誤訊息 mail 給指定的人 , 並將網頁導至
Maintenance.aspx
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
' 發生錯誤時引發
If (System.Web.HttpContext.Current.Request.Url.Authority <> "localhost") Then
''' Get the Exception object wrapped in the InnerException property
Dim unhandledException As Exception = Server.GetLastError().InnerException
''' Create a MailMessage
Dim mail As System.Web.Mail.MailMessage = New System.Web.Mail.MailMessage
mail.From = "error@abc.com"
mail.To = "admin@abc.com"
mail.BodyFormat = System.Web.Mail.MailFormat.Text
mail.Subject = "unHandledException.Message"
mail.Body = unhandledException.ToString()
System.Web.Mail.SmtpMail.SmtpServer = "127.0.0.1"
''' Send the email
System.Web.Mail.SmtpMail.Send(mail)
''' Redirect the user to a maintenence page
System.Web.HttpContext.Current.Response.Redirect("Maintenance.aspx")
End If
End Sub
當系統發生意外情況時 , 則會將錯誤訊息 mail 給指定的人 , 並將網頁導至
Maintenance.aspx
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
' 發生錯誤時引發
If (System.Web.HttpContext.Current.Request.Url.Authority <> "localhost") Then
''' Get the Exception object wrapped in the InnerException property
Dim unhandledException As Exception = Server.GetLastError().InnerException
''' Create a MailMessage
Dim mail As System.Web.Mail.MailMessage = New System.Web.Mail.MailMessage
mail.From = "error@abc.com"
mail.To = "admin@abc.com"
mail.BodyFormat = System.Web.Mail.MailFormat.Text
mail.Subject = "unHandledException.Message"
mail.Body = unhandledException.ToString()
System.Web.Mail.SmtpMail.SmtpServer = "127.0.0.1"
''' Send the email
System.Web.Mail.SmtpMail.Send(mail)
''' Redirect the user to a maintenence page
System.Web.HttpContext.Current.Response.Redirect("Maintenance.aspx")
End If
End Sub
星期一, 8月 15, 2005
利用crystal report 直接匯出pdf檔給client
'''利用crystal report 直接匯出pdf檔給client
'''在作業目錄底下新建一個reports目錄,權限設定為everyone可讀寫
'''記得要imports 以下兩項
'''Imports CrystalDecisions.CrystalReports.Engine
'''Imports CrystalDecisions.Shared
'''
Dim RptDoc As New ReportDocument
Dim rptFile As String = Server.MapPath("license.rpt")
'''
RptDoc.Load(rptFile)
''' 登入資料庫
Dim logonInfo As New TableLogOnInfo
Dim rptTable As Table
For Each rptTable In RptDoc.Database.Tables
logonInfo = rptTable.LogOnInfo
With logonInfo.ConnectionInfo
.ServerName = "localhost"
.DatabaseName = "ff"
.UserID = "aa"
.Password = "aa"
End With
rptTable.ApplyLogOnInfo(logonInfo)
Next
'RptDoc.ExportOptions.ExportFormatType = ExportFormatType.WordForWindows
RptDoc.ExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat
RptDoc.ExportOptions.FormatOptions = New PdfRtfWordFormatOptions
''' 設定參數
Dim Paravalues As New ParameterValues
Dim ParaDisValue As New ParameterDiscreteValue
'ParaDisValue = New ParameterDiscreteValue
ParaDisValue.Value = 6
Paravalues.Add(ParaDisValue)
RptDoc.DataDefinition.ParameterFields("License_Num").ApplyCurrentValues(Paravalues)
Dim crExportOptions As ExportOptions
Dim crDiskFileDestinationOptions As DiskFileDestinationOptions
Dim fname As String
fname = Server.MapPath("exports/") & Session.SessionID.ToString & ".pdf"
crDiskFileDestinationOptions = New DiskFileDestinationOptions
crDiskFileDestinationOptions.DiskFileName = fname
crExportOptions = RptDoc.ExportOptions
With crExportOptions
.DestinationOptions = crDiskFileDestinationOptions
.ExportDestinationType = ExportDestinationType.DiskFile
.ExportFormatType = ExportFormatType.PortableDocFormat
End With
RptDoc.Export()
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/pdf"
Response.WriteFile(fname)
Response.Flush()
Response.Close()
System.IO.File.Delete(fname)
'''在作業目錄底下新建一個reports目錄,權限設定為everyone可讀寫
'''記得要imports 以下兩項
'''Imports CrystalDecisions.CrystalReports.Engine
'''Imports CrystalDecisions.Shared
'''
Dim RptDoc As New ReportDocument
Dim rptFile As String = Server.MapPath("license.rpt")
'''
RptDoc.Load(rptFile)
''' 登入資料庫
Dim logonInfo As New TableLogOnInfo
Dim rptTable As Table
For Each rptTable In RptDoc.Database.Tables
logonInfo = rptTable.LogOnInfo
With logonInfo.ConnectionInfo
.ServerName = "localhost"
.DatabaseName = "ff"
.UserID = "aa"
.Password = "aa"
End With
rptTable.ApplyLogOnInfo(logonInfo)
Next
'RptDoc.ExportOptions.ExportFormatType = ExportFormatType.WordForWindows
RptDoc.ExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat
RptDoc.ExportOptions.FormatOptions = New PdfRtfWordFormatOptions
''' 設定參數
Dim Paravalues As New ParameterValues
Dim ParaDisValue As New ParameterDiscreteValue
'ParaDisValue = New ParameterDiscreteValue
ParaDisValue.Value = 6
Paravalues.Add(ParaDisValue)
RptDoc.DataDefinition.ParameterFields("License_Num").ApplyCurrentValues(Paravalues)
Dim crExportOptions As ExportOptions
Dim crDiskFileDestinationOptions As DiskFileDestinationOptions
Dim fname As String
fname = Server.MapPath("exports/") & Session.SessionID.ToString & ".pdf"
crDiskFileDestinationOptions = New DiskFileDestinationOptions
crDiskFileDestinationOptions.DiskFileName = fname
crExportOptions = RptDoc.ExportOptions
With crExportOptions
.DestinationOptions = crDiskFileDestinationOptions
.ExportDestinationType = ExportDestinationType.DiskFile
.ExportFormatType = ExportFormatType.PortableDocFormat
End With
RptDoc.Export()
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/pdf"
Response.WriteFile(fname)
Response.Flush()
Response.Close()
System.IO.File.Delete(fname)
利用window.open開啟新視窗
利用asp.net(VS.net)開發web程式, 相信很多人都知道, 一個aspx的網頁只能有一個
form, 也就是說如果要在程式中利用button按鈕點一下後,連結到新的視窗,一般就只能
靠java script 來完成了.
最好是利用 window.open, 而不要使用window.showModalDialog , 因為
後者並非標準的語法,只有IE能解譯.
例如:
Private Sub BTP_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles BTPestUse1.Load
Dim JavaScript As String
Dim Url As String
Url = "'pChoice.aspx?pestcd=' + " & "Form1." & Me.TBP.ClientID & ".value" '''
Url = "encodeURIComponent(" & Url & ")"
JavaScript = "window.open(" & Url & ",'','height=600,width=800,menubar=no');"
Me.BTP.Attributes("onclick") = JavaScript
end sub
於子視窗 pChoice.aspx 中可以利用request("pestcd")取得TBP這個TextBox輸入的值
form, 也就是說如果要在程式中利用button按鈕點一下後,連結到新的視窗,一般就只能
靠java script 來完成了.
最好是利用 window.open, 而不要使用window.showModalDialog , 因為
後者並非標準的語法,只有IE能解譯.
例如:
Private Sub BTP_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles BTPestUse1.Load
Dim JavaScript As String
Dim Url As String
Url = "'pChoice.aspx?pestcd=' + " & "Form1." & Me.TBP.ClientID & ".value" '''
Url = "encodeURIComponent(" & Url & ")"
JavaScript = "window.open(" & Url & ",'','height=600,width=800,menubar=no');"
Me.BTP.Attributes("onclick") = JavaScript
end sub
於子視窗 pChoice.aspx 中可以利用request("pestcd")取得TBP這個TextBox輸入的值
星期二, 5月 17, 2005
取得 MCAD 認證(Microsoft Certified Application Developer )
之前就差一科就能取得 MCAD , 拖了好久 , 終於在昨天通過了 , 耶~~~
Microsoft Certification Status
Certification Version Date Achieved
Microsoft Certified Application Developer May 16, 2005
For Microsoft .NET May 16, 2005
Microsoft Certified Professional Dec 29, 2003
Microsoft Certification Exams Completed Successfully
Exam ID Description Date Completed
306 Developing and Implementing Windows®-based Applications with Microsoft® Visual Basic® .NET and Microsoft® Visual Studio® .NET May 16, 2005
310 Developing XML Web Services and Server Components with Microsoft® Visual Basic® .NET and the Microsoft® .NET Framework Feb 23, 2004
305 Developing and Implementing Web Applications with Microsoft® Visual Basic® .NET and Microsoft® Visual Studio® .NET
Microsoft Certification Status
Certification Version Date Achieved
Microsoft Certified Application Developer May 16, 2005
For Microsoft .NET May 16, 2005
Microsoft Certified Professional Dec 29, 2003
Microsoft Certification Exams Completed Successfully
Exam ID Description Date Completed
306 Developing and Implementing Windows®-based Applications with Microsoft® Visual Basic® .NET and Microsoft® Visual Studio® .NET May 16, 2005
310 Developing XML Web Services and Server Components with Microsoft® Visual Basic® .NET and the Microsoft® .NET Framework Feb 23, 2004
305 Developing and Implementing Web Applications with Microsoft® Visual Basic® .NET and Microsoft® Visual Studio® .NET
星期四, 11月 18, 2004
星期二, 10月 19, 2004
壓縮 MS SQL 2000 中的資料檔及交易明細檔
use 資料庫名稱
Backup Log 資料庫名稱 with Truncate_only
DBCC ShrinkDataBase (資料庫名稱) --壓縮資料檔 --> *.mdf
DBCC ShrinkFile (資料庫名稱_log) --壓縮交易紀錄檔 --> *.ldf
http://charlesbc.blogspot.tw/2011/01/sql-server-log.html
SQL Server 2008
到了 SQL Server 2008,Trancate_only 的指令正式被取消了。由於資料庫的復原模式為簡單的情形下是不記錄所有的 log資料的。我們可以利用這一點清除 log 資料。因此,替代的方法,是將資料庫的復原模式先換成簡單模式,再調整為完整。指令如下
use master
go
--備份目前的 log
backup log DatabaseName to disk='c:\db.log' WITH NOFORMAT
--將資料庫復原模式切換到簡單模式
ALTER DATABASE DatabaseName SET RECOVERY SIMPLE WITH NO_WAIT
--找到 DatabaseNameLog 的值
use DatabaseName
go
select name from sys.database_files
where type_desc = 'log'
--縮減 log file 到 1MB
DBCC SHRINKFILE(DatabaseNameLog, 1)
--將資料庫復原模式切換到完整模式
USE [master]
GO
ALTER DATABASE [DatabaseName] SET RECOVERY FULL WITH NO_WAIT
Backup Log 資料庫名稱 with Truncate_only
DBCC ShrinkDataBase (資料庫名稱) --壓縮資料檔 --> *.mdf
DBCC ShrinkFile (資料庫名稱_log) --壓縮交易紀錄檔 --> *.ldf
http://charlesbc.blogspot.tw/2011/01/sql-server-log.html
SQL Server 2008
到了 SQL Server 2008,Trancate_only 的指令正式被取消了。由於資料庫的復原模式為簡單的情形下是不記錄所有的 log資料的。我們可以利用這一點清除 log 資料。因此,替代的方法,是將資料庫的復原模式先換成簡單模式,再調整為完整。指令如下
use master
go
--備份目前的 log
backup log DatabaseName to disk='c:\db.log' WITH NOFORMAT
--將資料庫復原模式切換到簡單模式
ALTER DATABASE DatabaseName SET RECOVERY SIMPLE WITH NO_WAIT
--找到 DatabaseNameLog 的值
use DatabaseName
go
select name from sys.database_files
where type_desc = 'log'
--縮減 log file 到 1MB
DBCC SHRINKFILE(DatabaseNameLog, 1)
--將資料庫復原模式切換到完整模式
USE [master]
GO
ALTER DATABASE [DatabaseName] SET RECOVERY FULL WITH NO_WAIT
星期二, 10月 05, 2004
Freebsd and Debian
前一陣子因工作需求,同時使用Freebsd與Debian,
Freebsd 的 port 與 Debian 的 apt 都相當好用,
只不過同時使用這兩個作業系統時,常會指令混淆~~ :-)
Freebsd 的 port 與 Debian 的 apt 都相當好用,
只不過同時使用這兩個作業系統時,常會指令混淆~~ :-)
星期五, 8月 27, 2004
使用nagios 配合 twsms 監測系統
先說明, 以下是用 debian 完成 , 安裝細節不多說
還有必須先至 http://www.twsms.com 購買通數
這只是簡單說明, 詳細使用還請自行查看 Document
1. 先安裝好 apache2
2. 安裝 nagios
apt-get install nagios
使用 htpasswd2 建立使用者
例如要建立 miles 這個使用者
htpasswd -c /etc/nagios/htpasswd.users miles
輸入密碼即可
chmod 640 htpasswd.users
3. nagios 的設定檔是在 /etc/nagios
4. 設定好 apache2 與 nagios 的連結
cd /etc/apache2/conf.d
ln -s /etc/nagios/apache.conf nagios
/etc/init.d/apache2 restart
5. 修改 nagios 設定檔
cd /etc/nagios
先修改nagios.cfg
大部份用預設值即可, 我是只修改
admin_email=nagios
admin_pager=pagenagios
這兩項的值, 改為我需要的Email
6. 修改 cgi.cfg
主要是修改有關 authorized 的選項即可
修改為之前用htpasswd2建立的使用者
7. 修改 contactgroups.cfg
這是設定系統聯絡人群組
例如我的設定
# 'linux-admins' contact group definition
define contactgroup{
contactgroup_name linux-admins
alias Linux Administrators
members nagios,miles
}
表是 linux-admins 這個系統群組的人員有nagios及miles
8. 修改 contacts.cfg
例如我的設定
# 'miles' contact definition
define contact{
contact_name miles
alias Nagios Admin
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,u,r
service_notification_commands notify-by-sms
host_notification_commands host-notify-by-email
email my@email.server
}
其中 service_notification_commands notify-by-sms
當中的 notify-by-sms , 等一下在misccommands.cfg 中會加上
這是指當service有問題時,如何通知系統人員
9. 修改 hostgroups.cfg
這是設定主機群組
例如我的設定檔
# 'linux-boxes' host group definition
define hostgroup{
hostgroup_name linux-boxes
alias Linux Servers
contact_groups linux-admins
members debian,Mandrake
}
表示 linux-boxes 這個主機群組包括debian及Mandrake這兩台主機, 其系統聯絡人群組為 linux-admins
linux-admins 包括兩位人員miles及nagios , 這在之前已設定過了
10. 修改 hosts.cfg
第一項中的
# Generic host definition template
建議使用預設值
只要在其後面加上
例如我的設定檔
# 'linux' host definition
define host{
use generic-host ; Name of host template to use host_name debian
alias realserver
address 192.168.1.226
check_command check-host-alive
max_check_attempts 10
notification_interval 120
notification_period 24x7
notification_options d,u,r
}
其中 check_command check-host-alive 是表示要檢查系統是否存活, 可在checkcommands.cfg 找到相關資訊
# Generic service definition template
11. 修改 services.cfg
同樣的, 建議以下也使用預設值
# Generic service definition template
然後加上有關設定, 例如
# Service definition
define service{
use generic-service ; Name of service template to use
host_name debian
service_description HTTP is_volatile 0
check_period 24x7
max_check_attempts 3
normal_check_interval 5
retry_check_interval 1
contact_groups linux-admins
notification_interval 120
notification_period 24x7
notification_options w,u,c,r
check_command check_http
}
表示要對 debian這台主機監測 http的服務
其系統聯絡人群組是linux-admins
12. 修改 misccommands.cfg
使其系統有問題時能用手機簡訊通知
在檔案中加上
# 'notify-by-sms' command definition
define command{
command_name notify-by-sms
command_line /usr/bin/printf "%b" "pw:yourpasswd\nmobile:09xxxxxxxx" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ alert - $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" yourid.sms@twsms.com
}
其中 yourpasswd 就是指你在 twsms中的密碼,
yourid就是帳號,09xxxxxxxx 就是你的手機號碼
13. 檢查 nagios 的設定檔是否正確
nagios -v nagios.cfg
如果沒問題, 啟動 /etc/init.d/nagios start
14. 進入 http://your.server.name/nagios
輸入之前設定的帳號密碼
15. 記得要 Enable checks of this host 和
Enable checks of this service
Enable notifications for this host
Enable notifications for this service
如此系統有問題時才會通知喔
_________________
還有必須先至 http://www.twsms.com 購買通數
這只是簡單說明, 詳細使用還請自行查看 Document
1. 先安裝好 apache2
2. 安裝 nagios
apt-get install nagios
使用 htpasswd2 建立使用者
例如要建立 miles 這個使用者
htpasswd -c /etc/nagios/htpasswd.users miles
輸入密碼即可
chmod 640 htpasswd.users
3. nagios 的設定檔是在 /etc/nagios
4. 設定好 apache2 與 nagios 的連結
cd /etc/apache2/conf.d
ln -s /etc/nagios/apache.conf nagios
/etc/init.d/apache2 restart
5. 修改 nagios 設定檔
cd /etc/nagios
先修改nagios.cfg
大部份用預設值即可, 我是只修改
admin_email=nagios
admin_pager=pagenagios
這兩項的值, 改為我需要的Email
6. 修改 cgi.cfg
主要是修改有關 authorized 的選項即可
修改為之前用htpasswd2建立的使用者
7. 修改 contactgroups.cfg
這是設定系統聯絡人群組
例如我的設定
# 'linux-admins' contact group definition
define contactgroup{
contactgroup_name linux-admins
alias Linux Administrators
members nagios,miles
}
表是 linux-admins 這個系統群組的人員有nagios及miles
8. 修改 contacts.cfg
例如我的設定
# 'miles' contact definition
define contact{
contact_name miles
alias Nagios Admin
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,u,r
service_notification_commands notify-by-sms
host_notification_commands host-notify-by-email
email my@email.server
}
其中 service_notification_commands notify-by-sms
當中的 notify-by-sms , 等一下在misccommands.cfg 中會加上
這是指當service有問題時,如何通知系統人員
9. 修改 hostgroups.cfg
這是設定主機群組
例如我的設定檔
# 'linux-boxes' host group definition
define hostgroup{
hostgroup_name linux-boxes
alias Linux Servers
contact_groups linux-admins
members debian,Mandrake
}
表示 linux-boxes 這個主機群組包括debian及Mandrake這兩台主機, 其系統聯絡人群組為 linux-admins
linux-admins 包括兩位人員miles及nagios , 這在之前已設定過了
10. 修改 hosts.cfg
第一項中的
# Generic host definition template
建議使用預設值
只要在其後面加上
例如我的設定檔
# 'linux' host definition
define host{
use generic-host ; Name of host template to use host_name debian
alias realserver
address 192.168.1.226
check_command check-host-alive
max_check_attempts 10
notification_interval 120
notification_period 24x7
notification_options d,u,r
}
其中 check_command check-host-alive 是表示要檢查系統是否存活, 可在checkcommands.cfg 找到相關資訊
# Generic service definition template
11. 修改 services.cfg
同樣的, 建議以下也使用預設值
# Generic service definition template
然後加上有關設定, 例如
# Service definition
define service{
use generic-service ; Name of service template to use
host_name debian
service_description HTTP is_volatile 0
check_period 24x7
max_check_attempts 3
normal_check_interval 5
retry_check_interval 1
contact_groups linux-admins
notification_interval 120
notification_period 24x7
notification_options w,u,c,r
check_command check_http
}
表示要對 debian這台主機監測 http的服務
其系統聯絡人群組是linux-admins
12. 修改 misccommands.cfg
使其系統有問題時能用手機簡訊通知
在檔案中加上
# 'notify-by-sms' command definition
define command{
command_name notify-by-sms
command_line /usr/bin/printf "%b" "pw:yourpasswd\nmobile:09xxxxxxxx" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ alert - $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" yourid.sms@twsms.com
}
其中 yourpasswd 就是指你在 twsms中的密碼,
yourid就是帳號,09xxxxxxxx 就是你的手機號碼
13. 檢查 nagios 的設定檔是否正確
nagios -v nagios.cfg
如果沒問題, 啟動 /etc/init.d/nagios start
14. 進入 http://your.server.name/nagios
輸入之前設定的帳號密碼
15. 記得要 Enable checks of this host 和
Enable checks of this service
Enable notifications for this host
Enable notifications for this service
如此系統有問題時才會通知喔
_________________
星期五, 8月 20, 2004
使用 rsync 來做備份
rsync 的安裝方式很簡單, 在此就不多說
設定檔也很簡單, 也不詳述
client 端執行 rsync 時並不需要是 root , 一般 user 也可以
目的端的目錄權限必須設定好, 否則備份會有問題喔
例如:
在 server 端中的 rsyncd.conf 中設定 ,
[webs]
path = /var/www/test
auth users=miles
uid=miles
gid=users
在 clinet 端執行
rsync -avzP --delete --password-file=/home/miles/rsync/rsyncd.secrets
/var/www/test/ miles@my.server::webs
則其中server 端的 /var/www/test 目錄必須要能有 miles:users 的讀寫權限喔
設定檔也很簡單, 也不詳述
client 端執行 rsync 時並不需要是 root , 一般 user 也可以
目的端的目錄權限必須設定好, 否則備份會有問題喔
例如:
在 server 端中的 rsyncd.conf 中設定 ,
[webs]
path = /var/www/test
auth users=miles
uid=miles
gid=users
在 clinet 端執行
rsync -avzP --delete --password-file=/home/miles/rsync/rsyncd.secrets
/var/www/test/ miles@my.server::webs
則其中server 端的 /var/www/test 目錄必須要能有 miles:users 的讀寫權限喔
星期日, 7月 25, 2004
星期五, 7月 23, 2004
星期四, 7月 22, 2004
使用 Google Web APIs 及 php 實現網站內容全文檢索
使用 Google Web APIs 及 php 實現網站內容全文檢索
1. 先至
http://www.google.com/apis/
申請一個帳號 , 並且取得一組序號
2. 至 http://www.digitalpoint.com/tools/search/
下載 search.zip , 並將其解壓縮至網頁目錄
3. 修改 results.php
將 $key="1234567890";
更改為 google 給你的那一組序號
將 $site="www.yoursite.com"
更改為你想要查詢的網站
4. 編寫測試網頁
在同一目錄下, 編寫一個網頁 mysearch.big5
其內容為
<HTML>
<HEAD>
<META NAME="Content-Type" Content="text/html; charset=utf-8">
<TITLE>mnoGoSearch: </TITLE>
</HEAD>
測試 Google Web APIs <hr>
<FORM METHOD="get" ACTION="results.php">
<INPUT TYPE="text" NAME="q" VALUE="">
<INPUT TYPE="submit" VALUE="Search!">
</FORM>
然後將其內容轉成 utf-8 格式
iconv -f big5 -t utf-8 mysearch.big5 > mysearch.htm
5. 測試網頁
連接到 mysearch.htm , 隨便敲個關鍵字試看看
6. 詳細說明
http://www.digitalpoint.com/tools/search/
1. 先至
http://www.google.com/apis/
申請一個帳號 , 並且取得一組序號
2. 至 http://www.digitalpoint.com/tools/search/
下載 search.zip , 並將其解壓縮至網頁目錄
3. 修改 results.php
將 $key="1234567890";
更改為 google 給你的那一組序號
將 $site="www.yoursite.com"
更改為你想要查詢的網站
4. 編寫測試網頁
在同一目錄下, 編寫一個網頁 mysearch.big5
其內容為
<HTML>
<HEAD>
<META NAME="Content-Type" Content="text/html; charset=utf-8">
<TITLE>mnoGoSearch: </TITLE>
</HEAD>
測試 Google Web APIs <hr>
<FORM METHOD="get" ACTION="results.php">
<INPUT TYPE="text" NAME="q" VALUE="">
<INPUT TYPE="submit" VALUE="Search!">
</FORM>
然後將其內容轉成 utf-8 格式
iconv -f big5 -t utf-8 mysearch.big5 > mysearch.htm
5. 測試網頁
連接到 mysearch.htm , 隨便敲個關鍵字試看看
6. 詳細說明
http://www.digitalpoint.com/tools/search/
MnoGoSearch 網站內容全文檢索
MnoGoSearch 網站內容全文檢索
網頁:
http://www.mnogosearch.org/
MnoGoSearch 3.2 版以後已支援雙位元的字碼 , 如繁體中文, 簡體中文, 日文等等
安裝方式:
請先至 http://www.mnogosearch.org/下載軟體
將其解壓縮後, 執行 ./configure --help 可以查看其相關設定
例如要使用postgresql的資料庫, 並加入雙位元字的支援, 則下
./configure --with-extra-charsets=all --with-pgsql
執行make , 如果沒有問題, 則執行 make install
預設程式會安裝在 /usr/local/mnogosearch 中
將 /usr/local/mnogosearch/bin/search.cgi 覆製到 Apache 的cgi-bin目錄中
建立一個資料庫, createdb mnoGoSearch
初始化此資料庫 /usr/local/mnogosearch/sbin/indexer -Ecreate
cd /usr/local/mnogosearch/etc/
cp indexer.conf-dist indexer.conf , 然後修改indexer.conf
重點是修改
#DBAddr mysql://foo:bar@localhost/mnogosearch/?dbmode=single
及
LocalCharset 使用UTF-8 , 及加上
LoadChineseList BIG5 /usr/local/mnogosearch/etc/TraditionalChinese.freq
最後修改
Server http://your.server.name/
cp langmap.conf-dist langmap.conf; cp search.htm-dist search.htm; cp stopwords.conf-dist stopwords.conf
修改search.htm
重點是修改
#DBAddr mysql://foo:bar@localhost/udm/?dbmode=single
DBAddr pgsql://yourname:yourpassword@localhost/mnoGoSearch/?dbmode=single
#LocalCharset iso-8859-1
LocalCharset utf-8
#BrowserCharset iso-8859-1
BrowserCharset big5
執行 /usr/local/mnogosearch/sbin/indexer -a
測試 http://your.server.name/cgi-bin/search.cgi
網頁:
http://www.mnogosearch.org/
MnoGoSearch 3.2 版以後已支援雙位元的字碼 , 如繁體中文, 簡體中文, 日文等等
安裝方式:
請先至 http://www.mnogosearch.org/下載軟體
將其解壓縮後, 執行 ./configure --help 可以查看其相關設定
例如要使用postgresql的資料庫, 並加入雙位元字的支援, 則下
./configure --with-extra-charsets=all --with-pgsql
執行make , 如果沒有問題, 則執行 make install
預設程式會安裝在 /usr/local/mnogosearch 中
將 /usr/local/mnogosearch/bin/search.cgi 覆製到 Apache 的cgi-bin目錄中
建立一個資料庫, createdb mnoGoSearch
初始化此資料庫 /usr/local/mnogosearch/sbin/indexer -Ecreate
cd /usr/local/mnogosearch/etc/
cp indexer.conf-dist indexer.conf , 然後修改indexer.conf
重點是修改
#DBAddr mysql://foo:bar@localhost/mnogosearch/?dbmode=single
及
LocalCharset 使用UTF-8 , 及加上
LoadChineseList BIG5 /usr/local/mnogosearch/etc/TraditionalChinese.freq
最後修改
Server http://your.server.name/
cp langmap.conf-dist langmap.conf; cp search.htm-dist search.htm; cp stopwords.conf-dist stopwords.conf
修改search.htm
重點是修改
#DBAddr mysql://foo:bar@localhost/udm/?dbmode=single
DBAddr pgsql://yourname:yourpassword@localhost/mnoGoSearch/?dbmode=single
#LocalCharset iso-8859-1
LocalCharset utf-8
#BrowserCharset iso-8859-1
BrowserCharset big5
執行 /usr/local/mnogosearch/sbin/indexer -a
測試 http://your.server.name/cgi-bin/search.cgi
於 Mandrake 9.2上安裝SASL for postfix
於 Mandrake 9.2上安裝SASL for postfix
必要套件
cyrus-sasl-2.1.15-4mdk
libsasl2-devel-2.1.15-4mdk
libsasl2-2.1.15-4mdk
libsasl2-plug-login-2.1.15-4mdk
libsasl2-plug-plain-2.1.15-4mdk
SASL的設定
1.cd /usr/lib/sasl2
2.vi smtpd.conf , 其內容為
pwcheck_method: saslauthd
mech_list:plain login
3.查看saslauthed 是否有啟動,若沒有, 則執行 service saslauthed start
pam的設定
1. cd /etc/pam.d
2. ln -s imap smtp
3. ln -s imap mail
POSTFIX 的設定
1. vi /etc/postfix/master.cf
將 smtp inet n - y - - smtpd
改為 smtp inet n - n - - smtpd
2.
vi /etc/postfix/main.cf
broken_sasl_auth_clients = yes
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain =
smtpd_recipient_restrictions = permit_mynetworks ,permit_sasl_authenticated, check_relay_domains
smtpd_sasl_security_options = noanonymous
測試
1. 先產生密碼, 例如帳號 test , 密碼為 5555, 則執行
printf 'testtest5555' | mmencode
然後將結果複製起來, 例如是: @#$%!@#%
2. 重新啟動 postfix
/etc/rc.d/init.d/postfix restart
3. telnet localhost 25
ehlo localhost
auth plain @#$%!@#%
必要套件
cyrus-sasl-2.1.15-4mdk
libsasl2-devel-2.1.15-4mdk
libsasl2-2.1.15-4mdk
libsasl2-plug-login-2.1.15-4mdk
libsasl2-plug-plain-2.1.15-4mdk
SASL的設定
1.cd /usr/lib/sasl2
2.vi smtpd.conf , 其內容為
pwcheck_method: saslauthd
mech_list:plain login
3.查看saslauthed 是否有啟動,若沒有, 則執行 service saslauthed start
pam的設定
1. cd /etc/pam.d
2. ln -s imap smtp
3. ln -s imap mail
POSTFIX 的設定
1. vi /etc/postfix/master.cf
將 smtp inet n - y - - smtpd
改為 smtp inet n - n - - smtpd
2.
vi /etc/postfix/main.cf
broken_sasl_auth_clients = yes
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain =
smtpd_recipient_restrictions = permit_mynetworks ,permit_sasl_authenticated, check_relay_domains
smtpd_sasl_security_options = noanonymous
測試
1. 先產生密碼, 例如帳號 test , 密碼為 5555, 則執行
printf 'testtest5555' | mmencode
然後將結果複製起來, 例如是: @#$%!@#%
2. 重新啟動 postfix
/etc/rc.d/init.d/postfix restart
3. telnet localhost 25
ehlo localhost
auth plain @#$%!@#%
使用 iptables 設定基本的單機版防火牆
使用 iptables 設定基本的單機版防火牆
#!/bin/sh# 簡單的單機版防火牆設定範例
# 重設所有的規則
iptables -F
iptables -t nat -F
iptables -t mangle -F
# 定義預設的規則
iptables -P FORWARD DROP
iptables -P INPUT DROP
iptables -P OUTPUT ACCEPT
# 允許所有本機的連線
iptables -A INPUT -i lo -j ACCEPT
# 允許 ssh 連線 , 其他的服務請自行設定
iptables -A INPUT -i eth0 -p tcp --dport 22 -j ACCEPT
# iptables -A INPUT -i eth0 -p tcp --dport 23 -j ACCEPT
# iptables -A INPUT -i eth0 -p tcp --dport 80 -j ACCEPT
# iptables -A INPUT -p tcp -d 192.168.1.226 -j ACCEPT
# 是否要紀錄log
# iptables -A INPUT -p tcp -d 0.0.0.0/24 -j LOG --log-prefix "DROP_AAA__ " --log-level info
# iptables -A INPUT -p tcp --dport 1:65535 -j LOG --log-prefix "DROP_BBB__ " --log-level info
# 允許所有本機主動的連線
iptables -A INPUT -i eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
# 拒絕所有非本機主動的連線
iptables -A INPUT -i eth0 -m state --state NEW,INVALID -j DROP
#!/bin/sh# 簡單的單機版防火牆設定範例
# 重設所有的規則
iptables -F
iptables -t nat -F
iptables -t mangle -F
# 定義預設的規則
iptables -P FORWARD DROP
iptables -P INPUT DROP
iptables -P OUTPUT ACCEPT
# 允許所有本機的連線
iptables -A INPUT -i lo -j ACCEPT
# 允許 ssh 連線 , 其他的服務請自行設定
iptables -A INPUT -i eth0 -p tcp --dport 22 -j ACCEPT
# iptables -A INPUT -i eth0 -p tcp --dport 23 -j ACCEPT
# iptables -A INPUT -i eth0 -p tcp --dport 80 -j ACCEPT
# iptables -A INPUT -p tcp -d 192.168.1.226 -j ACCEPT
# 是否要紀錄log
# iptables -A INPUT -p tcp -d 0.0.0.0/24 -j LOG --log-prefix "DROP_AAA__ " --log-level info
# iptables -A INPUT -p tcp --dport 1:65535 -j LOG --log-prefix "DROP_BBB__ " --log-level info
# 允許所有本機主動的連線
iptables -A INPUT -i eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
# 拒絕所有非本機主動的連線
iptables -A INPUT -i eth0 -m state --state NEW,INVALID -j DROP
訂閱:
文章 (Atom)