/** * 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; }
public function save() { parent::validate(''); Mollom::setPublicKey($this->publicKey); Mollom::setPrivateKey($this->privateKey); Mollom::setServerList(CoOrg::config()->get('mollom/serverlist')); try { if (!Mollom::verifyKey()) { $this->publicKey_error = t('Invalid keys'); throw new ValidationException($this); } } catch (ServerListException $e) { CoOrg::config()->set('mollom/serverlist', Mollom::getServerList()); try { if (!Mollom::verifyKey()) { $this->publicKey_error = t('Invalid keys'); CoOrg::config()->save(); // Save the new serverlist throw new ValidationException($this); } } catch (InternalException $e) { } catch (ServerListException $e) { } } CoOrg::config()->set('mollom/public', $this->publicKey); CoOrg::config()->set('mollom/private', $this->privateKey); CoOrg::config()->save(); }
/** * The function for processing a message to see if it might be SPAM * returns: * 0 if the message is SPAM * 1 if the message might be SPAM (it will be marked for moderation) * 2 if the message is not SPAM * * @param string $author Author field from the posting * @param string $email Email field from the posting * @param string $website Website field from the posting * @param string $body The text of the comment * @param string $imageLink A link to the album/image on which the post was made * @param string $ip the IP address of the comment poster * * @return int */ function filterMessage($author, $email, $website, $body, $imageLink, $ip) { // set keys Mollom::setPublicKey(getOption('public_key')); Mollom::setPrivateKey(getOption('private_key')); $servers = Mollom::getServerList(); Mollom::setServerList($servers); // get feedback try { $feedback = Mollom::checkContent(null, null, $body, $author, $website, $email); } catch (Exception $e) { // mark comment for moderation, Mollom is acting strange } // process feedback if (in_array($feedback['spam'], array('unsure', 'unknow'))) { $result = 1; } elseif ($feedback['spam'] == 'ham') { $result = 2; } elseif ($feedback['spam'] == 'spam') { $result = 0; } return $result; }
/** * Check if comment is spam using Mollom. * * @param Comment $comment The Comment object * @param string $public_key The Mollom public key * @param string $private_key The Mollom private key * * @return void * * @since 2.0 */ public function mollom($comment, $public_key = '', $private_key = '') { // check if curl functions are available if (!function_exists('curl_init')) { return; } // load mollom class $this->app->loader->register('Mollom', 'libraries:mollom/mollom.php'); // set keys and get servers Mollom::setPublicKey($public_key); Mollom::setPrivateKey($private_key); Mollom::setServerList(Mollom::getServerList()); // check comment $feedback = Mollom::checkContent(null, null, $comment->content, $comment->author, $comment->url, $comment->email); // set state if ($feedback['spam'] != 'ham') { $comment->state = Comment::STATE_SPAM; } }
private function prepare() { Mollom::setPublicKey(CoOrg::config()->get('mollom/public')); Mollom::setPrivateKey(CoOrg::config()->get('mollom/private')); Mollom::setServerList(CoOrg::config()->get('mollom/serverlist')); }
public function action_init() { $this->load_text_domain('mollom'); $this->add_template('mollom_fallback_captcha', dirname(__FILE__) . '/templates/mollom_fallback_captcha.php'); Mollom::setUserAgent('habari/' . Version::get_habariversion()); Mollom::$serverListRefreshCallback = array($this, 'filter_mollom_update_server_list_cron'); if (Options::get('mollom__private_key')) { Mollom::setPrivateKey(Options::get('mollom__private_key')); Mollom::setPublicKey(Options::get('mollom__public_key')); if (!($servers = Options::get('mollom__servers'))) { try { $servers = Mollom::getServerList(); Options::set('mollom__servers', $servers); Mollom::setServerList($servers); } catch (Exception $e) { EventLog::log($e->getMessage(), 'crit', 'comment', 'Mollom'); } } else { Mollom::setServerList($servers); } } }