用VB编写标准CGI程序

来源:计算机等级考试    发布时间:2012-08-29    计算机等级考试视频    评论


  If delim1 = 0 Then
  Exit Do
  End If
  delim2 = InStr(pointer2, sFormData, "=")
  pointer2 = delim2 + 1
  Loop
  End Function
  ' 本函数可以对用户输入的数据进行URL解码
  Public Function UrlDecode(ByVal sEncoded As String) As String
  Dim pointer As Long 'sEncoded position pointer
  Dim pos As Long  'position of InStr target
  Dim temp As String
  If sEncoded = "" Then Exit Function
  pointer = 1
  '本循环体用于将"+"转换成空格
  Do
  pos = InStr(pointer, sEncoded, "+")
  If pos = 0 Then Exit Do
  Mid$(sEncoded, pos, 1) = " "
  pointer = pos + 1
  Loop
  pointer = 1
  '本循环体用于将%XX转换成字符。对于两个连续的%XX,如果第一个%XX 不是某些特指的Web系统保留字符,将把它们转换成汉字
  Do
  pos = InStr(pointer, sEncoded, "%")
  If pos = 0 Then Exit Do
  temp = Chr$("&H" & (Mid$(sEncoded, pos + 1, 2)))
  If Mid(sEncoded, pos + 3, 1) = "%" And (temp <> ":") And (temp <> "/") _
  And (temp <> "(") And (temp <> ")") And (temp <> ".") And (temp <> ",") _
  And (temp <> ";") And (temp <> "%") Then
  Mid$(sEncoded, pos, 2) = Chr$("&H" & (Mid$(sEncoded, pos + 1, 2)) _
  & (Mid$(sEncoded, pos + 4, 2)))
  sEncoded = Left$(sEncoded, pos) & Mid$(sEncoded, pos + 6)
  pointer = pos + 1
  Else
  Mid$(sEncoded, pos, 1) = temp
  sEncoded = Left$(sEncoded, pos) & Mid$(sEncoded, pos + 3)
  pointer = pos + 1
  End If
  Loop
  UrlDecode = sEncoded
  Exit Function
  End Function
  '本函数可以获得一个唯一的临时文件名
  Public Function TempFile(sPath As String, sPrefix As String) As String
  Dim x As Long,rc As Long
  TempFile = String(127, Chr$(0))
  rc = GetTempFileName(sPath, sPrefix, ByVal 0&, TempFile)
  x = InStr(TempFile, Chr$(0))
  If x > 0 Then TempFile = Left$(TempFile, x - 1)
  End Function
  CGI程序guestbook.bas所要处理的表单如下所示:
  <html><head><title>贵宾留言簿</title></head>
  <body>
  <h3>贵宾留言簿测试</h3>
  <form action="/cgi-bin/guest.exe" method="post">
  您的姓名: <input type="text" name="name"><br>
  您的Email信箱: <input type="text" name="email"><br>
  您的主页的URL: <input type="text" name="URL"><br>
  您的建议:<br> <textarea name="URL_Comment" rows=4 cols=30></textarea><br>
  您来自: <input type="text" name="from"><br>
  <input type="submit" value=" 留言 ">
  </form>
  </body></html>

上一页345下一页

视频学习

我考网版权与免责声明

① 凡本网注明稿件来源为"原创"的所有文字、图片和音视频稿件,版权均属本网所有。任何媒体、网站或个人转载、链接转贴或以其他方式复制发表时必须注明"稿件来源:我考网",违者本网将依法追究责任;

② 本网部分稿件来源于网络,任何单位或个人认为我考网发布的内容可能涉嫌侵犯其合法权益,应该及时向我考网书面反馈,并提供身份证明、权属证明及详细侵权情况证明,我考网在收到上述法律文件后,将会尽快移除被控侵权内容。

最近更新

社区交流

考试问答