本文整理汇总了PHP中Akismet::setContent方法的典型用法代码示例。如果您正苦于以下问题:PHP Akismet::setContent方法的具体用法?PHP Akismet::setContent怎么用?PHP Akismet::setContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Akismet
的用法示例。
在下文中一共展示了Akismet::setContent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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'));
}
}
示例2: 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;
}