寧夏網絡公司|寧夏網站建設|銀川網絡公司|銀川網站建設
  15595599605 13309518098 掃描加微信:
   
網站首頁 | 網站建設 | 關于我們 | 網絡營銷 | 常見問題 | 相關知識 | 聯系我們 | 客戶案例
售前: 15595599605
13309518098
售后: 13014290997
15008617747
QQ:  建站咨詢
 建站咨詢
 業務受理
 售后服務
套餐類型 一 初級型 2015-02-10
套餐類型 二 經濟型 2015-02-10
套餐類型 三 普通型 2015-02-10
套餐類型 四 標準型 2015-02-10
套餐類型 五 行業型 2015-02-10
套餐類型 六 門戶型 2015-02-10
您的位置:網站首頁>>>一套簡單的asp驗證碼的程序
一套簡單的asp驗證碼的程序
作者:銀川志達四方電子科技有限公司  來源:本站整理  
發布時間:2010-07-05 16:53:58  發布人:志達四方

包含三個ASP頁面

一:index.asp(用于調用驗證碼,并提交驗證碼至“from.asp”

<form method="post" action="from.asp">
<input name="Form_Code" type="text" /><input name="Submit1" type="submit" value="提交" />
<SCRIPT language=javascript> document.write("<img src=code.asp align=absmiddle id=Image1 onclick=Image1.src='code.asp?'+Math.random(); alt=看不清楚/>");</SCRIPT>
</form>

二:code.asp(用于生成驗證碼)

<%
Option Explicit        ' 顯示聲明
Class Com_GifCode_Class
    Public Noisy, Count, Width, Height, Angle, Offset, Border
    Private Graph(), Margin(3)
    Private Sub Class_Initialize()
        Randomize
        Noisy    = 0    ' 干擾點出現的概率
        Count    = 6    ' 字符數量
        Width    = 80    ' 圖片寬度
        Height    = 18    ' 圖片高度
        Angle    = 1    ' 角度隨機變化量
        Offset    = 10    ' 偏移隨機變化量
        Border = 2    ' 邊框大小
    End Sub
    Public Function Create()
        Const cCharSet = "123456789"
        Dim i, x, y
        Dim vValidCode : vValidCode = ""
        Dim vIndex
        ReDim Graph(Width-1, Height-1)
        For i = 0 To Count - 1
            vIndex = Int(Rnd * Len(cCharSet))
            vValidCode = vValidCode + Mid(cCharSet, vIndex+1 , 1)
            SetDraw vIndex, i
        Next
        Create = vValidCode
    End Function
    Sub SetDot(pX, pY)
        If pX * (Width-pX-1) >= 0 And pY * (Height-pY-1) >= 0 Then
            Graph(pX, pY) = 1
        End If
    End Sub
    Public Sub SetDraw(pIndex, pNumber)
        ' 字符數據
        Dim DotData(8)
        DotData(0) = Array(30, 15, 50, 1, 50, 100)
        DotData(1) = Array(1 ,34 ,30 ,1 ,71, 1, 100, 34, 1, 100, 93, 100, 100, 86)
        DotData(2) = Array(1, 1, 100, 1, 42, 42, 100, 70, 50, 100, 1, 70)
        DotData(3) = Array(100, 73, 6, 73, 75, 6, 75, 100)
        DotData(4) = Array(100, 1, 1, 1, 1, 50, 50, 35, 100, 55, 100, 80, 50, 100, 1, 95)
        DotData(5) = Array(100, 20, 70, 1, 20, 1, 1, 30, 1, 80, 30, 100, 70, 100, 100, 80, 100, 60, 70, 50, 30, 50, 1, 60)
        DotData(6) = Array(6, 26, 6, 6, 100, 6, 53, 100)
        DotData(7) = Array(100, 30, 100, 20, 70, 1, 30, 1, 1, 20, 1, 30, 100, 70, 100, 80, 70, 100, 30, 100, 1, 80, 1, 70, 100, 30)
        DotData(8) = Array(1, 80, 30, 100, 80, 100, 100, 70, 100, 20, 70, 1, 30, 1, 1, 20, 1, 40, 30, 50, 70, 50, 100, 40)
        Dim vExtent : vExtent = Width / Count
        Margin(0) = Border + vExtent * (Rnd * Offset) / 100 + Margin(1)
        Margin(1) = vExtent * (pNumber + 1) - Border - vExtent * (Rnd * Offset) / 100
        Margin(2) = Border + Height * (Rnd * Offset) / 100
        Margin(3) = Height - Border - Height * (Rnd * Offset) / 100
        Dim vStartX, vEndX, vStartY, vEndY
        Dim vWidth, vHeight, vDX, vDY, vDeltaT
        Dim vAngle, vLength
        vWidth = Int(Margin(1) - Margin(0))
        vHeight = Int(Margin(3) - Margin(2))
        ' 起始坐標
        vStartX = Int((DotData(pIndex)(0)-1) * vWidth / 100)
        vStartY = Int((DotData(pIndex)(1)-1) * vHeight / 100)
        Dim i, j
        For i = 1 To UBound(DotData(pIndex), 1)/2
            If DotData(pIndex)(2*i-2) <> 0 And DotData(pIndex)(2*i) <> 0 Then
                ' 終點坐標
                vEndX = (DotData(pIndex)(2*i)-1) * vWidth / 100
                vEndY = (DotData(pIndex)(2*i+1)-1) * vHeight / 100
                ' 橫向差距
                vDX = vEndX - vStartX
                ' 縱向差距
                vDY = vEndY - vStartY
                ' 傾斜角度
                If vDX = 0 Then
                    vAngle = Sgn(vDY) * 3.14/2
                Else
                    vAngle = Atn(vDY / vDX)
                End If
                ' 兩坐標距離
                If Sin(vAngle) = 0 Then
                    vLength = vDX
                Else
                    vLength = vDY / Sin(vAngle)
                End If
                ' 隨機轉動角度
                vAngle = vAngle + (Rnd - 0.5) * 2 * Angle * 3.14 * 2 / 100
                vDX = Int(Cos(vAngle) * vLength)
                vDY = Int(Sin(vAngle) * vLength)
                If Abs(vDX) > Abs(vDY) Then vDeltaT = Abs(vDX) Else vDeltaT = Abs(vDY)
                For j = 1 To vDeltaT
                    SetDot Margin(0) + vStartX + j * vDX / vDeltaT, Margin(2) + vStartY + j * vDY / vDeltaT
                Next
                vStartX = vStartX + vDX
                vStartY = vStartY + vDY
            End If
        Next
    End Sub
    Public Sub Output()
        Response.Expires = -9999
        Response.AddHeader "pragma", "no-cache"
        Response.AddHeader "cache-ctrol", "no-cache"
        Response.ContentType = "image/gif"
        ' 文件類型
        Response.BinaryWrite ChrB(Asc("G")) & ChrB(Asc("I")) & ChrB(Asc("F"))
        ' 版本信息
        Response.BinaryWrite ChrB(Asc("8")) & ChrB(Asc("9")) & ChrB(Asc("a"))
        ' 邏輯屏幕寬度
        Response.BinaryWrite ChrB(Width Mod 256) & ChrB((Width \ 256) Mod 256)
        ' 邏輯屏幕高度
        Response.BinaryWrite ChrB(Height Mod 256) & ChrB((Height \ 256) Mod 256)
        Response.BinaryWrite ChrB(128) & ChrB(0) & ChrB(0)
        ' 全局顏色列表背景顏色
        Response.BinaryWrite ChrB(0) & ChrB(0) & ChrB(0)
        ' 文字顏色
        Response.BinaryWrite ChrB(255) & ChrB(255) & ChrB(0)
        ' 圖象標識符
        Response.BinaryWrite ChrB(Asc(","))
        Response.BinaryWrite ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0)
        ' 圖象寬度
        Response.BinaryWrite ChrB(Width Mod 256) & ChrB((Width \ 256) Mod 256)
        ' 圖象高度
        Response.BinaryWrite ChrB(Height Mod 256) & ChrB((Height \ 256) Mod 256)
        Response.BinaryWrite ChrB(0) & ChrB(7) & ChrB(255)
        Dim x, y, i : i = 0
        For y = 0 To Height - 1
            For x = 0 To Width - 1
                If Rnd < Noisy / 100 Then
                    Response.BinaryWrite ChrB(1-Graph(x, y))
                Else
                    If x * (x-Width) = 0 Or y * (y-Height) = 0 Then
                        Response.BinaryWrite ChrB(Graph(x, y))
                    Else
                        If Graph(x-1, y) = 1 Or Graph(x, y) Or Graph(x, y-1) = 1 Then
                            Response.BinaryWrite ChrB(1)
                        Else
                            Response.BinaryWrite ChrB(0)
                        End If
                    End If
                End If
                If (y * Width + x + 1) Mod 126 = 0 Then
                    Response.BinaryWrite ChrB(128)
                    i = i + 1
                End If
                If (y * Width + x + i + 1) Mod 255 = 0 Then
                    If (Width*Height - y * Width - x - 1) > 255 Then
                        Response.BinaryWrite ChrB(255)
                    Else
                        Response.BinaryWrite ChrB(Width * Height Mod 255)
                    End If
                End If
            Next
        Next
        Response.BinaryWrite ChrB(128) & ChrB(0) & ChrB(129) & ChrB(0) & ChrB(59)
    End Sub
End Class
'刷新
Response.expires=-1
Response.AddHeader"pragma","no-cache"
Response.AddHeader"cache-control","no-store"
    Dim mCode
    Set mCode = New Com_GifCode_Class
    Session("GetCode") = mCode.Create()    ' 將驗證碼存到Session中
    mCode.Output()    ' 輸出數據
    Set mCode = Nothing
%>

二:from.asp(用于接收驗證碼)

<%
If IsEmpty(Session("GetCode")) Or Session("GetCode") <> UCase(Request.form("Form_Code")) Then
Response.Write "<script>alert('驗證碼輸入錯誤!');history.go(-1)</script>"
Response.End
Else
Session("GetCode") = Empty    ' 清空Session
End If
%>

-------------------------------------------------------------------------------------------------

業務范圍:網站建設 網頁設計 網站制作 網頁制作 手機網站 微信網站

編輯:【銀川志達四方電子科技有限公司】錄入:【網站建設部】

】 【返回】 【打印】 【關閉

     
營業執照 組織機構 稅務登記 安全網站
 
銀川志達四方電子科技有限公司
業務電話:15595599605 13309518098
客服熱線:13014290997 15008617747
地址:銀川市金鳳區康平路悅海新天地購物廣場
E-mail:49773161@qq.com
在線客服:點擊這里給我發消息 點擊這里給我發消息 點擊這里給我發消息
版權所有 © 2015 銀川志達四方電子科技有限公司 寧ICP備05000522號  寧公網安備 64010602000041號 
色综合久久五月色婷婷_久久婷婷丁香五月色综合啪_亚洲自偷精品视频自拍