Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.68 KB | None | 0 0
  1. <%@ EnableSessionState=False %>
  2. <% 'Option Explicit %>
  3. <%
  4. ' -- Codigos de conexão ------------------------------------------------------
  5. Dim characterDBconnectionString,stageDBconnectionString,guildDBconnectionString,gateDBconnectionString,cashDBconnectionString,cashBconnectionString
  6. characterDBconnectionString = GetConnStr("DESKTOP-1B983TI\ULTIMATE","v3_character","sa","123456")
  7. stageDBconnectionString = GetConnStr("DESKTOP-1B983TI\ULTIMATE","v4_stage","sa","123456")
  8. guildDBconnectionString = GetConnStr("DESKTOP-1B983TI\ULTIMATE","v3_guild","sa","123456")
  9. gateDBconnectionString = GetConnStr("DESKTOP-1B983TI\ULTIMATE","v3_gate","sa","123456")
  10. cashDBconnectionString = GetConnStr("DESKTOP-1B983TI\ULTIMATE","d-shop","sa","123456")
  11. cashBconnectionString = GetConnStr("DESKTOP-1B983TI\ULTIMATE","Billing","sa","123456")
  12.  
  13. ' Constantes indefinidas
  14. const ServerGroupName = "PTB"
  15. const ServerGroupCode = 127
  16. const LoginWSDL ="http://127.0.0.1/ServiceLogin.asmx?wsdl"
  17.  
  18. Dim remoteIp
  19. remoteIp=Request.ServerVariables("REMOTE_ADDR")
  20.  
  21. ' Constantes indefinidas
  22. Dim SEPARATOR, SUBSEPARATOR, OPERATION, MINIMALPARAMETER, REQUESTERID
  23. Dim Parameters
  24.  
  25. ' // funcoes ////////////////////////////////////////////////////////////////////////////
  26. Function GetConnStr(SERVER,DBNAME,UID,PWD)
  27. 'GetConnStr = "DRIVER=SQL Server;SERVER="& SERVER &";DATABASE="& DBNAME &";Network=DBMSSOCN;Address="& SERVER &";User Id="& UID &";PASSWORD="& PWD &";"
  28. GetConnStr = "Provider=SQLOLEDB;Data Source="& SERVER &";Initial Catalog="& DBNAME &";user ID="& UID &";password="& PWD &";"
  29. End Function
  30.  
  31. ' USE this function - ExecSP like this
  32. ' Dim ret, params
  33. ' params=Array("1", "2")
  34. ' ret=ExecSP(connectionString, "test1", params)
  35. ' ' params gets array if the stored procedure has output parameters
  36. Function ExecSP(connectionString, procedure, params)
  37. Dim connection, command, ret
  38.  
  39. Set connection=Server.CreateObject("ADODB.Connection")
  40. Set command=Server.CreateObject("ADODB.Command")
  41.  
  42. connection.Open(connectionString)
  43. command.ActiveConnection=connection
  44. command.CommandType = 4 ' adCmdStoredProc
  45. command.CommandText = procedure
  46.  
  47. If IsArray(params) Then
  48. Dim i
  49. For i=0 To UBound(params)
  50. command.Parameters(i+1).Value=params(i)
  51. Next
  52. command.Execute()
  53. ExecSP=command.Parameters(0) ' return value
  54. Else ' to make non-array support
  55. If params<>"" Then command.Parameters(1)=params
  56. command.Execute()
  57. ExecSP=command.Parameters(0) ' return value
  58. End If
  59.  
  60. Dim retcnt
  61. retcnt=0
  62. For i=1 To command.Parameters.Count-1
  63. If command.Parameters(i).Direction=3 Then retcnt=retcnt+1 ' number of output paramters
  64. Next
  65. If retcnt=0 Then params="" Else Redim params(retcnt-1) ' set return parameters
  66. retcnt=0
  67. For i=1 To command.Parameters.Count-1
  68. If command.Parameters(i).Direction=3 Then ' OUTPUT
  69. params(retcnt)=command.Parameters(i).Value
  70. retcnt=retcnt+1
  71. End If
  72. Next
  73.  
  74. connection.Close()
  75.  
  76. Set command=Nothing
  77. Set connection=Nothing
  78. End Function
  79.  
  80. ' return parameters
  81. ' ex) Call Ok(Array("aaaa", "bbbb", "cccc"))
  82. Function Ok(params)
  83. 'Response.Write(RequestID & SEPARATOR & OPERATION)
  84. If IsArray(params) Then
  85. Dim i
  86. For i=0 To UBound(params)
  87. Response.Write(params(i))
  88. If i<>UBound(params) Then Response.Write(SEPARATOR)
  89. Next
  90. Else
  91. If Not IsNull(params) Then
  92. Response.Write(params)
  93. End If
  94. End If
  95.  
  96. Response.End()
  97. End Function
  98.  
  99. Function Error(errorCode)
  100. If IsNumeric(errorCode) Then
  101. Response.Status=600+errorCode
  102. Response.Write("ERROR NUMBER :" & errorCode)
  103. Else
  104. Response.Status=699
  105. Response.Write("ERROR :" & errorCode)
  106. End If
  107. Response.End()
  108. End Function
  109.  
  110. Function DebugError(errorMessage)
  111. Response.Status=699
  112. Response.Write("ERROR : " & errorMessage)
  113. Response.End()
  114. End Function
  115.  
  116. Function SqlQuot(str)
  117. SqlQuot="N'" & Replace(str, "'", "''") & "'"
  118. End Function
  119.  
  120. Function URLDecode(byVal encodedstring)
  121. Dim strIn, strOut, intPos, strLeft
  122. Dim strRight, intLoop
  123. strIn = encodedstring : strOut = "" : intPos = Instr(strIn, "+")
  124. Do While intPos
  125. strLeft = "" : strRight = ""
  126. If intPos > 1 then strLeft = Left(strIn, intPos - 1)
  127. If intPos < len(strIn) then strRight = Mid(strIn, intPos + 1)
  128. strIn = strLeft & " " & strRight
  129. intPos = InStr(strIn, "+")
  130. intLoop = intLoop + 1
  131. Loop
  132. intPos = InStr(strIn, "%")
  133. Do while intPos
  134. If intPos > 1 then strOut = strOut & Left(strIn, intPos - 1)
  135. strOut = strOut & Chr(CInt("&H" & mid(strIn, intPos + 1, 2)))
  136. If intPos > (len(strIn) - 3) then
  137. strIn = ""
  138. Else
  139. strIn = Mid(strIn, intPos + 3)
  140. End If
  141. intPos = InStr(strIn, "%")
  142. Loop
  143. URLDecode = strOut & strIn
  144. End Function
  145.  
  146. ' internal initialize without parameter validation
  147. ' Op : Request operation
  148. Function InitL(Op)
  149. SUBSEPARATOR=Chr(11)
  150. SEPARATOR=Chr(8)
  151. OPERATION=Op
  152. REQUESTERID=Request.ServerVariables("HTTP_REQUESTER") ' "HTTP_" prefix is attached by IIS
  153. If REQUESTERID="" Then REQUESTERID="(empty)"
  154.  
  155. Parameters=Split(URLDecode(Request.QueryString), SEPARATOR)
  156. End Function
  157.  
  158. ' iniciando
  159. Function Init()
  160. Dim Url, Op
  161. Url=Request.ServerVariables("URL")
  162. Url=Split(Url, ".")(0)
  163.  
  164. Op=Mid(Url, InStrRev(Url, "/")+1)
  165. InitL(Op)
  166. End Function
  167.  
  168. ' strict initializing and preparing service
  169. Function InitS(Op, Mp)
  170. MINIMALPARAMETER=Mp
  171. Call InitL(Op)
  172. If UBound(Parameters)<(MINIMALPARAMETER-1) Then
  173. call Error (1)
  174. End If
  175. End Function
  176.  
  177. Function FormatDt(argDt,argType)
  178. Select Case CStr("" & argType)
  179. Case "ISO"
  180. FormatDt = Year(argDt) & Right("0" & Month(argDt), 2) & Right("0" & Day(argDt),2)
  181. Case "KOR"
  182. FormatDt = Year(argDt) & "/" & Right("0" & Month(argDt), 2) & "/" & Right("0" & Day(argDt), 2)
  183. Case "ENG"
  184. FormatDt = Right("0" & Month(argDt), 2) & "/" & Right("0" & Day(argDt),2) & "/" & Year(argDt)
  185. Case "ISO_TM"
  186. FormatDt = Year(argDt) & Right("0" & Month(argDt), 2) & Right("0" & Day(argDt), 2)
  187. FormatDt = FormatDt & Right("0" & Hour(argDt), 2) & Right("0" & Minute(argDt), 2) & Right("0" & Second(argDt), 2)
  188. Case "KOR_TM"
  189. FormatDt = Year(argDt) & "/" & Right("0" & Month(argDt), 2) & "/" & Right("0" & Day(argDt), 2) & ", "
  190. FormatDt = FormatDt & Right("0" & Hour(argDt), 2) & ":" & Right("0" & Minute(argDt), 2) & ":" & Right("0" & Second(argDt), 2)
  191. Case "ENG_TM"
  192. FormatDt = Right("0" & Month(argDt), 2) & "/" & Right("0" & Day(argDt),2) & "/" & Year(argDt) & ", "
  193. FormatDt = FormatDt & Right("0" & Hour(argDt), 2) & ":" & Right("0" & Minute(argDt), 2) & ":" & Right("0" & Second(argDt), 2)
  194. Case "SQL"
  195. FormatDt = Year(argDt) & "-" & Right("0" & Month(argDt), 2) & "-" & Right("0" & Day(argDt), 2)
  196. Case "SQL_TM"
  197. FormatDt = Year(argDt) & "-" & Right("0" & Month(argDt), 2) & "-" & Right("0" & Day(argDt),2) & " "
  198. FormatDt = FormatDt & Right("0" & Hour(argDt), 2) & ":" & Right("0" & Minute(argDt), 2) & ":" & Right("0" & Second(argDt), 2)
  199. Case "SQL_WK"
  200. FormatDt = Year(argDt) & "-" & Right("0" & Month(argDt), 2) & "-" & Right("0" & Day(argDt), 2) & " (" & WeekDayName(WeekDay(LogDate)) & ")"
  201. Case "SSN"
  202. FormatDt = Right("0" & Year(argDt), 2) & Right("0" & Month(argDt), 2) & Right("0" & Day(argDt), 2)
  203. Case Else
  204. FormatDt = ""
  205. End Select
  206. End Function
  207.  
  208. Function getConvAscii(value)
  209. Dim strV,i,s,intChr,ichr1,ichr2,strS
  210. s = LenB(value) : strV = "" :
  211. For i = 1 to s
  212. intChr = AscB(MidB(value,i,2))
  213. if intChr > 128 then
  214. ichr1 = intChr
  215. i = i + 1
  216. ichr2 = AscB(MidB(value,i,2))
  217. strS = "&H" & Hex(ichr1) & Hex(ichr2)
  218. strV = strV & Chr(strS)
  219. Else
  220. strV = strV & Chr(intChr)
  221. End If
  222. Next
  223. getConvAscii = strV
  224. End Function
  225.  
  226. Function GetAccountName(characterName)
  227. Dim sphn,blsResult : blsResult = False
  228. Dim accountName : accountName = ""
  229.  
  230. Set sphn = new SPHelper_NoTran
  231. with sphn
  232. .DEBUG = False
  233. Set .cmd = Command
  234. .ConnStr = characterDBconnectionString
  235. .SPName = "dbo.GetAccountName"
  236. Call .InitCommand()
  237. Call .AppendParam("RETURN_VALUE",adInteger,adParamReturnValue,,null)
  238. Call .AppendParam("@characterName",adVarWChar,adParamInput,50,characterName)
  239. Call .AppendParam("@accountName",adVarWChar,adParamOutput,50,null)
  240. blsResult = .ExecNoRecords()
  241. End with
  242.  
  243. If blsResult Then
  244. Dim ret
  245. ret = sphn.GetParamValue("RETURN_VALUE")
  246. if ret<>0 Then
  247. Call Error(ret)
  248. End If
  249. accountName = sphn.GetParamValue("@accountName")
  250. End If
  251. set sphn = Nothing
  252.  
  253. GetAccountName = accountName
  254. End Function
  255.  
  256. ' //////////////////////////////////////////////////////////////////////////// functions //
  257. %>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement