Merge branch 'master' of http://10.10.10.11:3000/KRi/KIN
This commit is contained in:
205
new-contact-api.asp
Normal file
205
new-contact-api.asp
Normal file
@@ -0,0 +1,205 @@
|
|||||||
|
<!-- #include virtual = "lib/config.asp" -->
|
||||||
|
<%
|
||||||
|
Response.Buffer = True
|
||||||
|
Response.ContentType = "application/json"
|
||||||
|
Response.Charset = "utf-8"
|
||||||
|
|
||||||
|
Response.AddHeader "Access-Control-Allow-Origin", "*"
|
||||||
|
Response.AddHeader "Access-Control-Allow-Methods", "GET, POST, OPTIONS"
|
||||||
|
Response.AddHeader "Access-Control-Allow-Headers", "Content-Type, Authorization, X-Requested-With"
|
||||||
|
Response.AddHeader "Access-Control-Max-Age", "86400"
|
||||||
|
|
||||||
|
If Request.ServerVariables("REQUEST_METHOD") = "OPTIONS" Then
|
||||||
|
Response.Status = "200 OK"
|
||||||
|
Response.End
|
||||||
|
End If
|
||||||
|
|
||||||
|
|
||||||
|
Dim remoteIp
|
||||||
|
Dim clientId
|
||||||
|
Dim requestMethod
|
||||||
|
Dim cmd
|
||||||
|
Dim rs
|
||||||
|
Dim returnString
|
||||||
|
|
||||||
|
remoteIp = Trim(Request.ServerVariables("REMOTE_ADDR"))
|
||||||
|
clientId = Trim(Request("clientId"))
|
||||||
|
requestMethod = UCase(Request.ServerVariables("REQUEST_METHOD"))
|
||||||
|
|
||||||
|
|
||||||
|
' ============================================================
|
||||||
|
' POST : clientId<49><64> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> IP <20>Ҵ<EFBFBD>(<28><><EFBFBD>輺<EFBFBD><E8BCBA> <20>־<EFBFBD> <20><><EFBFBD><EFBFBD>)
|
||||||
|
' ============================================================
|
||||||
|
'If requestMethod = "POST" Then
|
||||||
|
'
|
||||||
|
' If clientId = "" Then
|
||||||
|
' Response.Status = "400 Bad Request"
|
||||||
|
' Response.Write "{""success"":false,""message"":""clientId<49><64> <20>ʿ<EFBFBD><CABF>մϴ<D5B4>.""}"
|
||||||
|
' Response.End
|
||||||
|
' End If
|
||||||
|
'
|
||||||
|
'
|
||||||
|
' On Error Resume Next
|
||||||
|
'
|
||||||
|
' adoconn.BeginTrans
|
||||||
|
'
|
||||||
|
'
|
||||||
|
' ' --------------------------------------------------------
|
||||||
|
' ' 1. <20><><EFBFBD><EFBFBD> IP<49><50> <20>̹<EFBFBD> <20>ٸ<EFBFBD> client<6E><74> <20>Ҵ<EFBFBD><D2B4>Ǿ<EFBFBD> <20>ִٸ<D6B4> <20><><EFBFBD><EFBFBD>
|
||||||
|
' ' --------------------------------------------------------
|
||||||
|
' Set cmd = Server.CreateObject("ADODB.Command")
|
||||||
|
'
|
||||||
|
' With cmd
|
||||||
|
' .ActiveConnection = adoconn
|
||||||
|
' .CommandType = 1 ' adCmdText
|
||||||
|
'
|
||||||
|
' .CommandText = _
|
||||||
|
' "UPDATE [new_cati].[dbo].[client] " & _
|
||||||
|
' "SET [client_ip] = NULL " & _
|
||||||
|
' "WHERE [client_ip] = ? " & _
|
||||||
|
' "AND [client_id] <> ?"
|
||||||
|
'
|
||||||
|
' .Parameters.Append .CreateParameter("@clientIp", 200, 1, 50, remoteIp)
|
||||||
|
' .Parameters.Append .CreateParameter("@clientId", 200, 1, 50, clientId)
|
||||||
|
'
|
||||||
|
' .Execute
|
||||||
|
' End With
|
||||||
|
'
|
||||||
|
' Set cmd = Nothing
|
||||||
|
'
|
||||||
|
'
|
||||||
|
' If Err.Number <> 0 Then
|
||||||
|
' adoconn.RollbackTrans
|
||||||
|
'
|
||||||
|
' Response.Status = "500 Internal Server Error"
|
||||||
|
' Response.Write _
|
||||||
|
' "{""success"":false,""message"":""<22><><EFBFBD><EFBFBD> IP <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><EFBFBD><DFBB>߽<EFBFBD><DFBD>ϴ<EFBFBD>.""}"
|
||||||
|
'
|
||||||
|
' Response.End
|
||||||
|
' End If
|
||||||
|
'
|
||||||
|
'
|
||||||
|
' ' --------------------------------------------------------
|
||||||
|
' ' 2. <20><><EFBFBD><EFBFBD><DEB9><EFBFBD> clientId<49><64> <20><><EFBFBD><EFBFBD> IP <20>Ҵ<EFBFBD>
|
||||||
|
' ' --------------------------------------------------------
|
||||||
|
' Set cmd = Server.CreateObject("ADODB.Command")
|
||||||
|
'
|
||||||
|
' With cmd
|
||||||
|
' .ActiveConnection = adoconn
|
||||||
|
' .CommandType = 1
|
||||||
|
'
|
||||||
|
' .CommandText = _
|
||||||
|
' "UPDATE [new_cati].[dbo].[client] " & _
|
||||||
|
' "SET [client_ip] = ? " & _
|
||||||
|
' "WHERE [client_id] = ?"
|
||||||
|
'
|
||||||
|
' .Parameters.Append .CreateParameter("@clientIp", 200, 1, 50, remoteIp)
|
||||||
|
' .Parameters.Append .CreateParameter("@clientId", 200, 1, 50, clientId)
|
||||||
|
'
|
||||||
|
' .Execute
|
||||||
|
' End With
|
||||||
|
'
|
||||||
|
' Set cmd = Nothing
|
||||||
|
'
|
||||||
|
'
|
||||||
|
' If Err.Number <> 0 Then
|
||||||
|
' adoconn.RollbackTrans
|
||||||
|
'
|
||||||
|
' Response.Status = "500 Internal Server Error"
|
||||||
|
' Response.Write _
|
||||||
|
' "{""success"":false,""message"":""IP <20>Ҵ<EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><EFBFBD><DFBB>߽<EFBFBD><DFBD>ϴ<EFBFBD>.""}"
|
||||||
|
'
|
||||||
|
' Response.End
|
||||||
|
' End If
|
||||||
|
'
|
||||||
|
'
|
||||||
|
' adoconn.CommitTrans
|
||||||
|
'
|
||||||
|
' On Error GoTo 0
|
||||||
|
'
|
||||||
|
'End If
|
||||||
|
|
||||||
|
|
||||||
|
' ============================================================
|
||||||
|
' GET / POST <20><><EFBFBD><EFBFBD>
|
||||||
|
' <20><><EFBFBD><EFBFBD> IP<49><50> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> client <20><>ȸ
|
||||||
|
' ============================================================
|
||||||
|
|
||||||
|
Set cmd = Server.CreateObject("ADODB.Command")
|
||||||
|
|
||||||
|
With cmd
|
||||||
|
.ActiveConnection = adoconn
|
||||||
|
.CommandType = 1
|
||||||
|
|
||||||
|
.CommandText = _
|
||||||
|
"SELECT " & _
|
||||||
|
" [client_id], " & _
|
||||||
|
" [internal_no], " & _
|
||||||
|
" [external_no], " & _
|
||||||
|
" [client_ip] " & _
|
||||||
|
"FROM [new_cati].[dbo].[client] WITH(NOLOCK) " & _
|
||||||
|
"WHERE [client_ip] = ?"
|
||||||
|
|
||||||
|
.Parameters.Append .CreateParameter("@clientIp", 200, 1, 50, remoteIp)
|
||||||
|
|
||||||
|
Set rs = .Execute
|
||||||
|
End With
|
||||||
|
|
||||||
|
|
||||||
|
If Not rs.EOF Then
|
||||||
|
|
||||||
|
returnString = "{"
|
||||||
|
returnString = returnString & """success"":true,"
|
||||||
|
returnString = returnString & """clientId"":""" & JsonEscape(rs("client_id")) & ""","
|
||||||
|
returnString = returnString & """internalNo"":""" & JsonEscape(rs("internal_no")) & ""","
|
||||||
|
returnString = returnString & """externalNo"":""" & JsonEscape(rs("external_no")) & ""","
|
||||||
|
returnString = returnString & """clientIp"":""" & JsonEscape(rs("client_ip")) & """"
|
||||||
|
returnString = returnString & "}"
|
||||||
|
|
||||||
|
Else
|
||||||
|
|
||||||
|
returnString = "{"
|
||||||
|
returnString = returnString & """success"":true,"
|
||||||
|
returnString = returnString & """clientId"":"""","
|
||||||
|
returnString = returnString & """internalNo"":"""","
|
||||||
|
returnString = returnString & """externalNo"":"""","
|
||||||
|
returnString = returnString & """clientIp"":""" & remoteIp & """"
|
||||||
|
returnString = returnString & "}"
|
||||||
|
|
||||||
|
End If
|
||||||
|
|
||||||
|
|
||||||
|
rs.Close
|
||||||
|
Set rs = Nothing
|
||||||
|
Set cmd = Nothing
|
||||||
|
|
||||||
|
Response.Write returnString
|
||||||
|
Response.End
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
' ============================================================
|
||||||
|
' JSON <20><><EFBFBD>ڿ<EFBFBD> Escape
|
||||||
|
' ============================================================
|
||||||
|
Function JsonEscape(value)
|
||||||
|
|
||||||
|
Dim str
|
||||||
|
|
||||||
|
If IsNull(value) Then
|
||||||
|
JsonEscape = ""
|
||||||
|
Exit Function
|
||||||
|
End If
|
||||||
|
|
||||||
|
str = CStr(value)
|
||||||
|
|
||||||
|
str = Replace(str, "\", "\\")
|
||||||
|
str = Replace(str, """", "\""")
|
||||||
|
str = Replace(str, vbCrLf, "\n")
|
||||||
|
str = Replace(str, vbCr, "\n")
|
||||||
|
str = Replace(str, vbLf, "\n")
|
||||||
|
str = Replace(str, vbTab, "\t")
|
||||||
|
|
||||||
|
JsonEscape = str
|
||||||
|
|
||||||
|
End Function
|
||||||
|
%>
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
<!-- #include virtual = "lib/config.asp" -->
|
|
||||||
<%
|
|
||||||
Response.Buffer = True
|
|
||||||
|
|
||||||
Response.AddHeader "Access-Control-Allow-Origin", "*"
|
|
||||||
Response.AddHeader "Access-Control-Allow-Methods", "*"
|
|
||||||
Response.AddHeader "Access-Control-Allow-Headers", "Content-Type, Authorization, X-Requested-With"
|
|
||||||
Response.AddHeader "Access-Control-Max-Age", "86400"
|
|
||||||
|
|
||||||
If Request.ServerVariables("REQUEST_METHOD") = "OPTIONS" Then
|
|
||||||
Response.Status = "200 OK"
|
|
||||||
Response.Write ""
|
|
||||||
Response.End
|
|
||||||
End If
|
|
||||||
%>
|
|
||||||
<%
|
|
||||||
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''20260428 <20><><EFBFBD>ؼ<EFBFBD>'''''''''''''''''''''''''''''''''''''''''''''''''''''''''
|
|
||||||
'''''''''''''''''''''''''''New Contact<63><74><EFBFBD><EFBFBD> <20><>Ʈ<EFBFBD><C6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> IP<49><50> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȣ<EFBFBD><C8A3> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> Page'''''''''''''''''''''''''''
|
|
||||||
dim remoteIp : remoteIp = Request.ServerVariables("REMOTE_ADDR")
|
|
||||||
dim query : query = ""
|
|
||||||
dim returnString : returnString = ""
|
|
||||||
|
|
||||||
query = query & " SELECT [client_id], [internal_no], [external_no], [client_ip] " & VbCrlf
|
|
||||||
query = query & " FROM [new_cati].[dbo].[client] WITH(NOLOCK) " & VbCrlf
|
|
||||||
query = query & " WHERE client_ip = '" & remoteIp & "' " & VbCrlf
|
|
||||||
|
|
||||||
adoRs.open query, adoconn, 1,1
|
|
||||||
IF Not adoRs.EOF Then
|
|
||||||
returnString = "{"
|
|
||||||
returnString = returnString & """clientId"":""" & adoRs("client_id") & ""","
|
|
||||||
returnString = returnString & """internalNo"":""" & adoRs("internal_no") & ""","
|
|
||||||
returnString = returnString & """externalNo"":""" & adoRs("external_no") & ""","
|
|
||||||
returnString = returnString & """clientIp"":""" & adoRs("client_ip") & """"
|
|
||||||
returnString = returnString & "}"
|
|
||||||
ELSE
|
|
||||||
returnString = "{"
|
|
||||||
returnString = returnString & """clientId"":"""","
|
|
||||||
returnString = returnString & """internalNo"":"""","
|
|
||||||
returnString = returnString & """externalNo"":"""","
|
|
||||||
returnString = returnString & """clientIp"":"""""
|
|
||||||
returnString = returnString & "}"
|
|
||||||
END IF
|
|
||||||
|
|
||||||
Response.ContentType = "application/json"
|
|
||||||
Response.Charset = "utf-8"
|
|
||||||
Response.write returnString
|
|
||||||
'''''''''''''''''''''''''''New Contact<63><74><EFBFBD><EFBFBD> <20><>Ʈ<EFBFBD><C6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> IP<49><50> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȣ<EFBFBD><C8A3> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> Page'''''''''''''''''''''''''''
|
|
||||||
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''20260428 <20><><EFBFBD>ؼ<EFBFBD>'''''''''''''''''''''''''''''''''''''''''''''''''''''''''
|
|
||||||
%>
|
|
||||||
Reference in New Issue
Block a user