• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Akismet类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: detect_spam

 /**
  * Passes form content to the Akismet API. If spam is detected, sends an error message back to the user.
  */
 public function detect_spam()
 {
     $form_contents = '';
     foreach ($this->disco_form->get_values() as $k => $v) {
         if (is_array($v)) {
             $form_contents .= implode($v, ' ') . ' ';
         } else {
             // don't include hidden elements which contain objects as values
             if (!(get_class($this->disco_form->get_element($k)) == 'hiddenType' && substr($v, 0, 3) == 'id_')) {
                 $form_contents .= $v . ' ';
             }
         }
     }
     $akismet_api_key = constant("AKISMET_API_KEY");
     if (!empty($akismet_api_key)) {
         $url = carl_construct_link();
         //$akismet = new Akismet($url, $akismet_api_key, $is_test=1); // for testing
         $akismet = new Akismet($url, $akismet_api_key);
         $akismet->setCommentContent($form_contents);
         //$akismet->setCommentAuthor('viagra-test-123'); // for testing
         if ($akismet->isCommentSpam()) {
             $this->disco_form->set_error(NULL, 'Spam detected in this submission. If this message was made in error, please contact an administrator.', $element_must_exist = false);
         }
     }
 }
开发者ID:hunter2814,项目名称:reason_package,代码行数:28,代码来源:akismet.php


示例2: 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


示例3: 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


示例4: buildAkismet

 /**
  * Build an Akismet object.
  *
  * @param string $key Authentication key.
  * @param string $server Remote URL.
  * @return Akismet
  */
 private static function buildAkismet($key, $server = false)
 {
     $Akismet = new Akismet(Gdn::request()->url('/', true), $key);
     if ($server) {
         $Akismet->setAkismetServer($server);
     }
     return $Akismet;
 }
开发者ID:vanilla,项目名称:addons,代码行数:15,代码来源:class.akismet.plugin.php


示例5: register

 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     $this->app->singleton('nickurt\\Akismet\\Akismet', function ($app) {
         $config = $app['config']->get('akismet');
         $akismet = new Akismet();
         $akismet->setApiKey($config['api_key']);
         $akismet->setBlogUrl($config['blog_url']);
         return $akismet;
     });
     $this->app->alias('nickurt\\Akismet\\Akismet', 'Akismet');
 }
开发者ID:nickurt,项目名称:laravel-akismet,代码行数:16,代码来源:ServiceProvider.php


示例6: doModel

 function doModel()
 {
     switch ($this->action) {
         case 'spamNbots':
             // calling the spam and bots view
             $akismet_key = osc_akismet_key();
             $akismet_status = 3;
             if ($akismet_key != '') {
                 require_once osc_lib_path() . 'Akismet.class.php';
                 $akismet_obj = new Akismet(osc_base_url(), $akismet_key);
                 $akismet_status = 2;
                 if ($akismet_obj->isKeyValid()) {
                     $akismet_status = 1;
                 }
             }
             View::newInstance()->_exportVariableToView('akismet_status', $akismet_status);
             $this->doView('settings/spamNbots.php');
             break;
         case 'akismet_post':
             // updating spam and bots option
             osc_csrf_check();
             $updated = 0;
             $akismetKey = Params::getParam('akismetKey');
             $akismetKey = trim($akismetKey);
             $updated = osc_set_preference('akismetKey', $akismetKey);
             if ($akismetKey == '') {
                 osc_add_flash_info_message(_m('Your Akismet key has been cleared'), 'admin');
             } else {
                 osc_add_flash_ok_message(_m('Your Akismet key has been updated'), 'admin');
             }
             $this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=spamNbots');
             break;
         case 'recaptcha_post':
             // updating spam and bots option
             osc_csrf_check();
             $iUpdated = 0;
             $recaptchaPrivKey = Params::getParam('recaptchaPrivKey');
             $recaptchaPrivKey = trim($recaptchaPrivKey);
             $recaptchaPubKey = Params::getParam('recaptchaPubKey');
             $recaptchaPubKey = trim($recaptchaPubKey);
             $iUpdated += osc_set_preference('recaptchaPrivKey', $recaptchaPrivKey);
             $iUpdated += osc_set_preference('recaptchaPubKey', $recaptchaPubKey);
             if ($recaptchaPubKey == '') {
                 osc_add_flash_info_message(_m('Your reCAPTCHA key has been cleared'), 'admin');
             } else {
                 osc_add_flash_ok_message(_m('Your reCAPTCHA key has been updated'), 'admin');
             }
             $this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=spamNbots');
             break;
     }
 }
开发者ID:oanav,项目名称:closetshare,代码行数:51,代码来源:spamnbots.php


示例7: Akismet

 /**
  * @return Akismet
  */
 public static function Akismet()
 {
     static $Akismet;
     if (!$Akismet) {
         $Key = C('Plugins.Akismet.Key', C('Plugins.Akismet.MasterKey'));
         if (!$Key) {
             return NULL;
         }
         $Akismet = new Akismet(Gdn::Request()->Url('/', TRUE), $Key);
         $Server = C('Plugins.Akismet.Server');
         if ($Server) {
             $Akismet->setAkismetServer($Server);
         }
     }
     return $Akismet;
 }
开发者ID:nilsen,项目名称:addons,代码行数:19,代码来源:class.akismet.plugin.php


示例8: check

 /**
  * Checks one or more comments against the Akismet API.
  *
  * ## OPTIONS
  * <comment_id>...
  * : The ID(s) of the comment(s) to check.
  *
  * [--noaction]
  * : Don't change the status of the comment. Just report what Akismet thinks it is.
  *
  * ## EXAMPLES
  *
  *     wp akismet check 12345
  *
  * @alias comment-check
  */
 public function check($args, $assoc_args)
 {
     foreach ($args as $comment_id) {
         if (isset($assoc_args['noaction'])) {
             // Check the comment, but don't reclassify it.
             $api_response = Akismet::check_db_comment($comment_id, 'wp-cli');
         } else {
             $api_response = Akismet::recheck_comment($comment_id, 'wp-cli');
         }
         if ('true' === $api_response) {
             WP_CLI::line(sprintf(__("Comment #%d is spam.", 'akismet'), $comment_id));
         } else {
             if ('false' === $api_response) {
                 WP_CLI::line(sprintf(__("Comment #%d is not spam.", 'akismet'), $comment_id));
             } else {
                 if (false === $api_response) {
                     WP_CLI::error(__("Failed to connect to Akismet.", 'akismet'));
                 } else {
                     if (is_wp_error($api_response)) {
                         WP_CLI::warning(sprintf(__("Comment #%d could not be checked.", 'akismet'), $comment_id));
                     }
                 }
             }
         }
     }
 }
开发者ID:coreymargulis,项目名称:karenmargulis,代码行数:42,代码来源:class.akismet-cli.php


示例9: 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


示例10: HandleGuestStore

function HandleGuestStore($pagename, $auth)
{
    global $wpcom_api_key, $wpcom_home;
    $akismet = new Akismet($wpcom_home, $wpcom_api_key);
    $akismet->setCommentAuthor($_POST['name']);
    $akismet->setCommentAuthorEmail($_POST['email']);
    $akismet->setCommentAuthorURL($_POST['url']);
    $akismet->setCommentContent($_POST['comment']);
    $itemurl = $pagename . date("Ymd") . "-" . uniqid();
    $akismet->setPermalink($itemurl);
    $page['name'] = $itemurl;
    $page['text'] = "----\n";
    $page['text'] .= strlen($_POST['name']) > 0 ? $_POST['name'] : "Unbekannt";
    if (strlen($_POST['email']) > 0) {
        $page['text'] .= " [[&#9993;->mailto:";
        $page['text'] .= $_POST['email'];
        $page['text'] .= "]]";
    }
    if (strlen($_POST['url']) > 0) {
        $page['text'] .= " [[&#10138;->";
        $page['text'] .= substr($_POST['url'], 0, 4) == "http" ? $_POST['url'] : "http://" . $_POST['url'];
        $page['text'] .= "]]";
    }
    $page['text'] .= " schrieb am ";
    $page['text'] .= date("d.m.Y");
    $page['text'] .= ":\n\n";
    $page['text'] .= $_POST['comment'];
    $page['text'] .= $akismet->isCommentSpam() ? "(:spam: true:)" : "(:spam: false:)";
    $page['time'] = $Now;
    $page['host'] = $_SERVER['REMOTE_ADDR'];
    $page['agent'] = @$_SERVER['HTTP_USER_AGENT'];
    UpdatePage($page['name'], $page, $page);
    HandleBrowse($pagename);
}
开发者ID:ansgar,项目名称:pmguest,代码行数:34,代码来源:guest.php


示例11: 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


示例12: 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


示例13: 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


示例14: execute

 public function execute()
 {
     $comment_id = (int) waRequest::post('spam');
     $comment_model = new blogCommentModel();
     $comment = $comment_model->getById($comment_id);
     $this->response['status'] = null;
     if ($comment) {
         $comment_model->updateById($comment_id, array('akismet_spam' => 1, 'status' => blogCommentModel::STATUS_DELETED));
         $this->response['status'] = blogCommentModel::STATUS_DELETED;
         $blog_plugin = wa()->getPlugin('akismet');
         $akismet = new Akismet(wa()->getRouting()->getUrl('blog', array(), true), $blog_plugin->getSettingValue('api_key'));
         $akismet->setCommentAuthor($comment['name']);
         $akismet->setCommentAuthorEmail($comment['email']);
         $akismet->setCommentContent($comment['text']);
         if (!waSystemConfig::isDebug() && $blog_plugin->getSettingValue('send_spam')) {
             $akismet->submitSpam();
         }
     }
 }
开发者ID:cjmaximal,项目名称:webasyst-framework,代码行数:19,代码来源:blogAkismetPluginBackend.controller.php


示例15: check

 public static function check($input, &$model)
 {
     $application = JFactory::getApplication();
     $params = JComponentHelper::getParams('com_k2');
     $user = JFactory::getUser();
     // Google reCAPTCHA
     if ($params->get('antispam') == 'recaptcha' || $params->get('antispam') == 'both') {
         if ($user->guest || $params->get('recaptchaForRegistered')) {
             $data = array();
             $data['secret'] = $params->get('recaptcha_private_key');
             $data['remoteip'] = $_SERVER["REMOTE_ADDR"];
             $data['response'] = $application->input->post->get('g-recaptcha-response', '', 'raw');
             $ch = curl_init();
             curl_setopt($ch, CURLOPT_URL, 'https://www.google.com/recaptcha/api/siteverify?' . http_build_query($data));
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
             $response = curl_exec($ch);
             $error = curl_error($ch);
             curl_close($ch);
             if ($response === false) {
                 $model->setError($error);
                 return false;
             }
             $json = json_decode($response);
             if (!$json->success) {
                 $model->setError(JText::_('K2_WE_COULD_NOT_VERIFY_THAT_YOU_ARE_HUMAN'));
                 return false;
             }
         }
     }
     // Akismet
     if ($params->get('antispam') == 'akismet' || $params->get('antispam') == 'both') {
         if ($user->guest || $params->get('akismetForRegistered')) {
             if ($params->get('akismetApiKey')) {
                 require_once JPATH_ADMINISTRATOR . 'components/com_k2/classes/akismet.class.php';
                 $akismetApiKey = $params->get('akismetApiKey');
                 $akismet = new Akismet(JURI::root(false), $akismetApiKey);
                 $akismet->setCommentAuthor($input['name']);
                 $akismet->setCommentAuthorEmail($input['email']);
                 $akismet->setCommentAuthorURL($input['url']);
                 $akismet->setCommentContent($input['text']);
                 $akismet->setPermalink(JURI::root(false) . 'index.php?option=com_k2&view=item&id=' . $input['itemId']);
                 try {
                     if ($akismet->isCommentSpam()) {
                         $model->setError(JText::_('K2_SPAM_ATTEMPT_HAS_BEEN_DETECTED_THE_COMMENT_HAS_BEEN_REJECTED'));
                         return false;
                     }
                 } catch (Exception $e) {
                     $model->setError($e->getMessage());
                     return false;
                 }
             }
         }
     }
     return true;
 }
开发者ID:Naldo100,项目名称:k2-v3-dev-build,代码行数:55,代码来源:captcha.php


示例16: get_api_key

 public static function get_api_key()
 {
     if (is_callable(array('Akismet', 'get_api_key'))) {
         // Akismet v3.0+
         return (bool) Akismet::get_api_key();
     }
     if (function_exists('akismet_get_key')) {
         return (bool) akismet_get_key();
     }
     return false;
 }
开发者ID:devilcranx,项目名称:landing-pages,代码行数:11,代码来源:class.inbound-forms.akismet.php


示例17: flamingo_akismet_is_active

function flamingo_akismet_is_active()
{
    if (is_callable(array('Akismet', 'get_api_key'))) {
        // Akismet v3.0+
        return (bool) Akismet::get_api_key();
    }
    if (function_exists('akismet_get_key')) {
        return (bool) akismet_get_key();
    }
    return false;
}
开发者ID:jgacuca567,项目名称:jamesvanwaza,代码行数:11,代码来源:akismet.php


示例18: verify

 /**
 		Akismet key verification
 			@return boolean
 			@param $key string
 			@public
 	**/
 static function verify($key)
 {
     $response = Web::http('GET http://rest.akismet.com/1.1/verify-key', http_build_query(array('key' => $key, 'blog' => 'http://' . $_SERVER['SERVER_NAME'])));
     if (preg_match('/invalid/i', $response)) {
         trigger_error(self::TEXT_VerifyFail);
         self::$key = NULL;
     } else {
         self::$key = $key;
     }
     return self::$key;
 }
开发者ID:pshreez,项目名称:PHP,代码行数:17,代码来源:akismet.php


示例19: is_akismet_available

 protected function is_akismet_available()
 {
     if (!class_exists('Akismet')) {
         return false;
     }
     $api_key = Akismet::get_api_key();
     if (empty($api_key)) {
         return false;
     }
     return true;
 }
开发者ID:sabdev1,项目名称:ljcdevsab,代码行数:11,代码来源:class-akismet-wrapper-factory.php


示例20: create

 /**
  * Function: create
  * Attempts to create a comment using the passed information. If the Akismet API key is present, it will check it.
  *
  * Parameters:
  *     $body - The comment.
  *     $author - The name of the commenter.
  *     $url - The commenter's website.
  *     $email - The commenter's email.
  *     $post - The <Post> they're commenting on.
  *     $parent - The <Comment> they're replying to.
  *     $notify - Notification on follow-up comments.
  *     $type - The type of comment. Optional, used for trackbacks/pingbacks.
  */
 static function create($body, $author, $url, $email, $post, $parent, $notify, $type = null)
 {
     if (!self::user_can($post->id) and !in_array($type, array("trackback", "pingback"))) {
         return;
     }
     $config = Config::current();
     $route = Route::current();
     $visitor = Visitor::current();
     if (!$type) {
         $status = $post->user_id == $visitor->id ? "approved" : $config->default_comment_status;
         $type = "comment";
     } else {
         $status = $type;
     }
     if (!empty($config->akismet_api_key)) {
         $akismet = new Akismet($config->url, $config->akismet_api_key);
         $akismet->setCommentContent($body);
         $akismet->setCommentAuthor($author);
         $akismet->setCommentAuthorURL($url);
         $akismet->setCommentAuthorEmail($email);
         $akismet->setPermalink($post->url());
         $akismet->setCommentType($type);
         $akismet->setReferrer($_SERVER['HTTP_REFERER']);
         $akismet->setUserIP($_SERVER['REMOTE_ADDR']);
         if ($akismet->isCommentSpam()) {
             self::add($body, $author, $url, $email, $_SERVER['REMOTE_ADDR'], $_SERVER['HTTP_USER_AGENT'], "spam", $post->id, $visitor->id, $parent, $notify);
             error(__("Spam Comment"), __("Your comment has been marked as spam. It has to be reviewed and/or approved by an admin.", "comments"));
         } else {
             $comment = self::add($body, $author, $url, $email, $_SERVER['REMOTE_ADDR'], $_SERVER['HTTP_USER_AGENT'], $status, $post->id, $visitor->id, $parent, $notify);
             fallback($_SESSION['comments'], array());
             $_SESSION['comments'][] = $comment->id;
             if (isset($_POST['ajax'])) {
                 exit("{ \"comment_id\": \"" . $comment->id . "\", \"comment_timestamp\": \"" . $comment->created_at . "\" }");
             }
             Flash::notice(__("Comment added."), $post->url() . "#comments");
         }
     } else {
         $comment = self::add($body, $author, $url, $email, $_SERVER['REMOTE_ADDR'], $_SERVER['HTTP_USER_AGENT'], $status, $post->id, $visitor->id, $parent, $notify);
         fallback($_SESSION['comments'], array());
         $_SESSION['comments'][] = $comment->id;
         if (isset($_POST['ajax'])) {
             exit("{ \"comment_id\": \"" . $comment->id . "\", \"comment_timestamp\": \"" . $comment->created_at . "\" }");
         }
         Flash::notice(__("Comment added."), $post->url() . "#comment");
     }
 }
开发者ID:betsyzhang,项目名称:chyrp,代码行数:60,代码来源:model.Comment.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Akismet_Admin类代码示例发布时间:2022-05-23
下一篇:
PHP AkeebaHelperIncludes类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap