<%
SBASE_64_CHARACTERS = "AbcdefghijklmnopqrStuvwxyzabcdefghijklmnopqrStuvwxyz0123456789 /" SBASE_64_Characters = Strunicode2ansi (SBASE_64_Characlet)
Function strunicodelen (ascontents) 'Calculate the length of ANSI encoding of Unicode strings ascontents1 = "a" & ascontentslen1 = len (ascontents1) k = 0for i = 1 to len1ASC1 = ASC (MID (AsconTents1, i, 1)) IF ASC1 <0 THEN ASC1 = 65536 ASC1IF ASC1> 255 THENK = K 2ELSEK = K 1END IFNEXTSTRUNICODELEN = K-1END FUNCTION
Function strunicode2ansi (ascontents) 'converts Unicode encoded strings to ANSI encoded strings strunicode2ansi = "" len1 = len (ascontents) for i = 1 to len1varchar = MID (AsconTents, I, 1) Varasc = ASC (varchar) ) if varasc <0 then varasc = varasc 65536if varasc> 255 thenvarHex = Hex (varasc) varlow = left (varHex, 2) varhigh = right (varHex, 2) strUnicode2Ansi = strUnicode2Ansi & chrb ( "& H" & varlow) & chrb ("& H" & varhigh) Elsestrunicode2ansi = Strunicode2ansi & Chrb (VARASC) End ifnextend FUNCTION
Function Stransi2Unicode (ascontents) 'Encourse the ANSI Coded string to Unicode encoded strings STRANSI2UNICODE = "" Len1 = lenb (ascontents) if len1 = 0 THEN EXIT FUNCTIONFOR i = 1 to len1varchar = MIDB (Ascontents, I, 1 ) varasc = ascb (varchar) if varasc> 127 then strAnsi2Unicode = strAnsi2Unicode & chr (ascw (midb (asContents, i 1,1) & varchar)) i = i 1elsestrAnsi2Unicode = strAnsi2Unicode & chr (varasc) end ifnextEnd function
Function Base64encode (asContents) 'the Ansi Base64 encoded encoded string' asContents ANSI should be encoded string (binary string may be) Dim lnPosition Dim lsResult Dim Char1 Dim Char2 Dim Char3 Dim Char4 Dim Byte1 Dim Byte2 Dim Byte3 Dim SaveBits1 Dim SaveBits2 Dim Lsgroupbinary Dim Lsgroup64 Dim M4, LEN1, LEN2LEN1 = Lenb (Ascontents) if len1 <1 dam ("exit functionendiff
M3 = len1 mod 3 if m3> 0 Then Ascontents = Ascontents & String (3-m3, chrb (0)) 'Supplement bits are for easy calculations
IF m3> 0 THEN LEN1 = LEN1 (3-M3) len2 = len1-3elselen2 = len1nd if
LsResult = ""
For lnposition = 1 to len2 step 3 lsgroup64 = "" lsgroupbinary = MIDB (Ascontents, LnPosition, 3)
BYTE1 = ASCB (MIDB (Lsgroupbinary, 1, 1): SaveBits1 = BYTE1 AND 3 BYTE2 = ASCB (MIDB (LsGroupBinary, 2, 1)): SaveBits2 = Byte2 and 15 Byte3 = ASCB (MIDB (Lsgroupbinary, 3, 1) )
Char1 = MIDB (SBASE_64_Characters, (Byte1 and 252) / 4) 1, 1) Char2 = MIDB (SBase_64_Characters, (((Byte2 and 240) / 16) or (SaveBits1 * 16) And & HFF) 1, 1) Char3 = miDB (SBase_64_Characters ((Byte3 and 192) / 64) or (Savebits2 * 4) and & HFF) 1, 1) Char4 = MIDB (SBase_64_Characters, (Byte3 and 63) 1, 1) lsgroup64 = char1 & Char2 & char3 & char4
LsResult = lsResult & lsgroup64 Next
'Handling the last remaining characters IF M3> 0 Thenlsgroup64 = "" "" LsGroupBinary = MIDB (Ascontents, Len2 1, 3)
BYTE1 = ASCB (MIDB (Lsgroupbinary, 1, 1): SaveBits1 = BYTE1 AND 3 BYTE2 = ASCB (MIDB (LsGroupBinary, 2, 1)): SaveBits2 = Byte2 and 15 Byte3 = ASCB (MIDB (Lsgroupbinary, 3, 1) )
Char1 = MIDB (SBASE_64_Characters, (Byte1 and 252) / 4) 1, 1) Char2 = MIDB (SBase_64_Characters, (((Byte2 and 240) / 16) or (SaveBits1 * 16) And & HFF) 1, 1) Char3 = MIDB (SBASE_64_Characters ((Byte3 and 192) / 64) or (Savebits2 * 4) and & HFF) 1, 1) IF M3 = 1 ThenlSgroup64 = Char1 & Char2 & Chrb (61) & Chrb (61) ' Use = 号 补 位 位 Elselsgroup64 = char1 & char2 & char3 & chrb (61) 'Use = 号 补 位 数 END IF
LsResult = lsResult & lsgroup64 endiff
Base64encode = lsresult
END FUNCTION
Function base64decode (ascontents) 'Convert Base64 encoded strings to ANSI encoded strings' ascontents should also be ANSI encoded strings (binary strings can also be) DIM LSRESULT DIM LNPSITION DIM LSGROUP64, LSGROUPBINARY DIM CHAR1, CHAR2, CHAR3, Char4 Dim Byte1, Byte2, Byte3 Dim M4, Len1, Len2
Len1 = lenb (ascontents) M4 = len1 mod 4
If Len1 <1 or M4> 0 THEN 'string length should be 4 multiples64decode = "" EXIT FUNCTION END IF
'Judgment the last bit is = 号' Judgment the second bit is = 号 'Here M4 indicates the last remaining character number IF MIDB (ascontents, len1, 1) = chrb (61) THEN M4 = 3 IF MIDB (Ascontents, Len1-1, 1) = chrb (61) THEN M4 = 2
IF m4 = 0 Thenlen2 = len1elselen2 = len1-4nd IF
For lnPosition = 1 To Len2 Step 4 lsGroupBinary = "" lsGroup64 = Midb (asContents, lnPosition, 4) Char1 = InStrb (sBASE_64_CHARACTERS, Midb (lsGroup64, 1, 1)) - 1 Char2 = InStrb (sBASE_64_CHARACTERS, Midb (lsGroup64, 2 , 1) - 1 CHAR3 = INSTRB (SBase_64_Characters, MIDB (Lsgroup64, 3, 1)) - 1 Char4 = INSTRB (SBase_64_Characters, MIDB (Lsgroup64, 4, 1)) - 1 Byte1 = ChRB (((Char2 and 48) / 16) OR (char1 * 4) and & hff) BYTE2 = LSGroupBinary & ChRB ((Char3 and 60) / 4) OR (char2 * 16) And & HFF) Byte3 = chrb ((((Char3 and 3) * 64) And & HFF) OR (Char4 and 63)) lsgroupbinary = BYTE1 & BYTE2 & BYTE3LSRESULT = LsResult & lsgroupbinary Next
'Handling the last remaining characters IF M4> 0 Then LsgroupBinary = "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" THEN 'complements 4 bits, is to make it easy to calculate lrsgroup64 = lsgroup64 & chrb (65) end ifchar1 = INSTRB (SBASE_64_Characters, MIDB (LsGroup64, 1, 1)) - 1 Char2 = INSTRB (SBase_64_Characters, MIDB (LsGroup64, 2, 1) ) - 1 Char3 = INSTRB (SBase_64_Characters, MIDB (Lsgroup64, 3, 1)) - 1 Char4 = INSTRB (SBase_64_Characters, MIDB (LsGroup64, 4, 1)) - 1 Byte1 = ChRB (((Char2 and 48) / 16) OR (Char1 * 4) and & hff) BYTE2 = LSGroupBinary & ChRB ((Char3 and 60) / 4) OR (Char2 * 16) And & HFF) BYTE3 = ChRB (((Char3 and 3) * 64) And & HFF) OR (Char4 and 63)))
IF M4 = 2 ThenlsgroupBinary = Byte1ELSEIF M4 = 3 ThenlsgroupBinary = BYTE1 & BYTE2END IF
LsResult = lsResult & lsgroupbinary endiff
Base64decode = lsresult
END FUNCTION
Set conn = server.createObject ("adoDb.connection") conn.open "driver = SQL Server; UID = *; PWD = *; server = *. *. *. *; database = *" set XML = Server.createObject ("Microsoft.xmldom") xml.async = falsexml.load requestset root = xml.documentelement
Transaction ID = root.childNodes.Item (0) .textset Obj = root.childNodes.Item (1) .childNodes.Item (0)
MsgType = obj.childNodes.item (1) .textSend_Address_DeviceType = obj.childNodes.item (2) .childNodes.item (0) .textSend_Address_DeviceID = obj.childNodes.item (2) .childNodes.item (1) .textDest_Address_DeviceType = obj .childNodes.item (3) .childNodes.item (0) .textDest_Address_DeviceID = obj.childNodes.item (3) .childNodes.item (1) .textFeeUser_ID_UserIDType = obj.childNodes.item (4) .childNodes.item (0) .textFeeUser_ID_MSISDN = obj.childNodes.item (4) .childNodes.item (1) .textFeeUser_ID_PseudoCode = obj.childNodes.item (4) .childNodes.item (2) .textDestUser_ID_UserIDType = obj.childNodes.item (5) .childNodes. item (0) .textDestUser_ID_MSISDN = obj.childNodes.item (5) .childNodes.item (1) .textDestUser_ID_PseudoCode = obj.childNodes.item (5) .childNodes.item (2) .textLinkID = obj.childNodes.item (6 ) .textActionID = obj.childNodes.item (7) .textActionReasonID = obj.childNodes.item (8) .textSPID = obj.childNodes.item (9) .textSPServiceID = obj.childNodes.item (10) .textAccessMode = obj. ChildNodes.Item (11) .Textfeatures Tr = STRANSI2UNICODE (Base64Decode (Strunicode2ansi (Obj.childNodes.Item (12) .text))))
conn.execute ( "provision '" & MsgType & "', '" & TransactionID & "', '" & Send_Address_DeviceType & "', '" & Send_Address_DeviceID & "', '" & Dest_Address_DeviceType & "', '" & Dest_Address_DeviceID & "', '" & FeeUser_ID_UserIDType & "', '" & FeeUser_ID_MSISDN & " ','" & FeeUser_ID_PseudoCode & " ','" & DestUser_ID_UserIDType & " ','" & DestUser_ID_MSISDN & " ','" & DestUser_ID_PseudoCode & " ','" & LinkID & " ','" & ActionID & " ','" & ActionReasonID & " ','" & SPID & " ',' "& SPServiceID &" ',' "& AccessMode &" ',' "& FeatureStr &" ' ")' response.write" provision ' "& MsgType &"', ' "& TransactionID &"', ' "& Send_Address_DeviceType &"', ' "& Send_Address_DeviceID &"' , ' "& Dest_Address_DeviceType &"', ' "& Dest_Address_DeviceID &"', ' "& FeeUser_ID_UserIDType &"', ' "& FeeUser_ID_MSISDN &"', ' "& FeeUser_ID_PseudoCode &"', ' "& DestUser_ID_UserIDType &"', ' "& DestUser_ID_MSISDN &"', ' "& DestUser_ID_PseudoCode &"', ' "& Linkid &", '"& ActionID &",' "& ActionReasonid &", '"& SPID &",' "& SPServiceID &"
, '"& Accessmode &",' "& featureStr &" "DIM XMLSTRRRESPONSE.CONTENTTYPE =" Text / XML "Xmlstr = Xmlstr " "1.0" "Encoding =" "UTF-8" "?>" & Vbcrlfxmlstr = XMLSTR "
%>