ASP常用函数

'替换出字符串内非法字符
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
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值