def timing(): """ 定时执行 """ #获取日期 servers = get_gs_from_db() day = public.get_yesterday(days=1) for server in servers: print server try: #下载充值数据库 download_pay_log(server,day) #写玩家付费信息 write_payer_info(server, day, day) except: public.print_str('serverid [%s] \t %r'%(server.get('svrid','0'),tb.format_exc()))
def login(request): """ 入口 """ if DEBUG: print 'HTTP_HOST:', request.META['HTTP_HOST'] public.print_str('login') public.print_str('------- request.user: %s' % request.user) public.print_str('------- request.user.username: %s' % request.user.username) if DEBUG: print 'request.method: ', request.method if request.method == 'GET': pre_path = request.get_full_path() if DEBUG: print 'GET pre_path: ', pre_path if pre_path in ['/login/', '/quity/']: pre_path = DEFAULT_LOGIN_PATH if request.user.is_authenticated(): return HttpResponseRedirect(pre_path) content = { 'form_action': '/login/', 'glocale': glocale, 'pre_path': pre_path } content.update(csrf(request)) return render_to_response(LOGIN_PAGE, content) elif request.method == 'POST': pre_path = request.POST.get('pre_path') msg = register.login(request) if msg.get('status', 1) == 0: if not request.user.has_perm('auth.view_web'): register.logout(request) return HttpResponseForbidden() if pre_path is None: pre_path = DEFAULT_LOGIN_PATH if DEBUG: print 'POST pre_path: ', pre_path return HttpResponseRedirect(pre_path) else: content = { 'tips': msg.get('tips', glocale.LN_UID_NAME_ERROR), 'form_action': '/login/', 'glocale': glocale, 'pre_path': pre_path } content.update(csrf(request)) return render_to_response(LOGIN_PAGE, content, context_instance=RequestContext(request)) else: return HttpResponseServerError()
def alter_password(request): """ 修改密码 """ if DEBUG: print 'HTTP_HOST:', request.META['HTTP_HOST'] public.print_str('login') public.print_str('------- request.user: %s' % request.user) public.print_str('------- request.user.username: %s' % request.user.username) content = { 'data_title': glocale.LN_ALTER_PASSWORD, 'form_action': '/alter_password/', } if request.method == 'GET': pre_path = request.get_full_path() if pre_path == '/alter_password/': pre_path = DEFAULT_LOGIN_PATH if request.user.is_authenticated(): return HttpResponseRedirect(pre_path) content['pre_path'] = pre_path content.update(csrf(request)) return render_to_response(ALTER_PAGE, content) elif request.method == 'POST': pre_path = request.POST.get('pre_path') msg = register.alter(request) if msg.get('status', 1) == 0: if not request.user.has_perm('auth.view_web'): register.logout(request) return HttpResponseForbidden() if pre_path is None: pre_path = DEFAULT_LOGIN_PATH return HttpResponseRedirect(pre_path) else: content.update({ 'tips': msg.get('tips', glocale.LN_FAIL), 'pre_path': pre_path }) content.update(csrf(request)) return render_to_response(ALTER_PAGE, content, context_instance=RequestContext(request)) else: return HttpResponseServerError()
def parameters(request,pid='',localeid='',sheetid=''): #分发 try: if request.GET.get('reqmode') != 'js': #检查是否登录not request.user.is_authenticated(): if not request.user.is_authenticated(): return param_main.entrance(request) #如果没有权限访问该网站,则直接踢出去 if not request.user.has_perm('auth.view_web'): logout(request) return HttpResponseForbidden() public.print_str('parameters') public.print_str('------- request.user: %s'%request.user) public.print_str('------- request.user.username: %s'%request.user.username) if public.objIsEmpty(pid) or public.objIsEmpty(localeid): return param_main.choose_param(request) return param_main.param_main_response(request,pid,localeid,sheetid) except: print '%r'%tb.format_exc() return HttpResponseServerError()