CSDN博客

img YangYuWeb

ASP常用函数

发表于2004/9/22 17:17:00  655人阅读

'替换出字符串内非法字符
Function ManageStr(Str)     
If Str <> "" Then   
    ManageStr = Replace(Str, "'", "''")
    ManageStr = Replace(ManageStr, "|", "")
    ManageStr = Replace(ManageStr, "delete", "")
    'Managestr = Replace(str, "", "")
    'managestr=replace(managestr,"insert","")
    'managestr=replace(managestr,"""","""")
    ManageStr = Replace(ManageStr, "<", "&lt;")
    ManageStr = Replace(ManageStr, ">", "&gt;")
    ManageStr = Replace(ManageStr, "[[", "<")
    ManageStr = Replace(ManageStr, "]]", ">")
    ManageStr = Replace(ManageStr, "|", "")
    'response.write (instr(lcase(str),"select")<>0)
    '   End If
End If   
End Function


'取出文件名
Function DisImageFileName(strFileName)
  If inStr(strFileName,"/") > 0 Then
   For I = Len(strFileName) To 1 Step -1
    If Mid(strFileName,I,1) = "/" Then
     DisImageFileName = "file:///" & strPicPath & Right(strFileName,Len(strFileName) - I)
     Exit For
    End If
   Next
  Else
   DisImageFileName = "file:///" & strPicPath & strFileName 
  End If 
  'DisImageFileName = "file:///" & strPicPath & DisImageFileName
  
End Function 

'给出JS提示信息产跳转到指定页面
Sub DisJsMessageRedirect(strJsMessage,strRedirectUrl)
%>
  <Script Language="JavaScript">
  <!--   
   alert('<%=strJsMessage%>');
   window.location.href='<%=strRedirectUrl%>';
   //return true;
  -->
  </Script>
<%
 Response.End
End Sub

'把文本串加上单引号,AddComma("a,b,c,d")返回'a','b','c','d'
Function AddComma(strString) 
 strString = Replace(strString," ","")
 If Len(strString)>0 Then
  arrAddComma = Split(strString,",")
  For intL = 0 To Ubound(arrAddComma)
   If AddComma = "" Then
    AddComma = "'" & arrAddComma(intL) & "'"
   Else 
    AddComma = AddComma & ",'" & arrAddComma(intL) & "'"
   End If
  Next  
 End If
End Function


'发生错误时弹出一个窗口
Function GoError(strErrMsg)
%>
  <Script Language="JavaScript">
  <!--
   alert('<%=strErrMsg%>');
   window.location.href='../index.asp';
  -->
  </Script>
<%
  Response.End
End Function

'发送邮件
Sub SendMailByJmail(strFrom, strTo, strFromName, strToName, strSubject, strMailContent, strAddFileName)

    Dim objMail
    Dim arrMail
    Set objMail = CreateObject("JMail.Message")
   
    On Error Resume Next
    'objMail.Charset = "BIG5"
    objMail.From = strFrom
    objMail.FromName = strFromName
    objMail.AddRecipient strTo, strToName
    'arrMail = Split(strTo, ";")
    'For I = 0 To UBound(arrMail)
        'objMail.AddRecipient arrMail(I), arrMail(I)
    'Next
    objMail.Subject = strSubject
    objMail.HtmlBody = strMailContent

    'objMail.Send "hater:hater1234@211.147.7.6"
    objMail.Send "hater:hater1234@211.147.7.9"
   
    If Err.Number <> 0 Then
        'MsgBox Err.Description
        'MsgBox strTo
        intMailErrCount = intMailErrCount + 1
        strMailErr = strMailErr & " ; " & strTo
        
    End If

   
    If objMail.Silent Then
        g_str=g_str& objMail.ErrorMessage&Chr(10)
    End If
   
    objMail.Close
    Set objMail = Nothing

End Sub

'读取文本文件
Function ReadTextFile(strFileName)
    Set fs = Server.CreateObject("Scripting.FileSystemObject")
    Set a = fs.OpenTextFile(strFileName)
    ReadTextFile = a.ReadAll
    Set a = Nothing
    Set fs = Nothing
End Function


0 0

相关博文

我的热门文章

img
取 消
img