Esempio n. 1
0
 def add_servers_ip(self):
     # 超过N个角色后封禁账号IP,这个N是从banip_list的f2来的
     server_list = Server.get_server_list()
     count = int(BanIpList.objects.filter(id=1)[0].f2) or 0
     if not count:
         print u'没有设定超过数'
         return
     for s in server_list:
         player_ip_list = self.get_player_list(s.id, count)
         if not player_ip_list:
             continue
         for i in player_ip_list:
             _bm = BanIpList.objects.filter(ip=i[0])
             if not _bm:
                 model = BanIpList()
                 model.username = i[2]
                 model.ip = i[0]
                 model.last_time = datetime.datetime.now()
                 model.f1 = 0
                 model.f2 = i[1]
                 model.status = 0
                 model.save(using="write")
                 continue
             _bm = _bm[0]
             _ip = _bm.ip
             _bm.f2 = i[1]
             _bm.last_time = datetime.datetime.now()
             _bm.save(using="write")
Esempio n. 2
0
def log_server(request, log_id=0):
    if log_id > 0 :
        log_def = LogDefine.objects.get(id=log_id)
    
    list_server = Server.get_server_list()
    
    parg = {}
    parg["list_server"] = list_server
    parg["log_def"] = log_def
    
    return render_to_response('log/log_server.html', parg)
Esempio n. 3
0
def sync_log_index(request, server_id=0):
    if server_id == 0:
        server_id = int(request.GET.get('server_id', '0'))
    
    log_list = []
    server_list = []
    if server_id == 0:
        log_list = LogDefine.objects.filter(status = LogDefine.Status.CENTER)
    else:
        server_list = Server.get_server_list()
        log_list = LogDefine.objects.filter(status = LogDefine.Status.NORMAL)
        
    return render_to_response('log/sync_log_index.html', {"server_id": server_id, "log_list": log_list, "server_list":server_list})
Esempio n. 4
0
def server_make(request):
    list_group = Group.objects.using('read').all()
    # folderPath = os.path.abspath(os.path.join(STATIC_ROOT, 'server'))
    folderPath = os.path.abspath(os.path.join(STATIC_PATH, 'server'))
    _folderPath = os.path.abspath(
        os.path.join(STATIC_ROOT, 'client', 'static', 'server'))
    if not os.path.exists(folderPath):
        os.mkdir(folderPath)
    #     # clear old file
    # for file_item in os.listdir(folderPath):
    #     try:
    #         itemsrc = os.path.join(folderPath, file_item)
    #         if os.path.isfile(itemsrc):
    #             os.remove(itemsrc)
    #     except:
    #         pass

    list_server = Server.get_server_list()

    serverList = []
    for item in list_server:
        mongo_port = 27017
        db_address = ''
        if item.log_db_config != '':
            try:
                db_config = json.loads(item.log_db_config)
            except:
                continue
            mongo_port = int(db_config.get('mongo_port', '') or 27017)
            db_address = db_config.get('db_addr', item.game_addr)

        if None != item.report_url and '' != item.report_url:
            item.report_url = item.report_url.replace('http://', '')
            item.report_url = item.report_url.replace('/', '')

        name = item.name
        game_addr = item.game_addr
        game_addr = game_addr.replace('"', '\\"')
        name = name.replace('"', '\\"')
        # item_json = u'{"id":%d,"name":"%s","alias":"%s","address":"%s","db_address": "%s","gate_port":%d,"db_port":%d,"status":%d,"battle_report_url":"%s"}' % (
        #     item.id, name, item.alias, game_addr, db_address, item.game_port, mongo_port, item.status, item.report_url)
        item_json = u'{"id":%d,"name":"%s","alias":"%s","address":"%s","db_address": "%s","gate_port":%d,"db_port":%d,"status":%d}' % (
            item.id, name, item.alias, game_addr, db_address, item.game_port,
            mongo_port, item.status)
        try:
            json.loads(item_json)
        except Exception, ex:
            print ex, item_json
            return render_to_response('feedback.html',
                                      {"err_msg": "服务器ID:%s配置错误" % name})
        serverList.append(item_json)
Esempio n. 5
0
def table_info(request):
    
    log_id = int(request.GET.get('log_id', '0'))
    server_id = int(request.GET.get('server_id', '0'))
    
    if 0 == server_id:
        server_id = int(request.POST.get('server_id', '0'))
    
    log_list = []
    if 0 == server_id:
        log_list = LogDefine.objects.filter(status = LogDefine.Status.CENTER).all()
    else:
        log_list = LogDefine.objects.filter(status = LogDefine.Status.NORMAL).all()
    
    server_list = Server.get_server_list()
    
    parg = {}
    
    if 0 != log_id and -1 != server_id:
        if 0 == LogDefine.objects.filter(id = log_id).count():
            return HttpResponse('请选择日志表')
        
        log_def = None
        for item in log_list:
            if item.id == log_id:
                log_def = item
        
        if None == log_def:
            return HttpResponse('请选择日志表')
        
        query_sql = 'show index from log_%s' %  log_def.key
        conn = conn_switch(server_id)
        cursor = conn.cursor()
        cursor.execute(query_sql) 
        list_data = cursor.fetchall()
        #raise Exception, query_sql
        conn.close()
        
        parg['log_def'] = log_def
        parg['list_data'] = list_data
    
    parg['log_id'] = log_id
    parg['log_list'] = log_list
    parg['server_list'] = server_list
    parg['server_id'] = server_id
    
    return render_to_response('log/table_info.html', parg)