Пример #1
0
 /**
  * generates a Mollom captcha for comments
  *
  * Returns the captcha code string and image URL (via the $image parameter).
  *
  * @return string;
  */
 function generateCaptcha(&$image)
 {
     Mollom::setPublicKey(getOption('public_key'));
     Mollom::setPrivateKey(getOption('private_key'));
     $servers = Mollom::getServerList();
     Mollom::setServerList($servers);
     // get captcha
     $captcha = Mollom::getImageCaptcha();
     $session_id = $captcha['session_id'];
     query('DELETE FROM ' . prefix('captcha') . ' WHERE `ptime`<' . (time() - 3600), true);
     // expired tickets
     query("INSERT INTO " . prefix('captcha') . " (ptime, hash) VALUES ('" . escape(time()) . "','" . escape($session_id) . "')", true);
     $image = $captcha['url'];
     return $session_id;
 }
Пример #2
0
	private function getCaptcha($sessID, $type, $retry = true)
	{
		try
		{
			if ($type == 'image')
			{
				$info = Mollom::getImageCaptcha($sessID);
			}
			else
			{
				$info = Mollom::getAudioCaptcha($sessID);
			}
			return $info;
		}
		catch (KeyNotSetException $e)
		{
			return null;
		}
		catch (InternalException $e)
		{
			return null;
		}
		catch (OutdatedServerListException $e)
		{
			CoOrg::config()->set('mollom/serverlist', Mollom::getServerList());
			CoOrg::config()->save();
			return $retry ? self::getCaptcha($sessID, $type, false) : null;
		}
		catch (NoServerListException $e)
		{
			CoOrg::config()->set('mollom/serverlist', Mollom::getServerList());
			CoOrg::config()->save();
			return $retry ? self::getCaptcha($sessID, $type, false) : null;
		}
	}
Пример #3
0
 /**
  * @todo use formui
  */
 private function send_captcha($comment = null)
 {
     Session::add_to_set('mollom', $comment, 'comment');
     $theme = Themes::create();
     $theme->comment = $comment;
     try {
         $theme->captcha = Mollom::getImageCaptcha($comment->info->mollom_session_id);
         $theme->audio_captcha = Mollom::getAudioCaptcha($comment->info->mollom_session_id);
     } catch (Exception $e) {
     }
     $theme->display('mollom_fallback_captcha');
 }