def __init__(self, dbpth='./db/hard'): super(hardKeysTool, self).__init__() self.dbPth = dbpth if not os.path.exists(self.dbPth): os.mkdir(self.dbPth) #用户硬件信息,使用硬件唯一uuid作为key self.hardDBpth = self.dbPth + os.sep + 'hard' self.hardDB = dbTool.DBMObj(self.hardDBpth) #用户硬件登陆次数 self.loginTimesPth = self.dbPth + os.sep + 'hardloginTimes' self.loginDB = dbTool.DBMObj(self.loginTimesPth)
def addUserListDBWithRegCode(self, hardID, purls): tmpdb = dbTool.DBMObj(self.userpth + os.sep + hardID) keys = [] values = [] ks = tmpdb.allKeys() startn = 1 if ks != None and len(ks) > 1000: #只记录用户的最后1000个下载地址 ks = ks[-800:] for i in range(len(ks)): keys.append(str(i + 1)) values.append(ks[i]) startn = 801 for n in range(len(purls)): keys.append(str(startn + n)) base64str = base64.b64encode(purls[n]) values.append(base64str) tmpdb.insetList(keys, values) return len(keys) else: if ks == None or len(ks) < 1: startn = 1 else: startn = len(ks) + 1 for n in range(len(purls)): keys.append(str(startn + n)) base64str = base64.b64encode(purls[n]) values.append(base64str) tmpdb.insetList(keys, values) if ks == None: return len(keys) else: return len(keys) + len(ks)
def __init__(self, dbpth='./db/userdb'): super(UserDBTool, self).__init__() if not os.path.exists('db'): os.mkdir('db') if not os.path.exists(dbpth): os.mkdir(dbpth) #试用用户下载目录 self.testdbpth = dbpth + os.sep + 'testdir' if not os.path.exists(self.testdbpth): os.mkdir(self.testdbpth) self.testdb = dbTool.DBMObj(self.testdbpth + os.sep + 'test') #正式用户下载记录 self.userpth = dbpth + os.sep + 'reguser' if not os.path.exists(self.userpth): os.mkdir(self.userpth) self.basedbPth = dbpth self.usrIPpth = dbpth + os.sep + 'ip' if not os.path.exists(self.usrIPpth): os.mkdir(self.usrIPpth)
def __init__(self, dbpth='./db/regcode'): super(RegKeysTool, self).__init__() if not os.path.exists('db'): os.mkdir('db') if not os.path.exists(dbpth): os.mkdir(dbpth) #已付费注册用户 self.dbPth = dbpth + os.sep + 'regcode' self.db = dbTool.DBMObj(self.dbPth) # self.regCodeObj = {} #{regCode:{UUID:{硬件唯一码},os:{操作系统信息},hard:{硬件信息}}} #新生成的未使用注册码 self.creagedbpth = dbpth + os.sep + 'create' self.createdb = dbTool.DBMObj(self.creagedbpth)
def addUserDBWithRegCode(self, regCode, purl): tmpdb = dbTool.DBMObj(self.userpth + os.sep + regCode) base64str = base64.b64encode(purl) ks = tmpdb.allKeys() if ks == None or len(ks) < 1: tmpdb.inset('1', base64str) else: key = len(ks) + 1 tmpdb.inset(str(key), )
def addUserDBWithRegCode(self, regCode, usrIP): tmpdb = dbTool.DBMObj(self.usrIPpth + os.sep + regCode) dictmp = {'ip': usrIP, 'time': int(time.time())} jstr = json.dumps(dictmp) ks = tmpdb.allKeys() if ks == None or len(ks) < 1: tmpdb.inset('1', jstr) else: key = len(ks) + 1 tmpdb.inset(str(key), jstr)
def __init__(self,dbpth = './db/softkey'): super(SoftKeysTool, self).__init__() if not os.path.exists('db'): os.mkdir('db') if not os.path.exists(dbpth): os.mkdir(dbpth) self.dbPth = dbpth + os.sep + 'softkey' #此数据库保存用户唯一ID和用户硬件信息,操作系统信息,保存的数据只用作用户分析,不打算用来验证用户是否为注册用户,验证用户是否注册使用注册码和硬件码 self.db = dbTool.DBMObj(self.dbPth)
def __init__(self, dtime=60 * 60 * 2): #默认两小时更新一次数据 super(BS4HTMLTool, self).__init__() self.sysSystem = platform.system() if not os.path.exists('img'): os.mkdir('img') if not os.path.exists('db'): os.mkdir('db') self.upTime = dtime self.dcount = 0 self.dubDic = {} #保存所有数据 self.dbpth = 'db' + os.sep + 'data' self.db = dbTool.DBMObj(self.dbpth) self.initTool()
def conventDBToJson(): dbpth = 'db' + os.sep + 'data.db' if not os.path.exists(dbpth): outstr = '数据库不存在:%s' % (dbpth) print(outstr.decode()) return db = dbTool.DBMObj(dbpth) dicdat = db.getDBDatas() jstr = json.dumps(dicdat) if not os.path.exists('jsonout'): os.mkdir('jsonout') f = open('jsonout' + os.sep + 'jsondb.json', 'w') f.write(jstr) f.close()
def addUserListDBWithRegCode(self, regCode, purls): tmpdb = dbTool.DBMObj(self.userpth + os.sep + regCode) keys = [] values = [] ks = tmpdb.allKeys() startn = 1 if ks == None or len(ks) < 1: startn = 1 else: startn = len(ks) + 1 for n in range(len(purls)): keys.append(str(startn + n)) base64str = base64.b64encode(purls[n]) values.append(base64str) tmpdb.insetList(keys, values)
def __init__(self, keyPth='./regkeys', dbpth='./db/keysdb'): super(RegistTool, self).__init__() self.keyPth = keyPth self.userPubKeyPth = keyPth + '/userpubkey' if not os.path.exists(self.keyPth): os.mkdir(self.keyPth) os.mkdir(self.userPubKeyPth) self.RSAObj = None self.dbPth = dbpth self.userPubKeys = {} self.db = dbTool.DBMObj(self.dbPth) self.initRSAKey()
def addUserDBIPWithHardID(self, hardid, usrIP): tmpdb = dbTool.DBMObj(self.usrIPpth + os.sep + hardid) dictmp = {'ip': usrIP, 'time': int(time.time())} jstr = json.dumps(dictmp) ks = tmpdb.allKeys() if ks != None and len(ks) > 100: #只记录最近100次的登陆IP地址 keys = [] values = [] ks = ks[-99:] for i in range(len(ks)): keys.append(str(i + 1)) values.append(ks[i]) keys.append('100') values.append(jstr) tmpdb.insetList(keys, values) else: if ks == None or len(ks) < 1: tmpdb.inset('1', jstr) else: key = len(ks) + 1 tmpdb.inset(str(key), jstr)
def addUserDBWithRegCode(self, hardID, purl): tmpdb = dbTool.DBMObj(self.userpth + os.sep + hardID) base64str = base64.b64encode(purl) ks = tmpdb.allKeys() if ks != None and len(ks) > 1000: #只记录用户的最后1000个下载地址 keys = [] values = [] ks = ks[-800:] for i in range(len(ks)): keys.append(str(i + 1)) values.append(ks[i]) keys.append('801') values.append(base64str) tmpdb.insetList(keys, values) return len(ks) + 1 else: if ks == None or len(ks) < 1: tmpdb.inset('1', base64str) return 1 else: key = len(ks) + 1 tmpdb.inset(str(key), base64str) return len(ks) + 1