本文整理汇总了PHP中Akismet::http_post方法的典型用法代码示例。如果您正苦于以下问题:PHP Akismet::http_post方法的具体用法?PHP Akismet::http_post怎么用?PHP Akismet::http_post使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Akismet
的用法示例。
在下文中一共展示了Akismet::http_post方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fu_akismet_check_submission
function fu_akismet_check_submission($should_process, $layout)
{
// Akismet is not enabled or not configured, or too old, just return the filter value
if (!class_exists('Akismet') || !method_exists('Akismet', 'get_api_key') || !Akismet::get_api_key()) {
return $should_process;
}
$content = array();
$content['comment_author'] = isset($_POST['post_author']) ? sanitize_text_field($_POST['post_author']) : null;
$content['comment_content'] = isset($_POST['post_content']) ? $_POST['post_content'] : null;
// Permalink of the post with upload form, fallback to wp_get_referer()
// Fallback is used to
$content['permalink'] = isset($_POST['form_post_id']) ? get_permalink($_POST['form_post_id']) : wp_get_referer();
// Set required Akismet values
$content['user_ip'] = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : null;
$content['user_agent'] = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null;
$content['referrer'] = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null;
$content['blog'] = get_option('home');
$content['blog_lang'] = get_locale();
$content['blog_charset'] = get_option('blog_charset');
// Ignore these keys in POST and SERVER superglobals, add the rest to request
// This approach is stolen from Akismet::auto_check_comment()
$ignore = array('HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW', 'ff', 'fu_nonce');
foreach ($_POST as $key => $value) {
if (!in_array($key, $ignore) && is_string($value)) {
$content["POST_{$key}"] = $value;
}
}
foreach ($_SERVER as $key => $value) {
if (!in_array($key, $ignore) && is_string($value)) {
$content["{$key}"] = $value;
} else {
$content["{$key}"] = '';
}
}
// Build a query and make a request to Akismet
$request = build_query($content);
$response = Akismet::http_post($request, 'comment-check');
// It's a spam
if ($response[1] == 'true') {
$should_process = false;
}
return $should_process;
}
示例2: flamingo_akismet_submit
function flamingo_akismet_submit($comment, $as = 'spam')
{
global $akismet_api_host, $akismet_api_port;
if (!flamingo_akismet_is_active()) {
return false;
}
if (!in_array($as, array('spam', 'ham'))) {
return false;
}
$query_string = '';
foreach ((array) $comment as $key => $data) {
$query_string .= $key . '=' . urlencode(wp_unslash((string) $data)) . '&';
}
if (is_callable(array('Akismet', 'http_post'))) {
// Akismet v3.0+
$response = Akismet::http_post($query_string, 'submit-' . $as);
} else {
$response = akismet_http_post($query_string, $akismet_api_host, '/1.1/submit-' . $as, $akismet_api_port);
}
return (bool) $response[1];
}
示例3: sharing_email_check_for_spam_via_akismet
function sharing_email_check_for_spam_via_akismet($data)
{
if (!function_exists('akismet_http_post') && !method_exists('Akismet', 'http_post')) {
return $data;
}
// Prepare the body_request for akismet
$body_request = array('blog' => get_option('home'), 'permalink' => get_permalink($data['post']->ID), 'comment_type' => 'share', 'comment_author' => $data['name'], 'comment_author_email' => $data['source'], 'comment_content' => sharing_email_send_post_content($data), 'user_agent' => isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null);
if (method_exists('Akismet', 'http_post')) {
$body_request['user_ip'] = Akismet::get_ip_address();
$response = Akismet::http_post(build_query($body_request), 'comment-check');
} else {
global $akismet_api_host, $akismet_api_port;
$body_request['user_ip'] = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : null;
$response = akismet_http_post(build_query($body_request), $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
}
// The Response is spam lets not send the email.
if (!empty($response) && isset($response[1]) && 'true' == trim($response[1])) {
// 'true' is spam
return false;
// don't send the email
}
return $data;
}
示例4: api_check
public static function api_check($params)
{
global $akismet_api_host, $akismet_api_port;
/* bail if no content to check against akismet */
if (!isset($params['comment_content'])) {
return;
}
$spam = false;
$query_string = '';
foreach ($params as $key => $data) {
$query_string .= $key . '=' . urlencode(wp_unslash((string) $data)) . '&';
}
if (is_callable(array('Akismet', 'http_post'))) {
// Akismet v3.0+
$response = Akismet::http_post($query_string, 'comment-check');
} else {
$response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
}
/* returns true if spam else return false */
if ('true' == $response[1]) {
return true;
}
return false;
}
示例5: akismet
/**
* Check entries for spam
*
* @return boolean true if is spam
*/
public static function akismet($values)
{
$content = FrmEntriesHelper::entry_array_to_string($values);
if (empty($content)) {
return false;
}
$datas = array();
self::parse_akismet_array($datas, $content);
$query_string = '';
foreach ($datas as $key => $data) {
$query_string .= $key . '=' . urlencode(stripslashes($data)) . '&';
unset($key, $data);
}
$response = Akismet::http_post($query_string, 'comment-check');
return is_array($response) && $response[1] == 'true';
}
示例6: gwolle_gb_akismet_entry_check
function gwolle_gb_akismet_entry_check($comment, $action)
{
global $akismet_api_host, $akismet_api_port;
$query_string = '';
foreach ($comment as $key => $data) {
if (is_array($data)) {
continue;
}
$query_string .= $key . '=' . urlencode(wp_unslash((string) $data)) . '&';
}
if (is_callable(array('Akismet', 'http_post'))) {
// Akismet v3.0+
$response = Akismet::http_post($query_string, $action);
} else {
$response = akismet_http_post($query_string, $akismet_api_host, '/1.1/' . $action, $akismet_api_port);
}
//if ( WP_DEBUG ) { echo "Akismet response: "; var_dump($response); }
if ($action == 'comment-check' && isset($response[1]) && 'true' == $response[1]) {
return true;
} else {
if ($action == 'submit-ham' && isset($response[1])) {
return true;
} else {
if ($action == 'submit-spam' && isset($response[1])) {
return true;
} else {
return false;
}
}
}
}
示例7: ll_akismet_comment_check
function ll_akismet_comment_check($comment)
{
global $akismet_api_host, $akismet_api_port;
$spam = false;
$query_string = http_build_query($comment);
if (is_callable(array('Akismet', 'http_post'))) {
// Akismet v3.0+
$response = Akismet::http_post($query_string, 'comment-check');
} else {
$response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
}
if ('true' == $response[1]) {
$spam = true;
}
if ($submission = WPCF7_Submission::get_instance()) {
$submission->akismet = array('comment' => $comment, 'spam' => $spam);
}
return apply_filters('ll_akismet_comment_check', $spam, $comment);
}
示例8: submit_spam_comment
public static function submit_spam_comment($comment_id)
{
global $wpdb, $current_user, $current_site;
$comment_id = (int) $comment_id;
$comment = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->comments} WHERE comment_ID = %d", $comment_id));
if (!$comment) {
// it was deleted
return;
}
if ('spam' != $comment->comment_approved) {
return;
}
// use the original version stored in comment_meta if available
$as_submitted = self::sanitize_comment_as_submitted(get_comment_meta($comment_id, 'akismet_as_submitted', true));
if ($as_submitted && is_array($as_submitted) && isset($as_submitted['comment_content'])) {
$comment = (object) array_merge((array) $comment, $as_submitted);
}
$comment->blog = get_bloginfo('url');
$comment->blog_lang = get_locale();
$comment->blog_charset = get_option('blog_charset');
$comment->permalink = get_permalink($comment->comment_post_ID);
if (is_object($current_user)) {
$comment->reporter = $current_user->user_login;
}
if (is_object($current_site)) {
$comment->site_domain = $current_site->domain;
}
$comment->user_role = '';
if (isset($comment->user_ID)) {
$comment->user_role = Akismet::get_user_roles($comment->user_ID);
}
if (self::is_test_mode()) {
$comment->is_test = 'true';
}
$post = get_post($comment->comment_post_ID);
$comment->comment_post_modified_gmt = $post->post_modified_gmt;
$response = Akismet::http_post(Akismet::build_query($comment), 'submit-spam');
if ($comment->reporter) {
self::update_comment_history($comment_id, '', 'report-spam');
update_comment_meta($comment_id, 'akismet_user_result', 'true');
update_comment_meta($comment_id, 'akismet_user', $comment->reporter);
}
do_action('akismet_submit_spam_comment', $comment_id, $response[1]);
}
示例9: akismet
function akismet($values)
{
$content = FrmEntriesHelper::entry_array_to_string($values);
if (empty($content)) {
return false;
}
$datas = array();
$datas['blog'] = FrmAppHelper::site_url();
$datas['user_ip'] = preg_replace('/[^0-9., ]/', '', $_SERVER['REMOTE_ADDR']);
$datas['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
$datas['referrer'] = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : false;
$datas['comment_type'] = 'formidable';
if ($permalink = get_permalink()) {
$datas['permalink'] = $permalink;
}
$datas['comment_content'] = $content;
foreach ($_SERVER as $key => $value) {
if (!in_array($key, array('HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW')) && is_string($value)) {
$datas["{$key}"] = $value;
} else {
$datas["{$key}"] = '';
}
unset($key, $value);
}
$query_string = '';
foreach ($datas as $key => $data) {
$query_string .= $key . '=' . urlencode(stripslashes($data)) . '&';
unset($key, $data);
}
if (is_callable('Akismet::http_post')) {
$response = Akismet::http_post($query_string, 'comment-check');
} else {
global $akismet_api_host, $akismet_api_port;
$response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
}
return (is_array($response) and $response[1] == 'true') ? true : false;
}
示例10: akismet_http_post
function akismet_http_post($request, $host, $path, $port = 80, $ip = null)
{
$path = str_replace('/1.1/', '', $path);
return Akismet::http_post($request, $path, $ip);
}
示例11: http_post
public function http_post($request_data, $path, $ip = null)
{
return Akismet::http_post($request_data, $path, $ip);
}
示例12: akismet_check
/**
* Akismet check for marking an entry as Spam/Not Spam
*
* @since 2.1
* @returns bool|wp_error
*/
protected function akismet_check($type, $id)
{
if (!method_exists('Akismet', 'http_post') || !function_exists('akismet_http_post')) {
return new WP_Error('missing_akismet', 'Akismet does not appear to be installed and/or active. Entry not marked as spam.');
}
global $akismet_api_host, $akismet_api_port, $wpdb;
$query_string = '';
$api = 'spam' == $type ? 'submit-spam' : 'submit-ham';
$akismet_data = maybe_unserialize($wpdb->get_var($wpdb->prepare("SELECT akismet FROM {$this->entries_table_name} WHERE entries_id = %d", $id)));
foreach (array_keys($akismet_data) as $k) {
$query_string .= $k . '=' . urlencode($akismet_data[$k]) . '&';
}
if (method_exists('Akismet', 'http_post')) {
$response = Akismet::http_post($query_string, $api);
} else {
$response = akismet_http_post($query_string, $akismet_api_host, "/1.1/{$api}", $akismet_api_port);
}
// Only return true if a response is available
if ($response) {
if ('Thanks for making the web a better place.' == $response[1]) {
return true;
}
} else {
return new WP_Error('unexpected_response', 'No response returned from Akismet. This could be a connectivity issue or a missing Akismet API key. Entry not marked as spam.');
}
return false;
}
示例13: is_spam
public function is_spam($contact)
{
if (method_exists('Akismet', 'http_post')) {
$comment = array('comment_author' => $contact['name'], 'comment_author_email' => $contact['email'], 'comment_content' => $contact['message'], 'comment_type' => $this->tag, 'user_ip' => preg_replace('/[^0-9., ]/', '', $_SERVER['REMOTE_ADDR']), 'user_agent' => $_SERVER['HTTP_USER_AGENT'], 'referrer' => $_SERVER['HTTP_REFERER'], 'blog' => get_option('home'), 'blog_lang' => get_locale(), 'blog_charset' => get_option('blog_charset'));
foreach ($_SERVER as $key => $value) {
if ($key != 'HTTP_COOKIE' && is_string($value)) {
$comment[$key] = $value;
}
}
$response = Akismet::http_post(Akismet::build_query($comment), 'comment-check');
if ('true' == trim($response[1])) {
return true;
}
}
return false;
}
示例14: akismet_check
/**
* Check submission against Akismet
*
* Passes back true (it's spam) or false (it's ham)
*/
public function akismet_check($query_string)
{
global $akismet_api_host, $akismet_api_port;
$spam = false;
if (is_callable(array('Akismet', 'http_post'))) {
// Akismet v3.0+
$response = Akismet::http_post($query_string, 'comment-check');
} else {
$response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
}
if ('true' == $response[1]) {
$spam = true;
}
return $spam;
}
示例15: akismet_check
/**
* Akismet check
*
* @access protected
* @param mixed $data
* @return void
*/
protected function akismet_check($data)
{
if (!function_exists('akismet_http_post')) {
return false;
}
do_action('vfb_akismet_check', $data);
global $akismet_api_host, $akismet_api_port;
$query_string = '';
$result = false;
foreach (array_keys($data) as $k) {
$query_string .= $k . '=' . urlencode($data[$k]) . '&';
}
if (method_exists('Akismet', 'http_post')) {
$response = Akismet::http_post($query_string, 'comment-check');
} else {
$response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
}
// Only return true if a response is available
if ($response) {
if ('true' == trim($response[1])) {
$result = true;
}
}
return $result;
}