Beispiel #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;
 }
	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();
	}
Beispiel #3
0
 /**
  * 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;
 }
Beispiel #4
0
 /**
  * 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'));
	}
Beispiel #6
0
if (isset($wgMollomDebug) && $wgMollomDebug) {
    $wgDebugLogGroups['MollomMW'] = dirname(__FILE__) . '/debug.log';
}
if (isset($wgMollomReverseProxyAddresses) && is_array($wgMollomReverseProxyAddresses)) {
    MollomClient::setAllowedReverseProxyAddresses($wgMollomReverseProxyAddresses);
}
if (isset($wgMollomRunsOnClusterSetup)) {
    MollomClient::setUsesServerSetup($wgMollomRunsOnClusterSetup);
}
if (!isset($wgMollomMWAcceptPolicy) && !is_bool($wgMollomMWAcceptPolicy)) {
    $wgMollomMWAPIAcceptPolicy = true;
}
if (!isset($wgMollomMWAPIAcceptPolicy) && !is_bool($wgMollomMWAPIAcceptPolicy)) {
    $wgMollomMWAPIAcceptPolicy = false;
}
Mollom::setPublicKey($wgMollomPublicKey);
Mollom::setPrivateKey($wgMollomPrivateKey);
/* Connect the hooks for the mollom filters */
global $wgHooks;
$wgHooks['EditFilter'][] = 'MollomSpamFilter::onEditFilter';
$wgHooks['APIEditBeforeSave'][] = 'MollomSpamFilter::onAPIEditBeforeSave';
/**
 * Extension initialisation function, used to set up special pages.
 */
function setupMollomMW()
{
    /* setup autoloading of special page classes */
    global $wgAutoloadClasses;
    $wgAutoloadClasses['MollomSpamFilter'] = dirname(__FILE__) . '/mollommw.filter.php';
    $wgAutoloadClasses['MollomMWStatPage'] = dirname(__FILE__) . '/pages/mollommw.stats.php';
    $wgAutoloadClasses['MollomMWBlacklistPage'] = dirname(__FILE__) . '/pages/mollommw.blacklist.php';
 private function performChecks()
 {
     $request = JRequest::get();
     // Calc check
     if ($this->params->get('type_calc')) {
         if ($this->_session->get('rot13', null, 'easycalccheck') == 1) {
             $spamcheckresult = base64_decode(str_rot13($this->_session->get('spamcheckresult', null, 'easycalccheck')));
         } else {
             $spamcheckresult = base64_decode($this->_session->get('spamcheckresult', null, 'easycalccheck'));
         }
         $spamcheck = JRequest::getInt($this->_session->get('spamcheck', null, 'easycalccheck'), '', 'post');
         $this->_session->clear('rot13', 'easycalccheck');
         $this->_session->clear('spamcheck', 'easycalccheck');
         $this->_session->clear('spamcheckresult', 'easycalccheck');
         if (!is_numeric($spamcheckresult) || $spamcheckresult != $spamcheck) {
             return false;
             // Failed
         }
     }
     // Hidden field
     if ($this->params->get('type_hidden')) {
         $hidden_field = $this->_session->get('hidden_field', null, 'easycalccheck');
         $this->_session->clear('hidden_field', 'easycalccheck');
         if (JRequest::getVar($hidden_field, '', 'post')) {
             return false;
             // Hidden field was filled out - failed
         }
     }
     // Time lock
     if ($this->params->get('type_time')) {
         $time = $this->_session->get('time', null, 'easycalccheck');
         $this->_session->clear('time', 'easycalccheck');
         if (time() - $this->params->get('type_time_sec') <= $time) {
             return false;
             // Submitted too fast - failed
         }
     }
     // Own Question
     // Conversion to lower case
     if ($this->params->get('question')) {
         $answer = strtolower(JRequest::getString($this->_session->get('question', null, 'easycalccheck'), '', 'post'));
         $this->_session->clear('question', 'easycalccheck');
         if ($answer != strtolower($this->params->get('question_a'))) {
             return false;
             // Question wasn't answered - failed
         }
     }
     // StopForumSpam - Check the IP Address
     // Further informations: http://www.stopforumspam.com
     if ($this->params->get('stopforumspam')) {
         $url = 'http://www.stopforumspam.com/api?ip=' . $this->_session->get('ip', null, 'easycalccheck');
         // Function test - Comment out to test - Important: Enter a active Spam-IP
         // $ip = '88.180.52.46';
         // $url = 'http://www.stopforumspam.com/api?ip='.$ip;
         $response = false;
         $is_spam = false;
         if (function_exists('curl_init')) {
             $ch = curl_init($url);
             curl_setopt($ch, CURLOPT_HEADER, 0);
             curl_setopt($ch, CURLOPT_POST, 0);
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
             $response = curl_exec($ch);
             curl_close($ch);
         }
         if ($response) {
             preg_match('#<appears>(.*)</appears>#', $response, $out);
             $is_spam = $out[1];
         } else {
             $response = @fopen($url, 'r');
             if ($response) {
                 while (!feof($response)) {
                     $line = fgets($response, 1024);
                     if (preg_match('#<appears>(.*)</appears>#', $line, $out)) {
                         $is_spam = $out[1];
                         break;
                     }
                 }
                 fclose($response);
             }
         }
         if ($is_spam == 'yes' and $response == true) {
             return false;
             // Spam-IP - failed
         }
     }
     // Honeypot Project
     // Further informations: http://www.projecthoneypot.org/home.php
     // BL ACCESS KEY - http://www.projecthoneypot.org/httpbl_configure.php
     if ($this->params->get('honeypot')) {
         require_once dirname(__FILE__) . DS . 'easycalccheckplus' . DS . 'honeypot.php';
         $http_blKey = $this->params->get('honeypot_key');
         if ($http_blKey) {
             $http_bl = new http_bl($http_blKey);
             $result = $http_bl->query($this->_session->get('ip', null, 'easycalccheck'));
             // Function test - Comment out to test - Important: Enter a active Spam-IP
             // $ip = '117.21.224.251';
             // $result = $http_bl->query($ip);
             if ($result == 2) {
                 return false;
             }
         }
     }
     // Akismet
     // Further informations: http://akismet.com/
     if ($this->params->get('akismet')) {
         require_once dirname(__FILE__) . DS . 'easycalccheckplus' . DS . 'akismet.php';
         $akismet_key = $this->params->get('akismet_key');
         if ($akismet_key) {
             $akismet_url = JURI::getInstance()->toString();
             $name = '';
             $email = '';
             $url = '';
             $comment = '';
             if ($request['option'] == 'com_contact') {
                 $name = $request['jform']['contact_name'];
                 $email = $request['jform']['contact_email'];
                 $comment = $request['jform']['contact_message'];
             } elseif ($request['option'] == 'com_users') {
                 $name = $request['jform']['name'];
                 $email = $request['jform']['email1'];
                 if (isset($request['jform']['email'])) {
                     $email = $request['jform']['email'];
                 }
             } elseif ($request['option'] == 'com_comprofiler') {
                 $name = $request['name'];
                 $email = $request['email'];
                 if (isset($request['checkusername'])) {
                     $name = $request['checkusername'];
                 }
                 if (isset($request['checkemail'])) {
                     $email = $request['checkemail'];
                 }
             } elseif ($request['option'] == 'com_easybookreloaded') {
                 $name = $request['gbname'];
                 $email = $request['gbmail'];
                 $comment = $request['gbtext'];
                 if (isset($request['gbpage'])) {
                     $url = $request['gbpage'];
                 }
             } elseif ($request['option'] == 'com_phocaguestbook') {
                 $name = $request['pgusername'];
                 $email = $request['email'];
                 $comment = $request['pgbcontent'];
             } elseif ($request['option'] == 'com_dfcontact') {
                 $name = $request['name'];
                 $email = $request['email'];
                 $comment = $request['message'];
             } elseif ($request['option'] == 'com_flexicontact') {
                 $name = $request['from_name'];
                 $email = $request['from_email'];
                 $comment = $request['area_data'];
             } elseif ($request['option'] == 'com_alfcontact') {
                 $name = $request['name'];
                 $email = $request['email'];
                 $comment = $request['message'];
             } elseif ($request['option'] == 'com_community') {
                 $name = $request['usernamepass'];
                 $email = $request['emailpass'];
             } elseif ($request['option'] == 'com_virtuemart') {
                 $name = $request['name'];
                 $email = $request['email'];
                 $comment = $request['comment'];
             } elseif ($request['option'] == 'com_jshopping') {
                 $name = $request['f_name'];
                 $email = $request['email'];
             }
             $akismet = new Akismet($akismet_url, $akismet_key);
             $akismet->setCommentAuthor($name);
             $akismet->setCommentAuthorEmail($email);
             $akismet->setCommentAuthorURL($url);
             $akismet->setCommentContent($comment);
             if ($akismet->isCommentSpam()) {
                 return false;
             }
         }
     }
     // ReCaptcha
     // Further informations: http://www.google.com/recaptcha
     if ($this->params->get('recaptcha') and $this->params->get('recaptcha_publickey') and $this->params->get('recaptcha_privatekey')) {
         require_once dirname(__FILE__) . DS . 'easycalccheckplus' . DS . 'recaptchalib.php';
         $privatekey = $this->params->get('recaptcha_privatekey');
         $resp = recaptcha_check_answer($privatekey, $this->_session->get('ip', null, 'easycalccheck'), $request['recaptcha_challenge_field'], $request['recaptcha_response_field']);
         if (!$resp->is_valid) {
             return false;
         }
     }
     // Botscout - Check the IP Address
     // Further informations: http://botscout.com/
     if ($this->params->get('botscout') and $this->params->get('botscout_key')) {
         $url = 'http://botscout.com/test/?ip=' . $this->_session->get('ip', null, 'easycalccheck') . '&key=' . $this->params->get('botscout_key');
         // Function test - Comment out to test - Important: Enter a active Spam-IP
         // $ip = '87.103.128.199';
         // $url = 'http://botscout.com/test/?ip='.$ip.'&key='.$this->params->get('botscout_key');
         $response = false;
         $is_spam = false;
         if (function_exists('curl_init')) {
             $ch = curl_init($url);
             curl_setopt($ch, CURLOPT_HEADER, 0);
             curl_setopt($ch, CURLOPT_POST, 0);
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
             $response = curl_exec($ch);
             curl_close($ch);
         }
         if ($response) {
             $is_spam = substr($response, 0, 1);
         } else {
             $response = @fopen($url, 'r');
             if ($response) {
                 while (!feof($response)) {
                     $line = fgets($response, 1024);
                     $is_spam = substr($line, 0, 1);
                 }
                 fclose($response);
             }
         }
         if ($is_spam == 'Y' and $response == true) {
             // Spam-IP - failed
             return false;
         }
     }
     // Mollom
     // Further informations: http://mollom.com/
     if ($this->params->get('mollom') and $this->params->get('mollom_publickey') and $this->params->get('mollom_privatekey')) {
         require_once dirname(__FILE__) . DS . 'easycalccheckplus' . DS . 'mollom.php';
         Mollom::setPublicKey($this->params->get('mollom_publickey'));
         Mollom::setPrivateKey($this->params->get('mollom_privatekey'));
         $servers = Mollom::getServerList();
         $name = '';
         $email = '';
         $url = '';
         $comment = '';
         if ($request['option'] == 'com_contact') {
             $name = $request['jform']['contact_name'];
             $email = $request['jform']['contact_email'];
             $comment = $request['jform']['contact_message'];
         } elseif ($request['option'] == 'com_users') {
             $name = $request['jform']['name'];
             $email = $request['jform']['email1'];
             if (isset($request['jform']['email'])) {
                 $email = $request['jform']['email'];
             }
         } elseif ($request['option'] == 'com_comprofiler') {
             $name = $request['name'];
             $email = $request['email'];
             if (isset($request['checkusername'])) {
                 $name = $request['checkusername'];
             }
             if (isset($request['checkemail'])) {
                 $email = $request['checkemail'];
             }
         } elseif ($request['option'] == 'com_easybookreloaded') {
             $name = $request['gbname'];
             $email = $request['gbmail'];
             $comment = $request['gbtext'];
             if (isset($request['gbpage'])) {
                 $url = $request['gbpage'];
             }
         } elseif ($request['option'] == 'com_phocaguestbook') {
             $name = $request['pgusername'];
             $email = $request['email'];
             $comment = $request['pgbcontent'];
         } elseif ($request['option'] == 'com_dfcontact') {
             $name = $request['name'];
             $email = $request['email'];
             $comment = $request['message'];
         } elseif ($request['option'] == 'com_flexicontact') {
             $name = $request['from_name'];
             $email = $request['from_email'];
             $comment = $request['area_data'];
         } elseif ($request['option'] == 'com_alfcontact') {
             $name = $request['name'];
             $email = $request['email'];
             $comment = $request['message'];
         } elseif ($request['option'] == 'com_community') {
             $name = $request['usernamepass'];
             $email = $request['emailpass'];
         } elseif ($request['option'] == 'com_virtuemart') {
             $name = $request['name'];
             $email = $request['email'];
             $comment = $request['comment'];
         } elseif ($request['option'] == 'com_jshopping') {
             $name = $request['f_name'];
             $email = $request['email'];
         }
         $feedback = Mollom::checkContent(null, null, $comment, $name, $url, $email);
         if ($feedback['spam'] == 'spam') {
             return false;
         }
     }
     $this->_session->clear('ip', 'easycalccheck');
     $this->_session->clear('saved_data', 'easycalccheck');
     return true;
 }
Beispiel #8
0
 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);
         }
     }
 }