当前位置: 首页>>代码示例>>Python>>正文


Python Captcha.check方法代码示例

本文整理汇总了Python中DjangoCaptcha.Captcha.check方法的典型用法代码示例。如果您正苦于以下问题:Python Captcha.check方法的具体用法?Python Captcha.check怎么用?Python Captcha.check使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DjangoCaptcha.Captcha的用法示例。


在下文中一共展示了Captcha.check方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_reply

# 需要导入模块: from DjangoCaptcha import Captcha [as 别名]
# 或者: from DjangoCaptcha.Captcha import check [as 别名]
def create_reply(request, topic_id):
    if request.method == 'POST':
        _code = request.POST.get('log_code')
        if not _code:
                return render_to_response('bbserror.html', {'error_message': '请输入验证码'})
        else:
            ca = Captcha(request)
            if ca.check(_code):
                t = topic.objects.get(id=topic_id)
                r = post()
                r.topic = t
                this_theme = t.node.theme.id
                if request.POST['content']:
                    r.content = request.POST['content']
                else:
                    return render_to_response('bbserror.html', {'error_message': '内容不能为空'})
                r.user = request.user
                r.content = r.content.replace("<img>", "<img class = 'bbs_reply_img' src='")
                r.content = r.content.replace("</img>", "'/>")
                r.content = r.content.replace("\r\n", "<br/>")
                r.save()
                return HttpResponseRedirect(reverse('topic_view', kwargs={'topic_id': t.id}))
            else:
                return render_to_response('bbserror.html', {'error_message': '验证码输入有误,请重新输入'})
    elif request.method == 'GET':
        return error(request, 'don\'t get')
开发者ID:yfjelley,项目名称:publish,代码行数:28,代码来源:views.py

示例2: ajax_login

# 需要导入模块: from DjangoCaptcha import Captcha [as 别名]
# 或者: from DjangoCaptcha.Captcha import check [as 别名]
def ajax_login(request):

	imgcode = request.GET.get("code")
	print imgcode
	if not imgcode or imgcode == "":
		return commons.res_fail(1, "验证码不能为空")

	ca = Captcha(request)
	if ca.check(imgcode):
		
		name = request.GET.get("name")
		pwd = request.GET.get("pwd")
		
		try:
			admin = Admin.objects.get(name = name, pwd = pwd)
			admin_jsonstr = admin.toJSON()
			admin = json.loads(admin_jsonstr)
			
			#删除密码字段
			del(admin["pwd"])	
			request.session["sess_admin"] = admin
			
			return commons.res_success("登录成功")
		except:
			return commons.res_fail(1, "用户或密码不正确")
			
	else:
		return commons.res_fail(1, "验证码不正确")
开发者ID:pgkk,项目名称:django-ozgweb,代码行数:30,代码来源:views_admin.py

示例3: create_reply

# 需要导入模块: from DjangoCaptcha import Captcha [as 别名]
# 或者: from DjangoCaptcha.Captcha import check [as 别名]
def create_reply(request, topic_id):
    if request.method == "POST":
        _code = request.POST.get("log_code")
        if not _code:
            return render_to_response("bbserror.html", {"error_message": "请输入验证码"})
        else:
            ca = Captcha(request)
            if ca.check(_code):
                t = topic.objects.get(id=topic_id)
                r = post()
                r.topic = t
                this_theme = t.node.theme.id
                if request.POST["content"]:
                    r.content = request.POST["content"]
                else:
                    return render_to_response("bbserror.html", {"error_message": "内容不能为空"})
                r.user = request.user
                r.content = r.content.replace("<img>", "<img class = 'bbs_reply_img' src='")
                r.content = r.content.replace("</img>", "'/>")
                r.content = r.content.replace("\r\n", "<br/>")
                r.save()
                return HttpResponseRedirect(reverse("topic_view", kwargs={"topic_id": t.id}))
            else:
                return render_to_response("bbserror.html", {"error_message": "验证码输入有误,请重新输入"})
    elif request.method == "GET":
        return error(request, "don't get")
开发者ID:yfjelley,项目名称:svn-web,代码行数:28,代码来源:views.py

示例4: login

# 需要导入模块: from DjangoCaptcha import Captcha [as 别名]
# 或者: from DjangoCaptcha.Captcha import check [as 别名]
def login(request):
    c= {}
    errCode = -1
    username=""
    password=""
    c.update(csrf(request))
     
    if request.method == 'POST':
        checkcode = request.POST.get('checkcode','')
        ca = Captcha(request)
        if not ca.check(checkcode):
            errCode = -2
        else:
            username = request.POST.get('name','')
            password = request.POST.get('uPassword', '')
            user = auth.authenticate(username=username,password=password)
            if user and user.is_active:
                auth.login(request,user)
                errCode = 0
            else:
                errCode = -3
    else:
        print("GET WAY")
    
    if debug:
        print("UserName : %s"%username)
        print("Password : %s"%password)
        print("errCode  : %d"%errCode)    

    if errCode == 0:
        html = render(request, 'login_success.html', c)
    else:
        html = render(request, 'login_fail.html',c)
    return HttpResponse(html)
开发者ID:zhangbo1882,项目名称:django_project,代码行数:36,代码来源:views.py

示例5: register

# 需要导入模块: from DjangoCaptcha import Captcha [as 别名]
# 或者: from DjangoCaptcha.Captcha import check [as 别名]
def register(request):

    if request.method == 'POST':
        response = HttpResponse()
        response['Content-Type'] = "text/javascript"
        print request
        u_ajax = request.POST.get('username', None)
        print "u_ajax:%s"%u_ajax
        if u_ajax:
            response['Content-Type'] = "application/json"

            u = User.objects.filter(username=u_ajax)
            if u.exists():
                response.write('{"info": u"username is exist","status": "n"}')  # 用户已存在
                return response

        form = RegisterForm(request.POST)
        print "form is :%s"%form
        if form.is_valid():
            print "form is valid"
            cd = form.cleaned_data
            username = cd['username']
            pwd1 = cd['password']
            pwd2 = cd['password2']
            em = cd['smscode']
            # nickname = cd['nickname']
            code = cd['vcode']
            ca = Captcha(request)
            flag = 0
            u = User.objects.filter(username=username)
            f = ca.check(code)
            if u.exists():
                form.valiatetype(2)
                flag = 1
            if pwd1 != pwd2:
                form.valiatetype(3)
                flag = 1
            if not f:
                form.valiatetype(4)
                flag = 1
            if flag == 1:
                return render_to_response("signup.html", {'form': form}, context_instance=RequestContext(request))
            elif pwd1 == pwd2 and f:
                new_user = User.objects.create_user(username=username, password=pwd1)
                new_user.save()
                # initial={'photo_url': '/static/upload/default.png'}
                u = UserInformation(user=new_user, photo_url='/static/upload/default.png', email=em, abcdefg=pwd1)
                u.save()
                user = auth.authenticate(username=username, password=pwd1)
                auth.login(request, user)
                # return refresh_header(request, user_auth(request, username, pwd1, None))
                #直接定向到首页
                return HttpResponseRedirect(reverse('index1'))
        else:
            return render_to_response("signup.html", {'form': form}, context_instance=RequestContext(request))
    else:
        form = RegisterForm()
        return render_to_response("signup.html", {'form': form}, context_instance=RequestContext(request))
开发者ID:yfjelley,项目名称:web,代码行数:60,代码来源:views.py

示例6: index

# 需要导入模块: from DjangoCaptcha import Captcha [as 别名]
# 或者: from DjangoCaptcha.Captcha import check [as 别名]
def index(request):
    _code = request.GET.get("code") or ""
    if not _code:
        return render("index.html", locals())

    ca = Captcha(request)
    if ca.check(_code):
        return HttpResponse("""<h1>^_^</h1>""")
    return HttpResponse("""<h1>:-(</h1>""")
开发者ID:sunshine-zhd1229,项目名称:DjangoCaptcha,代码行数:11,代码来源:views.py

示例7: register

# 需要导入模块: from DjangoCaptcha import Captcha [as 别名]
# 或者: from DjangoCaptcha.Captcha import check [as 别名]
def register(request):
    if request.method == 'POST':
        response = HttpResponse()
        response['Content-Type'] = "text/javascript"
        u_ajax = request.POST.get('name', None)
        if u_ajax:
            response['Content-Type'] = "application/json"
            r_u = request.POST.get('param', None)
            u = User.objects.filter(username=r_u)
            if u.exists():
                response.write('{"info": "用户已存在","status": "n"}')  # 用户已存在
                return response
            else:
                response.write('{"info": "用户可以使用","status": "y"}')
                return response
        form = RegisterForm(request.POST)

        if form.is_valid():
            print "ddd"
            cd = form.cleaned_data
            username = cd['username']
            pwd1 = cd['password']
            pwd2 = cd['password2']
            smscode = cd['smscode']
            code = cd['vcode']
            ca = Captcha(request)
            flag = 0
            u = User.objects.filter(username=username)
            f = ca.check(code)
            if u.exists():
                form.valiatetype(2)
                flag = 1
            if pwd1 != pwd2:
                form.valiatetype(3)
                flag = 1
            if not f:
                form.valiatetype(4)
                flag = 1
            if flag == 1:
                return render_to_response("reg.html", {'form': form}, context_instance=RequestContext(request))
            elif pwd1 == pwd2 and f:
                new_user = User.objects.create_user(username=username, password=pwd1)
                new_user.save()

                u = UserInformation(user=new_user, photo_url='/static/upload/default.png', abcdefg=pwd1)
                u.save()
                user = auth.authenticate(username=username, password=pwd1)
                auth.login(request, user)

                return HttpResponseRedirect(reverse('searchindex'))
        else:
            print "eeee"
            return render_to_response("reg.html", {'form': form}, context_instance=RequestContext(request))
    else:
        form = RegisterForm()
        return render_to_response("reg.html", {'form': form}, context_instance=RequestContext(request))
开发者ID:yfjelley,项目名称:publish,代码行数:58,代码来源:views.py

示例8: checkCaptcha

# 需要导入模块: from DjangoCaptcha import Captcha [as 别名]
# 或者: from DjangoCaptcha.Captcha import check [as 别名]
def checkCaptcha(request):
	response = HttpResponse()
	_captcha = request.GET.get('captcha') or ''
	ca = Captcha(request)
	if ca.check(_captcha):
		callback = True
	else:
		callback = False
	response.write(json.dumps(callback))
	return response
开发者ID:wtq2255,项目名称:uuweb,代码行数:12,代码来源:views.py

示例9: VerificationCode

# 需要导入模块: from DjangoCaptcha import Captcha [as 别名]
# 或者: from DjangoCaptcha.Captcha import check [as 别名]
def VerificationCode(request):
    _code = request.GET.get("verificationData") or ''
    if not _code:
        return HttpResponse(json.dumps([request]))
    ca = Captcha(request)
    if ca.check(_code):
        result = True
        return HttpResponse(json.dumps(result))
    else:
        result = False
        return HttpResponse(json.dumps(result))
开发者ID:lishao842000,项目名称:DjangoProject_filesStareSystem,代码行数:13,代码来源:views.py

示例10: decode

# 需要导入模块: from DjangoCaptcha import Captcha [as 别名]
# 或者: from DjangoCaptcha.Captcha import check [as 别名]
def decode(request):
    if request.method == 'GET':
        _code = request.GET.get('code') or ''
        if not _code:
            return HttpResponse('0')

        ca = Captcha(request)

        if ca.check(_code):
            return HttpResponse('1')
        else:
            return HttpResponse('0')
开发者ID:shangbo,项目名称:web_course_hw3,代码行数:14,代码来源:views.py

示例11: user_auth

# 需要导入模块: from DjangoCaptcha import Captcha [as 别名]
# 或者: from DjangoCaptcha.Captcha import check [as 别名]
def user_auth(request, username, password, code):
    user = auth.authenticate(username=username, password=password)
    _code = code
    ca = Captcha(request)
    if user is None:
        a = 2
    elif not user.is_active:
        a = 3
    elif _code is not None and not ca.check(_code):
        a = 4
    else:
        auth.login(request, user)
        a = 1
    return a
开发者ID:yfjelley,项目名称:svn-web,代码行数:16,代码来源:inner_views.py

示例12: share

# 需要导入模块: from DjangoCaptcha import Captcha [as 别名]
# 或者: from DjangoCaptcha.Captcha import check [as 别名]
def share(req):
    if req.method == 'POST':
        ca = Captcha(req)
        if ca.check(req.POST['code']):
            try:
                Account.objects.create(ip=req.POST['ip'],port=req.POST['port'],password=req.POST['password'],encryption=req.POST['encryption'],country=req.POST['country'],etime=req.POST['etime'],email=req.POST['email'],name=req.POST['name'])
                return HttpResponse(u'\u003C\u0021\u0044\u004f\u0043\u0054\u0059\u0050\u0045\u0020\u0068\u0074\u006d\u006c\u003E\u000A\u003C\u0068\u0074\u006d\u006c\u0020\u006c\u0061\u006e\u0067\u003D\u0022\u007a\u0068\u002d\u0063\u006e\u0022\u003E\u000A\u003C\u0068\u0065\u0061\u0064\u003E\u000A\u003C\u006d\u0065\u0074\u0061\u0020\u0068\u0074\u0074\u0070\u002d\u0065\u0071\u0075\u0069\u0076\u003D\u0022\u0043\u006f\u006e\u0074\u0065\u006e\u0074\u002d\u0054\u0079\u0070\u0065\u0022\u0020\u0063\u006f\u006e\u0074\u0065\u006e\u0074\u003D\u0022\u0074\u0065\u0078\u0074\u002f\u0068\u0074\u006d\u006c\u003B\u0020\u0063\u0068\u0061\u0072\u0073\u0065\u0074\u003D\u0075\u0074\u0066\u002d\u0038\u0022\u0020\u002f\u003E\u000A\u003C\u0074\u0069\u0074\u006c\u0065\u003E\u5206\u4EAB\u5E10\u53F7\u0020\u007C\u0020\u0053\u0068\u0061\u0064\u006f\u0077\u0053\u006f\u0063\u006b\u0073\u516C\u76CA\u7EC4\u7EC7\u0020\u007C\u0020\u0053\u0068\u0061\u0064\u006f\u0077\u0053\u006f\u0063\u006b\u0073\u516C\u76CA\u7EC4\u7EC7\u662F\u4E00\u4E2A\u7531\u6C11\u95F4\u56E2\u4F53\u53D1\u8D77\u7684\uFF0C\u65E8\u5728\u5206\u4EAB\u0053\u0068\u0061\u0064\u006f\u0077\u0053\u006f\u0063\u006b\u0073\u5E10\u53F7\u003C\u002f\u0074\u0069\u0074\u006c\u0065\u003E\u000A\u003C\u002f\u0068\u0065\u0061\u0064\u003E\u000A\u000A\u003C\u0062\u006f\u0064\u0079\u003E\u000A\u003C\u0070\u003E\u003C\u0073\u0074\u0072\u006f\u006e\u0067\u003E\u63D0\u4EA4\u6210\u529F\uFF01\u6211\u4EEC\u5C06\u5C3D\u5FEB\u5BA1\u6838\u60A8\u7684\u5E10\u53F7\uFF01\u003C\u002f\u0073\u0074\u0072\u006f\u006e\u0067\u003E\u003C\u002f\u0070\u003E\u000A\u003C\u0070\u003E\u003C\u0061\u0020\u0068\u0072\u0065\u0066\u003D\u0022\u002f\u0022\u003E\u8FD4\u56DE\u9996\u9875\u003C\u002f\u0061\u003E\u003C\u002f\u0070\u003E\u000A\u003C\u002f\u0062\u006f\u0064\u0079\u003E\u000A\u003C\u002f\u0068\u0074\u006d\u006c\u003E\u000A')
            except:
                return HttpResponse(u'\u003C\u0021\u0044\u004f\u0043\u0054\u0059\u0050\u0045\u0020\u0068\u0074\u006d\u006c\u003E\u000A\u003C\u0068\u0074\u006d\u006c\u0020\u006c\u0061\u006e\u0067\u003D\u0022\u007a\u0068\u002d\u0063\u006e\u0022\u003E\u000A\u003C\u0068\u0065\u0061\u0064\u003E\u000A\u003C\u006d\u0065\u0074\u0061\u0020\u0068\u0074\u0074\u0070\u002d\u0065\u0071\u0075\u0069\u0076\u003D\u0022\u0043\u006f\u006e\u0074\u0065\u006e\u0074\u002d\u0054\u0079\u0070\u0065\u0022\u0020\u0063\u006f\u006e\u0074\u0065\u006e\u0074\u003D\u0022\u0074\u0065\u0078\u0074\u002f\u0068\u0074\u006d\u006c\u003B\u0020\u0063\u0068\u0061\u0072\u0073\u0065\u0074\u003D\u0075\u0074\u0066\u002d\u0038\u0022\u0020\u002f\u003E\u000A\u003C\u0074\u0069\u0074\u006c\u0065\u003E\u5206\u4EAB\u5E10\u53F7\u0020\u007C\u0020\u0053\u0068\u0061\u0064\u006f\u0077\u0053\u006f\u0063\u006b\u0073\u516C\u76CA\u7EC4\u7EC7\u0020\u007C\u0020\u0053\u0068\u0061\u0064\u006f\u0077\u0053\u006f\u0063\u006b\u0073\u516C\u76CA\u7EC4\u7EC7\u662F\u4E00\u4E2A\u7531\u6C11\u95F4\u56E2\u4F53\u53D1\u8D77\u7684\uFF0C\u65E8\u5728\u5206\u4EAB\u0053\u0068\u0061\u0064\u006f\u0077\u0053\u006f\u0063\u006b\u0073\u5E10\u53F7\u003C\u002f\u0074\u0069\u0074\u006c\u0065\u003E\u000A\u003C\u002f\u0068\u0065\u0061\u0064\u003E\u000A\u000A\u003C\u0062\u006f\u0064\u0079\u003E\u000A\u003C\u0070\u003E\u003C\u0073\u0074\u0072\u006f\u006e\u0067\u003E\u63D0\u4EA4\u5931\u8D25\uFF01\u8BF7\u91CD\u65B0\u63D0\u4EA4\uFF01\u003C\u002f\u0073\u0074\u0072\u006f\u006e\u0067\u003E\u003C\u002f\u0070\u003E\u000A\u003C\u0070\u003E\u003C\u0061\u0020\u0068\u0072\u0065\u0066\u003D\u0022\u0073\u0068\u0061\u0072\u0065\u0022\u003E\u8FD4\u56DE\u003C\u002f\u0061\u003E\u003C\u002f\u0070\u003E\u000A\u003C\u002f\u0062\u006f\u0064\u0079\u003E\u000A\u003C\u002f\u0068\u0074\u006d\u006c\u003E\u000A')
        else:
            return HttpResponse(u'\u003C\u0021\u0044\u004f\u0043\u0054\u0059\u0050\u0045\u0020\u0068\u0074\u006d\u006c\u003E\u000A\u003C\u0068\u0074\u006d\u006c\u0020\u006c\u0061\u006e\u0067\u003D\u0022\u007a\u0068\u002d\u0063\u006e\u0022\u003E\u000A\u003C\u0068\u0065\u0061\u0064\u003E\u000A\u003C\u006d\u0065\u0074\u0061\u0020\u0068\u0074\u0074\u0070\u002d\u0065\u0071\u0075\u0069\u0076\u003D\u0022\u0043\u006f\u006e\u0074\u0065\u006e\u0074\u002d\u0054\u0079\u0070\u0065\u0022\u0020\u0063\u006f\u006e\u0074\u0065\u006e\u0074\u003D\u0022\u0074\u0065\u0078\u0074\u002f\u0068\u0074\u006d\u006c\u003B\u0020\u0063\u0068\u0061\u0072\u0073\u0065\u0074\u003D\u0075\u0074\u0066\u002d\u0038\u0022\u0020\u002f\u003E\u000A\u003C\u0074\u0069\u0074\u006c\u0065\u003E\u5206\u4EAB\u5E10\u53F7\u0020\u007C\u0020\u0053\u0068\u0061\u0064\u006f\u0077\u0053\u006f\u0063\u006b\u0073\u516C\u76CA\u7EC4\u7EC7\u0020\u007C\u0020\u0053\u0068\u0061\u0064\u006f\u0077\u0053\u006f\u0063\u006b\u0073\u516C\u76CA\u7EC4\u7EC7\u662F\u4E00\u4E2A\u7531\u6C11\u95F4\u56E2\u4F53\u53D1\u8D77\u7684\uFF0C\u65E8\u5728\u5206\u4EAB\u0053\u0068\u0061\u0064\u006f\u0077\u0053\u006f\u0063\u006b\u0073\u5E10\u53F7\u003C\u002f\u0074\u0069\u0074\u006c\u0065\u003E\u000A\u003C\u002f\u0068\u0065\u0061\u0064\u003E\u000A\u000A\u003C\u0062\u006f\u0064\u0079\u003E\u000A\u003C\u0070\u003E\u003C\u0073\u0074\u0072\u006f\u006e\u0067\u003E\u9A8C\u8BC1\u7801\u9519\u8BEF\uFF0C\u8BF7\u91CD\u65B0\u8F93\u5165\uFF01\u003C\u002f\u0073\u0074\u0072\u006f\u006e\u0067\u003E\u003C\u002f\u0070\u003E\u000A\u003C\u0070\u003E\u003C\u0061\u0020\u0068\u0072\u0065\u0066\u003D\u0022\u0073\u0068\u0061\u0072\u0065\u0022\u003E\u8FD4\u56DE\u003C\u002f\u0061\u003E\u003C\u002f\u0070\u003E\u000A\u003C\u002f\u0062\u006f\u0064\u0079\u003E\u000A\u003C\u002f\u0068\u0074\u006d\u006c\u003E\u000A')
    else:
        c = {}
        c.update(csrf(req))
        return render_to_response('share.html', c)
开发者ID:imlonghao,项目名称:ShadowSocks.NET,代码行数:17,代码来源:views.py

示例13: email

# 需要导入模块: from DjangoCaptcha import Captcha [as 别名]
# 或者: from DjangoCaptcha.Captcha import check [as 别名]
def email(req,ids):
    if req.method == 'POST':
        ca = Captcha(req)
        if ca.check(req.POST['code']):
            try:
                account = Account.objects.get(id=ids,status=1)
                accountmail(req.POST['mailto'],account.id,account.ip,account.port,account.password,account.encryption,account.name)
                return HttpResponse(u'success')
            except:
                return HttpResponse(u'ID error')
        else:
            return HttpResponse(u'code error')
    else:
        c = {}
        c.update(csrf(req))
        return render_to_response('email.html', c)
开发者ID:imlonghao,项目名称:ShadowSocks.NET,代码行数:18,代码来源:views.py

示例14: user_auth

# 需要导入模块: from DjangoCaptcha import Captcha [as 别名]
# 或者: from DjangoCaptcha.Captcha import check [as 别名]
def user_auth(request, username, password, code):
    user = auth.authenticate(username=username, password=password)
    _code = code
    print "_code", type(_code), _code
    print user.is_active
    ca = Captcha(request)
    if user is None:
        a = 2
    elif not user.is_active:
        a = 3
    elif _code is not None and not ca.check(_code) and int(_code) != 8765:
        a = 4
    else:
        auth.login(request, user)
        a = 1
    print "a is:", a
    return a
开发者ID:yfjelley,项目名称:no_8000,代码行数:19,代码来源:inner_views.py

示例15: ValidCode

# 需要导入模块: from DjangoCaptcha import Captcha [as 别名]
# 或者: from DjangoCaptcha.Captcha import check [as 别名]
def ValidCode(request):
    mod = request.REQUEST.get("a", "")
    if mod <> "check":
        ca = Captcha(request)
        # ca.words = ['hello','world','helloworld']
        ca.type = 'number'
        # ca.type = 'word'
        ca.img_width = 140
        ca.img_height = 30
        return ca.display()
    else:
        _code = request.GET.get('code')
        ca = Captcha(request)
        if ca.check(_code):
            J = Json_Code(data='', msg="验证成功", error=0)
        else:
            J = Json_Code(data='', msg="验证失败", error=1)
        return HttpResponse(J)
开发者ID:banjin,项目名称:klb,代码行数:20,代码来源:views.py


注:本文中的DjangoCaptcha.Captcha.check方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。