
Partial Class IsStatus
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then '?code=" & xTime & "," & xCookie & "&IP=" & xIP
            'ユーザー認証
            Dim sw As Integer = 0
            Dim xResult As String = "不明,0,0,0,0,0,0,"
            Dim xCode As String = Page.Request.QueryString.Get("code") 'Time,Cookie
            Dim xIP As String = Page.Request.QueryString.Get("IP") 'IP
            If String.IsNullOrEmpty(xCode) Then
                xResult = "不明,0,0,0,0,0,0,0" 'この時点で終了
                Response.Write(xResult)
                Response.End()
            End If
            Dim xNowEnd As Integer = Integer.Parse(Format(Now.AddMinutes(1), "hhmmss"))
            Dim xNowStart As Integer = Integer.Parse(Format(Now.AddMinutes(-1), "hhmmss"))
            If Not String.IsNullOrEmpty(xCode) Then 'コード有り
                Dim xxCode As String() = Split(xCode, ",") 'Time,Cookie
                Dim xNow As Integer = Integer.Parse(xxCode(0))
                If xNowStart <= xNow And xNow <= xNowEnd Then 'Timeスタンプで確認、正規の問合せ
                    'IP アドレス認証
                    If Not String.IsNullOrEmpty(xIP) Then
                        Session("IP") = xIP
                        Dim ds As Data.DataView = SqlDataSourceMemberByIP.Select(DataSourceSelectArguments.Empty)
                        If ds IsNot Nothing AndAlso ds.Count <> 0 Then
                            sw = 1
                            xResult = ""
                            For i = 0 To 6 'id,date,name,mail,IP,status,cookie,
                                xResult = xResult & ds.Item(0).Row(i).ToString & ","
                            Next
                        End If
                    End If
                    'Cookie認証
                    'フォーマット No:mail
                    Session("cookie") = xxCode(1) 'Cookieは、 
                    Dim dt As Data.DataView = SqlDataSourceMemberByCookie.Select(DataSourceSelectArguments.Empty)
                    If dt IsNot Nothing AndAlso dt.Count <> 0 Then '会員
                        xResult = ""
                        For i = 0 To 6 'id,date,name,mail,IP,status,cookie,
                            xResult = xResult & dt.Item(0).Row(i).ToString & ","
                        Next
                        sw = sw Or 1
                    End If
                    If sw <> 0 Then
                        dt = SqlDataSourceAdminByCookie.Select(DataSourceSelectArguments.Empty) 'Admin
                        If dt IsNot Nothing AndAlso dt.Count <> 0 Then
                            sw = sw Or 2
                        End If
                        dt = SqlDataSourceSystemByCookie.Select(DataSourceSelectArguments.Empty) 'System
                        If dt IsNot Nothing AndAlso dt.Count <> 0 Then
                            sw = sw Or 4
                        End If
                    End If

                Else
                    xResult = "不明,0,0,0,0,0,0,"
                    sw = 0
                End If
            Else
                xResult = "不明,0,0,0,0,0,0,"
                sw = 0
            End If
            xResult = xResult & sw.ToString
            Response.Write(xResult)
            Response.End()
        End If
    End Sub
End Class
