首页 > 开发 > Asp > 正文

ASP常用函数收藏乱七八糟未整理版

2020-06-20 13:36:47
字体:
来源:转载
供稿:网友
<%
'*******************************************************************
'取得IP地址
'*******************************************************************

Function Userip()
    Dim GetClientIP
    '如果客户端用了代理服务器,则应该用ServerVariables("HTTP_X_FORWARDED_FOR")方法
    GetClientIP = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
    If GetClientIP = "" or IsNull(GetClientIP) or IsEmpty(GetClientIP) Then
        '如果客户端没用代理,应该用Request.ServerVariables("REMOTE_ADDR")方法
        GetClientIP = Request.ServerVariables("REMOTE_ADDR")
    End If
    Userip = GetClientIP
End Function

'*******************************************************************
'转换IP地址
'*******************************************************************

Function cip(sip)
    tip = CStr(sip)
    sip1 = Left(tip, CInt(InStr(tip, ".") -1))
    tip = Mid(tip, CInt(InStr(tip, ".") + 1))
    sip2 = Left(tip, CInt(InStr(tip, ".") -1))
    tip = Mid(tip, CInt(InStr(tip, ".") + 1))
    sip3 = Left(tip, CInt(InStr(tip, ".") -1))
    sip4 = Mid(tip, CInt(InStr(tip, ".") + 1))
    cip = CInt(sip1) * 256 * 256 * 256 + CInt(sip2) * 256 * 256 + CInt(sip3) * 256 + CInt(sip4)
End Function

'*******************************************************************
' 弹出对话框
'*******************************************************************

Sub alert(message)
    message = Replace(message, "'", "/'")
    Response.Write ("<script>alert('" & message & "')</script>")
End Sub

'*******************************************************************
' 返回上一页,一般用在判断信息提交是否完全之后
'*******************************************************************

Sub GoBack()
    Response.Write ("<script>history.go(-1)</script>")
End Sub

'*******************************************************************
' 重定向另外的连接
'*******************************************************************

Sub Go(url)
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表