Changeset 362
- Timestamp:
- 21.01.2009 13:50:49 (3 years ago)
- Location:
- CMESS/captcha/trunk/com/zms/captcha
- Files:
-
- 2 added
- 4 edited
-
Gastada.ttf (added)
-
PILCaptcha.py (added)
-
README.txt (modified) (2 diffs)
-
c_captcha_basic.py (modified) (4 diffs)
-
c_handler_captcha.py (modified) (2 diffs)
-
zms/captcha.metaobj.xml (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
CMESS/captcha/trunk/com/zms/captcha/README.txt
r329 r362 16 16 ICONS, http://famfamfam.com 17 17 CAPTCHAS.NET, http://captchas.net 18 RECAPTCHA.NET, http://recaptcha.net 19 PIL, http://www.pythonware.com/products/pil/ 18 20 19 21 LICENSE: Creative Commons Attribution-Share Alike 2.0 Germany … … 23 25 HISTORY 24 26 27 v1.1.0.200901211350 28 - added ReCaptcha-service 29 - added PILCaptcha-service 30 25 31 v1.0.0.200811281134 26 32 - configuration via meta-object (attr_captcha) 27 - captcha-services "captcha .net" and "static_pics" integrated33 - captcha-services "captchas.net" and "static_pics" integrated 28 34 - wrapper for different captcha-services (captcha_getContent, captcha_isValid) 29 35 -
CMESS/captcha/trunk/com/zms/captcha/c_captcha_basic.py
r355 r362 1 1 from com.zms.captcha.CaptchasDotNet import CaptchasDotNet 2 from com.zms.captcha.PILCaptcha import * 2 3 from com.zms.captcha.reCaptcha import * 3 4 4 5 class C_Captcha_Basic: 5 def __init__(self): 6 self.id = None 6 def __init__(self, zms_context): 7 self.id = None 8 9 self.zms_context = zms_context 10 self.zms_lang = self.zms_context.REQUEST.get('lang', self.zms_context.getPrimaryLanguage()) 7 11 8 12 def GetContent(self): … … 19 23 class C_Captcha_Dot_Net(C_Captcha_Basic): 20 24 def __init__(self, zms_context): 25 C_Captcha_Basic.__init__(self, zms_context) 26 21 27 temp_client = zms_context.attr_captcha.getObjProperty('captchaClient', zms_context.REQUEST) 22 28 temp_secret = zms_context.attr_captcha.getObjProperty('captchaSecret', zms_context.REQUEST) … … 27 33 self.id = 'captchas.net' 28 34 self.captcha = CaptchasDotNet(temp_client, temp_secret, alphabet = temp_chars) 29 self.zms_context = zms_context 30 self.zms_lang = self.zms_context.REQUEST.get('lang', self.zms_context.getPrimaryLanguage()) 31 35 32 36 def GetContent(self): 33 37 temp_result = '<input type="hidden" name="captcha_random" value="%s" />'%self.captcha.random() … … 51 55 52 56 return temp_result 57 58 class C_PIL_Captcha(C_Captcha_Basic): 59 def __init__(self, zms_context): 60 C_Captcha_Basic.__init__(self, zms_context) 61 62 self.id = 'PILCaptcha' 53 63 64 def GetContent(self): 65 temp_img = generateImage(self.zms_context.temp_folder, 66 self.zms_context.attr_captcha.getObjProperty('pilcaptchaCharCount', self.zms_context.REQUEST), 67 self.zms_context.attr_captcha.getObjProperty('pilcaptchaFontSize', self.zms_context.REQUEST), 68 self.zms_context.REQUEST) 69 70 temp_result = '<img src="%s" />'%temp_img.absolute_url() + '<br />' 71 temp_result += '<input type="submit" name="captcha_new" value="%s" /><br />'%self.zms_context.getLangStr('captchaNewCode', self.zms_lang) 72 temp_result += '<label>%s</label><br />'%self.zms_context.getLangStr('captchaLabel', self.zms_lang) 73 temp_result += '<input type="text" name="captcha_password" size="16" />' 74 75 return temp_result 76 77 def IsCodeValid(self): 78 if (self.zms_context.REQUEST.SESSION['sess_captcha'] == self.zms_context.REQUEST.form.get('captcha_password', '')): 79 temp_result = (True, '') 80 else: 81 temp_result = (False, self.zms_context.getLangStr('captchaWrongVerification', self.zms_lang)) 82 83 return temp_result 84 54 85 class C_ReCaptcha(C_Captcha_Basic): 55 86 def __init__(self, zms_context): 56 self.id = 'reCaptcha'57 self.zms_context = zms_context58 self. zms_lang = self.zms_context.REQUEST.get('lang', self.zms_context.getPrimaryLanguage())87 C_Captcha_Basic.__init__(self, zms_context) 88 89 self.id = 'reCaptcha' 59 90 60 91 def GetContent(self): -
CMESS/captcha/trunk/com/zms/captcha/c_handler_captcha.py
r355 r362 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_PIL_Captcha 3 4 from com.zms.captcha.c_captcha_basic import C_ReCaptcha 4 5 … … 8 9 if (zms_context.attr_captcha.getObjProperty('captchaService', zms_context.REQUEST) == 'captchas.net'): 9 10 self.captcha_obj = C_Captcha_Dot_Net(zms_context) 11 elif (zms_context.attr_captcha.getObjProperty('captchaService', zms_context.REQUEST) == 'PILCaptcha'): 12 self.captcha_obj = C_PIL_Captcha(zms_context) 10 13 elif (zms_context.attr_captcha.getObjProperty('captchaService', zms_context.REQUEST) == 'reCaptcha'): 11 14 self.captcha_obj = C_ReCaptcha(zms_context) -
CMESS/captcha/trunk/com/zms/captcha/zms/captcha.metaobj.xml
r355 r362 16 16 $("#tr_captchaClient").show(); 17 17 $("#tr_captchaSecret").show(); 18 $("#captchaInfo").show(); 18 19 } 19 20 else … … 21 22 $("#tr_captchaClient").hide(); 22 23 $("#tr_captchaSecret").hide(); 24 $("#captchaInfo").hide(); 23 25 } 24 26 } … … 30 32 $("#tr_recaptchaPublicKey").show(); 31 33 $("#tr_recaptchaPrivateKey").show(); 34 $("#recaptchaInfo").show(); 32 35 } 33 36 else … … 35 38 $("#tr_recaptchaPublicKey").hide(); 36 39 $("#tr_recaptchaPrivateKey").hide(); 40 $("#recaptchaInfo").hide(); 41 } 42 } 43 44 function changeVisibilityServicePILCaptcha(show) 45 { 46 if (show) 47 { 48 $("#tr_pilcaptchaCharCount").show(); 49 $("#tr_pilcaptchaFontSize").show(); 50 $("#pilcaptchaInfo").show(); 51 } 52 else 53 { 54 $("#tr_pilcaptchaCharCount").hide(); 55 $("#tr_pilcaptchaFontSize").hide(); 56 $("#pilcaptchaInfo").hide(); 37 57 } 38 58 } … … 50 70 changeVisibilityServiceDotNet(isEnabled() && ($("#captchaService_<dtml-var lang>").attr('value') == 'captchas.net')); 51 71 changeVisibilityServiceReCaptcha(isEnabled() && ($("#captchaService_<dtml-var lang>").attr('value') == 'reCaptcha')); 72 changeVisibilityServicePILCaptcha(isEnabled() && ($("#captchaService_<dtml-var lang>").attr('value') == 'PILCaptcha')); 52 73 } 53 74 … … 85 106 <item key="keys" type="list"><list> 86 107 <item><![CDATA[captchas.net]]></item> 108 <item><![CDATA[PILCaptcha]]></item> 87 109 <item><![CDATA[reCaptcha]]></item> 88 110 <item><![CDATA[static_pics]]></item> … … 97 119 </item> 98 120 <item type="dictionary"><dictionary> 121 <item key="id"><![CDATA[captchaInfo]]></item> 122 <item key="mandatory" type="int">0</item> 123 <item key="multilang" type="int">0</item> 124 <item key="name"><![CDATA[</td></tr><tr id="captchaInfo"><td></td><td class="form-text"><strong>Hint:</strong> more information at <a href="http://captchas.net/" target="_blank">captchas.net</a>]]></item> 125 <item key="repetitive" type="int">0</item> 126 <item key="type"><![CDATA[hint]]></item> 127 </dictionary> 128 </item> 129 <item type="dictionary"><dictionary> 99 130 <item key="default"><![CDATA[demo]]></item> 100 131 <item key="id"><![CDATA[captchaClient]]></item> … … 117 148 </item> 118 149 <item type="dictionary"><dictionary> 150 <item key="id"><![CDATA[recaptchaInfo]]></item> 151 <item key="mandatory" type="int">0</item> 152 <item key="multilang" type="int">0</item> 153 <item key="name"><![CDATA[</td></tr><tr id="recaptchaInfo"><td></td><td class="form-text"><strong>Hint:</strong> get your public/private key at <a href="http://recaptcha.net/" target="_blank">recaptcha.net</a>]]></item> 154 <item key="repetitive" type="int">0</item> 155 <item key="type"><![CDATA[hint]]></item> 156 </dictionary> 157 </item> 158 <item type="dictionary"><dictionary> 119 159 <item key="id"><![CDATA[recaptchaPublicKey]]></item> 120 160 <item key="mandatory" type="int">0</item> … … 132 172 <item key="repetitive" type="int">0</item> 133 173 <item key="type"><![CDATA[string]]></item> 174 </dictionary> 175 </item> 176 <item type="dictionary"><dictionary> 177 <item key="id"><![CDATA[pilcaptchaInfo]]></item> 178 <item key="mandatory" type="int">0</item> 179 <item key="multilang" type="int">0</item> 180 <item key="name"><![CDATA[</td></tr><tr id="pilcaptchaInfo"><td></td><td class="form-text"><strong>Hint:</strong> Python Imaging Library (<a href="http://www.pythonware.com/products/pil/" target="_blank">PIL</a>) is required]]></item> 181 <item key="repetitive" type="int">0</item> 182 <item key="type"><![CDATA[hint]]></item> 183 </dictionary> 184 </item> 185 <item type="dictionary"><dictionary> 186 <item key="default"><![CDATA[5]]></item> 187 <item key="id"><![CDATA[pilcaptchaCharCount]]></item> 188 <item key="mandatory" type="int">0</item> 189 <item key="multilang" type="int">1</item> 190 <item key="name"><![CDATA[Char Count]]></item> 191 <item key="repetitive" type="int">0</item> 192 <item key="type"><![CDATA[int]]></item> 193 </dictionary> 194 </item> 195 <item type="dictionary"><dictionary> 196 <item key="default"><![CDATA[36]]></item> 197 <item key="id"><![CDATA[pilcaptchaFontSize]]></item> 198 <item key="mandatory" type="int">0</item> 199 <item key="multilang" type="int">1</item> 200 <item key="name"><![CDATA[Font Size]]></item> 201 <item key="repetitive" type="int">0</item> 202 <item key="type"><![CDATA[int]]></item> 134 203 </dictionary> 135 204 </item> … … 189 258 <item key="name"><![CDATA[CaptchaConfig]]></item> 190 259 <item key="package"><![CDATA[com.zms.captcha]]></item> 191 <item key="revision"><![CDATA[1. 0.0]]></item>260 <item key="revision"><![CDATA[1.1.0]]></item> 192 261 <item key="type"><![CDATA[ZMSResource]]></item> 193 262 </dictionary> … … 467 536 <item key="name"><![CDATA[CaptchaLib]]></item> 468 537 <item key="package"><![CDATA[com.zms.captcha]]></item> 469 <item key="revision"><![CDATA[1. 0.0]]></item>538 <item key="revision"><![CDATA[1.1.0]]></item> 470 539 <item key="type"><![CDATA[ZMSLibrary]]></item> 471 540 </dictionary> … … 479 548 </list> 480 549 </item> 481 <item key="enabled" type="int">1</item> 550 <item key="access" type="dictionary"><dictionary> 551 <item key="delete" type="list"><list> 552 </list> 553 </item> 554 <item key="delete_custom"></item> 555 <item key="edit" type="list"><list> 556 </list> 557 </item> 558 <item key="edit_custom"></item> 559 <item key="insert" type="list"><list> 560 </list> 561 </item> 562 <item key="insert_custom"></item> 563 </dictionary> 564 </item> 565 <item key="enabled" type="int">0</item> 482 566 <item key="id"><![CDATA[com.zms.captcha]]></item> 483 567 <item key="name"><![CDATA[com.zms.captcha]]></item> 484 568 <item key="package"></item> 485 <item key="revision"><![CDATA[1. 0.0]]></item>569 <item key="revision"><![CDATA[1.1.0]]></item> 486 570 <item key="type"><![CDATA[ZMSPackage]]></item> 487 571 </dictionary>
Note: See TracChangeset
for help on using the changeset viewer.
