def code(request): code = Code(request) #code.img_width = 83 #code.img_height = 30 #code.font_color = ['black','darkblue','darkred'] font_size = 30 return code.display()
def process_request(self,request): if request.path == self.verify_code_uri: code = Code(request) code.type = 'number' return code.display() elif request.path == self.verify_page_uri: return render('verify.html',locals(),context_instance=RequestContext(request)) elif request.path == self.verify_check_uri: code = Code(request) _code = request.REQUEST.get('verify','') # 检查用户输入的验证码是否正确 if not code.check(_code): next = self.verify_page_uri else: request.session['post_times'] = 0 request.session['post_stamp'] = time.time() next = request.session.get('next','/') return HttpResponseRedirect(next) if not request.path in self.expaths: timer = time.time() - request.session.get('post_stamp',0) post_times = request.session.get('post_times',0) # 提交次数是否大于单位时间的最大值 if request.method == 'POST': if post_times >= 4: request.session['next'] = request.META.get('HTTP_REFERER','/') # backup data for k,v in request.POST.items(): k = 'backup_{}'.format(k) try: request.session[k] = v except: pass return HttpResponseRedirect(self.verify_page_uri) elif timer >= 60: request.session['post_times'] = 0 request.session['post_stamp'] = time.time() request.session['post_times'] = request.session['post_times']+1 request.session.save()
def process_request(self, request): if request.path == self.verify_code_uri: code = Code(request) code.type = 'number' return code.display() elif request.path == self.verify_page_uri: return render('verify.html', locals(), context_instance=RequestContext(request)) elif request.path == self.verify_check_uri: code = Code(request) _code = request.REQUEST.get('verify', '') print 'request', request.REQUEST # 检查用户输入的验证码是否正确 if not code.check(_code): next = self.verify_page_uri else: request.session['post_times'] = 0 request.session['post_stamp'] = time.time() next = request.session.get('next', '/') return HttpResponseRedirect(next) if not request.path in self.expaths: timer = time.time() - request.session.get('post_stamp', 0) post_times = request.session.get('post_times', 0) # 提交次数是否大于单位时间的最大值 if request.method == 'POST': if post_times >= 3: request.session['next'] = request.META.get( 'HTTP_REFERER', '/') return HttpResponseRedirect(self.verify_page_uri) elif timer >= 60: request.session['post_times'] = 0 request.session['post_stamp'] = time.time() request.session[ 'post_times'] = request.session['post_times'] + 1 request.session.save()
def code(request): code = Code(request) code.worlds = ['hello','world','helloworld'] #code.type = 'world' code.type = 'number' return code.display()
def code(request): code=Code(request) return code.display()
def captcha( request ): code = Code(request) code.type = 'number' code.img_width = 120 code.img_height = 70 return code.display()
def verify_code(request): code = Code(request) code.type = 'number' return code.display()
def code(request): code = Code(request) code.worlds = ['hello', 'world', 'helloworld'] #code.type = 'world' code.type = 'number' return code.display()
def code(request): code = Code(request) return code.display()