'本循环体用于将留言簿中字符串"<! ENDHEAD >"前面的内容写入临时文件
Do
Line Input #2, tempstring
Print #1, tempstring
Loop While tempstring <> "<! ENDHEAD >" And Not EOF(2)
'向临时文件中插入客户端用户的留言
Print #1, "<hr>" & vbCrLf
Print #1, "<ul>" & vbCrLf
Print #1, "<li><b>留言时间</b>:" & Date$ & " " & Time$ & vbCrLf
Print #1, "<li><b>姓名: </b>" & sName & vbCrLf
If Len(sEmail) <> 0 Then
Print #1, "<li><b>E-mail: </b><a href=""mailto:" & sEmail & """ >" & sEmail & "</a>" & vbCrLf
End If
If Len(sURL) <> 0 Then
Print #1, "<li><b>我的主页: </b> <a href=""" & sURL & """ >" & sURL & "</a>" & vbCrLf
End If
If Len(sfrom) <> 0 Then
Print #1, "<li><b>我来自: </b>" & sfrom & vbCrLf
End If
Print #1, "<li><b>我的建议: </b>" & vbCrLf
Print #1, sComment & vbCrLf
Print #1, "</ul>" & vbCrLf
'本循环体用于将留言簿剩余的东西写入留言簿
Do
Line Input #2, tempstring
Print #1, tempstring
Loop While Not EOF(2)
Close #1
Close #2
Kill guestbook '删除旧的留言簿
Name tempFileName As guestbook '将临时文件改成新的留言簿
OutPut "<P>非常感谢您的留言!" & chinesetail
OutPut "<P>欢迎您经常光顾本主页!" & chinesetail
OutPut "</FONT>"
End Sub
Sub OutPut(s As String) ' 本子程序用于向标准输出写信息
Dim lBytesWritten As Long
s = s & vbCrLf
WriteFile hStdOut, s, Len(s), lBytesWritten, ByVal 0&
End Sub
' 本子程序可以获取表单上某一元素的数据
Public Function GetCgiValue(cgiName As String) As String
Dim delim2 As Long ' position of "="
Dim delim1 As Long ' position of "&"
Dim n As Integer
Dim pointer1 As Long,pointer2 As Long,length As Long,length1 As Long
Dim tmpstring1 As String,tmpstring2 As String
pointer1 = 1
pointer2 = 1
delim2 = InStr(pointer2, sFormData, "=")
pointer2 = delim2 + 1
Do
length = delim2 - pointer1
tmpstring1 = Mid(sFormData, pointer1, length)
delim1 = InStr(pointer1, sFormData, "&")
pointer1 = delim1 + 1
length1 = delim1 - pointer2
If delim1 = 0 Then length1 = lContentLength + 1 - pointer2
If tmpstring1 = cgiName Then
tmpstring2 = Mid$(sFormData, pointer2, length1)
GetCgiValue = UrlDecode(tmpstring2)
Exit Do
End If