Move to MariaDB
This commit is contained in:
parent
ae8c50c464
commit
6fbce934d8
|
@ -25,16 +25,16 @@ def TryAdd():
|
|||
authToken = jsonData['authToken']
|
||||
|
||||
c = db.cursor()
|
||||
cur = c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
count = rows[0]
|
||||
if count == 0:
|
||||
result['status'] = USER_DOES_NOT_EXIST
|
||||
return 0
|
||||
|
||||
#Find Username
|
||||
cur = c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
username = rows[0]
|
||||
|
||||
c.execute('INSERT INTO areaList VAlUES (?,NULL,?,NULL,NULL)',(username,areaId,))
|
||||
|
@ -42,7 +42,7 @@ def TryAdd():
|
|||
|
||||
|
||||
try:
|
||||
db = sqlite3.connect(SQLLITE_DB_PATH)
|
||||
db = DbConnect()
|
||||
TryAdd()
|
||||
db.commit()
|
||||
db.close()
|
||||
|
|
|
@ -25,20 +25,20 @@ def TryGet():
|
|||
authToken = jsonData['authToken']
|
||||
|
||||
c = db.cursor()
|
||||
cur = c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
count = rows[0]
|
||||
if count == 0:
|
||||
result['status'] = USER_DOES_NOT_EXIST
|
||||
return 0
|
||||
|
||||
#Find Username
|
||||
cur = c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
username = rows[0]
|
||||
|
||||
cur = c.execute('SELECT AreaId,LastVisit,NextRubishSpawnTime from areaList WHERE Name=?',(username,))
|
||||
rows = cur.fetchall()
|
||||
c.execute('SELECT AreaId,LastVisit,NextRubishSpawnTime from areaList WHERE Name=?',(username,))
|
||||
rows = c.fetchall()
|
||||
areaList = []
|
||||
for row in rows:
|
||||
area = {}
|
||||
|
@ -51,8 +51,8 @@ def TryGet():
|
|||
area['nextRubishSpawnTime'] = row[2]
|
||||
if not (row[0] == None and row[1] == None and row[2] == None):
|
||||
areaList.append(area)
|
||||
cur = c.execute('SELECT ActualAreaId from areaList WHERE Name=? and ActualAreaId IS NOT NULL',(username,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT ActualAreaId from areaList WHERE Name=? and ActualAreaId IS NOT NULL',(username,))
|
||||
rows = c.fetchone()
|
||||
actualAreaId = rows[0]
|
||||
result['actualAreaId'] = actualAreaId
|
||||
result['areas'] = areaList
|
||||
|
@ -60,7 +60,7 @@ def TryGet():
|
|||
|
||||
|
||||
try:
|
||||
db = sqlite3.connect(SQLLITE_DB_PATH)
|
||||
db = DbConnect()
|
||||
TryGet()
|
||||
db.commit()
|
||||
db.close()
|
||||
|
|
|
@ -26,16 +26,16 @@ def TrySave():
|
|||
authToken = jsonData['authToken']
|
||||
|
||||
c = db.cursor()
|
||||
cur = c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
count = rows[0]
|
||||
if count == 0:
|
||||
result['status'] = USER_DOES_NOT_EXIST
|
||||
return 0
|
||||
|
||||
#Find Username
|
||||
cur = c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
username = rows[0]
|
||||
|
||||
for Area in Areas:
|
||||
|
@ -60,7 +60,7 @@ def TrySave():
|
|||
c.execute('INSERT INTO areaList VAlUES (?,NULL,NULL,NULL,?)',(username,ActualAreaId))
|
||||
|
||||
try:
|
||||
db = sqlite3.connect(SQLLITE_DB_PATH)
|
||||
db = DbConnect()
|
||||
TrySave()
|
||||
db.commit()
|
||||
db.close()
|
||||
|
|
|
@ -29,20 +29,20 @@ def TryUpdate():
|
|||
|
||||
|
||||
c = db.cursor()
|
||||
cur = c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
count = rows[0]
|
||||
if count == 0:
|
||||
result['status'] = USER_DOES_NOT_EXIST
|
||||
return 0
|
||||
|
||||
#Find Username
|
||||
cur = c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
username = rows[0]
|
||||
|
||||
cur = c.execute('SELECT COUNT(1) from areaList WHERE Name=? and AreaId=?',(username,areaId))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT COUNT(1) from areaList WHERE Name=? and AreaId=?',(username,areaId))
|
||||
rows = c.fetchone()
|
||||
count = rows[0]
|
||||
if count == 0:
|
||||
c.execute('INSERT INTO areaList VALUES(?,NULL,?,?,NULL)',(username,areaId,nextRubishSpawnTime))
|
||||
|
@ -53,7 +53,7 @@ def TryUpdate():
|
|||
|
||||
|
||||
try:
|
||||
db = sqlite3.connect(SQLLITE_DB_PATH)
|
||||
db = DbConnect()
|
||||
TryUpdate()
|
||||
db.commit()
|
||||
db.close()
|
||||
|
|
|
@ -29,17 +29,17 @@ def TryLogin():
|
|||
|
||||
#Check User Exists
|
||||
c = db.cursor()
|
||||
cur = c.execute('SELECT COUNT(1) from users WHERE Name=?',(username,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT COUNT(1) from users WHERE Name=?',(username,))
|
||||
rows = c.fetchone()
|
||||
count = rows[0]
|
||||
|
||||
if count == 0:
|
||||
result['status'] = USER_DOES_NOT_EXIST
|
||||
return 0
|
||||
#Check Password
|
||||
cur = c.execute('SELECT PassHash,Salt from users WHERE Name= ?',(username,))
|
||||
c.execute('SELECT PassHash,Salt from users WHERE Name= ?',(username,))
|
||||
|
||||
rows = cur.fetchone()
|
||||
rows = c.fetchone()
|
||||
|
||||
PassHash = rows[0]
|
||||
Salt = rows[1]
|
||||
|
@ -56,7 +56,7 @@ def TryLogin():
|
|||
c.execute('UPDATE users SET PassHash=? WHERE Name=?',(NewSaltedHash,username))
|
||||
c.execute('UPDATE users SET LastSession=NULL WHERE Name=?',(username,))
|
||||
|
||||
db = sqlite3.connect(SQLLITE_DB_PATH)
|
||||
db = DbConnect()
|
||||
TryLogin()
|
||||
db.commit()
|
||||
db.close()
|
||||
|
|
|
@ -26,8 +26,8 @@ result = {"status":SUCCESS}
|
|||
|
||||
def CheckUserExists(username):
|
||||
c = db.cursor()
|
||||
cur = c.execute('SELECT COUNT(1) from users WHERE Name=?',(username,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT COUNT(1) from users WHERE Name=?',(username,))
|
||||
rows = c.fetchone()
|
||||
count = rows[0]
|
||||
return count
|
||||
|
||||
|
@ -67,7 +67,7 @@ def TryCreate():
|
|||
c.execute('INSERT INTO securityQuestion VAlUES (?,?,?)',(username,questionType,AnswerHashSalted))
|
||||
|
||||
|
||||
db = sqlite3.connect(SQLLITE_DB_PATH)
|
||||
db = DbConnect()
|
||||
TryCreate()
|
||||
db.commit()
|
||||
db.close()
|
||||
|
|
|
@ -28,17 +28,17 @@ def TryLogin():
|
|||
|
||||
#Check User Exists
|
||||
c = db.cursor()
|
||||
cur = c.execute('SELECT COUNT(1) from users WHERE Name=?',(username,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT COUNT(1) from users WHERE Name=?',(username,))
|
||||
rows = c.fetchone()
|
||||
count = rows[0]
|
||||
|
||||
if count == 0:
|
||||
result['status'] = USER_DOES_NOT_EXIST
|
||||
return 0
|
||||
#Check Password
|
||||
cur = c.execute('SELECT PassHash,Salt from users WHERE Name= ?',(username,))
|
||||
c.execute('SELECT PassHash,Salt from users WHERE Name= ?',(username,))
|
||||
|
||||
rows = cur.fetchone()
|
||||
rows = c.fetchone()
|
||||
|
||||
PassHash = rows[0]
|
||||
Salt = rows[1]
|
||||
|
@ -52,7 +52,7 @@ def TryLogin():
|
|||
c.execute('UPDATE users SET LastSession=? WHERE Name=?',(authToken,username))
|
||||
|
||||
|
||||
db = sqlite3.connect(SQLLITE_DB_PATH)
|
||||
db = DbConnect()
|
||||
TryLogin()
|
||||
db.commit()
|
||||
db.close()
|
||||
|
|
|
@ -29,20 +29,20 @@ def TryRetrive():
|
|||
|
||||
#Check User Exists
|
||||
c = db.cursor()
|
||||
cur = c.execute('SELECT COUNT(1) from users WHERE Name=?',(username,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT COUNT(1) from users WHERE Name=?',(username,))
|
||||
rows = c.fetchone()
|
||||
count = rows[0]
|
||||
|
||||
if count == 0:
|
||||
result['status'] = USER_DOES_NOT_EXIST
|
||||
return 0
|
||||
#Check Answer
|
||||
cur = c.execute('SELECT AnswerHash from securityQuestion WHERE Name= ?',(username,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT AnswerHash from securityQuestion WHERE Name= ?',(username,))
|
||||
rows = c.fetchone()
|
||||
AnswerHash = rows[0]
|
||||
|
||||
cur = c.execute('SELECT Salt from users WHERE Name=?',(username,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT Salt from users WHERE Name=?',(username,))
|
||||
rows = c.fetchone()
|
||||
Salt = rows[0]
|
||||
|
||||
InputHash = pass_salt_algo(answer, Salt)
|
||||
|
@ -64,7 +64,7 @@ def TryRetrive():
|
|||
|
||||
result['password'] = newPass
|
||||
|
||||
db = sqlite3.connect(SQLLITE_DB_PATH)
|
||||
db = DbConnect()
|
||||
TryRetrive()
|
||||
db.commit()
|
||||
db.close()
|
||||
|
|
|
@ -27,21 +27,21 @@ def TryRetrive():
|
|||
|
||||
#Check User Exists
|
||||
c = db.cursor()
|
||||
cur = c.execute('SELECT COUNT(1) from users WHERE Name=?',(username,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT COUNT(1) from users WHERE Name=?',(username,))
|
||||
rows = c.fetchone()
|
||||
count = rows[0]
|
||||
|
||||
if count == 0:
|
||||
result['status'] = USER_DOES_NOT_EXIST
|
||||
return 0
|
||||
#Check QuestionType
|
||||
cur = c.execute('SELECT QuestionType from securityQuestion WHERE Name=?',(username,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT QuestionType from securityQuestion WHERE Name=?',(username,))
|
||||
rows = c.fetchone()
|
||||
QuestionType = rows[0]
|
||||
result['questionId'] = QuestionType
|
||||
|
||||
|
||||
db = sqlite3.connect(SQLLITE_DB_PATH)
|
||||
db = DbConnect()
|
||||
TryRetrive()
|
||||
db.commit()
|
||||
db.close()
|
||||
|
|
|
@ -25,16 +25,16 @@ def TryAdd():
|
|||
authToken = jsonData['authToken']
|
||||
|
||||
c = db.cursor()
|
||||
cur = c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
count = rows[0]
|
||||
if count == 0:
|
||||
result['status'] = USER_DOES_NOT_EXIST
|
||||
return 0
|
||||
|
||||
#Find Username
|
||||
cur = c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
username = rows[0]
|
||||
|
||||
c.execute('DELETE from characterList where Name=? and CharacterId=?',(username,CharacterId))
|
||||
|
@ -42,7 +42,7 @@ def TryAdd():
|
|||
|
||||
|
||||
try:
|
||||
db = sqlite3.connect(SQLLITE_DB_PATH)
|
||||
db = DbConnect()
|
||||
TryAdd()
|
||||
db.commit()
|
||||
db.close()
|
||||
|
|
|
@ -25,27 +25,27 @@ def TryGet():
|
|||
authToken = jsonData['authToken']
|
||||
|
||||
c = db.cursor()
|
||||
cur = c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
count = rows[0]
|
||||
if count == 0:
|
||||
result['status'] = USER_DOES_NOT_EXIST
|
||||
return 0
|
||||
|
||||
#Find Username
|
||||
cur = c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
username = rows[0]
|
||||
|
||||
cur = c.execute('SELECT actualCharacterId from characterList WHERE Name=? AND ActualCharacterId NOT NULL',(username,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT actualCharacterId from characterList WHERE Name=? AND actualCharacterId IS NOT NULL',(username,))
|
||||
rows = c.fetchone()
|
||||
actualCharacterId = rows[0]
|
||||
|
||||
cur = c.execute('SELECT CharacterId from characterList WHERE Name=?',(username,))
|
||||
rows = cur.fetchall()
|
||||
|
||||
c.execute('SELECT CharacterId from characterList WHERE Name=?',(username,))
|
||||
rows = c.fetchall()
|
||||
characterIds = []
|
||||
for row in rows:
|
||||
if row[0] != None:
|
||||
if row[0] != None and row[0] != "":
|
||||
characterIds.append(row[0])
|
||||
|
||||
result['actualCharacterId'] = actualCharacterId
|
||||
|
@ -54,7 +54,7 @@ def TryGet():
|
|||
|
||||
|
||||
try:
|
||||
db = sqlite3.connect(SQLLITE_DB_PATH)
|
||||
db = DbConnect()
|
||||
TryGet()
|
||||
db.commit()
|
||||
db.close()
|
||||
|
|
|
@ -27,8 +27,8 @@ def TrySave():
|
|||
|
||||
|
||||
c = db.cursor()
|
||||
cur = c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
count = rows[0]
|
||||
if count == 0:
|
||||
result['status'] = USER_DOES_NOT_EXIST
|
||||
|
@ -36,8 +36,8 @@ def TrySave():
|
|||
|
||||
|
||||
#Find Username
|
||||
cur = c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
username = rows[0]
|
||||
|
||||
for CharacterId in CharacterIds:
|
||||
|
@ -49,7 +49,7 @@ def TrySave():
|
|||
|
||||
|
||||
try:
|
||||
db = sqlite3.connect(SQLLITE_DB_PATH)
|
||||
db = DbConnect()
|
||||
TrySave()
|
||||
db.commit()
|
||||
db.close()
|
||||
|
|
|
@ -25,23 +25,23 @@ def TrySwitch():
|
|||
authToken = jsonData['authToken']
|
||||
|
||||
c = db.cursor()
|
||||
cur = c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
count = rows[0]
|
||||
if count == 0:
|
||||
result['status'] = USER_DOES_NOT_EXIST
|
||||
return 0
|
||||
|
||||
#Find Username
|
||||
cur = c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
username = rows[0]
|
||||
|
||||
c.execute('UPDATE characterList SET ActualCharacterId=? WHERE Name=? and ActualCharacterId IS NOT NULL',(CharacterId,username))
|
||||
|
||||
|
||||
try:
|
||||
db = sqlite3.connect(SQLLITE_DB_PATH)
|
||||
db = DbConnect()
|
||||
TrySwitch()
|
||||
db.commit()
|
||||
db.close()
|
||||
|
|
|
@ -123,8 +123,8 @@ def TryGet():
|
|||
authToken = jsonData['authToken']
|
||||
|
||||
c = db.cursor()
|
||||
cur = c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
count = rows[0]
|
||||
if count == 0:
|
||||
result['status'] = USER_DOES_NOT_EXIST
|
||||
|
@ -226,7 +226,7 @@ def TryGet():
|
|||
|
||||
result["code"] = logoutPassword
|
||||
try:
|
||||
db = sqlite3.connect(SQLLITE_DB_PATH)
|
||||
db = DbConnect()
|
||||
TryGet()
|
||||
db.commit()
|
||||
db.close()
|
||||
|
|
|
@ -103,8 +103,8 @@ def TryGet():
|
|||
authToken = jsonData['authToken']
|
||||
|
||||
c = db.cursor()
|
||||
cur = c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
count = rows[0]
|
||||
if count == 0:
|
||||
result['status'] = USER_DOES_NOT_EXIST
|
||||
|
@ -168,7 +168,7 @@ def TryGet():
|
|||
|
||||
|
||||
try:
|
||||
db = sqlite3.connect(SQLLITE_DB_PATH)
|
||||
db = DbConnect()
|
||||
TryGet()
|
||||
db.commit()
|
||||
db.close()
|
||||
|
|
|
@ -27,21 +27,21 @@ def TryAdd():
|
|||
authToken = jsonData['authToken']
|
||||
|
||||
c = db.cursor()
|
||||
cur = c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
count = rows[0]
|
||||
if count == 0:
|
||||
result['status'] = USER_DOES_NOT_EXIST
|
||||
return 0
|
||||
|
||||
#Find Username
|
||||
cur = c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
username = rows[0]
|
||||
|
||||
c = db.cursor()
|
||||
cur = c.execute('SELECT COUNT(1) from currencyList WHERE Name=? and CurrencyId=?',(username,CurrencyId))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT COUNT(1) from currencyList WHERE Name=? and CurrencyId=?',(username,CurrencyId))
|
||||
rows = c.fetchone()
|
||||
count = rows[0]
|
||||
if count == 0:
|
||||
c.execute('INSERT INTO currencyList VAlUES (?,?,?)',(username,CurrencyId,Quantity))
|
||||
|
@ -51,7 +51,7 @@ def TryAdd():
|
|||
|
||||
|
||||
try:
|
||||
db = sqlite3.connect(SQLLITE_DB_PATH)
|
||||
db = DbConnect()
|
||||
TryAdd()
|
||||
db.commit()
|
||||
db.close()
|
||||
|
|
|
@ -25,20 +25,20 @@ def TryGet():
|
|||
authToken = jsonData['authToken']
|
||||
|
||||
c = db.cursor()
|
||||
cur = c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
count = rows[0]
|
||||
if count == 0:
|
||||
result['status'] = USER_DOES_NOT_EXIST
|
||||
return 0
|
||||
|
||||
#Find Username
|
||||
cur = c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
username = rows[0]
|
||||
|
||||
cur = c.execute('SELECT CurrencyId,Quantity from currencyList WHERE Name=?',(username,))
|
||||
rows = cur.fetchall()
|
||||
c.execute('SELECT CurrencyId,Quantity from currencyList WHERE Name=?',(username,))
|
||||
rows = c.fetchall()
|
||||
currencyList = []
|
||||
for row in rows:
|
||||
currency = {'currencyId':row[0], 'quantity':row[1]}
|
||||
|
@ -48,7 +48,7 @@ def TryGet():
|
|||
|
||||
|
||||
try:
|
||||
db = sqlite3.connect(SQLLITE_DB_PATH)
|
||||
db = DbConnect()
|
||||
TryGet()
|
||||
db.commit()
|
||||
db.close()
|
||||
|
|
|
@ -27,16 +27,16 @@ def TryRemove():
|
|||
authToken = jsonData['authToken']
|
||||
|
||||
c = db.cursor()
|
||||
cur = c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
count = rows[0]
|
||||
if count == 0:
|
||||
result['status'] = USER_DOES_NOT_EXIST
|
||||
return 0
|
||||
|
||||
#Find Username
|
||||
cur = c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
username = rows[0]
|
||||
|
||||
c.execute('UPDATE currencyList SET Quantity=Quantity-? WHERE Name=? and CurrencyId=?',(Quantity,username,CurrencyId))
|
||||
|
@ -44,7 +44,7 @@ def TryRemove():
|
|||
|
||||
|
||||
try:
|
||||
db = sqlite3.connect(SQLLITE_DB_PATH)
|
||||
db = DbConnect()
|
||||
TryRemove()
|
||||
db.commit()
|
||||
db.close()
|
||||
|
|
|
@ -25,16 +25,16 @@ def TrySave():
|
|||
authToken = jsonData['authToken']
|
||||
|
||||
c = db.cursor()
|
||||
cur = c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
count = rows[0]
|
||||
if count == 0:
|
||||
result['status'] = USER_DOES_NOT_EXIST
|
||||
return 0
|
||||
|
||||
#Find Username
|
||||
cur = c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
username = rows[0]
|
||||
|
||||
for Currency in Currencys:
|
||||
|
@ -45,7 +45,7 @@ def TrySave():
|
|||
|
||||
|
||||
try:
|
||||
db = sqlite3.connect(SQLLITE_DB_PATH)
|
||||
db = DbConnect()
|
||||
TrySave()
|
||||
db.commit()
|
||||
db.close()
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
# Add <server_path>/friends/cgi-bin to $PYTHONPATH in /etc/enviroment and as a SetVar for your VirtualHost in apache2
|
||||
|
||||
import sqlite3
|
||||
import mariadb
|
||||
import binascii
|
||||
import hashlib
|
||||
|
||||
#MAKE SURE THE DB IS *OUTSIDE* THE PUBLIC_HTML!!!
|
||||
SQLLITE_DB_PATH = "/home/web/DreamTown.db"
|
||||
#SQLLITE_DB_PATH = "/home/web/DreamTown.db"
|
||||
|
||||
SUCCESS = 1
|
||||
USER_DOES_NOT_EXIST = 2
|
||||
|
@ -13,9 +13,17 @@ INVALID_PASSWORD = 3
|
|||
NAME_ALREADY_USED = 4
|
||||
ANSWER_INCORRECT = 5
|
||||
|
||||
|
||||
db = sqlite3.connect(SQLLITE_DB_PATH)
|
||||
|
||||
def DbConnect():
|
||||
return mariadb.connect(
|
||||
user="root",
|
||||
password="MYSQL_PASSWORD",
|
||||
host="127.0.0.1",
|
||||
port=3306,
|
||||
database="dreamtown"
|
||||
)
|
||||
|
||||
db = DbConnect()
|
||||
|
||||
def xor(data, key):
|
||||
l = len(key)
|
||||
|
@ -40,11 +48,6 @@ def pass_salt_algo(passwd, Salt):
|
|||
|
||||
c = db.cursor()
|
||||
|
||||
try:
|
||||
c.execute("""PRAGMA journal_mode=WAL;""")
|
||||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
c.execute("""
|
||||
CREATE TABLE users(
|
||||
|
|
|
@ -27,20 +27,20 @@ def TryAdd():
|
|||
authToken = jsonData['authToken']
|
||||
|
||||
c = db.cursor()
|
||||
cur = c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
count = rows[0]
|
||||
if count == 0:
|
||||
result['status'] = USER_DOES_NOT_EXIST
|
||||
return 0
|
||||
|
||||
#Find Username
|
||||
cur = c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
username = rows[0]
|
||||
|
||||
cur = c.execute('SELECT COUNT(1) from containerList where Name=? and AreaId=? and containerName=?',(username,AreaId,ContainerName))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT COUNT(1) from containerList where Name=? and AreaId=? and containerName=?',(username,AreaId,ContainerName))
|
||||
rows = c.fetchone()
|
||||
count = rows[0]
|
||||
if count == 0:
|
||||
c.execute('INSERT INTO containerList VAlUES (?,?,NULL,?,?)',(username,HarvestableTemplateId,ContainerName,AreaId))
|
||||
|
@ -49,7 +49,7 @@ def TryAdd():
|
|||
|
||||
|
||||
try:
|
||||
db = sqlite3.connect(SQLLITE_DB_PATH)
|
||||
db = DbConnect()
|
||||
TryAdd()
|
||||
db.commit()
|
||||
db.close()
|
||||
|
|
|
@ -30,16 +30,16 @@ def TryAdd():
|
|||
authToken = jsonData['authToken']
|
||||
|
||||
c = db.cursor()
|
||||
cur = c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
count = rows[0]
|
||||
if count == 0:
|
||||
result['status'] = USER_DOES_NOT_EXIST
|
||||
return 0
|
||||
|
||||
#Find Username
|
||||
cur = c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
username = rows[0]
|
||||
|
||||
c.execute('DELETE from harvestablesList where Name=? and HarvestableName=? and AreaId=? and ParentContainerName=?',(username,HarvestableName,AreaId,ContainerName))
|
||||
|
@ -47,7 +47,7 @@ def TryAdd():
|
|||
|
||||
|
||||
try:
|
||||
db = sqlite3.connect(SQLLITE_DB_PATH)
|
||||
db = DbConnect()
|
||||
TryAdd()
|
||||
db.commit()
|
||||
db.close()
|
||||
|
|
|
@ -25,21 +25,21 @@ def TryGet():
|
|||
authToken = jsonData['authToken']
|
||||
|
||||
c = db.cursor()
|
||||
cur = c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
count = rows[0]
|
||||
if count == 0:
|
||||
result['status'] = USER_DOES_NOT_EXIST
|
||||
return 0
|
||||
|
||||
#Find Username
|
||||
cur = c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
username = rows[0]
|
||||
|
||||
|
||||
cur = c.execute('SELECT HarvestableTemplateId,LastHarvest,ContainerName,AreaId from containerList WHERE Name=?',(username,))
|
||||
rows = cur.fetchall()
|
||||
c.execute('SELECT HarvestableTemplateId,LastHarvest,ContainerName,AreaId from containerList WHERE Name=?',(username,))
|
||||
rows = c.fetchall()
|
||||
containerList = []
|
||||
|
||||
for row in rows:
|
||||
|
@ -48,8 +48,8 @@ def TryGet():
|
|||
containerName=row[2]
|
||||
areaId=row[3]
|
||||
|
||||
cur = c.execute('SELECT ItemTemplateId,UpdateTime,SlotIndex,HarvestableName from harvestablesList WHERE Name=? AND ParentContainerName=? AND AreaId=?',(username,containerName,areaId))
|
||||
rows2 = cur.fetchall()
|
||||
c.execute('SELECT ItemTemplateId,UpdateTime,SlotIndex,HarvestableName from harvestablesList WHERE Name=? AND ParentContainerName=? AND AreaId=?',(username,containerName,areaId))
|
||||
rows2 = c.fetchall()
|
||||
harvestablesList = []
|
||||
for row2 in rows2:
|
||||
harvestable = {'itemTemplateId':row2[0],'updateTime':row2[1],'index':row2[2],'harvestableName':row2[3]}
|
||||
|
@ -65,7 +65,7 @@ def TryGet():
|
|||
|
||||
|
||||
try:
|
||||
db = sqlite3.connect(SQLLITE_DB_PATH)
|
||||
db = DbConnect()
|
||||
TryGet()
|
||||
db.commit()
|
||||
db.close()
|
||||
|
|
|
@ -30,23 +30,23 @@ def TryAdd():
|
|||
authToken = jsonData['authToken']
|
||||
|
||||
c = db.cursor()
|
||||
cur = c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
count = rows[0]
|
||||
if count == 0:
|
||||
result['status'] = USER_DOES_NOT_EXIST
|
||||
return 0
|
||||
|
||||
#Find Username
|
||||
cur = c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
username = rows[0]
|
||||
|
||||
c.execute('DELETE from harvestablesList where Name=? and HarvestableName=? and AreaId=? and ParentContainerName=?',(username,HarvestableName,AreaId,ContainerName))
|
||||
c.execute('UPDATE containerList SET LastHarvest=? WHERE Name=? AND ContainerName=? AND AreaId=?',(math.floor(time.time()*1000),username,ContainerName,AreaId))
|
||||
|
||||
try:
|
||||
db = sqlite3.connect(SQLLITE_DB_PATH)
|
||||
db = DbConnect()
|
||||
TryAdd()
|
||||
db.commit()
|
||||
db.close()
|
||||
|
|
|
@ -25,16 +25,16 @@ def TrySave():
|
|||
authToken = jsonData['authToken']
|
||||
|
||||
c = db.cursor()
|
||||
cur = c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
count = rows[0]
|
||||
if count == 0:
|
||||
result['status'] = USER_DOES_NOT_EXIST
|
||||
return 0
|
||||
|
||||
#Find Username
|
||||
cur = c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
username = rows[0]
|
||||
|
||||
for Container in Containers:
|
||||
|
@ -51,7 +51,7 @@ def TrySave():
|
|||
|
||||
|
||||
try:
|
||||
db = sqlite3.connect(SQLLITE_DB_PATH)
|
||||
db = DbConnect()
|
||||
TrySave()
|
||||
db.commit()
|
||||
db.close()
|
||||
|
|
|
@ -26,20 +26,20 @@ def TryAdd():
|
|||
authToken = jsonData['authToken']
|
||||
|
||||
c = db.cursor()
|
||||
cur = c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
count = rows[0]
|
||||
if count == 0:
|
||||
result['status'] = USER_DOES_NOT_EXIST
|
||||
return 0
|
||||
|
||||
#Find Username
|
||||
cur = c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
username = rows[0]
|
||||
|
||||
cur = c.execute('SELECT COUNT(1) from itemList WHERE Name=? and ItemId=?',(username,ItemId))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT COUNT(1) from itemList WHERE Name=? and ItemId=?',(username,ItemId))
|
||||
rows = c.fetchone()
|
||||
count = rows[0]
|
||||
if count != 0:
|
||||
c.execute('UPDATE itemList SET Quantity=Quantity+? WHERE Name=? and ItemId=?',(Quantity,username,ItemId))
|
||||
|
@ -50,7 +50,7 @@ def TryAdd():
|
|||
|
||||
|
||||
try:
|
||||
db = sqlite3.connect(SQLLITE_DB_PATH)
|
||||
db = DbConnect()
|
||||
TryAdd()
|
||||
db.commit()
|
||||
db.close()
|
||||
|
|
|
@ -25,20 +25,20 @@ def TryGet():
|
|||
authToken = jsonData['authToken']
|
||||
|
||||
c = db.cursor()
|
||||
cur = c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
count = rows[0]
|
||||
if count == 0:
|
||||
result['status'] = USER_DOES_NOT_EXIST
|
||||
return 0
|
||||
|
||||
#Find Username
|
||||
cur = c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
username = rows[0]
|
||||
|
||||
cur = c.execute('SELECT ItemId,Quantity from itemList WHERE Name=?',(username,))
|
||||
rows = cur.fetchall()
|
||||
c.execute('SELECT ItemId,Quantity from itemList WHERE Name=?',(username,))
|
||||
rows = c.fetchall()
|
||||
itemList = []
|
||||
for row in rows:
|
||||
item = {'itemId':row[0], 'quantity':row[1]}
|
||||
|
@ -48,7 +48,7 @@ def TryGet():
|
|||
|
||||
|
||||
try:
|
||||
db = sqlite3.connect(SQLLITE_DB_PATH)
|
||||
db = DbConnect()
|
||||
TryGet()
|
||||
db.commit()
|
||||
db.close()
|
||||
|
|
|
@ -26,20 +26,20 @@ def TryRemove():
|
|||
authToken = jsonData['authToken']
|
||||
|
||||
c = db.cursor()
|
||||
cur = c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
count = rows[0]
|
||||
if count == 0:
|
||||
result['status'] = USER_DOES_NOT_EXIST
|
||||
return 0
|
||||
|
||||
#Find Username
|
||||
cur = c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
username = rows[0]
|
||||
|
||||
cur = c.execute('SELECT Quantity from itemList WHERE Name=? and ItemId=?',(username,ItemId))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT Quantity from itemList WHERE Name=? and ItemId=?',(username,ItemId))
|
||||
rows = c.fetchone()
|
||||
curQuantity = rows[0]
|
||||
if curQuantity - Quantity > 0:
|
||||
c.execute('UPDATE itemList SET Quantity=Quantity-? WHERE Name=? and ItemId=?',(Quantity,username,ItemId))
|
||||
|
@ -50,7 +50,7 @@ def TryRemove():
|
|||
|
||||
|
||||
try:
|
||||
db = sqlite3.connect(SQLLITE_DB_PATH)
|
||||
db = DbConnect()
|
||||
TryRemove()
|
||||
db.commit()
|
||||
db.close()
|
||||
|
|
|
@ -25,16 +25,16 @@ def TrySave():
|
|||
authToken = jsonData['authToken']
|
||||
|
||||
c = db.cursor()
|
||||
cur = c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
count = rows[0]
|
||||
if count == 0:
|
||||
result['status'] = USER_DOES_NOT_EXIST
|
||||
return 0
|
||||
|
||||
#Find Username
|
||||
cur = c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
username = rows[0]
|
||||
|
||||
for Item in Items:
|
||||
|
@ -45,7 +45,7 @@ def TrySave():
|
|||
|
||||
|
||||
try:
|
||||
db = sqlite3.connect(SQLLITE_DB_PATH)
|
||||
db = DbConnect()
|
||||
TrySave()
|
||||
db.commit()
|
||||
db.close()
|
||||
|
|
|
@ -25,20 +25,20 @@ def TryGet():
|
|||
authToken = jsonData['authToken']
|
||||
|
||||
c = db.cursor()
|
||||
cur = c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
count = rows[0]
|
||||
if count == 0:
|
||||
result['status'] = USER_DOES_NOT_EXIST
|
||||
return 0
|
||||
|
||||
#Find Username
|
||||
cur = c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
username = rows[0]
|
||||
|
||||
cur = c.execute('SELECT CharacterId,NextTimestamp,Pool from npcList WHERE Name=?',(username,))
|
||||
rows = cur.fetchall()
|
||||
c.execute('SELECT CharacterId,NextTimestamp,Pool from npcList WHERE Name=?',(username,))
|
||||
rows = c.fetchall()
|
||||
npcsList = []
|
||||
for row in rows:
|
||||
npc = {'characterId':row[0], 'nextTimestamp':row[1], 'pool':row[2]}
|
||||
|
@ -48,7 +48,7 @@ def TryGet():
|
|||
|
||||
|
||||
try:
|
||||
db = sqlite3.connect(SQLLITE_DB_PATH)
|
||||
db = DbConnect()
|
||||
TryGet()
|
||||
db.commit()
|
||||
db.close()
|
||||
|
|
|
@ -25,16 +25,16 @@ def TrySave():
|
|||
authToken = jsonData['authToken']
|
||||
|
||||
c = db.cursor()
|
||||
cur = c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
count = rows[0]
|
||||
if count == 0:
|
||||
result['status'] = USER_DOES_NOT_EXIST
|
||||
return 0
|
||||
|
||||
#Find Username
|
||||
cur = c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
username = rows[0]
|
||||
|
||||
for Npc in Npcs:
|
||||
|
@ -48,7 +48,7 @@ def TrySave():
|
|||
|
||||
|
||||
try:
|
||||
db = sqlite3.connect(SQLLITE_DB_PATH)
|
||||
db = DbConnect()
|
||||
TrySave()
|
||||
db.commit()
|
||||
db.close()
|
||||
|
|
|
@ -29,22 +29,22 @@ def TryUpdate():
|
|||
|
||||
|
||||
c = db.cursor()
|
||||
cur = c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
count = rows[0]
|
||||
if count == 0:
|
||||
result['status'] = USER_DOES_NOT_EXIST
|
||||
return 0
|
||||
|
||||
#Find Username
|
||||
cur = c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
username = rows[0]
|
||||
|
||||
|
||||
|
||||
cur = c.execute('SELECT COUNT(1) from npcList WHERE Name=? AND CharacterId=?',(username,CharacterId))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT COUNT(1) from npcList WHERE Name=? AND CharacterId=?',(username,CharacterId))
|
||||
rows = c.fetchone()
|
||||
count = rows[0]
|
||||
if count == 0:
|
||||
c.execute('INSERT INTO npcList VALUES(?,?,?,?,?)',(username,CharacterId,NextTimestamp,Pool,RequestLevel))
|
||||
|
@ -53,7 +53,7 @@ def TryUpdate():
|
|||
|
||||
|
||||
try:
|
||||
db = sqlite3.connect(SQLLITE_DB_PATH)
|
||||
db = DbConnect()
|
||||
TryUpdate()
|
||||
db.commit()
|
||||
db.close()
|
||||
|
|
|
@ -24,21 +24,21 @@ def TryGet():
|
|||
authToken = jsonData['authToken']
|
||||
|
||||
c = db.cursor()
|
||||
cur = c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
count = rows[0]
|
||||
if count == 0:
|
||||
result['status'] = USER_DOES_NOT_EXIST
|
||||
return 0
|
||||
|
||||
#Find Username
|
||||
cur = c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
username = rows[0]
|
||||
|
||||
|
||||
cur = c.execute('SELECT CharacterId,Level,Progress from relationsList WHERE Name=?',(username,))
|
||||
rows = cur.fetchall()
|
||||
c.execute('SELECT CharacterId,Level,Progress from relationsList WHERE Name=?',(username,))
|
||||
rows = c.fetchall()
|
||||
relations = []
|
||||
for row in rows:
|
||||
relation = {"characterId": row[0],"level": row[1],"progress": row[2]}
|
||||
|
@ -46,7 +46,7 @@ def TryGet():
|
|||
result['relations'] = relations
|
||||
|
||||
try:
|
||||
db = sqlite3.connect(SQLLITE_DB_PATH)
|
||||
db = DbConnect()
|
||||
TryGet()
|
||||
db.commit()
|
||||
db.close()
|
||||
|
|
|
@ -25,16 +25,16 @@ def TrySave():
|
|||
authToken = jsonData['authToken']
|
||||
|
||||
c = db.cursor()
|
||||
cur = c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
count = rows[0]
|
||||
if count == 0:
|
||||
result['status'] = USER_DOES_NOT_EXIST
|
||||
return 0
|
||||
|
||||
#Find Username
|
||||
cur = c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
username = rows[0]
|
||||
|
||||
for Relation in Relations:
|
||||
|
@ -46,7 +46,7 @@ def TrySave():
|
|||
|
||||
|
||||
try:
|
||||
db = sqlite3.connect(SQLLITE_DB_PATH)
|
||||
db = DbConnect()
|
||||
TrySave()
|
||||
db.commit()
|
||||
db.close()
|
||||
|
|
|
@ -28,20 +28,20 @@ def TryUpdate():
|
|||
|
||||
|
||||
c = db.cursor()
|
||||
cur = c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
count = rows[0]
|
||||
if count == 0:
|
||||
result['status'] = USER_DOES_NOT_EXIST
|
||||
return 0
|
||||
|
||||
#Find Username
|
||||
cur = c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
username = rows[0]
|
||||
|
||||
cur = c.execute('SELECT COUNT(1) from relationsList WHERE Name=? AND CharacterId=?',(username,CharacterId))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT COUNT(1) from relationsList WHERE Name=? AND CharacterId=?',(username,CharacterId))
|
||||
rows = c.fetchone()
|
||||
count = rows[0]
|
||||
if count == 0:
|
||||
c.execute('INSERT INTO relationsList VALUES(?,?,?,?)',(username,CharacterId,Level,Progress))
|
||||
|
@ -50,7 +50,7 @@ def TryUpdate():
|
|||
|
||||
|
||||
try:
|
||||
db = sqlite3.connect(SQLLITE_DB_PATH)
|
||||
db = DbConnect()
|
||||
TryUpdate()
|
||||
db.commit()
|
||||
db.close()
|
||||
|
|
|
@ -29,16 +29,16 @@ def TryAdd():
|
|||
authToken = jsonData['authToken']
|
||||
|
||||
c = db.cursor()
|
||||
cur = c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
count = rows[0]
|
||||
if count == 0:
|
||||
result['status'] = USER_DOES_NOT_EXIST
|
||||
return 0
|
||||
|
||||
#Find Username
|
||||
cur = c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
username = rows[0]
|
||||
|
||||
c.execute('DELETE from rubishList where Name=? and Id=?',(username,Id))
|
||||
|
@ -46,7 +46,7 @@ def TryAdd():
|
|||
|
||||
|
||||
try:
|
||||
db = sqlite3.connect(SQLLITE_DB_PATH)
|
||||
db = DbConnect()
|
||||
TryAdd()
|
||||
db.commit()
|
||||
db.close()
|
||||
|
|
|
@ -25,20 +25,20 @@ def TryGet():
|
|||
authToken = jsonData['authToken']
|
||||
|
||||
c = db.cursor()
|
||||
cur = c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
count = rows[0]
|
||||
if count == 0:
|
||||
result['status'] = USER_DOES_NOT_EXIST
|
||||
return 0
|
||||
|
||||
#Find Username
|
||||
cur = c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
username = rows[0]
|
||||
|
||||
cur = c.execute('SELECT Id,X,Y, AreaId,ItemTemplateId from rubishList WHERE Name=?',(username,))
|
||||
rows = cur.fetchall()
|
||||
c.execute('SELECT Id,X,Y, AreaId,ItemTemplateId from rubishList WHERE Name=?',(username,))
|
||||
rows = c.fetchall()
|
||||
rubishsList = []
|
||||
|
||||
for row in rows:
|
||||
|
@ -49,7 +49,7 @@ def TryGet():
|
|||
|
||||
|
||||
try:
|
||||
db = sqlite3.connect(SQLLITE_DB_PATH)
|
||||
db = DbConnect()
|
||||
TryGet()
|
||||
db.commit()
|
||||
db.close()
|
||||
|
|
|
@ -25,16 +25,16 @@ def TryRemove():
|
|||
authToken = jsonData['authToken']
|
||||
|
||||
c = db.cursor()
|
||||
cur = c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
count = rows[0]
|
||||
if count == 0:
|
||||
result['status'] = USER_DOES_NOT_EXIST
|
||||
return 0
|
||||
|
||||
#Find Username
|
||||
cur = c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
username = rows[0]
|
||||
|
||||
|
||||
|
@ -43,7 +43,7 @@ def TryRemove():
|
|||
|
||||
|
||||
try:
|
||||
db = sqlite3.connect(SQLLITE_DB_PATH)
|
||||
db = DbConnect()
|
||||
TryRemove()
|
||||
db.commit()
|
||||
db.close()
|
||||
|
|
|
@ -25,16 +25,16 @@ def TrySave():
|
|||
authToken = jsonData['authToken']
|
||||
|
||||
c = db.cursor()
|
||||
cur = c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
count = rows[0]
|
||||
if count == 0:
|
||||
result['status'] = USER_DOES_NOT_EXIST
|
||||
return 0
|
||||
|
||||
#Find Username
|
||||
cur = c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
username = rows[0]
|
||||
|
||||
for Rubish in Rubishs:
|
||||
|
@ -49,7 +49,7 @@ def TrySave():
|
|||
|
||||
|
||||
try:
|
||||
db = sqlite3.connect(SQLLITE_DB_PATH)
|
||||
db = DbConnect()
|
||||
TrySave()
|
||||
db.commit()
|
||||
db.close()
|
||||
|
|
|
@ -25,16 +25,16 @@ def TryAdd():
|
|||
authToken = jsonData['authToken']
|
||||
|
||||
c = db.cursor()
|
||||
cur = c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
count = rows[0]
|
||||
if count == 0:
|
||||
result['status'] = USER_DOES_NOT_EXIST
|
||||
return 0
|
||||
|
||||
#Find Username
|
||||
cur = c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
username = rows[0]
|
||||
|
||||
c.execute('DELETE from scenario where Name=? and ScenarioId=?',(username,ScenarioId))
|
||||
|
@ -42,7 +42,7 @@ def TryAdd():
|
|||
|
||||
|
||||
try:
|
||||
db = sqlite3.connect(SQLLITE_DB_PATH)
|
||||
db = DbConnect()
|
||||
TryAdd()
|
||||
db.commit()
|
||||
db.close()
|
||||
|
|
|
@ -26,23 +26,23 @@ def TryUpdate():
|
|||
|
||||
|
||||
c = db.cursor()
|
||||
cur = c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
count = rows[0]
|
||||
if count == 0:
|
||||
result['status'] = USER_DOES_NOT_EXIST
|
||||
return 0
|
||||
|
||||
#Find Username
|
||||
cur = c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
username = rows[0]
|
||||
|
||||
c.execute('UPDATE scenario SET Completed=1 WHERE Name=? AND ScenarioId=?',(username,ScenarioId))
|
||||
|
||||
|
||||
try:
|
||||
db = sqlite3.connect(SQLLITE_DB_PATH)
|
||||
db = DbConnect()
|
||||
TryUpdate()
|
||||
db.commit()
|
||||
db.close()
|
||||
|
|
|
@ -25,20 +25,20 @@ def TryGet():
|
|||
authToken = jsonData['authToken']
|
||||
|
||||
c = db.cursor()
|
||||
cur = c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
count = rows[0]
|
||||
if count == 0:
|
||||
result['status'] = USER_DOES_NOT_EXIST
|
||||
return 0
|
||||
|
||||
#Find Username
|
||||
cur = c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
username = rows[0]
|
||||
|
||||
cur = c.execute('SELECT ScenarioId,CustomData,StepId, Completed from scenario WHERE Name=?',(username,))
|
||||
rows = cur.fetchall()
|
||||
c.execute('SELECT ScenarioId,CustomData,StepId, Completed from scenario WHERE Name=?',(username,))
|
||||
rows = c.fetchall()
|
||||
scenariosList = []
|
||||
|
||||
|
||||
|
@ -50,7 +50,7 @@ def TryGet():
|
|||
|
||||
|
||||
try:
|
||||
db = sqlite3.connect(SQLLITE_DB_PATH)
|
||||
db = DbConnect()
|
||||
TryGet()
|
||||
db.commit()
|
||||
db.close()
|
||||
|
|
|
@ -28,20 +28,20 @@ def TryUpdate():
|
|||
|
||||
|
||||
c = db.cursor()
|
||||
cur = c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
count = rows[0]
|
||||
if count == 0:
|
||||
result['status'] = USER_DOES_NOT_EXIST
|
||||
return 0
|
||||
|
||||
#Find Username
|
||||
cur = c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
username = rows[0]
|
||||
|
||||
cur = c.execute('SELECT COUNT(1) from scenario WHERE Name=? AND ScenarioId=?',(username,ScenarioId))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT COUNT(1) from scenario WHERE Name=? AND ScenarioId=?',(username,ScenarioId))
|
||||
rows = c.fetchone()
|
||||
count = rows[0]
|
||||
if count == 0:
|
||||
c.execute('INSERT INTO scenario VALUES(?,?,?,?,0)',(username,ScenarioId,CustomData,StepId))
|
||||
|
@ -50,7 +50,7 @@ def TryUpdate():
|
|||
|
||||
|
||||
try:
|
||||
db = sqlite3.connect(SQLLITE_DB_PATH)
|
||||
db = DbConnect()
|
||||
TryUpdate()
|
||||
db.commit()
|
||||
db.close()
|
||||
|
|
|
@ -26,20 +26,20 @@ def TryGet():
|
|||
authToken = jsonData['authToken']
|
||||
|
||||
c = db.cursor()
|
||||
cur = c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
count = rows[0]
|
||||
if count == 0:
|
||||
result['status'] = USER_DOES_NOT_EXIST
|
||||
return 0
|
||||
|
||||
#Find Username
|
||||
cur = c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
username = rows[0]
|
||||
|
||||
cur = c.execute('SELECT CreationDate from users WHERE Name=?',(username,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT CreationDate from users WHERE Name=?',(username,))
|
||||
rows = c.fetchone()
|
||||
CreationTime = rows[0]
|
||||
|
||||
result['serverTime'] = math.floor(time.time()*1000)
|
||||
|
@ -48,7 +48,7 @@ def TryGet():
|
|||
|
||||
|
||||
try:
|
||||
db = sqlite3.connect(SQLLITE_DB_PATH)
|
||||
db = DbConnect()
|
||||
TryGet()
|
||||
db.commit()
|
||||
db.close()
|
||||
|
|
|
@ -25,16 +25,16 @@ def TryAdd():
|
|||
authToken = jsonData['authToken']
|
||||
|
||||
c = db.cursor()
|
||||
cur = c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
count = rows[0]
|
||||
if count == 0:
|
||||
result['status'] = USER_DOES_NOT_EXIST
|
||||
return 0
|
||||
|
||||
#Find Username
|
||||
cur = c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
username = rows[0]
|
||||
|
||||
c.execute('DELETE from tutorial where Name=? and TutorialTemplateId=?',(username,TutorialTemplateId))
|
||||
|
@ -42,7 +42,7 @@ def TryAdd():
|
|||
|
||||
|
||||
try:
|
||||
db = sqlite3.connect(SQLLITE_DB_PATH)
|
||||
db = DbConnect()
|
||||
TryAdd()
|
||||
db.commit()
|
||||
db.close()
|
||||
|
|
|
@ -25,20 +25,20 @@ def TryGet():
|
|||
authToken = jsonData['authToken']
|
||||
|
||||
c = db.cursor()
|
||||
cur = c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT COUNT(1) from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
count = rows[0]
|
||||
if count == 0:
|
||||
result['status'] = USER_DOES_NOT_EXIST
|
||||
return 0
|
||||
|
||||
#Find Username
|
||||
cur = c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = cur.fetchone()
|
||||
c.execute('SELECT Name from users WHERE LastSession=?',(authToken,))
|
||||
rows = c.fetchone()
|
||||
username = rows[0]
|
||||
|
||||
cur = c.execute('SELECT tutorialTemplateId from tutorial WHERE Name=?',(username,))
|
||||
rows = cur.fetchall()
|
||||
c.execute('SELECT tutorialTemplateId from tutorial WHERE Name=?',(username,))
|
||||
rows = c.fetchall()
|
||||
tutorialTemplateIds = []
|
||||
|
||||
for row in rows:
|
||||
|
@ -48,7 +48,7 @@ def TryGet():
|
|||
|
||||
|
||||
try:
|
||||
db = sqlite3.connect(SQLLITE_DB_PATH)
|
||||
db = DbConnect()
|
||||
TryGet()
|
||||
db.commit()
|
||||
db.close()
|
||||
|
|
Loading…
Reference in New Issue