Changeset 355 for CMESS/captcha
- Timestamp:
- 20.01.2009 10:20:42 (3 years ago)
- Location:
- CMESS/captcha/trunk/com/zms/captcha
- Files:
-
- 1 added
- 3 edited
-
c_captcha_basic.py (modified) (3 diffs)
-
c_handler_captcha.py (modified) (1 diff)
-
reCaptcha.py (added)
-
zms/captcha.metaobj.xml (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
CMESS/captcha/trunk/com/zms/captcha/c_captcha_basic.py
r318 r355 1 1 from com.zms.captcha.CaptchasDotNet import CaptchasDotNet 2 from com.zms.captcha.reCaptcha import * 2 3 3 4 class C_Captcha_Basic: … … 24 25 temp_chars += (temp_client != 'demo') and temp_chars.upper() + '0123456789' or '' 25 26 26 self.id = 'captcha .net'27 self.id = 'captchas.net' 27 28 self.captcha = CaptchasDotNet(temp_client, temp_secret, alphabet = temp_chars) 28 29 self.zms_context = zms_context … … 50 51 51 52 return temp_result 53 54 class C_ReCaptcha(C_Captcha_Basic): 55 def __init__(self, zms_context): 56 self.id = 'reCaptcha' 57 self.zms_context = zms_context 58 self.zms_lang = self.zms_context.REQUEST.get('lang', self.zms_context.getPrimaryLanguage()) 59 60 def GetContent(self): 61 temp_error = '' 62 temp_result = displayhtml(self.zms_context.attr_captcha.getObjProperty('recaptchaPublicKey', self.zms_context.REQUEST), True, temp_error) 63 64 print(temp_error) 65 66 return temp_result 67 68 def IsCodeValid(self): 69 temp_result = False 70 71 temp_response = submit(self.zms_context.REQUEST.form.get('recaptcha_challenge_field', ''), 72 self.zms_context.REQUEST.form.get('recaptcha_response_field', ''), 73 self.zms_context.attr_captcha.getObjProperty('recaptchaPrivateKey', self.zms_context.REQUEST), 74 '127.0.0.1') 75 76 if (temp_response.is_valid): 77 temp_result = (True, '') 78 else: 79 #incorrect-captcha-sol 80 if (temp_response.error_code == 'incorrect-captcha-sol'): 81 temp_result = (False, self.zms_context.getLangStr('captchaWrongVerification', self.zms_lang)) 82 #invalid-site-private-key 83 else: 84 temp_result = (False, self.zms_context.getLangStr('captchaInvalid', self.zms_lang)) 85 86 return temp_result -
CMESS/captcha/trunk/com/zms/captcha/c_handler_captcha.py
r319 r355 1 1 from com.zms.captcha.c_captcha_basic import C_Captcha_Basic 2 2 from com.zms.captcha.c_captcha_basic import C_Captcha_Dot_Net 3 from com.zms.captcha.c_captcha_basic import C_ReCaptcha 3 4 4 5 class C_Handler_Captcha: 5 6 def __init__(self, zms_context): 6 7 try: 7 if (zms_context.attr_captcha.getObjProperty('captchaService', zms_context.REQUEST) == 'captcha .net'):8 if (zms_context.attr_captcha.getObjProperty('captchaService', zms_context.REQUEST) == 'captchas.net'): 8 9 self.captcha_obj = C_Captcha_Dot_Net(zms_context) 10 elif (zms_context.attr_captcha.getObjProperty('captchaService', zms_context.REQUEST) == 'reCaptcha'): 11 self.captcha_obj = C_ReCaptcha(zms_context) 9 12 else: 10 13 self.captcha_obj = None -
CMESS/captcha/trunk/com/zms/captcha/zms/captcha.metaobj.xml
r319 r355 24 24 } 25 25 26 function changeVisibilityServiceReCaptcha(show) 27 { 28 if (show) 29 { 30 $("#tr_recaptchaPublicKey").show(); 31 $("#tr_recaptchaPrivateKey").show(); 32 } 33 else 34 { 35 $("#tr_recaptchaPublicKey").hide(); 36 $("#tr_recaptchaPrivateKey").hide(); 37 } 38 } 39 26 40 function checkEnabled() 27 41 { … … 34 48 function checkService() 35 49 { 36 changeVisibilityServiceDotNet(isEnabled() && ($("#captchaService_<dtml-var lang>").attr('value') == 'captcha.net')); 50 changeVisibilityServiceDotNet(isEnabled() && ($("#captchaService_<dtml-var lang>").attr('value') == 'captchas.net')); 51 changeVisibilityServiceReCaptcha(isEnabled() && ($("#captchaService_<dtml-var lang>").attr('value') == 'reCaptcha')); 37 52 } 38 53 … … 69 84 <item key="id"><![CDATA[captchaService]]></item> 70 85 <item key="keys" type="list"><list> 71 <item><![CDATA[captcha.net]]></item> 86 <item><![CDATA[captchas.net]]></item> 87 <item><![CDATA[reCaptcha]]></item> 72 88 <item><![CDATA[static_pics]]></item> 73 89 </list> … … 96 112 <item key="multilang" type="int">1</item> 97 113 <item key="name"><![CDATA[Secret]]></item> 114 <item key="repetitive" type="int">0</item> 115 <item key="type"><![CDATA[string]]></item> 116 </dictionary> 117 </item> 118 <item type="dictionary"><dictionary> 119 <item key="id"><![CDATA[recaptchaPublicKey]]></item> 120 <item key="mandatory" type="int">0</item> 121 <item key="multilang" type="int">1</item> 122 <item key="name"><![CDATA[Public Key]]></item> 123 <item key="repetitive" type="int">0</item> 124 <item key="type"><![CDATA[string]]></item> 125 </dictionary> 126 </item> 127 <item type="dictionary"><dictionary> 128 <item key="id"><![CDATA[recaptchaPrivateKey]]></item> 129 <item key="mandatory" type="int">0</item> 130 <item key="multilang" type="int">1</item> 131 <item key="name"><![CDATA[Private Key]]></item> 98 132 <item key="repetitive" type="int">0</item> 99 133 <item key="type"><![CDATA[string]]></item>
Note: See TracChangeset
for help on using the changeset viewer.
