source: products/qPloneCaptchas/tags/0.8/skins/plone_captchas/captcha_validator.vpy @ 1637

Last change on this file since 1637 was 1, checked in by myroslav, 19 years ago

Building directory structure

  • Property svn:eol-style set to native
File size: 821 bytes
Line 
1if state.getStatus()=='failure':
2    return  state
3request = context.REQUEST
4key = request.get('hashkey', '')
5evalkey = request.get('evalkey', '')
6test_key = request.get('key', '')
7if DateTime().timeTime() - float(evalkey)>3600:
8   return  state.set(status="failure", portal_status_message="Please re enter key")
9
10from Products.qPloneCaptchas.config import CAPTCHAS_COUNT
11from Products.qPloneCaptchas.utils import encrypt
12index = int(key[:4],16)%CAPTCHAS_COUNT
13if index == 0:
14    index = CAPTCHAS_COUNT
15img = getattr(context, '%s.jpg' % index)
16solution = img.title
17enc = encrypt(test_key)
18
19if enc != solution:
20   state.setError('key', 'Please submit the validation code.', 'key_required')
21   return  state.set(status="failure", portal_status_message="Please re enter validation code")
22return  state.set(status="success")
Note: See TracBrowser for help on using the repository browser.