Changeset 649
- Timestamp:
- 11/23/06 08:40:30
- Files:
-
- qPloneCaptchas/trunk/Extensions/Install.py (modified) (2 diffs)
- qPloneCaptchas/trunk/config.py (modified) (1 diff)
- qPloneCaptchas/trunk/skins/plone_captchas/captcha_validator.vpy (modified) (2 diffs)
- qPloneCaptchas/trunk/skins/plone_captchas/getCaptcha.py (modified) (1 diff)
- qPloneCaptchas/trunk/skins/plone_captchas/getCaptchaImage.py (modified) (1 diff)
- qPloneCaptchas/trunk/skins/plone_captchas_static (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
qPloneCaptchas/trunk/Extensions/Install.py
r648 r649 16 16 if not hasattr(portal, TOOL_ID): 17 17 constructTransientObjectContainer(portal, id=TOOL_ID, timeout_mins=60) 18 18 19 19 safeEditProperty(self, 'captcha_key', generateKey(8)) 20 20 21 Layers = [] 21 22 Layers += LAYERS 23 24 if static_captchas or (not havePIL): 25 Layers.append(LAYER_STATIC_CAPTCHAS) 26 else: 27 Layers.append(LAYER_DYNAMIC_CAPTCHAS) 28 22 29 qi = getToolByName(self, 'portal_quickinstaller') 23 30 mtool = getToolByName(self, 'portal_migration') 24 31 plone_version = mtool.getFileSystemVersion() 25 32 26 33 if plone_version.startswith('2.1'): 27 34 plone_version = '2.1.2' … … 39 46 discussion_layer = DiscussionLayer+'/'+plone_version 40 47 Layers.append(discussion_layer) 48 49 41 50 out.write('Call setupSkin... \n') 42 51 setupSkin(self, out, Layers) qPloneCaptchas/trunk/config.py
r648 r649 2 2 PRODUCT_NAME = 'qPloneCaptchas' 3 3 CAPTCHAS_COUNT = 165 4 LAYERS = ['captchas' , 'plone_captchas']4 LAYERS = ['captchas'] 5 5 LAYER_DISCUSSION = 'captchas_discussion' 6 6 LAYER_FORMMAILER = 'captchas_ploneformmailer' 7 ALL_LAYERS = LAYERS + [LAYER_DISCUSSION, LAYER_FORMMAILER] 7 LAYER_DYNAMIC_CAPTCHAS = 'plone_captchas' 8 LAYER_STATIC_CAPTCHAS = 'plone_captchas_static' 9 ALL_LAYERS = LAYERS + [LAYER_DISCUSSION, LAYER_FORMMAILER, LAYER_STATIC_CAPTCHAS, LAYER_DYNAMIC_CAPTCHAS] 8 10 TOOL_ICON = 'tool.gif' 9 11 TOOL_ID = 'portal_captchas' 10 havePIL = True 12 13 try: 14 import PIL 15 havePIL = True 16 except: 17 havePIL = False 18 19 static_captchas = True qPloneCaptchas/trunk/skins/plone_captchas/captcha_validator.vpy
r648 r649 1 from Products.qPloneCaptchas.config import havePIL2 1 from Products.qPloneCaptchas.utils import decrypt, parseKey, \ 3 2 encrypt1, getWord, addExpiredKey … … 16 15 date = parsed_key['date'] 17 16 18 if havePIL: 19 enc = test_key 20 solution = getWord(int(index)) 21 else: 22 img = getattr(context, '%s.jpg' % index) 23 solution = img.title 24 enc = encrypt1(test_key) 17 enc = test_key 18 solution = getWord(int(index)) 25 19 26 20 if (enc != solution) or (context.portal_captchas.has_key(decrypted_key)) \ qPloneCaptchas/trunk/skins/plone_captchas/getCaptcha.py
r648 r649 10 10 encrypt 11 11 12 from Products.qPloneCaptchas.config import havePIL13 12 from random import randint 14 key = formKey(randint(0, getCaptchasCount( havePIL)))13 key = formKey(randint(0, getCaptchasCount(True))) 15 14 encrypted_key = encrypt(context.captcha_key, key) 16 15 qPloneCaptchas/trunk/skins/plone_captchas/getCaptchaImage.py
r648 r649 9 9 from Products.qPloneCaptchas.utils import gen_captcha, decrypt, \ 10 10 getWord, parseKey 11 from Products.qPloneCaptchas.config import havePIL 11 12 12 hk = context.REQUEST.traverse_subpath[0] 13 13 dk = decrypt(context.captcha_key, hk) 14 14 key = parseKey(dk)['key'] 15 im = gen_captcha(getWord(int(key)), 27) 15 16 16 if havePIL: 17 im = gen_captcha(getWord(int(key)), 27) 18 context.REQUEST.RESPONSE.setHeader('Content-Type', 'image/jpeg') 19 context.REQUEST.RESPONSE.setHeader('Content-Length', im['size']) 20 context.REQUEST.RESPONSE.setHeader('Accept-Ranges', 'bytes') 21 return im['src'] 22 else: 23 img = getattr(context, '%s.jpg' % key) 24 return img.index_html(context.REQUEST, context.REQUEST.RESPONSE) 17 context.REQUEST.RESPONSE.setHeader('Content-Type', 'image/jpeg') 18 context.REQUEST.RESPONSE.setHeader('Content-Length', im['size']) 19 context.REQUEST.RESPONSE.setHeader('Accept-Ranges', 'bytes') 20 return im['src']
