当前位置: 首页>>代码示例>>PHP>>正文


PHP Akismet::isSpam方法代码示例

本文整理汇总了PHP中Akismet::isSpam方法的典型用法代码示例。如果您正苦于以下问题:PHP Akismet::isSpam方法的具体用法?PHP Akismet::isSpam怎么用?PHP Akismet::isSpam使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Akismet的用法示例。


在下文中一共展示了Akismet::isSpam方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testIsSpam

 function testIsSpam()
 {
     $this->akismet->commentUserIp = "113.91.127.32";
     $this->akismet->commentAuthor = "office 2010 download";
     $this->assertTrue(isset($this->akismet));
     $this->assertTrue($this->akismet->isSpam());
 }
开发者ID:paulomartinhago,项目名称:Silex-Blog-App,代码行数:7,代码来源:AkismetTest.php

示例2: akismet_create_topic

function akismet_create_topic($msg_options, $topic_options, $poster_options)
{
    global $modSettings, $scripturl, $smcFunc, $sourcedir;
    require $sourcedir . '/Akismet.class.php';
    // If the subject is 'akismet-test-123', then mark it as spam (this is a test)
    if ($msg_options['subject'] == 'akismet-test-123') {
        $spam = true;
    } else {
        // If the API key has been set
        if (isset($modSettings['akismetAPIKey']) && $modSettings['akismetAPIKey'] != "") {
            // Set up the Akismet class
            $akismet = new Akismet($scripturl, $modSettings['akismetAPIKey']);
            $akismet->setAuthor($poster_options['name']);
            $akismet->setAuthorEmail($poster_options['email']);
            //$akismet->setCommentAuthorURL(""); -- URL's not used in SMF.
            $akismet->setContent($msg_options['body']);
            if (!empty($topic_options['id'])) {
                $akismet->setPermalink($scripturl . '?topic=' . $topicOptions['id']);
            }
            $akismet->setType('smf-post');
            // Now, the moment of truth... Send the post to Akismet
            $akismet_return = $akismet->isSpam();
            // Was the server down?
            if ($akismet_return === 'conn_error') {
                // Assume it's not spam. We log an error to the error log later
                $spam = false;
                // Log it!
                if (empty($modSettings['akismetNoLog'])) {
                    log_error(sprintf($txt['akismet_cant_connect2'], $_POST['guestname'], $scripturl . '?topic=' . $topic . (isset($_REQUEST['msg']) ? '.msg' . $_REQUEST['msg'] : '')));
                }
            } elseif ($akismet_return === true) {
                // Oh, the horror! Someone posted spam to your forum!
                $spam = true;
            } else {
                $spam = false;
            }
        } else {
            // No API key, assume it isn't spam
            $spam = false;
        }
    }
    if ($spam) {
        // Mark the message as spam and unapprove the post. Post moderation is a big help here. :)
        $smcFunc['db_query']('', '
			UPDATE {db_prefix}topics
			SET spam = 1,
				approved = 0,
				unapproved_posts = 1
			WHERE id_topic = {int:id_topic}', array('id_topic' => $topic_options['id']));
        $smcFunc['db_query']('', '
			UPDATE {db_prefix}messages
			SET approved = 0
			WHERE id_msg = {int:id_msg}', array('id_msg' => $msg_options['id']));
        // Increase spam count
        $smcFunc['db_query']('', '
			UPDATE {db_prefix}settings
			SET value = value + 1
			WHERE variable = {string:akismetCaughtSpam}', array('akismetCaughtSpam' => 'akismetCaughtSpam'));
    }
}
开发者ID:valek0972,项目名称:hackits,代码行数:60,代码来源:Subs-Akismet.php

示例3: filterMessage

 /**
  * 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)
 {
     $commentData = array('author' => $author, 'email' => $email, 'website' => $website, 'body' => $body, 'permalink' => $imageLink);
     $zp_galUrl = FULLWEBPATH;
     // Sets the webpath for the Akismet server
     $zp_akismetKey = getOption('Akismet_key');
     $forgive = getOption('Forgiving');
     $die = 2;
     // good comment until proven bad
     $akismet = new Akismet($zp_galUrl, $zp_akismetKey, $commentData);
     if ($akismet->errorsExist()) {
         // TODO: Add more improved error handling (maybe)
         // echo "Couldn't connected to Akismet server!";
         // print_r ($akismet->getErrors());
         $die = 1;
         // mark for moderation if we can't check for Spam
     } else {
         if ($akismet->isSpam()) {
             // Message is spam according to Akismet
             // echo 'Spam detected';
             // echo "bad message.";
             $die = $forgive;
         } else {
             // Message is not spam according to Akismet
             // echo "spam filter is true. good message.";
         }
     }
     return $die;
 }
开发者ID:ItsHaden,项目名称:epicLanBootstrap,代码行数:45,代码来源:akismet.php

示例4: validate

	/**
	 * validate the elements data against the rule
	 * @param string data to check
	 * @param object element model
	 * @param int plugin sequence ref
	 * @return bol true if validation passes, false if fails
	 */

	function validate($data, &$elementModel, $c)
	{
		$params = $this->getParams();
		$user = JFactory::getUser();
		if ($params->get('akismet-key') != '')
		{
			$username = $user->get('username') != '' ? $user->get('username') : $this->_randomSring();
			$email = $user->get('email') != '' ? $user->get('email') : $this->_randomSring().'@'.$this->_randomSring().'com';
			require_once(JPATH_COMPONENT.DS.'plugins'.DS.'validationrule'.DS.'akismet'.DS.'akismet.class.php');
			$akismet_comment = array (
															'author' => $username,
															'email' => $user->get('email'),
															'website' => JURI::base(),
															'body' => $data
			);
			$akismet = new Akismet(JURI::base(), $params->get('akismet-key'), $akismet_comment);
			if ($akismet->errorsExist()) {
				JError::raiseNotice( JText::_("Couldn't connected to Akismet server!"));
			} else {

				if ($akismet->isSpam()) {
					return false;
				}
			}
		}
		return true;
	}
开发者ID:Jobar87,项目名称:fabrik,代码行数:35,代码来源:akismet.php

示例5: rules

 /**
  * Get the validation rules that apply to the request.
  *
  * @return array
  */
 public function rules()
 {
     $input = $this->all();
     // service Aksimet checked content and email
     \Akismet::setCommentContent($input['content'])->setCommentAuthorEmail($input['email']);
     $input['spam'] = \Akismet::isSpam() ? 1 : 0;
     $this->replace($input);
     return ['email' => 'email|required', 'content' => 'required', 'post_id' => 'integer', 'published_at' => 'regex:/[0-9]{4}\\-[0-9]{2}\\-[0-9]{2} [0-9]{2}\\:[0-9]{2}\\:[0-9]{2}/'];
 }
开发者ID:Antoine07,项目名称:student,代码行数:14,代码来源:CommentFormRequest.php

示例6: beforeSave

 /**
  * beforeSave is called before a model is saved. Returning false from a beforeSave callback
  * will abort the save operation.
  *
  * @param Model $model Model using this behavior
  * @param array $options Options passed from Model::save().
  *
  * @return mixed|void
  */
 public function beforeSave(\Model $model, $options = array())
 {
     parent::beforeSave($model);
     $request = new CakeRequest();
     $data = ['blog' => urlencode(Configure::read('General.site_url')), 'user_ip' => urlencode($model->data[$model->alias]['author_ip']), 'user_agent' => urlencode($model->data[$model->alias]['agent']), 'referrer' => urlencode($request->referer()), 'permalink' => urlencode($request->referer()), 'comment_type' => urlencode('comment'), 'comment_author' => urlencode($model->data[$model->alias]['author']), 'comment_author_email' => urlencode($model->data[$model->alias]['author_email']), 'comment_author_url' => urlencode($model->data[$model->alias]['author_url']), 'comment_content' => urlencode($model->data[$model->alias]['content'])];
     if (Akismet::isSpam($data, Configure::read('Akismet.api_key'))) {
         $model->data[$model->alias]['status'] = 'spam';
     }
 }
开发者ID:atkrad,项目名称:akismet,代码行数:18,代码来源:AkismetBehavior.php

示例7: sendContact

 /**
  * @param ContactFormRequest $request
  * @return \Illuminate\Http\RedirectResponse
  *
  * PAGE CONTACT - SEND MESSAGE
  */
 public function sendContact(ContactFormRequest $request)
 {
     $messageMain = $request->input('message');
     $email = $request->input('email');
     \Akismet::setCommentContent($request->input('message'))->setCommentAuthorEmail($request->input('email'))->setCommentAuthorUrl($request->url());
     if (\Akismet::isSpam()) {
         return redirect()->back()->with('error', 'Message considéré comme du spam ! Merci d\'envoyer un message sans intentions commerciales');
     } else {
         Mail::send('emails.email', compact('messageMain', 'email'), function ($message) use($request) {
             $message->from('hicode@hicode.fr', 'Laravel');
             $message->to('pierremartin.pro@gmail.com')->cc('bar@exemple.com');
         });
         return redirect()->back()->with('message', 'Message envoyé');
     }
 }
开发者ID:PierreMartin,项目名称:starwars,代码行数:21,代码来源:FrontController.php

示例8: plugin_akismet_validate

function plugin_akismet_validate($bool, $contents)
{
    if (!$bool) {
        return false;
    }
    global $fp_config;
    $akismet = new Akismet($fp_config['general']['www'], plugin_getoptions('akismet', 'apikey'));
    $akismet->setAuthor($contents['name']);
    $akismet->setAuthorEmail(isset($contents['email']) ? $contents['email'] : '');
    $akismet->setAuthorURL(isset($contents['url']) ? $contents['url'] : '');
    $akismet->setContent($contents['content']);
    if ($v = $akismet->isSpam()) {
        global $smarty;
        $smarty->assign('error', array('ERROR: Comment is invalid'));
        return false;
    }
    return true;
}
开发者ID:mroussel,项目名称:flatpress,代码行数:18,代码来源:plugin.akismet.php

示例9: validate

 /**
  * Validate the elements data against the rule
  *
  * @param   string  $data           To check
  * @param   int     $repeatCounter  Repeat group counter
  *
  * @return  bool  true if validation passes, false if fails
  */
 public function validate($data, $repeatCounter)
 {
     $params = $this->getParams();
     if ($params->get('akismet-key') != '') {
         $username = $this->user->get('username') != '' ? $this->user->get('username') : $this->_randomSring();
         require_once JPATH_COMPONENT . '/plugins/validationrule/akismet/libs/akismet.class.php';
         $akismet_comment = array('author' => $username, 'email' => $this->user->get('email'), 'website' => JURI::base(), 'body' => $data);
         $akismet = new Akismet(JURI::base(), $params->get('akismet-key'), $akismet_comment);
         if ($akismet->errorsExist()) {
             throw new RuntimeException("Couldn't connected to Akismet server!");
         } else {
             if ($akismet->isSpam()) {
                 return false;
             }
         }
     }
     return true;
 }
开发者ID:jfquestiaux,项目名称:fabrik,代码行数:26,代码来源:akismet.php

示例10: onSubmit

 function onSubmit($vals)
 {
     $ak = appconf('akismet_key');
     if ($ak) {
         loader_import('siteblog.Akismet');
         $comment = array('author' => $vals['name'], 'email' => $vals['email'], 'website' => $vals['url'], 'body' => $vals['body'], 'permalink' => site_url() . '/index/siteblog-post-action/id.' . $vals['post'] . '/title.' . siteblog_filter_link_title($title), 'user_ip' => $_SERVER['REMOTE_ADDR'], 'user_agent' => $_SERVER['HTTP_USER_AGENT']);
         $akismet = new Akismet(site_url(), $ak, $comment);
         if (!$akismet->errorsExist()) {
             // no errors
             if ($akismet->isSpam()) {
                 // akismet says spam
                 $title = db_shift('select subject from siteblog_post where id = ?', $vals['post']);
                 db_execute('insert into siteblog_akismet values (null, ?, now(), ?, ?, ?, ?, ?, ?)', $vals['post'], $comment['author'], $comment['email'], $comment['website'], $comment['user_ip'], $comment['user_agent'], $comment['body']);
                 header('Location: ' . site_prefix() . '/index/siteblog-post-action/id.' . $vals['post'] . '/title.' . siteblog_filter_link_title($title));
                 exit;
             }
         }
     }
     if (!empty($vals['post'])) {
         $res = db_execute('insert into siteblog_comment (id, child_of_post, body, date, author, email, url, ip) values (null, ?, ?, now(), ?, ?, ?, ?)', $vals['post'], $vals['body'], $vals['name'], $vals['email'], $vals['url'], $_SERVER['REMOTE_ADDR']);
         if (!$res) {
             die(db_error());
         }
         $id = db_lastid();
     } else {
         $res = db_execute('update siteblog_comment set body = ?, author = ?, email = ?, url = ? where id = ?', $vals['body'], $vals['name'], $vals['email'], $vals['url'], $vals['_key']);
         if (!$res) {
             die(db_error());
         }
         $id = $vals['_key'];
         $vals['post'] = db_shift('select child_of_post from siteblog_comment where id = ?', $vals['_key']);
     }
     $title = db_shift('select subject from siteblog_post where id = ?', $vals['post']);
     header('Location: ' . site_prefix() . '/index/siteblog-post-action/id.' . $vals['post'] . '/title.' . siteblog_filter_link_title($title) . '#siteblog-comment-' . $id);
     exit;
 }
开发者ID:vojtajina,项目名称:sitellite,代码行数:36,代码来源:index.php

示例11: get_pingback

 public function get_pingback($id)
 {
     $postdata = file_get_contents("php://input");
     if ($postdata) {
         $xml = new SimpleXMLElement($postdata);
         $pingback_sender_url = strval($xml->params->param[0]->value->string);
         $pingback_receiver_url = strval($xml->params->param[1]->value->string);
         // get content:
         if ($pingback_sender_url) {
             if ($url_content = $this->_get_url_content($pingback_sender_url)) {
                 if (strpos($url_content[1], BASE_URL . PAGE) !== false) {
                     // get title:
                     preg_match("/<title>(.*)<\\/title>/i", $url_content[1], $matches);
                     if (isset($matches[1]) && trim($matches[1]) != '') {
                         $pingback_title = trim(filter_control_characters($matches[1]));
                         if (mb_strlen($pingback_title) > $this->pingback_title_maxlength) {
                             $pingback_title = truncate($pingback_title, $this->pingback_title_maxlength);
                         }
                     } else {
                         $pingback_error = true;
                     }
                     // get body:
                     preg_match("/<body[^>]*>(.*)<\\/body>/smi", $url_content[1], $b_matches);
                     if (isset($b_matches[1]) && trim($b_matches[1]) != '') {
                         $body = strip_tags($b_matches[1]);
                         $body = preg_replace("/\r\n|\r|\n/", "\n", $body);
                         $body_lines = explode("\n", $body);
                         $cleared_body = '';
                         foreach ($body_lines as $body_line) {
                             if (trim($body_line) != '') {
                                 $cleared_body .= trim($body_line) . ' ';
                             }
                         }
                         $cleared_body = trim(filter_control_characters($cleared_body));
                     } else {
                         $pingback_error = true;
                     }
                     if (empty($pingback_error)) {
                         // not accepted words check:
                         $joined_message = mb_strtolower($pingback_title . ' ' . $pingback_sender_url . ' ' . $cleared_body);
                         $not_accepted_words = get_not_accepted_words($joined_message);
                         if ($not_accepted_words) {
                             $pingback_error = true;
                         }
                     }
                     if (empty($pingback_error)) {
                         // Akismet spam check:
                         if ($this->settings['akismet_key'] != '' && $this->settings['akismet_entry_check'] == 1) {
                             $check_posting['author'] = $pingback_title;
                             $check_posting['website'] = $pingback_sender_url;
                             $check_posting['body'] = truncate($cleared_body, 3000);
                             $akismet = new Akismet(BASE_URL, $this->settings['akismet_key'], $check_posting);
                             // test for errors
                             if ($akismet->errorsExist()) {
                                 //$pingback_error = true;
                                 if ($akismet->isError(AKISMET_INVALID_KEY)) {
                                     $akismet_errors[] = 'akismet_error_api_key';
                                 } elseif ($akismet->isError(AKISMET_RESPONSE_FAILED)) {
                                     $akismet_errors[] = 'akismet_error_connection';
                                 } elseif ($akismet->isError(AKISMET_SERVER_NOT_FOUND)) {
                                     $akismet_errors[] = 'akismet_error_connection';
                                 }
                             } else {
                                 // No errors, check for spam
                                 if ($akismet->isSpam()) {
                                     // TODO:
                                     #$pingback_error = true;
                                     $akismet_spam = true;
                                     #$mail = new Mail();
                                     #$mail->send($this->settings['email'], $this->settings['email'], 'Pingback-Spam?', $check_posting['author']."\n".$check_posting['website']."\n".$check_posting['body'], $this->settings['mail_parameter']);
                                 }
                             }
                         }
                     }
                     if (empty($pingback_error)) {
                         // check if url was already posted:
                         $dbr = Database::$entries->prepare("SELECT COUNT(*) FROM " . Database::$db_settings['comment_table'] . " WHERE comment_id=:comment_id AND type=0 AND comment='' AND email_hp=:email_hp");
                         $dbr->bindParam(':comment_id', $id, PDO::PARAM_INT);
                         $dbr->bindParam(':email_hp', $pingback_sender_url, PDO::PARAM_STR);
                         $dbr->execute();
                         $comment_count = $dbr->fetchColumn();
                         if ($comment_count > 0) {
                             $pingback_error = true;
                         }
                     }
                     if (empty($pingback_error)) {
                         $dbr = Database::$entries->prepare("INSERT INTO " . Database::$db_settings['comment_table'] . " (type, comment_id, time, ip, name, email_hp, comment) VALUES (0, :comment_id, :time, :ip, :name, :email_hp, '')");
                         $dbr->bindParam(':comment_id', $id, PDO::PARAM_INT);
                         $dbr->bindValue(':time', time(), PDO::PARAM_INT);
                         $dbr->bindParam(':ip', $_SERVER['REMOTE_ADDR'], PDO::PARAM_STR);
                         $dbr->bindParam(':name', $pingback_title, PDO::PARAM_STR);
                         $dbr->bindParam(':email_hp', $pingback_sender_url, PDO::PARAM_STR);
                         $dbr->execute();
                         // E-mail notification to admin:
                         if ($this->settings['comment_notification'] && $this->settings['email']) {
                             $this->_localization->replacePlaceholder('page', PAGE, 'pingback_notification_subject');
                             $this->_localization->replacePlaceholder('title', $pingback_title, 'pingback_notification_message');
                             $this->_localization->replacePlaceholder('url', $pingback_sender_url, 'pingback_notification_message');
                             $this->_localization->replacePlaceholder('link', BASE_URL . PAGE, 'pingback_notification_message');
                             // TODO:
//.........这里部分代码省略.........
开发者ID:hplc,项目名称:phpsqlitecms,代码行数:101,代码来源:Pingback.class.php

示例12: akismet_check_submit

function akismet_check_submit(&$vars)
{
    if (phpnum() >= 5) {
        include akismet_lib_path . 'Akismet.class_5.php';
        $x = $x['linkres'];
        $user = new User();
        $user->id = $x->author;
        $user->read();
        $akismet = new Akismet(my_base_url . my_pligg_base, get_misc_data('wordpress_key'));
        $akismet->setCommentAuthor($user->username);
        $akismet->setCommentAuthorEmail($user->email);
        $akismet->setCommentAuthorURL($x->url);
        $akismet->setCommentContent($x->content);
        $akismet->setPermalink(getmyurl('story', $x->id));
        if ($akismet->isCommentSpam()) {
            // store the comment but mark it as spam (in case of a mis-diagnosis)
            $spam_links = get_misc_data('spam_links');
            if ($spam_links != '') {
                $spam_links = unserialize(get_misc_data('spam_links'));
            } else {
                $spam_links = array();
            }
            $spam_links[] = $x->id;
            misc_data_update('spam_links', serialize($spam_links));
            totals_adjust_count($x->status, -1);
            totals_adjust_count('discard', 1);
            $x->status = 'discard';
        } else {
            // echo 'not spam';
        }
    } else {
        include akismet_lib_path . 'Akismet.class_4.php';
        $x = $vars['linkres'];
        $user = new User();
        $user->id = $x->author;
        $user->read();
        $story['author'] = $user->username;
        $story['email'] = $user->email;
        $story['website'] = $x->url;
        $story['body'] = $x->content;
        $story['permalink'] = getmyurl('story', $x->id);
        $story['user_ip'] = $user->extra_field['user_lastip'];
        $akismet = new Akismet(my_base_url . my_pligg_base, get_misc_data('wordpress_key'), $story);
        // test for errors
        if ($akismet->errorsExist()) {
            // returns true if any errors exist
            if ($akismet->isError('AKISMET_INVALID_KEY')) {
                // echo 'invalid key';
            } elseif ($akismet->isError('AKISMET_RESPONSE_FAILED')) {
                // echo 'response failed';
            } elseif ($akismet->isError('AKISMET_SERVER_NOT_FOUND')) {
                // echo 'server not found';
            }
        } else {
            // No errors, check for spam
            if ($akismet->isSpam()) {
                // returns true if Akismet thinks the comment is spam
                $spam_links = get_misc_data('spam_links');
                if ($spam_links != '') {
                    $spam_links = unserialize(get_misc_data('spam_links'));
                } else {
                    $spam_links = array();
                }
                $spam_links[] = $x->id;
                misc_data_update('spam_links', serialize($spam_links));
            } else {
                // echo 'not spam';
            }
        }
    }
}
开发者ID:pantofla,项目名称:waterfan,代码行数:71,代码来源:akismet_main.php

示例13: check_data


//.........这里部分代码省略.........
             }
         }
         if (empty($data['name'])) {
             $this->errors[] = 'comment_error_no_name';
         }
         if (empty($data['comment_text'])) {
             $this->errors[] = 'comment_error_no_text';
         }
         if (mb_strlen($data['name']) > $this->name_maxlength) {
             $this->errors[] = 'comment_error_name_too_long';
         }
         if (mb_strlen($data['email_hp']) > $this->email_hp_maxlength) {
             $this->errors[] = 'comment_error_email_hp_too_long';
         }
         if (!empty($data['email_hp'])) {
             if (strpos($data['email_hp'], ' ') !== false || strpos($data['email_hp'], '.') === false) {
                 $this->errors[] = 'comment_error_email_hp_invalid';
             }
         }
         if (mb_strlen($data['comment_text']) > $this->comment_maxlength) {
             $text_length = mb_strlen($data['comment_text']);
             $this->errors[] = 'comment_error_text_too_long';
             $this->_localization->replacePlaceholder('characters', $text_length, 'comment_error_text_too_long');
             $this->_localization->replacePlaceholder('max_characters', $this->comment_maxlength, 'comment_error_text_too_long');
         }
     }
     if (empty($this->errors)) {
         if ($too_long_words = too_long_words(strip_tags($this->format_comment($data['comment_text'])), $this->word_maxlength)) {
             foreach ($too_long_words as $too_long_word) {
                 $stripped_too_long_words[] = htmlspecialchars(mb_substr($too_long_word, 0, $this->word_maxlength)) . '...';
             }
             $too_long_words_listing = implode(', ', $stripped_too_long_words);
             if (count($too_long_words) == 1) {
                 $this->errors[] = 'comment_error_too_long_word';
                 #$this->assign_lang_placeholder('word', $too_long_words_listing, 'comment_error_too_long_word');
                 $this->_localization->replacePlaceholder('word', $too_long_words_listing, 'comment_error_too_long_word');
             } else {
                 $this->errors[] = 'comment_error_too_long_words';
                 #$this->assign_lang_placeholder('words', $too_long_words_listing, 'comment_error_too_long_words');
                 $this->_localization->replacePlaceholder('words', $too_long_words_listing, 'comment_error_too_long_words');
             }
         }
         // check for double and repeated entries:
         $dbr = Database::$entries->prepare("SELECT COUNT(*) FROM " . Database::$db_settings['comment_table'] . " WHERE time>:time AND comment_id=:comment_id AND name=:name AND email_hp=:email_hp AND comment=:comment");
         $time = time() - 300;
         // last 5 minutes
         $dbr->bindParam(':time', $time, PDO::PARAM_INT);
         $dbr->bindParam(':comment_id', $this->comment_id, PDO::PARAM_INT);
         $dbr->bindParam(':name', $data['name'], PDO::PARAM_STR);
         $dbr->bindParam(':email_hp', $data['email_hp'], PDO::PARAM_STR);
         $dbr->bindParam(':comment', $data['comment_text'], PDO::PARAM_STR);
         $dbr->execute();
         if ($dbr->fetchColumn() > 0) {
             $this->errors[] = 'comment_error_entry_exists';
         }
         if ($this->prevent_repeated_posts_minutes > 0) {
             $dbr = Database::$entries->prepare("SELECT COUNT(*) FROM " . Database::$db_settings['comment_table'] . " WHERE time>:time AND comment_id=:comment_id AND ip=:ip");
             $time = time() - $this->prevent_repeated_posts_minutes * 60;
             $dbr->bindParam(':time', $time, PDO::PARAM_INT);
             $dbr->bindParam(':comment_id', $this->comment_id, PDO::PARAM_INT);
             $dbr->bindParam(':ip', $_SERVER["REMOTE_ADDR"], PDO::PARAM_STR);
             $dbr->execute();
             if ($dbr->fetchColumn() > 0) {
                 $this->errors[] = 'comment_error_repeated_post';
             }
         }
         if ($save) {
             // Akismet spam check:
             if ($this->akismet_key != '' && $this->akismet_entry_check == 1) {
                 #require('./cms/modules/akismet/akismet.class.php');
                 $check_posting['author'] = $data['name'];
                 if ($data['email_hp'] != '') {
                     if (preg_match("/^[^@]+@.+\\.\\D{2,5}\$/", $email_hp)) {
                         $check_posting['email'] = $data['email_hp'];
                     } else {
                         $check_posting['website'] = $data['email_hp'];
                     }
                 }
                 $check_posting['body'] = $data['comment_text'];
                 $akismet = new Akismet(BASE_URL, $this->akismet_key, $check_posting);
                 // test for errors
                 if ($akismet->errorsExist()) {
                     if ($akismet->isError(AKISMET_INVALID_KEY)) {
                         $this->errors[] = 'akismet_error_api_key';
                     } elseif ($akismet->isError(AKISMET_RESPONSE_FAILED)) {
                         $this->errors[] = 'akismet_error_connection';
                     } elseif ($akismet->isError(AKISMET_SERVER_NOT_FOUND)) {
                         $this->errors[] = 'akismet_error_connection';
                     }
                 } else {
                     // No errors, check for spam
                     if ($akismet->isSpam()) {
                         $this->errors[] = 'akismet_spam_suspicion';
                     }
                 }
             }
         }
         // end if($save)
     }
 }
开发者ID:adartk,项目名称:phpsqlitecms,代码行数:101,代码来源:Comment.class.php

示例14: Akismet

         $check_mail['author'] = $mail_parts[0];
         $check_mail['email'] = $email;
         $check_mail['body'] = $message;
         $akismet = new Akismet(BASE_URL, $settings['akismet_key'], $check_mail);
         // test for errors
         if ($akismet->errorsExist()) {
             if ($akismet->isError(AKISMET_INVALID_KEY)) {
                 $errors[] = 'akismet_error_api_key';
             } elseif ($akismet->isError(AKISMET_RESPONSE_FAILED)) {
                 $errors[] = 'akismet_error_connection';
             } elseif ($akismet->isError(AKISMET_SERVER_NOT_FOUND)) {
                 $errors[] = 'akismet_error_connection';
             }
         } else {
             // No errors, check for spam
             if ($akismet->isSpam()) {
                 $errors[] = 'akismet_spam_suspicion';
             }
         }
     }
     // End Akismet spam check:
 }
 if (empty($errors)) {
     $mail->set_charset(CHARSET);
     if (empty($subject)) {
         $subject = Localization::$lang['formmailer_no_subject'];
     }
     foreach ($recipients as $recipient) {
         if ($mail->send($recipient, $email, $subject, $message, $settings['mail_parameter'])) {
             $template->assign('mail_sent', true);
             $template->assign('hide_content', true);
开发者ID:hplc,项目名称:phpsqlitecms,代码行数:31,代码来源:formmailer.php

示例15: spamfilter

 function spamfilter($comment = null)
 {
     global $vars, $defaultpage;
     // Through if GET (Check only POST)
     if ($_SERVER['REQUEST_METHOD'] === 'GET') {
         return;
     }
     // Through if POST is from akismet plugin (submitHam)
     if (isset($vars['cmd']) && $vars['cmd'] == 'akismet') {
         return;
     }
     // Through if in IGNORE list
     $cmd = isset($vars['cmd']) ? $vars['cmd'] : (isset($vars['plugin']) ? $vars['plugin'] : 'read');
     if (defined('PLUGIN_AKISMET_IGNORE_PLUGINS')) {
         if (in_array($cmd, explode(',', PLUGIN_AKISMET_IGNORE_PLUGINS))) {
             return;
         }
     }
     // Through if already known he is a human
     $use_authlevel = PLUGIN_AKISMET_THROUGH_IF_ENROLLEE ? ROLE_AUTH : (PLUGIN_AKISMET_THROUGH_IF_ADMIN ? ROLE_ADM_CONTENTS : 0);
     if (is_human(NULL, PLUGIN_AKISMET_USE_SESSION, $use_authlevel)) {
         return;
     }
     // Initialize $comment
     if (!isset($comment)) {
         // special case (now only supports edit plugin)
         if ($vars['cmd'] === 'edit' || $vars['plugin'] === 'edit') {
             $body = $vars['msg'];
         } else {
             $body = implode("\n", $vars);
         }
         $comment = array('author' => '', 'email' => '', 'website' => '', 'body' => $body, 'permalink' => '', 'user_ip' => $_SERVER['REMOTE_ADDR'], 'user_agent' => $_SERVER['HTTP_USER_AGENT']);
     }
     $is_spam = TRUE;
     if (PLUGIN_AKISMET_USE_AKISMET) {
         // Through if no body (Akismet recognizes as a spam if no body)
         if ($comment['body'] == '') {
             return;
         }
         // instantiate an instance of the class
         $akismet = new Akismet(get_script_uri(), PLUGIN_AKISMET_API_KEY, $comment);
         // test for errors
         if ($akismet->errorsExist()) {
             // returns TRUE if any errors exist
             if ($akismet->isError('AKISMET_INVALID_KEY')) {
                 die_message('akismet : APIキーが不正です.');
             } elseif ($akismet->isError('AKISMET_RESPONSE_FAILED')) {
                 //die_message('akismet : レスポンスの取得に失敗しました');
             } elseif ($akismet->isError('AKISMET_SERVER_NOT_FOUND')) {
                 //die_message('akismet : サーバへの接続に失敗しました.');
             }
             $is_spam = FALSE;
             // through if akismet.com is not available.
         } else {
             $is_spam = $akismet->isSpam();
         }
         if ($is_spam) {
             $detail = PLUGIN_AKISMET_SPAMLOG_DETAIL ? $comment : array();
             PluginAkismet::spamlog_write($vars, $detail, PLUGIN_AKISMET_SPAMLOG_FILENAME);
         }
     }
     if ($is_spam) {
         if (PLUGIN_AKISMET_RECAPTCHA_LOG) {
             PluginAkismet::spamlog_write($vars, array('body' => 'hit'), LOG_DIR . 'captchalog.txt');
         }
         $form = PluginAkismet::get_captcha_form($vars, $comment);
         // die_message('</strong>' . $form . '<strong>');
         $title = $page = 'キャプチャ認証';
         pkwk_common_headers();
         catbody($title, $page, $form);
         exit;
     }
 }
开发者ID:orangeal2o3,项目名称:pukiwiki-plugin,代码行数:73,代码来源:akismet.inc.php


注:本文中的Akismet::isSpam方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。