- Timestamp:
- 26.11.2008 10:45:44 (3 years ago)
- Location:
- CMESS/forum/branches/captcha/cmess
- Files:
-
- 1 edited
- 1 moved
-
. (moved) (moved from CMESS/forum/branches/captcha/org/cmess)
-
forum/c_captcha_basic.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
CMESS/forum/branches/captcha/cmess/forum/c_captcha_basic.py
r305 r315 1 from org.cmess.forum.CaptchasDotNet import CaptchasDotNet1 from com.zms.captcha.CaptchasDotNet import CaptchasDotNet 2 2 3 3 class C_Captcha_Basic: … … 17 17 18 18 class C_Captcha_Dot_Net(C_Captcha_Basic): 19 def __init__(self): 20 self.id = 'captcha.net' 21 self.captcha = CaptchasDotNet(client = 'demo', secret = 'secret') 19 def __init__(self, zms_context): 20 temp_client = zms_context.attr_captcha.getObjProperty('captchaClient', zms_context.REQUEST) 21 temp_secret = zms_context.attr_captcha.getObjProperty('captchaSecret', zms_context.REQUEST) 22 23 temp_chars = 'abcdefghkmnopqrstuvwxyz' 24 temp_chars += (temp_client != 'demo') and temp_chars.upper() + '0123456789' or '' 25 26 self.id = 'captcha.net' 27 self.captcha = CaptchasDotNet(temp_client, temp_secret, alphabet = temp_chars) 28 self.zms_context = zms_context 29 self.zms_lang = self.zms_context.REQUEST.get('lang', self.zms_context.getPrimaryLanguage()) 22 30 23 31 def GetContent(self): 24 32 temp_result = '<input type="hidden" name="captcha_random" value="%s" />'%self.captcha.random() 25 33 temp_result += self.captcha.image() + '<br />' 26 temp_result += '<input type="submit" name="captcha_new" value=" get new image" /><br />'27 temp_result += '<label> Please enter the shown characters</label><br />'34 temp_result += '<input type="submit" name="captcha_new" value="%s" /><br />'%self.zms_context.getLangStr('captchaNewCode', self.zms_lang) 35 temp_result += '<label>%s</label><br />'%self.zms_context.getLangStr('captchaLabel', self.zms_lang) 28 36 temp_result += '<input type="text" name="captcha_password" size="16" />' 29 37 30 38 return temp_result 31 39 32 def IsCodeValid(self , REQUEST):40 def IsCodeValid(self): 33 41 #check random string 34 if (self.captcha.validate( REQUEST.form.get('captcha_random', ''))):42 if (self.captcha.validate(self.zms_context.REQUEST.form.get('captcha_random', ''))): 35 43 #check captcha password 36 if (self.captcha.verify( REQUEST.form.get('captcha_password', ''))):37 temp_result = (True, ' correct password')44 if (self.captcha.verify(self.zms_context.REQUEST.form.get('captcha_password', ''))): 45 temp_result = (True, '') 38 46 else: 39 temp_result = (False, 'You entered the wrong password.')47 temp_result = (False, self.zms_context.getLangStr('captchaWrongVerification', self.zms_lang)) 40 48 else: 41 temp_result = (False, 'Every CAPTCHA can only be used once. The current CAPTCHA has already been used. Try again.')49 temp_result = (False, self.zms_context.getLangStr('captchaInvalid', self.zms_lang)) 42 50 43 51 return temp_result
Note: See TracChangeset
for help on using the changeset viewer.
