本文整理匯總了PHP中Akismet::setTimeOut方法的典型用法代碼示例。如果您正苦於以下問題:PHP Akismet::setTimeOut方法的具體用法?PHP Akismet::setTimeOut怎麽用?PHP Akismet::setTimeOut使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Akismet
的用法示例。
在下文中一共展示了Akismet::setTimeOut方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: isSpam
/**
* General method to check if something is spam
*
* @param string $content The content that was submitted.
* @param string $permaLink The permanent location of the entry the comment was submitted to.
* @param string[optional] $author Commenters name.
* @param string[optional] $email Commenters email address.
* @param string[optional] $URL Commenters URL.
* @param string[optional] $type May be blank, comment, trackback, pingback, or a made up value like "registration".
* @return bool|string Will return a boolean, except when we can't decide the status (unknown will be returned in that case)
*/
public static function isSpam($content, $permaLink, $author = null, $email = null, $URL = null, $type = 'comment')
{
// get some settings
$akismetKey = self::getModuleSetting('core', 'akismet_key');
// invalid key, so we can't detect spam
if ($akismetKey === '') {
return false;
}
// require the class
require_once PATH_LIBRARY . '/external/akismet.php';
// create new instance
$akismet = new Akismet($akismetKey, SITE_URL);
// set properties
$akismet->setTimeOut(10);
$akismet->setUserAgent('Fork CMS/' . FORK_VERSION);
// try it, to decide if the item is spam
try {
// check with Akismet if the item is spam
return $akismet->isSpam($content, $author, $email, $URL, $permaLink, $type);
} catch (Exception $e) {
// in debug mode we want to see exceptions, otherwise the fallback will be triggered
if (SPOON_DEBUG) {
throw $e;
}
// return unknown status
return 'unknown';
}
// when everything fails
return false;
}
示例2: submitSpam
/**
* Submit spam, his call is for submitting comments that weren't marked as spam but should have been.
*
* @return bool If everything went fine true will be returned, otherwise an exception will be triggered.
* @param string $userIp IP address of the comment submitter.
* @param string $userAgent User agent information.
* @param string[optional] $content The content that was submitted.
* @param string[optional] $author Submitted name with the comment.
* @param string[optional] $email Submitted email address.
* @param string[optional] $url Commenter URL.
* @param string[optional] $permalink The permanent location of the entry the comment was submitted to.
* @param string[optional] $type May be blank, comment, trackback, pingback, or a made up value like "registration".
* @param string[optional] $referrer The content of the HTTP_REFERER header should be sent here.
* @param array[optional] $others Other data (the variables from $_SERVER).
*/
public static function submitSpam($userIp, $userAgent, $content, $author = null, $email = null, $url = null, $permalink = null, $type = null, $referrer = null, $others = null)
{
// get some settings
$akismetKey = self::getModuleSetting('core', 'akismet_key');
// invalid key, so we can't detect spam
if ($akismetKey === '') {
return false;
}
// require the class
require_once PATH_LIBRARY . '/external/akismet.php';
// create new instance
$akismet = new Akismet($akismetKey, SITE_URL);
// set properties
$akismet->setTimeOut(10);
$akismet->setUserAgent('Fork CMS/2.1');
// try it to decide it the item is spam
try {
// check with Akismet if the item is spam
return $akismet->submitSpam($userIp, $userAgent, $content, $author = null, $email = null, $url = null, $permalink = null, $type = null, $referrer = null, $others = null);
} catch (Exception $e) {
// in debug mode we want to see exceptions, otherwise the fallback will be triggered
if (SPOON_DEBUG) {
throw $e;
}
}
// when everything fails
return false;
}