本文整理匯總了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;
}