def GetPage(self,data,get): #包含分页类 import page #实例化分页类 page = page.Page(); info = {} info['count'] = len(data) info['row'] = 15 info['p'] = 1 if hasattr(get,'p'): info['p'] = int(get['p']) info['uri'] = {} info['return_js'] = '' if hasattr(get,'tojs'): info['return_js'] = get.tojs #获取分页数据 result = {} result['page'] = page.GetPage(info) n = 0; result['data'] = []; for i in range(info['count']): if n > page.ROW: break; if i < page.SHIFT: continue; n += 1; result['data'].append(data[i]); return result;
def get_page(count,p=1,rows=12,callback='',result='1,2,3,4,5,8'): import page from BTPanel import request page = page.Page(); info = { 'count':count, 'row':rows, 'p':p, 'return_js':callback ,'uri':request.full_path} data = { 'page': page.GetPage(info,result), 'shift': str(page.SHIFT), 'row': str(page.ROW) } return data
def get_exception_logs(self, get): import page page = page.Page() count = public.M('logs').where( "type=? and strftime('%m-%d','now','localtime') = strftime('%m-%d',addtime)", (u'消息推送', )).count() limit = 12 info = {} info['count'] = count info['row'] = limit info['p'] = 1 if hasattr(get, 'p'): info['p'] = int(get['p']) info['uri'] = get info['return_js'] = '' if hasattr(get, 'tojs'): info['return_js'] = get.tojs data = {} # 获取分页数据 data['page'] = page.GetPage(info, '1,2,3,4,5,8') data['data'] = public.M('logs').where("type=? and strftime('%m-%d','now','localtime') = strftime('%m-%d',addtime)", (u'消息推送',))\ .order('id desc').limit(str(page.SHIFT) + ',' + str(page.ROW)).field('log,addtime').select() return data
def get_logs(OOOOOO0O00OO00OO0, O00OOO0O0OO0O00OO): #line:262 import page #line:263 page = page.Page() #line:264 OOOO0O000OO0OO00O = public.M('logs').where( 'type=? or type=?', (OOOOOO0O00OO00OO0.__O0O0O0O00O0O0OO00, u'SSH登录')).count() #line:265 OOOOOO000O0O0OO0O = 12 #line:266 O0O00000O000O0OO0 = {} #line:267 O0O00000O000O0OO0['count'] = OOOO0O000OO0OO00O #line:268 O0O00000O000O0OO0['row'] = OOOOOO000O0O0OO0O #line:269 O0O00000O000O0OO0['p'] = 1 #line:270 if hasattr(O00OOO0O0OO0O00OO, 'p'): #line:271 O0O00000O000O0OO0['p'] = int(O00OOO0O0OO0O00OO['p']) #line:272 O0O00000O000O0OO0['uri'] = {} #line:273 O0O00000O000O0OO0['return_js'] = '' #line:274 if hasattr(O00OOO0O0OO0O00OO, 'tojs'): #line:275 O0O00000O000O0OO0['return_js'] = O00OOO0O0OO0O00OO.tojs #line:276 OOO0O0000000OOO00 = {} #line:277 OOO0O0000000OOO00['page'] = page.GetPage(O0O00000O000O0OO0, '1,2,3,4,5') #line:278 OOO0O0000000OOO00['data'] = public.M('logs').where( 'type=? or type=?', (OOOOOO0O00OO00OO0.__O0O0O0O00O0O0OO00, u'SSH登录')).order( 'id desc').limit(str(page.SHIFT) + ',' + str(page.ROW)).field('log,addtime').select() #line:279 return OOO0O0000000OOO00
def get_replace_logs(self, get): import page page = page.Page() count = public.M('panel_search_log').order('id desc').count() limit = 12 info = {} info['count'] = count info['row'] = limit info['p'] = 1 if hasattr(get, 'p'): info['p'] = int(get['p']) info['uri'] = get info['return_js'] = '' if hasattr(get, 'tojs'): info['return_js'] = get.tojs data = {} data['page'] = page.GetPage(info, '1,2,3,4,5,8') data['data'] = public.M('panel_search_log').field( 'id,rtext,exts,path,mode,isword,iscase,noword,backup_path,time' ).order('id desc').limit(str(page.SHIFT) + ',' + str(page.ROW)).select() if isinstance(data['data'], str): return public.returnMsg(False, []) for i in data['data']: if not isinstance(i, dict): continue if 'backup_path' in i: path = i['backup_path'] if os.path.exists(path): i['is_path_status'] = True else: i['is_path_status'] = False return public.returnMsg(True, data)
def get_ssh_login_logs(O00OO0O0O000O0OO0, O0O0000OO0OOOO0OO): #line:182 import page #line:183 page = page.Page() #line:184 O00O0OOOOOO0O0O0O = public.M('logs').where('type=?', (u'SSH登录', )).count() #line:185 OO000O0OOO0O000O0 = 12 #line:186 OO0O000O0O000OOOO = {} #line:187 OO0O000O0O000OOOO['count'] = O00O0OOOOOO0O0O0O #line:188 OO0O000O0O000OOOO['row'] = OO000O0OOO0O000O0 #line:189 OO0O000O0O000OOOO['p'] = 1 #line:190 if hasattr(O0O0000OO0OOOO0OO, 'p'): #line:191 OO0O000O0O000OOOO['p'] = int(O0O0000OO0OOOO0OO['p']) #line:192 OO0O000O0O000OOOO['uri'] = {} #line:193 OO0O000O0O000OOOO['return_js'] = '' #line:194 if hasattr(O0O0000OO0OOOO0OO, 'tojs'): #line:195 OO0O000O0O000OOOO['return_js'] = O0O0000OO0OOOO0OO.tojs #line:196 OOOO0O00O0O00O00O = {} #line:197 OOOO0O00O0O00O00O['page'] = page.GetPage(OO0O000O0O000OOOO, '1,2,3,4,5') #line:198 OOOO0O00O0O00O00O['data'] = public.M('logs').where( 'type=?', (u'SSH登录', )).order('id desc').limit( str(page.SHIFT) + ',' + str(page.ROW)).field('log,addtime').select() #line:199 return OOOO0O00O0O00O00O
def GetSql(self,get,result = '1,2,3,4,5,8'): #判断前端是否传入参数 order = "id desc" if hasattr(get,'order'): order = get.order limit = 20 if hasattr(get,'limit'): limit = int(get.limit) if hasattr(get,'result'): result = get.result; data = {} #取查询条件 where = '' if hasattr(get,'search'): where = self.GetWhere(get.table,get.search); if get.table == 'backup': where += " and type='" + get.type+"'"; field = self.GetField(get.table) #实例化数据库对象 SQL = db.Sql(); #是否直接返回所有列表 if hasattr(get,'list'): data = SQL.table(get.table).where(where,()).field(field).order(order).select() return data #取总行数 count = SQL.table(get.table).where(where,()).count(); #get.uri = get #包含分页类 import page #实例化分页类 page = page.Page(); del(get.data) del(get.zunfile) info = {} info['count'] = count info['row'] = limit info['p'] = 1 if hasattr(get,'p'): info['p'] = int(get['p']) info['uri'] = get info['return_js'] = '' if hasattr(get,'tojs'): info['return_js'] = get.tojs data['where'] = where; #获取分页数据 data['page'] = page.GetPage(info,result) #取出数据 data['data'] = SQL.table(get.table).where(where,()).order(order).field(field).limit(bytes(page.SHIFT)+','+bytes(page.ROW)).select() return data;
def get_page(count, p=1, rows=12, callback='', result='1,2,3,4,5,8'): import page page = page.Page() info = { 'count': count, 'row': rows, 'p': p, 'return_js': callback, 'uri': '' } data = { 'page': page.GetPage(info, result), 'shift': str(page.SHIFT), 'row': str(page.ROW) } return data
def get_logs(self,get): import page page = page.Page(); count = public.M('logs').where('type=?',(u'防篡改程序',)).count(); limit = 12; info = {} info['count'] = count info['row'] = limit info['p'] = 1 if hasattr(get,'p'): info['p'] = int(get['p']) info['uri'] = {} info['return_js'] = '' if hasattr(get,'tojs'): info['return_js'] = get.tojs data = {} data['page'] = page.GetPage(info,'1,2,3,4,5'); data['data'] = public.M('logs').where('type=?',(u'防篡改程序',)).order('id desc').limit(str(page.SHIFT)+','+str(page.ROW)).field('log,addtime').select(); return data;
def getPageObject(args, result='1,2,3,4,5,8'): # 取分页 import page # 实例化分页类 page = page.Page() info = {} info['count'] = 0 if 'count' in args: info['count'] = int(args['count']) info['row'] = 10 if 'row' in args: info['row'] = int(args['row']) info['p'] = 1 if 'p' in args: info['p'] = int(args['p']) info['uri'] = {} info['return_js'] = '' if 'tojs' in args: info['return_js'] = args['tojs'] return (page.GetPage(info, result), page)
def get_logs(self, get): import page page = page.Page() count = public.M('logs').where('type=?', (u'负载均衡', )).count() limit = 11 info = {} info['count'] = count info['row'] = limit info['p'] = 1 if hasattr(get, 'p'): info['p'] = int(get['p']) info['uri'] = get info['return_js'] = '' if hasattr(get, 'tojs'): info['return_js'] = get.tojs data = {} # 获取分页数据 data['page'] = page.GetPage(info, '1,2,3,4,5,8') data['data'] = public.M('logs').where('type=?', (u'负载均衡', )).order( 'id desc').limit(bytes(page.SHIFT) + ',' + bytes(page.ROW)).field('log,addtime').select() return data
def GetDir(self, get): if not hasattr(get, 'path'): get.path = '/www/wwwroot' if sys.version_info[0] == 2: get.path = get.path.encode('utf-8') if not os.path.exists(get.path): get.path = '/www' import pwd dirnames = [] filenames = [] search = None if hasattr(get, 'search'): search = get.search.strip().lower() if hasattr(get, 'all'): return self.SearchFiles(get) #包含分页类 import page #实例化分页类 page = page.Page() info = {} info['count'] = self.GetFilesCount(get.path, search) info['row'] = 100 info['p'] = 1 if hasattr(get, 'p'): try: info['p'] = int(get['p']) except: info['p'] = 1 info['uri'] = {} info['return_js'] = '' if hasattr(get, 'tojs'): info['return_js'] = get.tojs if hasattr(get, 'showRow'): info['row'] = int(get.showRow) #获取分页数据 data = {} data['PAGE'] = page.GetPage(info, '1,2,3,4,5,6,7,8') i = 0 n = 0 for filename in os.listdir(get.path): if search: if filename.lower().find(search) == -1: continue i += 1 if n >= page.ROW: break if i < page.SHIFT: continue try: if sys.version_info[0] == 2: filename = filename.encode('utf-8') filePath = get.path + '/' + filename link = '' if os.path.islink(filePath): filePath = os.readlink(filePath) link = ' -> ' + filePath if not os.path.exists(filePath): filePath = get.path + '/' + filePath if not os.path.exists(filePath): continue stat = os.stat(filePath) accept = str(oct(stat.st_mode)[-3:]) mtime = str(int(stat.st_mtime)) user = '' try: user = pwd.getpwuid(stat.st_uid).pw_name except: user = str(stat.st_uid) size = str(stat.st_size) if os.path.isdir(filePath): dirnames.append(filename + ';' + size + ';' + mtime + ';' + accept + ';' + user + ';' + link) else: filenames.append(filename + ';' + size + ';' + mtime + ';' + accept + ';' + user + ';' + link) n += 1 except: continue data['DIR'] = sorted(dirnames) data['FILES'] = sorted(filenames) data['PATH'] = str(get.path) if hasattr(get, 'disk'): import system data['DISK'] = system.system().GetDiskInfo() return data
def GetSql(self, get, result='1,2,3,4,5,8'): #判断前端是否传入参数 order = "id desc" if hasattr(get, 'order'): order = get.order limit = 20 if hasattr(get, 'limit'): limit = int(get.limit) if hasattr(get, 'result'): result = get.result SQL = db.Sql() data = {} #取查询条件 where = '' if hasattr(get, 'search'): if sys.version_info[0] == 2: get.search = get.search.encode('utf-8') where = self.GetWhere(get.table, get.search) if get.table == 'backup': where += " and type='" + get.type + "'" if get.table == 'sites' and get.search: pid = SQL.table('domain').where( "name LIKE '%" + get.search + "%'", ()).getField('pid') if pid: if where: where += " or id=" + str(pid) else: where += "id=" + str(pid) if get.table == 'sites' and hasattr(get, 'type'): if get.type != '-1': type_where = "type_id=%s" % get.type if where == '': where = type_where else: where += " and " + type_where field = self.GetField(get.table) #实例化数据库对象 #是否直接返回所有列表 if hasattr(get, 'list'): data = SQL.table(get.table).where( where, ()).field(field).order(order).select() return data #取总行数 count = SQL.table(get.table).where(where, ()).count() #get.uri = get #包含分页类 import page #实例化分页类 page = page.Page() info = {} info['count'] = count info['row'] = limit info['p'] = 1 if hasattr(get, 'p'): info['p'] = int(get['p']) info['uri'] = get info['return_js'] = '' if hasattr(get, 'tojs'): info['return_js'] = get.tojs data['where'] = where #获取分页数据 data['page'] = page.GetPage(info, result) #取出数据 data['data'] = SQL.table(get.table).where( where, ()).order(order).field(field).limit( str(page.SHIFT) + ',' + str(page.ROW)).select() return data
def GetDir(self,get): if not hasattr(get,'path'): #return public.returnMsg(False,'错误的参数!') get.path = '/www/wwwroot' if sys.version_info[0] == 2: get.path = get.path.encode('utf-8'); if get.path == '': get.path = '/www'; if not os.path.exists(get.path): return public.ReturnMsg(False,'指定目录不存在!') import pwd dirnames = [] filenames = [] search = None if hasattr(get,'search'): search = get.search.strip().lower(); if hasattr(get,'all'): return self.SearchFiles(get) #包含分页类 import page #实例化分页类 page = page.Page(); info = {} info['count'] = self.GetFilesCount(get.path,search); info['row'] = 100 info['p'] = 1 if hasattr(get,'p'): try: info['p'] = int(get['p']) except: info['p'] = 1 info['uri'] = {} info['return_js'] = '' if hasattr(get,'tojs'): info['return_js'] = get.tojs if hasattr(get,'showRow'): info['row'] = int(get.showRow); #获取分页数据 data = {} data['PAGE'] = page.GetPage(info,'1,2,3,4,5,6,7,8') i = 0; n = 0; if not hasattr(get,'reverse'): for filename in os.listdir(get.path): filename = self.xssencode(filename) if search: if filename.lower().find(search) == -1: continue; i += 1; if n >= page.ROW: break; if i < page.SHIFT: continue; try: if sys.version_info[0] == 2: filename = filename.encode('utf-8'); filePath = get.path+'/'+filename link = ''; if os.path.islink(filePath): filePath = os.readlink(filePath); link = ' -> ' + filePath; if not os.path.exists(filePath): filePath = get.path + '/' + filePath; if not os.path.exists(filePath): continue; stat = os.stat(filePath) accept = str(oct(stat.st_mode)[-3:]); mtime = str(int(stat.st_mtime)) user = '' try: user = pwd.getpwuid(stat.st_uid).pw_name except: user = str(stat.st_uid) size = str(stat.st_size) if os.path.isdir(filePath): dirnames.append(filename+';'+size+';'+mtime+';'+accept+';'+user+';'+link); else: filenames.append(filename+';'+size+';'+mtime+';'+accept+';'+user+';'+link); n += 1; except: continue; data['DIR'] = sorted(dirnames); data['FILES'] = sorted(filenames); else: reverse = bool(get.reverse) if get.reverse == 'False': reverse = False for file_info in self.__list_dir(get.path,get.sort,reverse): filename = os.path.join(get.path,file_info['name']) if not os.path.exists(filename): continue if search: if file_info['name'].lower().find(search) == -1: continue; i += 1; if n >= page.ROW: break; if i < page.SHIFT: continue; r_file = file_info['name'] + ';' + str(file_info['size']) + ';' + str(file_info['mtime']) + ';' + str(file_info['accept']) + ';' + file_info['user']+ ';' + file_info['link'] if os.path.isdir(filename): dirnames.append(r_file) else: filenames.append(r_file) n += 1; data['DIR'] = dirnames data['FILES'] = filenames data['PATH'] = str(get.path) if hasattr(get,'disk'): import system data['DISK'] = system.system().GetDiskInfo(); return data
def GetDir(self,get): get.path = get.path.encode('utf-8'); if not os.path.exists(get.path): get.path = '/www'; import pwd dirnames = [] filenames = [] search = None if hasattr(get,'search'): search = get.search.strip().lower(); #包含分页类 import page #实例化分页类 page = page.Page(); info = {} info['count'] = self.GetFilesCount(get.path,search); info['row'] = 100 info['p'] = 1 if hasattr(get,'p'): info['p'] = int(get['p']) info['uri'] = {} info['return_js'] = '' if hasattr(get,'tojs'): info['return_js'] = get.tojs if hasattr(get,'showRow'): info['row'] = int(get.showRow); #获取分页数据 data = {} data['PAGE'] = page.GetPage(info,'1,2,3,4,5,6,7,8') i = 0; n = 0; for filename in os.listdir(get.path): if search: if filename.lower().find(search) == -1: continue; i += 1; if n >= page.ROW: break; if i < page.SHIFT: continue; try: filePath = (get.path+'/'+filename).encode('utf8') link = ''; if os.path.islink(filePath): filePath = os.readlink(filePath); link = ' -> ' + filePath; if not os.path.exists(filePath): filePath = get.path + '/' + filePath; if not os.path.exists(filePath): continue; stat = os.stat(filePath) accept = str(oct(stat.st_mode)[-3:]); mtime = str(int(stat.st_mtime)) user = '' try: user = pwd.getpwuid(stat.st_uid).pw_name except: user = str(stat.st_uid) size = str(stat.st_size) if os.path.isdir(filePath): dirnames.append(filename+';'+size+';'+mtime+';'+accept+';'+user+';'+link); else: filenames.append(filename+';'+size+';'+mtime+';'+accept+';'+user+';'+link); n += 1; except: continue; data['DIR'] = sorted(dirnames); data['FILES'] = sorted(filenames); data['PATH'] = get.path if hasattr(get,'disk'): import system data['DISK'] = system.system().GetDiskInfo(); return data