parent
3013917a56
commit
a815a38efb
|
@ -2,18 +2,18 @@
|
|||
|
||||
import cgi
|
||||
import cgitb;
|
||||
import urllib
|
||||
import urllib.parse
|
||||
|
||||
import urllib
|
||||
import urllib.parse
|
||||
|
||||
print("Content-Type: text/plain")
|
||||
print("")
|
||||
output = {"ResultCode":"OK"}
|
||||
loginNo = ""
|
||||
codeType = 0
|
||||
gotchiPoints = 0
|
||||
itemId = 0
|
||||
playing = ""
|
||||
requestType = 0
|
||||
output = {"ResultCode":"OK"}
|
||||
loginNo = ""
|
||||
codeType = 0
|
||||
gotchiPoints = 0
|
||||
itemId = 0
|
||||
playing = ""
|
||||
requestType = 0
|
||||
|
||||
|
||||
def CheckBit(code,verify=True,bit=9):
|
||||
|
@ -85,70 +85,70 @@ def GetTamaRegion(code, type):
|
|||
elif type == 4:
|
||||
return code[5]
|
||||
|
||||
|
||||
def CgiGetCode():
|
||||
try:
|
||||
argv = {}
|
||||
arguments = cgi.FieldStorage()
|
||||
for i in arguments.keys():
|
||||
argv[i]=arguments[i].value
|
||||
|
||||
#Read GET Paramaters
|
||||
requestType = int(argv['c'])
|
||||
if requestType == 1:
|
||||
loginNo = argv['u']+argv['d']
|
||||
if len(loginNo) != 10:
|
||||
output['ResultCode']="ERROR"
|
||||
return
|
||||
codeType = int(argv['m'])
|
||||
gotchiPoints = int(argv['g'])
|
||||
itemId = int(argv['i'])
|
||||
|
||||
#playing = argv['p']
|
||||
except:
|
||||
output['ResultCode']="ERROR"
|
||||
return
|
||||
|
||||
#Input Validation
|
||||
if requestType == 1:
|
||||
if gotchiPoints < 0 or gotchiPoints > 5:
|
||||
output['ResultCode']="ERROR"
|
||||
return
|
||||
if itemId < 0 or itemId > 999:
|
||||
output['ResultCode']="ERROR"
|
||||
return
|
||||
if codeType < 0 or codeType > 4:
|
||||
output['ResultCode']="ERROR"
|
||||
return
|
||||
# Actural Processing
|
||||
if requestType == 1:
|
||||
if codeType == 0: ## login
|
||||
type = FindType(loginNo)
|
||||
if type == 5:
|
||||
output['ResultCode']="ERROR"
|
||||
return
|
||||
else:
|
||||
output['ResultCode']="OK"
|
||||
CharCode = GetTamaIndex(loginNo,type)
|
||||
output['CharacterCode']=str(CharCode[0])+str(CharCode[1])
|
||||
output['VER']=str(GetTamaRegion(loginNo,type))
|
||||
return
|
||||
elif codeType != 0:
|
||||
type = FindType(loginNo)
|
||||
region = GetTamaRegion(loginNo,type)
|
||||
tamaIndex = GetTamaIndex(loginNo,type)
|
||||
|
||||
iid = str(itemId)
|
||||
while len(iid) != 2:
|
||||
iid = "0"+iid
|
||||
ggp = str(gotchiPoints)
|
||||
while len(ggp) != 2:
|
||||
ggp = "0"+ggp
|
||||
|
||||
logoutNo = str(codeType)+str(region)+str(iid)[0]+"0"+str(iid)[1]+str(tamaIndex[0])+ggp+str(tamaIndex[1])
|
||||
logoutNo += str(CheckBit(logoutNo,False,9))
|
||||
output['PasswordUp'] = logoutNo[:5]
|
||||
output['PasswordDown'] = logoutNo[5:]
|
||||
return
|
||||
CgiGetCode()
|
||||
print(urllib.parse.urlencode(output),end="")
|
||||
|
||||
def CgiGetCode():
|
||||
try:
|
||||
argv = {}
|
||||
arguments = cgi.FieldStorage()
|
||||
for i in arguments.keys():
|
||||
argv[i]=arguments[i].value
|
||||
|
||||
#Read GET Paramaters
|
||||
requestType = int(argv['c'])
|
||||
if requestType == 1:
|
||||
loginNo = argv['u']+argv['d']
|
||||
if len(loginNo) != 10:
|
||||
output['ResultCode']="ERROR"
|
||||
return
|
||||
codeType = int(argv['m'])
|
||||
gotchiPoints = int(argv['g'])
|
||||
itemId = int(argv['i'])
|
||||
|
||||
#playing = argv['p']
|
||||
except:
|
||||
output['ResultCode']="ERROR"
|
||||
return
|
||||
|
||||
#Input Validation
|
||||
if requestType == 1:
|
||||
if gotchiPoints < 0 or gotchiPoints > 5:
|
||||
output['ResultCode']="ERROR"
|
||||
return
|
||||
if itemId < 0 or itemId > 99:
|
||||
output['ResultCode']="ERROR"
|
||||
return
|
||||
if codeType < 0 or codeType > 4:
|
||||
output['ResultCode']="ERROR"
|
||||
return
|
||||
# Actural Processing
|
||||
if requestType == 1:
|
||||
if codeType == 0: ## login
|
||||
type = FindType(loginNo)
|
||||
if type == 5:
|
||||
output['ResultCode']="ERROR"
|
||||
return
|
||||
else:
|
||||
output['ResultCode']="OK"
|
||||
CharCode = GetTamaIndex(loginNo,type)
|
||||
output['CharacterCode']=str(CharCode[0])+str(CharCode[1])
|
||||
output['VER']=str(GetTamaRegion(loginNo,type))
|
||||
return
|
||||
elif codeType != 0:
|
||||
type = FindType(loginNo)
|
||||
region = GetTamaRegion(loginNo,type)
|
||||
tamaIndex = GetTamaIndex(loginNo,type)
|
||||
|
||||
iid = str(itemId)
|
||||
while len(iid) != 2:
|
||||
iid = "0"+iid
|
||||
ggp = str(gotchiPoints)
|
||||
while len(ggp) != 2:
|
||||
ggp = "0"+ggp
|
||||
|
||||
logoutNo = str(codeType)+str(region)+iid[0]+"0"+iid[1]+str(tamaIndex[0])+ggp+str(tamaIndex[1])
|
||||
logoutNo += str(CheckBit(logoutNo,False,9))
|
||||
output['PasswordUp'] = logoutNo[:5]
|
||||
output['PasswordDown'] = logoutNo[5:]
|
||||
return
|
||||
CgiGetCode()
|
||||
print(urllib.parse.urlencode(output),end="")
|
Loading…
Reference in New Issue