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 | |
---|
1 | if state.getStatus()=='failure': |
---|
2 | return state |
---|
3 | request = context.REQUEST |
---|
4 | key = request.get('hashkey', '') |
---|
5 | evalkey = request.get('evalkey', '') |
---|
6 | test_key = request.get('key', '') |
---|
7 | if DateTime().timeTime() - float(evalkey)>3600: |
---|
8 | return state.set(status="failure", portal_status_message="Please re enter key") |
---|
9 | |
---|
10 | from Products.qPloneCaptchas.config import CAPTCHAS_COUNT |
---|
11 | from Products.qPloneCaptchas.utils import encrypt |
---|
12 | index = int(key[:4],16)%CAPTCHAS_COUNT |
---|
13 | if index == 0: |
---|
14 | index = CAPTCHAS_COUNT |
---|
15 | img = getattr(context, '%s.jpg' % index) |
---|
16 | solution = img.title |
---|
17 | enc = encrypt(test_key) |
---|
18 | |
---|
19 | if 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") |
---|
22 | return state.set(status="success") |
---|
Note: See
TracBrowser
for help on using the repository browser.