+
+ # Check reCAPTCHA submission, if enabled
+ if mm_cfg.RECAPTCHA_SECRET_KEY:
+ request = urllib2.Request(
+ url = 'https://www.google.com/recaptcha/api/siteverify',
+ data = urllib.urlencode({
+ 'secret': mm_cfg.RECAPTCHA_SECRET_KEY,
+ 'response': cgidata.getvalue('g-recaptcha-response', ''),
+ 'remoteip': remote}))
+ try:
+ httpresp = urllib2.urlopen(request)
+ captcha_response = json.load(httpresp)
+ httpresp.close()
+ if not captcha_response['success']:
+ e_codes = COMMASPACE.join(captcha_response['error-codes'])
+ results.append(_('reCAPTCHA validation failed: %(e_codes)s'))
+ except urllib2.URLError, e:
+ e_reason = e.reason
+ results.append(_('reCAPTCHA could not be validated: %(e_reason)s'))
+