Changeset 17730
- Timestamp:
- Oct 28, 2023, 2:27:59 PM (9 months ago)
- Location:
- plugins/trunk/spam-filter/tracspamfilter
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/trunk/spam-filter/tracspamfilter/captcha/api.py
r17729 r17730 144 144 else: 145 145 data['error'] = _("CAPTCHA verification failed") 146 el se:146 el: 147 147 data['error'] = Markup(req.session.get("captcha_reject_reason")) 148 148 # cleanup old values … … 160 160 req.session['captcha_expected'] = result 161 161 req.session.save() 162 return 'verify_captcha.html', data, None162 return 'verify_captcha.html', data, 163 163 164 164 def pre_process_request(self, req, handler): -
plugins/trunk/spam-filter/tracspamfilter/captcha/expression.py
r17729 r17730 18 18 19 19 from trac.core import Component, TracError, implements 20 from trac.config import IntOption 20 from trac.config import IntOption,ListOption 21 from trac.util.html import html 21 22 22 23 from tracspamfilter.captcha import ICaptchaMethod … … 34 35 terms = IntOption('spam-filter', 'captcha_expression_terms', 3, 35 36 """Number of terms in numeric CAPTCHA expression.""", 37 38 39 40 41 36 42 doc_domain='tracspamfilter') 37 43 … … 71 77 [gettext(self.operations[o]) for o in operations])), 72 78 ())[:-1] 73 return expression, ' '.join(map(str, human)) 79 if self.trash: 80 human = list(human) 81 for i in range(random.randrange(1, self.terms)): 82 pos = random.randrange(0, len(human)) 83 elem = _(random.choice(self.trash)) 84 human.insert(pos, elem) 85 86 return expression, html.div(html.div(_('Compute the expression (ignoring operator precendence) and enter result. Ignore any addional text.')),html.p(' '.join(map(str, human)))) 74 87 75 88 def verify_captcha(self, req): -
plugins/trunk/spam-filter/tracspamfilter/templates/verify_captcha.html
r14842 r17730 1 <!DOCTYPE html 2 PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 3 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 4 <html xmlns="http://www.w3.org/1999/xhtml" 5 xmlns:xi="http://www.w3.org/2001/XInclude" 6 xmlns:py="http://genshi.edgewall.org/" 7 xmlns:i18n="http://genshi.edgewall.org/i18n" i18n:domain="tracspamfilter"> 8 <xi:include href="layout.html" /> 9 <head></head> 1 {# Copyright (C) 2023 Dirk Stöcker 2 3 This software is licensed as described in the file COPYING, which 4 you should have received as part of this distribution. The terms 5 are also available at https://trac.edgewall.org/wiki/TracLicense. 6 7 This software consists of voluntary contributions made by many 8 individuals. For the exact contribution history, see the revision 9 history and logs, available at https://trac.edgewall.org/. 10 #} 11 # extends 'layout.html' 12 <html> 10 13 <body> 14 11 15 <div id="content" class="${error and 'error' or 'traccaptcha'}"> 12 <py:if test="error">13 <h1>Captcha Error</h1>14 15 </py:if>16 17 </h1> 18 <div class="message">${error}</div> 19 16 20 <form method="post" action="${href.captcha()}"> 17 <p> Trac thinks your submission might be Spam.18 To prove otherwise please provide a response to the following.</p>19 <p py:if="random">Note - the captcha method is choosen randomly. Retry if the captcha does not work on your system!</p>20 <py:if test="defaultform">21 <blockquote><p>${challenge}</p></blockquote>22 <p>23 Response: <input type="text" name="captcha_response"/>24 <input type="submit" value="${dgettext('traspamfilter', 'Submit')}"/>25 </p>26 </p y:if>27 <py:if test="not defaultform">28 29 </py:if>21 <p> 22 23 <p>Note - the captcha method is choosen randomly. Retry if the captcha does not work on your system!</p> 24 25 26 > 27 > 28 "/> 29 > 30 </p> 31 32 ${challenge} 33 30 34 </form> 31 35 </div> 36 32 37 </body> 33 38 </html>
Note:
See TracChangeset
for help on using the changeset viewer.