def GET(self,domain): domainId = processData.domainInfo( web.cookies().email, web.cookies().password, domain=domain )#获取域名ID recordList = processData.recordList( web.cookies().email, web.cookies().password, id=domainId )#获取记录列表 fileHead = '主机|类型|线路|记录值|MX优先级|TTL'#导出文件的头部 s = '' s += fileHead + '\n' for i in recordList: s += i['name'].encode() + '\t' s += str(i['type']) + '\t' s += i['line'].encode('utf-8') + '\t' s += str(i['value']) + '\t' s += str(i['mx']) + '\t' s += str(i['ttl']) + '\n' web.header('Content-Type','static/txt') web.header('Content-Disposition',"attachment;filename="+domain+".txt") return s
def POST(self,balabala): domainId = processData.domainInfo( web.cookies().email, web.cookies().password, domain=domain_g )#获取域名ID x = web.input(myfile={}) count = 0 k = 0 for line in x['myfile'].file: line = line.split('\t') count += 1 if count == 1 or line[3] == 'f1g1ns1.dnspod.net.' or line[3] == 'f1g1ns2.dnspod.net.': k += 1 continue message = processData.addRecord( web.cookies().email,#邮箱 web.cookies().password,#密码 domain_id=domainId,#域名ID sub_domain = line[0],#主机记录 record_type = line[1],#记录类型 route_line = line[2],#线路类型 value = line[3],#记录值 mx = line[4],#MX值 ttl = line[5][:-1]#TTL ) count -= k return render.upload(domain_g,msg='成功导入'+str(count)+'条记录,请点击左上角的域名进行查看!')
def POST(self,domain_recordId): "保存修改后的记录类" string = domain_recordId.encode() domain = string.split('-')[0] recordId = string.split('-')[1] domainId = processData.domainInfo( web.cookies().email, web.cookies().password, domain=domain ) recordDict = processData.InfoRecord( web.cookies().email, web.cookies().password, did=domainId, rid=recordId ) i = web.input() message = processData.updateRecord( web.cookies().email,#邮箱 web.cookies().password,#密码 domain_id=domainId,#域名ID record_id=recordId,#记录ID sub_domain = i.hostName.encode(),#主机记录 record_type = i.recordType.encode(),#记录类型 route_line = i.routeType.encode('utf-8'),#线路类型 value = i.recordValue.encode(),#记录值 mx = i.MX.encode(),#MX值 ttl = i.TTL.encode()#TTL ) if message == '1': return render.update(recordDict,domain,msg = "修改成功,点击域名进行查看。") else: return render.update(recordDict,domain,msg = message)
def POST(self,domain): domainId = processData.domainInfo( web.cookies().email, web.cookies().password, domain=domain )#获取域名ID i = web.input() message = processData.addRecord( web.cookies().email,#邮箱 web.cookies().password,#密码 domain_id=domainId,#域名ID sub_domain = i.hostrecord.encode(),#主机记录 record_type = i.recordType.encode(),#记录类型 route_line = i.routeType.encode('utf-8'),#线路类型 value = i.recordValue.encode(),#记录值 mx = i.MX.encode(),#MX值 ttl = i.TTL.encode()#TTL ) if message == '1': recordList = processData.recordList( web.cookies().email, web.cookies().password, id=domainId ) return render.record(domain,recordList,delMsg='添加成功') else: recordList = processData.recordList( web.cookies().email, web.cookies().password, id=domainId ) return render.record(domain,recordList,delMsg=message)
def GET(sef,domain_recordId): string = domain_recordId.encode() domain = string.split('-')[0] recordId = string.split('-')[1] domainId = processData.domainInfo( web.cookies().email, web.cookies().password, domain=domain ) message = processData.delRecord( web.cookies().email, web.cookies().password, did=domainId, rid=recordId ) if message == '1': recordList = processData.recordList( web.cookies().email, web.cookies().password, id=domainId ) return render.record(domain,recordList,delMsg='删除成功') else: recordList = processData.recordList( web.cookies().email, web.cookies().password, id=domainId ) return render.record(domain,recordList,delMsg=message)
def GET(self,domain): domainId = processData.domainInfo( web.cookies().email, web.cookies().password, domain=domain_g )#获取域名ID count = 0 answers = dnsRecord.dnsRecord(domain) if not answers: return render.upload(domain,ans='没有扫描到任何记录!') else: for item in answers: if item['typename'] == 'NS': message = processData.addRecord( web.cookies().email,#邮箱 web.cookies().password,#密码 domain_id=domainId,#域名ID sub_domain = '@',#主机记录 record_type = item['typename'],#记录类型 route_line = '默认',#线路类型 value = item['data'],#记录值 mx = '',#MX值 ttl = '600'#TTL ) if message == '1':count += 1 if item['typename'] == 'A': message = processData.addRecord( web.cookies().email,#邮箱 web.cookies().password,#密码 domain_id=domainId,#域名ID sub_domain = 'www',#主机记录 record_type = item['typename'],#记录类型 route_line = '默认',#线路类型 value = item['data'],#记录值 mx = '',#MX值 ttl = '600'#TTL ) if message == '1':count += 1 if item['typename'] == 'MX': message = processData.addRecord( web.cookies().email,#邮箱 web.cookies().password,#密码 domain_id=domainId,#域名ID sub_domain = 'mail',#主机记录 record_type = item['typename'],#记录类型 route_line = '默认',#线路类型 value = item['data'][1]+'.',#记录值 mx = '1',#MX值#不知为什么,mx为空时,发生了mx错误,只好暂时设置为1。 ttl = '600'#TTL ) if message == '1':count += 1 return render.upload(domain,ans='成功导入'+ str(count)+ '条记录,点击左上角的域名进行查看。如果有遗漏,请手动添加或上传文件导入。')
def GET(self,domain): #获取指定域名ID domainID = processData.domainInfo( web.cookies().email, web.cookies().password, domain=domain ) recordList = processData.recordList( web.cookies().email, web.cookies().password, id=domainID ) return render.record(domain,recordList)
def GET(self,domain_recordId): string = domain_recordId.encode() domain = string.split('-')[0] recordId = string.split('-')[1] domainId = processData.domainInfo( web.cookies().email, web.cookies().password, domain=domain )#获取域名Id recordDict = processData.InfoRecord( web.cookies().email, web.cookies().password, did=domainId, rid=recordId ) return render.update(recordDict,domain)