def get(self, id, do): if id: row = db.ct("module", "*", "id="+id) if row: if do == 'del': db.d("module", "id="+id) self.redirect("http://"+URL+"/module") else: self.render( 'module_edit.html', username=self.get_secure_cookie("username"), datainfo=db.datainfo(), systeminfo=systeminfo(), heads=[ {'name':'Module', 'title':'Module list', 'url':'module/'}, {'name':urlde(row['name']), 'title': '', 'url': ''}, ], row=row, url=URL, urlde=urlde, ) else: self.render('404.html') else: if do == 'add': self.render( 'module_add.html', username=self.get_secure_cookie("username"), datainfo=db.datainfo(), systeminfo=systeminfo(), heads=[{'name':'Module', 'title':'Module list', 'url':'module/'},{'name':'Add', 'title':'', 'url':''}], url=URL, urlde=urlde, ) else: mrows = db.cts("module", "*", "1=1 order by id") modulen = len(mrows) self.render( "module.html", username=self.get_secure_cookie("username"), datainfo=db.datainfo(), systeminfo=systeminfo(), heads=[{'name':'Module', 'title': '', 'url': ''}], url=URL, urlde=urlde, timede=timede, mrows=mrows, modulen=modulen, )
def get(self): def gethostn(hostip): return db.c("host", "hostip='"+hostip+"'") def getname(id): return urlde(db.ct("project", "name", "id="+str(id))['name']) rows = db.cts("host", "hostip", "online=1") row = [] for x in rows: row.append(db.ct("host", "*", "hostip='"+x['hostip']+"' order by id desc limit 1")) self.render( "online.html", heads=[ {'name':'Online', 'title':'', 'url':''}, ], username=self.get_secure_cookie("username"), datainfo=db.datainfo(), systeminfo=systeminfo(), urlde=urlde, url=URL, timede=timede, urljson=urljson, getaddr=getaddr, row=row, getname=getname, gethostn=gethostn, )
def get(self, id): row = db.ct("host", "*", "id=" + id) if row: if row['online'] == 1: self.render('console.html', username=self.get_secure_cookie("username"), heads=[ { 'name': 'console', 'title': '', 'url': '' }, { 'name': row['hostip'], 'title': '', 'url': '' }, ], datainfo=db.datainfo(), systeminfo=systeminfo(), url=URL, urlde=urlde, hostip=row['hostip']) else: self.set_header('Content-type', 'text/html;charset=utf-8') self.write('(⊙ˍ⊙)') else: self.write(id)
def get(self): def getname(id): return urlde(db.ct("project","name","id="+id)['name']) month = time.strftime("%m", time.localtime(time.time())) tables = db.cts("host", "projectid,date_format(from_unixtime(addtime),'%%e') as day", "date_format(from_unixtime(addtime),'%%m')='"+month+"'") datatable = {} for table in tables: id = str(table['projectid']) if id not in datatable: datatable[id] = {} i = 1 while i <= 31: datatable[id][i] = 0 i += 1 else: datatable[id][int(table['day'])] += 1 x='' for data in datatable: for day in datatable[data]: x = x + '['+str(day)+', '+str(datatable[data][day])+'],' x = x[:-1] datatable[data] = x self.render( 'home.html', username=self.get_secure_cookie("username"), datainfo=db.datainfo(), systeminfo=systeminfo(), heads=[], url=URL, urlde=urlde, datatable=datatable, getname = getname, )
def get(self, projectid, ip, page, do): def getname(id): return urlde(db.ct("project", "name", "id=" + id)['name']) if ip and projectid: num = db.c('host', "hostip='" + ip + "' and projectid='" + projectid + "'") if num: page = str(page and (int(page) - 1 > 0 and (int(page) - 1 < num and int(page) - 1 or 0) or 0) or 0) host = db.ct( "host", "*", "hostip = '" + ip + "' and projectid='" + projectid + "' order by id desc limit " + page + ",1") if do == 'del': db.d("host", "id=" + str(host['id'])) if num == 1: hostlist = json.loads( db.ct("project", "hosts", "id=" + projectid)['hosts']) hostlist.remove(ip) db.u("project", "hosts='" + json.dumps(hostlist) + "'", "id=" + projectid) self.redirect("http://" + URL + "/project/" + projectid) self.redirect("http://" + URL + "/host/" + projectid + "/" + ip) else: self.render( "host.html", heads=[ { 'name': getname(projectid), 'title': 'Go to ' + getname(projectid), 'url': 'project/' + projectid }, { 'name': ip, 'title': '', 'url': '' }, ], username=self.get_secure_cookie("username"), datainfo=db.datainfo(), systeminfo=systeminfo(), urlde=urlde, timede=timede, url=URL, urljson=urljson, host=host, num=range(num), page=int(page) + 1, ) else: self.render('404.html') else: self.render('404.html')
def get(self, projectid, ip, page, do): def getname(id): return urlde(db.ct("project","name","id="+id)['name']) if ip and projectid: num = db.c('host', "hostip='"+ip+"' and projectid='"+projectid+"'") if num: page = str(page and (int(page)-1>0 and (int(page)-1<num and int(page)-1 or 0) or 0) or 0) host = db.ct( "host", "*", "hostip = '"+ip+"' and projectid='"+projectid+"' order by id desc limit "+page+",1") if do == 'del': db.d("host", "id="+str(host['id'])) if num == 1: hostlist = json.loads(db.ct("project", "hosts", "id="+projectid)['hosts']) hostlist.remove(ip) db.u("project", "hosts='"+json.dumps(hostlist)+"'", "id="+projectid) self.redirect("http://"+URL+"/project/"+projectid) self.redirect("http://"+URL+"/host/"+projectid+"/"+ip) else: self.render( "host.html", heads=[ {'name':getname(projectid), 'title': 'Go to ' + getname(projectid), 'url': 'project/'+projectid}, {'name': ip, 'title': '', 'url': ''}, ], username=self.get_secure_cookie("username"), datainfo=db.datainfo(), systeminfo=systeminfo(), urlde=urlde, timede=timede, url=URL, urljson=urljson, host=host, num=range(num), page=int(page)+1, ) else: self.render('404.html') else: self.render('404.html')
def get(self, id): row = db.ct("host", "*", "id="+id) if row: if row['online'] == 1: self.render( 'console.html', username=self.get_secure_cookie("username"), heads=[ {'name': 'console', 'title': '', 'url': ''}, {'name': row['hostip'], 'title':'', 'url':''}, ], datainfo=db.datainfo(), systeminfo=systeminfo(), url=URL, urlde=urlde, hostip=row['hostip'] ) else: self.set_header('Content-type', 'text/html;charset=utf-8') self.write('(⊙ˍ⊙)') else: self.write(id)
def get(self): def getname(id): return urlde(db.ct("project", "name", "id=" + id)['name']) month = time.strftime("%m", time.localtime(time.time())) tables = db.cts( "host", "projectid,date_format(from_unixtime(addtime),'%%e') as day", "date_format(from_unixtime(addtime),'%%m')='" + month + "'") datatable = {} for table in tables: id = str(table['projectid']) if id not in datatable: datatable[id] = {} i = 1 while i <= 31: datatable[id][i] = 0 i += 1 else: datatable[id][int(table['day'])] += 1 x = '' for data in datatable: for day in datatable[data]: x = x + '[' + str(day) + ', ' + str( datatable[data][day]) + '],' x = x[:-1] datatable[data] = x self.render( 'home.html', username=self.get_secure_cookie("username"), datainfo=db.datainfo(), systeminfo=systeminfo(), heads=[], url=URL, urlde=urlde, datatable=datatable, getname=getname, )
def get(self, id, do): def gethostn(hostip): return db.c("host", "hostip='" + hostip + "'") def getmcustom(code): code = urlde(code) s = re.findall("({set\..*})", code) return s if id: row = db.ct("project", "*", "id=" + id) if row: if do == "del": db.d("project", "id=" + id) self.redirect("http://" + URL + "/project") elif do == "edit": modules = db.cts("module", "*", "1=1") pmodules = json.loads(urlde(db.ct("project", "module", "id=" + id)["module"])) self.render( "project_edit.html", heads=[ {"name": "Project", "title": "Project list", "url": "project"}, {"name": urlde(row["name"]), "title": urlde(row["name"]) + "view", "url": "project/" + id}, ], username=self.get_secure_cookie("username"), datainfo=db.datainfo(), systeminfo=systeminfo(), urlde=urlde, getmcustom=getmcustom, row=row, url=URL, modules=modules, pmodules=pmodules, ) else: x = [] hosts = [] hostlist = json.loads(db.ct("project", "hosts", "id=" + id)["hosts"]) hostn = 0 if hostlist: for i in hostlist: x.append( db.ct( "host", "id", "hostip='" + i + "' and projectid=" + id + " order by id desc limit 1" )["id"] ) x.sort(reverse=True) hostn = len(x) for i in x: hosts.append( db.ct("host", "hostip,information,online,addtime,projectid,id", "id=" + str(i)) ) self.render( "project_select.html", heads=[ {"name": "Project", "title": "Project list", "url": "project"}, {"name": urlde(row["name"]), "title": "", "url": ""}, ], username=self.get_secure_cookie("username"), datainfo=db.datainfo(), systeminfo=systeminfo(), urlde=urlde, hostn=hostn, hosts=hosts, gethostn=gethostn, url=URL, timede=timede, urljson=urljson, getaddr=getaddr, ) else: self.render("404.html") else: if do == "add": modules = db.cts("module", "*", "1=1") self.render( "project_add.html", heads=[ {"name": "Project", "title": "Project list", "url": "project"}, {"name": "Add", "title": "", "url": ""}, ], username=self.get_secure_cookie("username"), datainfo=db.datainfo(), systeminfo=systeminfo(), url=URL, urlde=urlde, modules=modules, getmcustom=getmcustom, ) else: prows = db.cts("project", "*", "1=1 order by id") # 所有的project hrown = {} # host数目 hrowno = {} # host online 数目 if prows: for i in prows: hrown[i["id"]] = db.c("host", "projectid=" + str(i["id"])) hrowno[i["id"]] = db.c("host", "projectid=" + str(i["id"]) + " and online=1") self.render( "project.html", heads=[{"name": "Project", "title": "", "url": ""}], prows=prows, prown=len(prows), hrown=hrown, hrowno=hrowno, username=self.get_secure_cookie("username"), datainfo=db.datainfo(), systeminfo=systeminfo(), url=URL, urlde=urlde, timede=timede, )
def get(self, id, do): def gethostn(hostip): return db.c("host", "hostip='" + hostip + "'") def getmcustom(code): code = urlde(code) s = re.findall("({set\..*})", code) return s if id: row = db.ct("project", "*", "id=" + id) if row: if do == 'del': db.d("project", "id=" + id) self.redirect("http://" + URL + "/project") elif do == 'edit': modules = db.cts("module", "*", "1=1") pmodules = json.loads( urlde( db.ct("project", "module", "id=" + id)['module'])) self.render( "project_edit.html", heads=[ { 'name': 'Project', 'title': 'Project list', 'url': 'project' }, { 'name': urlde(row['name']), 'title': urlde(row['name']) + 'view', 'url': 'project/' + id }, ], username=self.get_secure_cookie("username"), datainfo=db.datainfo(), systeminfo=systeminfo(), urlde=urlde, getmcustom=getmcustom, row=row, url=URL, modules=modules, pmodules=pmodules, ) else: x = [] hosts = [] hostlist = json.loads( db.ct("project", "hosts", "id=" + id)['hosts']) hostn = 0 if hostlist: for i in hostlist: x.append( db.ct( "host", "id", "hostip='" + i + "' and projectid=" + id + " order by id desc limit 1")['id']) x.sort(reverse=True) hostn = len(x) for i in x: hosts.append( db.ct( "host", "hostip,information,online,addtime,projectid,id", "id=" + str(i))) self.render( "project_select.html", heads=[ { 'name': 'Project', 'title': 'Project list', 'url': 'project' }, { 'name': urlde(row['name']), 'title': '', 'url': '' }, ], username=self.get_secure_cookie("username"), datainfo=db.datainfo(), systeminfo=systeminfo(), urlde=urlde, hostn=hostn, hosts=hosts, gethostn=gethostn, url=URL, timede=timede, urljson=urljson, getaddr=getaddr, ) else: self.render('404.html') else: if do == 'add': modules = db.cts("module", "*", "1=1") self.render( "project_add.html", heads=[ { 'name': 'Project', 'title': 'Project list', 'url': 'project' }, { 'name': 'Add', 'title': '', 'url': '' }, ], username=self.get_secure_cookie("username"), datainfo=db.datainfo(), systeminfo=systeminfo(), url=URL, urlde=urlde, modules=modules, getmcustom=getmcustom, ) else: prows = db.cts("project", "*", "1=1 order by id") #所有的project hrown = {} #host数目 hrowno = {} #host online 数目 if prows: for i in prows: hrown[i['id']] = db.c("host", "projectid=" + str(i['id'])) hrowno[i['id']] = db.c( "host", "projectid=" + str(i['id']) + " and online=1") self.render( "project.html", heads=[{ 'name': 'Project', 'title': '', 'url': '' }], prows=prows, prown=len(prows), hrown=hrown, hrowno=hrowno, username=self.get_secure_cookie("username"), datainfo=db.datainfo(), systeminfo=systeminfo(), url=URL, urlde=urlde, timede=timede, )
def get(self, id, do): if id: row = db.ct("module", "*", "id=" + id) if row: if do == 'del': db.d("module", "id=" + id) self.redirect("http://" + URL + "/module") else: self.render( 'module_edit.html', username=self.get_secure_cookie("username"), datainfo=db.datainfo(), systeminfo=systeminfo(), heads=[ { 'name': 'Module', 'title': 'Module list', 'url': 'module/' }, { 'name': urlde(row['name']), 'title': '', 'url': '' }, ], row=row, url=URL, urlde=urlde, ) else: self.render('404.html') else: if do == 'add': self.render( 'module_add.html', username=self.get_secure_cookie("username"), datainfo=db.datainfo(), systeminfo=systeminfo(), heads=[{ 'name': 'Module', 'title': 'Module list', 'url': 'module/' }, { 'name': 'Add', 'title': '', 'url': '' }], url=URL, urlde=urlde, ) else: mrows = db.cts("module", "*", "1=1 order by id") modulen = len(mrows) self.render( "module.html", username=self.get_secure_cookie("username"), datainfo=db.datainfo(), systeminfo=systeminfo(), heads=[{ 'name': 'Module', 'title': '', 'url': '' }], url=URL, urlde=urlde, timede=timede, mrows=mrows, modulen=modulen, )