当前位置: 首页>>代码示例>>PHP>>正文


PHP check_comment函数代码示例

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


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

示例1: check_regist_form

function check_regist_form($id, $passwd, $passwd2, $name, $email, $comment)
{
    if (check_id($id) && check_passwd($passwd) && check_retype_passwd($passwd, $passwd2) && check_email($email) && check_comment($comment)) {
        return TRUE;
        // check_name($name) &&
    } else {
        return FALSE;
    }
}
开发者ID:jungin500,项目名称:KNU-Timetable-test,代码行数:9,代码来源:regist_check.php

示例2: wp_allow_comment

/**
 * wp_allow_comment() - Validates whether this comment is allowed to be made or not
 *
 * {@internal Missing Long Description}}
 *
 * @since 2.0.0
 * @uses $wpdb
 * @uses apply_filters() Calls 'pre_comment_approved' hook on the type of comment
 * @uses do_action() Calls 'check_comment_flood' hook on $comment_author_IP, $comment_author_email, and $comment_date_gmt
 *
 * @param array $commentdata Contains information on the comment
 * @return mixed Signifies the approval status (0|1|'spam')
 */
function wp_allow_comment($commentdata)
{
    global $wpdb;
    extract($commentdata, EXTR_SKIP);
    // Simple duplicate check
    // expected_slashed ($comment_post_ID, $comment_author, $comment_author_email, $comment_content)
    $dupe = "SELECT comment_ID FROM {$wpdb->comments} WHERE comment_post_ID = '{$comment_post_ID}' AND ( comment_author = '{$comment_author}' ";
    if ($comment_author_email) {
        $dupe .= "OR comment_author_email = '{$comment_author_email}' ";
    }
    $dupe .= ") AND comment_content = '{$comment_content}' LIMIT 1";
    if ($wpdb->get_var($dupe)) {
        wp_die(__('Duplicate comment detected; it looks as though you\'ve already said that!'));
    }
    do_action('check_comment_flood', $comment_author_IP, $comment_author_email, $comment_date_gmt);
    if ($user_id) {
        $userdata = get_userdata($user_id);
        $user = new WP_User($user_id);
        $post_author = $wpdb->get_var($wpdb->prepare("SELECT post_author FROM {$wpdb->posts} WHERE ID = %d LIMIT 1", $comment_post_ID));
    }
    if ($userdata && ($user_id == $post_author || $user->has_cap('level_9'))) {
        // The author and the admins get respect.
        $approved = 1;
    } else {
        // Everyone else's comments will be checked.
        if (check_comment($comment_author, $comment_author_email, $comment_author_url, $comment_content, $comment_author_IP, $comment_agent, $comment_type)) {
            $approved = 1;
        } else {
            $approved = 0;
        }
        if (wp_blacklist_check($comment_author, $comment_author_email, $comment_author_url, $comment_content, $comment_author_IP, $comment_agent)) {
            $approved = 'spam';
        }
    }
    $approved = apply_filters('pre_comment_approved', $approved);
    return $approved;
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:50,代码来源:comment.php

示例3: approve_comment

 /**
  * Similar to wp_approve_comment(), but does not check for duplicates or die on failure.
  *
  * @since 1.4.7
  *
  * @param $commentdata
  * @return int 1 for approved, 0 for not approved, 'spam' for spam
  */
 protected function approve_comment($commentdata)
 {
     $user = get_user_by('id', $this->user_id);
     $post = get_post($this->post_id);
     if (isset($user) && ($commentdata['user_id'] == $post->post_author || $user->has_cap('moderate_comments'))) {
         // The author and the admins get respect.
         $approved = 1;
     } else {
         // Everyone else's comments will be checked.
         if (check_comment($commentdata['comment_author'], $commentdata['comment_author_email'], $commentdata['comment_author_url'], $commentdata['comment_content'], $commentdata['comment_author_IP'], $commentdata['comment_agent'], $commentdata['comment_type'])) {
             $approved = 1;
         } else {
             $approved = 0;
         }
         if (wp_blacklist_check($commentdata['comment_author'], $commentdata['comment_author_email'], $commentdata['comment_author_url'], $commentdata['comment_content'], $commentdata['comment_author_IP'], $commentdata['comment_agent'])) {
             $approved = 'spam';
         }
     }
     /**
      * Filter a comment's approval status before it is set.
      *
      * @since 2.1.0
      *
      * @param bool|string $approved The approval status. Accepts 1, 0, or 'spam'.
      * @param array $commentdata Comment data.
      */
     $approved = apply_filters('pre_comment_approved', $approved, $commentdata);
     return $approved;
 }
开发者ID:postmatic,项目名称:beta-dist,代码行数:37,代码来源:comment-command.php

示例4: wp_allow_comment

/**
 * Validates whether this comment is allowed to be made.
 *
 * @since 2.0.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $commentdata Contains information on the comment
 * @return int|string Signifies the approval status (0|1|'spam')
 */
function wp_allow_comment($commentdata)
{
    global $wpdb;
    // Simple duplicate check
    // expected_slashed ($comment_post_ID, $comment_author, $comment_author_email, $comment_content)
    $dupe = $wpdb->prepare("SELECT comment_ID FROM {$wpdb->comments} WHERE comment_post_ID = %d AND comment_parent = %s AND comment_approved != 'trash' AND ( comment_author = %s ", wp_unslash($commentdata['comment_post_ID']), wp_unslash($commentdata['comment_parent']), wp_unslash($commentdata['comment_author']));
    if ($commentdata['comment_author_email']) {
        $dupe .= $wpdb->prepare("OR comment_author_email = %s ", wp_unslash($commentdata['comment_author_email']));
    }
    $dupe .= $wpdb->prepare(") AND comment_content = %s LIMIT 1", wp_unslash($commentdata['comment_content']));
    $dupe_id = $wpdb->get_var($dupe);
    /**
     * Filters the ID, if any, of the duplicate comment found when creating a new comment.
     *
     * Return an empty value from this filter to allow what WP considers a duplicate comment.
     *
     * @since 4.4.0
     *
     * @param int   $dupe_id     ID of the comment identified as a duplicate.
     * @param array $commentdata Data for the comment being created.
     */
    $dupe_id = apply_filters('duplicate_comment_id', $dupe_id, $commentdata);
    if ($dupe_id) {
        /**
         * Fires immediately after a duplicate comment is detected.
         *
         * @since 3.0.0
         *
         * @param array $commentdata Comment data.
         */
        do_action('comment_duplicate_trigger', $commentdata);
        if (defined('DOING_AJAX')) {
            die(__('Duplicate comment detected; it looks as though you’ve already said that!'));
        }
        wp_die(__('Duplicate comment detected; it looks as though you’ve already said that!'), 409);
    }
    /**
     * Fires immediately before a comment is marked approved.
     *
     * Allows checking for comment flooding.
     *
     * @since 2.3.0
     *
     * @param string $comment_author_IP    Comment author's IP address.
     * @param string $comment_author_email Comment author's email.
     * @param string $comment_date_gmt     GMT date the comment was posted.
     */
    do_action('check_comment_flood', $commentdata['comment_author_IP'], $commentdata['comment_author_email'], $commentdata['comment_date_gmt']);
    if (!empty($commentdata['user_id'])) {
        $user = get_userdata($commentdata['user_id']);
        $post_author = $wpdb->get_var($wpdb->prepare("SELECT post_author FROM {$wpdb->posts} WHERE ID = %d LIMIT 1", $commentdata['comment_post_ID']));
    }
    if (isset($user) && ($commentdata['user_id'] == $post_author || $user->has_cap('moderate_comments'))) {
        // The author and the admins get respect.
        $approved = 1;
    } else {
        // Everyone else's comments will be checked.
        if (check_comment($commentdata['comment_author'], $commentdata['comment_author_email'], $commentdata['comment_author_url'], $commentdata['comment_content'], $commentdata['comment_author_IP'], $commentdata['comment_agent'], $commentdata['comment_type'])) {
            $approved = 1;
        } else {
            $approved = 0;
        }
        if (wp_blacklist_check($commentdata['comment_author'], $commentdata['comment_author_email'], $commentdata['comment_author_url'], $commentdata['comment_content'], $commentdata['comment_author_IP'], $commentdata['comment_agent'])) {
            $approved = EMPTY_TRASH_DAYS ? 'trash' : 'spam';
        }
    }
    /**
     * Filter a comment's approval status before it is set.
     *
     * @since 2.1.0
     *
     * @param bool|string $approved    The approval status. Accepts 1, 0, or 'spam'.
     * @param array       $commentdata Comment data.
     */
    $approved = apply_filters('pre_comment_approved', $approved, $commentdata);
    return $approved;
}
开发者ID:hadywisam,项目名称:WordPress,代码行数:87,代码来源:comment-functions.php

示例5: cron_recheck

 public static function cron_recheck()
 {
     global $wpdb;
     $api_key = self::get_api_key();
     $status = self::verify_key($api_key);
     if (get_option('akismet_alert_code') || $status == 'invalid') {
         // since there is currently a problem with the key, reschedule a check for 6 hours hence
         wp_schedule_single_event(time() + 21600, 'akismet_schedule_cron_recheck');
         do_action('akismet_scheduled_recheck', 'key-problem-' . get_option('akismet_alert_code') . '-' . $status);
         return false;
     }
     delete_option('akismet_available_servers');
     $comment_errors = $wpdb->get_col("SELECT comment_id FROM {$wpdb->commentmeta} WHERE meta_key = 'akismet_error'\tLIMIT 100");
     load_plugin_textdomain('akismet');
     foreach ((array) $comment_errors as $comment_id) {
         // if the comment no longer exists, or is too old, remove the meta entry from the queue to avoid getting stuck
         $comment = get_comment($comment_id);
         if (!$comment || strtotime($comment->comment_date_gmt) < strtotime("-15 days")) {
             delete_comment_meta($comment_id, 'akismet_error');
             delete_comment_meta($comment_id, 'akismet_delayed_moderation_email');
             continue;
         }
         add_comment_meta($comment_id, 'akismet_rechecking', true);
         $status = self::check_db_comment($comment_id, 'retry');
         $event = '';
         if ($status == 'true') {
             $event = 'cron-retry-spam';
         } elseif ($status == 'false') {
             $event = 'cron-retry-ham';
         }
         // If we got back a legit response then update the comment history
         // other wise just bail now and try again later.  No point in
         // re-trying all the comments once we hit one failure.
         if (!empty($event)) {
             delete_comment_meta($comment_id, 'akismet_error');
             self::update_comment_history($comment_id, '', $event);
             update_comment_meta($comment_id, 'akismet_result', $status);
             // make sure the comment status is still pending.  if it isn't, that means the user has already moved it elsewhere.
             $comment = get_comment($comment_id);
             if ($comment && 'unapproved' == wp_get_comment_status($comment_id)) {
                 if ($status == 'true') {
                     wp_spam_comment($comment_id);
                 } elseif ($status == 'false') {
                     // comment is good, but it's still in the pending queue.  depending on the moderation settings
                     // we may need to change it to approved.
                     if (check_comment($comment->comment_author, $comment->comment_author_email, $comment->comment_author_url, $comment->comment_content, $comment->comment_author_IP, $comment->comment_agent, $comment->comment_type)) {
                         wp_set_comment_status($comment_id, 1);
                     } else {
                         if (get_comment_meta($comment_id, 'akismet_delayed_moderation_email', true)) {
                             wp_notify_moderator($comment_id);
                         }
                     }
                 }
             }
             delete_comment_meta($comment_id, 'akismet_delayed_moderation_email');
         } else {
             // If this comment has been pending moderation for longer than MAX_DELAY_BEFORE_MODERATION_EMAIL,
             // send a moderation email now.
             if (intval(gmdate('U')) - strtotime($comment->comment_date_gmt) < self::MAX_DELAY_BEFORE_MODERATION_EMAIL) {
                 delete_comment_meta($comment_id, 'akismet_delayed_moderation_email');
                 wp_notify_moderator($comment_id);
             }
             delete_comment_meta($comment_id, 'akismet_rechecking');
             wp_schedule_single_event(time() + 1200, 'akismet_schedule_cron_recheck');
             do_action('akismet_scheduled_recheck', 'check-db-comment-' . $status);
             return;
         }
         delete_comment_meta($comment_id, 'akismet_rechecking');
     }
     $remaining = $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->commentmeta} WHERE meta_key = 'akismet_error'");
     if ($remaining && !wp_next_scheduled('akismet_schedule_cron_recheck')) {
         wp_schedule_single_event(time() + 1200, 'akismet_schedule_cron_recheck');
         do_action('akismet_scheduled_recheck', 'remaining');
     }
 }
开发者ID:onedaylabs,项目名称:onedaylabs.com,代码行数:75,代码来源:class.akismet.php

示例6: import_comment

 function import_comment($comment_arr)
 {
     // Parse this comment into an array and insert
     $comment = $this->parse_comment($comment_arr);
     $comment = wp_filter_comment($comment);
     // redo comment approval
     if (check_comment($comment['comment_author'], $comment['comment_author_email'], $comment['comment_author_url'], $comment['comment_content'], $comment['comment_author_IP'], $comment['comment_agent'], $comment['comment_type'])) {
         $approved = 1;
     } else {
         $approved = 0;
     }
     if (wp_blacklist_check($comment['comment_author'], $comment['comment_author_email'], $comment['comment_author_url'], $comment['comment_content'], $comment['comment_author_IP'], $comment['comment_agent'])) {
         $approved = 'spam';
     } elseif ($this->askimet_spam_checker($comment)) {
         $approved = 'spam';
     }
     // auto approve imported comments
     if (get_t3i_options('approve_comments') && $approved !== 'spam') {
         $approved = 1;
     }
     $comment['comment_approved'] = $approved;
     // Simple duplicate check
     $dupe = "\n\t\t\tSELECT comment_ID\n\t\t\tFROM {$this->wpdb->comments}\n\t\t\tWHERE comment_post_ID = '{$comment['comment_post_ID']}'\n\t\t\t\tAND comment_approved != 'trash'\n\t\t\t\tAND comment_author = '{$comment['comment_author']}'\n\t\t\t\tAND comment_author_email = '{$comment['comment_author_email']}'\n\t\t\t\tAND comment_content = '{$comment['comment_content']}'\n\t\t\tLIMIT 1\n\t\t";
     $comment_ID = $this->wpdb->get_var($dupe);
     // echo '<li>';
     if (!$comment_ID) {
         // printf( __( 'Imported comment from <strong>%s</strong>', 'typo3-importer'), stripslashes( $comment['comment_author'] ) );
         $inserted = wp_insert_comment($comment);
     } else {
         // printf( __( 'Comment from <strong>%s</strong> already exists.', 'typo3-importer'), stripslashes( $comment['comment_author'] ) );
         $inserted = false;
     }
     // echo '</li>';
     // ob_flush(); flush();
     return $inserted;
 }
开发者ID:netzstrategen,项目名称:typo3-importer,代码行数:36,代码来源:typo3-importer.php

示例7: header

         header($header_location . $redirect);
         pageheader($lang_info, "<meta http-equiv=\"refresh\" content=\"1;url={$redirect}\" />");
         msg_box($lang_info, $lang_db_input_php['redirect_msg'], $lang_db_input_php['continue'], $redirect);
         pagefooter();
         ob_end_flush();
         exit;
     }
     break;
     // Comment
 // Comment
 case 'comment':
     if (!USER_CAN_POST_COMMENTS) {
         cpg_die(ERROR, $lang_errors['perm_denied'], __FILE__, __LINE__);
     }
     check_comment($_POST['msg_body']);
     check_comment($_POST['msg_author']);
     $msg_author = addslashes(trim($_POST['msg_author']));
     $msg_body = addslashes(trim($_POST['msg_body']));
     $pid = (int) $_POST['pid'];
     if ($msg_author == '' || $msg_body == '') {
         cpg_die(ERROR, $lang_db_input_php['empty_name_or_com'], __FILE__, __LINE__);
     }
     $result = cpg_db_query("SELECT comments FROM {$CONFIG['TABLE_PICTURES']}, {$CONFIG['TABLE_ALBUMS']} WHERE {$CONFIG['TABLE_PICTURES']}.aid = {$CONFIG['TABLE_ALBUMS']}.aid AND pid='{$pid}'");
     if (!mysql_num_rows($result)) {
         cpg_die(ERROR, $lang_errors['non_exist_ap'], __FILE__, __LINE__);
     }
     $album_data = mysql_fetch_array($result);
     mysql_free_result($result);
     if ($album_data['comments'] != 'YES') {
         cpg_die(ERROR, $lang_errors['perm_denied'], __FILE__, __LINE__);
     }
开发者ID:alencarmo,项目名称:OCF,代码行数:31,代码来源:db_input.php

示例8: wp_allow_comment

/**
 * Validates whether this comment is allowed to be made.
 *
 * @since 2.0.0
 * @uses $wpdb
 * @uses apply_filters() Calls 'pre_comment_approved' hook on the type of comment
 * @uses apply_filters() Calls 'comment_duplicate_trigger' hook on commentdata.
 * @uses do_action() Calls 'check_comment_flood' hook on $comment_author_IP, $comment_author_email, and $comment_date_gmt
 *
 * @param array $commentdata Contains information on the comment
 * @return mixed Signifies the approval status (0|1|'spam')
 */
function wp_allow_comment($commentdata)
{
    global $wpdb;
    extract($commentdata, EXTR_SKIP);
    // Simple duplicate check
    // expected_slashed ($comment_post_ID, $comment_author, $comment_author_email, $comment_content)
    $dupe = $wpdb->prepare("SELECT comment_ID FROM {$wpdb->comments} WHERE comment_post_ID = %d AND comment_parent = %s AND comment_approved != 'trash' AND ( comment_author = %s ", wp_unslash($comment_post_ID), wp_unslash($comment_parent), wp_unslash($comment_author));
    if ($comment_author_email) {
        $dupe .= $wpdb->prepare("OR comment_author_email = %s ", wp_unslash($comment_author_email));
    }
    $dupe .= $wpdb->prepare(") AND comment_content = %s LIMIT 1", wp_unslash($comment_content));
    if ($wpdb->get_var($dupe)) {
        do_action('comment_duplicate_trigger', $commentdata);
        if (defined('DOING_AJAX')) {
            die(__('Duplicate comment detected; it looks as though you&#8217;ve already said that!'));
        }
        wp_die(__('Duplicate comment detected; it looks as though you&#8217;ve already said that!'));
    }
    do_action('check_comment_flood', $comment_author_IP, $comment_author_email, $comment_date_gmt);
    if (!empty($user_id)) {
        $user = get_userdata($user_id);
        $post_author = $wpdb->get_var($wpdb->prepare("SELECT post_author FROM {$wpdb->posts} WHERE ID = %d LIMIT 1", $comment_post_ID));
    }
    if (isset($user) && ($user_id == $post_author || $user->has_cap('moderate_comments'))) {
        // The author and the admins get respect.
        $approved = 1;
    } else {
        // Everyone else's comments will be checked.
        if (check_comment($comment_author, $comment_author_email, $comment_author_url, $comment_content, $comment_author_IP, $comment_agent, $comment_type)) {
            $approved = 1;
        } else {
            $approved = 0;
        }
        if (wp_blacklist_check($comment_author, $comment_author_email, $comment_author_url, $comment_content, $comment_author_IP, $comment_agent)) {
            $approved = 'spam';
        }
    }
    $approved = apply_filters('pre_comment_approved', $approved, $commentdata);
    return $approved;
}
开发者ID:palimadra,项目名称:bubblegraphics-wpsite,代码行数:52,代码来源:comment.php

示例9: str_replace

        }
    }
    $str = str_replace($replacements, '(...)', $str);
}
if (!isset($_GET['event']) && !isset($_POST['event'])) {
    enl_die($lang_errors['param_missing']);
}
$event = isset($_POST['event']) ? $_POST['event'] : $_GET['event'];
switch ($event) {
    // Comment
    case 'comment':
        if (!USER_CAN_POST_COMMENTS) {
            enl_die($lang_errors['perm_denied']);
        }
        check_comment($_GET['msg_body']);
        check_comment($_GET['msg_author']);
        $msg_author = enl_utf8Urldecode(addslashes(trim($_GET['msg_author'])));
        $msg_body = enl_utf8Urldecode(addslashes(trim($_GET['msg_body'])));
        $pid = (int) $_GET['pos'];
        $pid = -$pid;
        if (($msg_author == '' || $msg_author == 'undefined') && !USER_ID) {
            enl_die($lang_db_input_php['empty_name_or_com']);
        }
        if ($msg_body == '' || $msg_body == 'undefined') {
            enl_die($lang_db_input_php['empty_name_or_com']);
        }
        $result = cpg_db_query("SELECT comments FROM {$CONFIG['TABLE_PICTURES']}, {$CONFIG['TABLE_ALBUMS']} WHERE {$CONFIG['TABLE_PICTURES']}.aid = {$CONFIG['TABLE_ALBUMS']}.aid AND pid='{$pid}'");
        if (!mysql_num_rows($result)) {
            enl_die($lang_errors['non_exist_ap']);
        }
        $album_data = mysql_fetch_array($result);
开发者ID:phill104,项目名称:branches,代码行数:31,代码来源:enl_addcomment.php

示例10: check_storyimage

     check_storyimage();
     break;
     //note 会员证件
 //note 会员证件
 case 'paper':
     check_paper();
     break;
     //note 举报受理
 //note 举报受理
 case 'report':
     check_report();
     break;
     //note 会员评价审核
 //note 会员评价审核
 case 'comment':
     check_comment();
     break;
     //note 意见反馈s
 //note 意见反馈s
 case 'feedback':
     check_feedback();
     break;
     //note 意见反馈搜索
 //note 意见反馈搜索
 case 'feedback_s':
     check_feedback_s();
     break;
 case 'imagick_rotate':
     check_imagick_rotate();
     break;
 case 'check_introduce':
开发者ID:noikiy,项目名称:zays,代码行数:31,代码来源:check_bak.php

示例11: wp_allow_comment

function wp_allow_comment($commentdata)
{
    global $wpdb;
    extract($commentdata);
    // Simple duplicate check
    $dupe = "SELECT comment_ID FROM {$wpdb->comments} WHERE comment_post_ID = '{$comment_post_ID}' AND ( comment_author = '{$comment_author}' ";
    if ($comment_author_email) {
        $dupe .= "OR comment_author_email = '{$comment_author_email}' ";
    }
    $dupe .= ") AND comment_content = '{$comment_content}' LIMIT 1";
    if ($wpdb->get_var($dupe)) {
        wp_die(__('Duplicate comment detected; it looks as though you\'ve already said that!'));
    }
    // Simple flood-protection
    if ($lasttime = $wpdb->get_var("SELECT comment_date_gmt FROM {$wpdb->comments} WHERE comment_author_IP = '{$comment_author_IP}' OR comment_author_email = '{$comment_author_email}' ORDER BY comment_date DESC LIMIT 1")) {
        $time_lastcomment = mysql2date('U', $lasttime);
        $time_newcomment = mysql2date('U', $comment_date_gmt);
        $flood_die = apply_filters('comment_flood_filter', false, $time_lastcomment, $time_newcomment);
        if ($flood_die) {
            do_action('comment_flood_trigger', $time_lastcomment, $time_newcomment);
            wp_die(__('You are posting comments too quickly.  Slow down.'));
        }
    }
    if ($user_id) {
        $userdata = get_userdata($user_id);
        $user = new WP_User($user_id);
        $post_author = $wpdb->get_var("SELECT post_author FROM {$wpdb->posts} WHERE ID = '{$comment_post_ID}' LIMIT 1");
    }
    if ($userdata && ($user_id == $post_author || $user->has_cap('level_9'))) {
        // The author and the admins get respect.
        $approved = 1;
    } else {
        // Everyone else's comments will be checked.
        if (check_comment($comment_author, $comment_author_email, $comment_author_url, $comment_content, $comment_author_IP, $comment_agent, $comment_type)) {
            $approved = 1;
        } else {
            $approved = 0;
        }
        if (wp_blacklist_check($comment_author, $comment_author_email, $comment_author_url, $comment_content, $comment_author_IP, $comment_agent)) {
            $approved = 'spam';
        }
    }
    $approved = apply_filters('pre_comment_approved', $approved);
    return $approved;
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:45,代码来源:comment.php

示例12: rps_comments_ajax_submit

function rps_comments_ajax_submit()
{
    $response = array('spam' => 'no', 'comment_sent' => 'no');
    global $wpdb;
    if (is_user_logged_in()) {
        global $current_user;
        get_currentuserinfo();
        $name = !empty($current_user->display_name) ? $wpdb->escape($current_user->display_name) : $wpdb->escape($current_user->user_login);
        $email = $wpdb->escape($current_user->user_email);
        $user_id = (int) $current_user->ID;
    } else {
        $name = $wpdb->escape(sanitize_text_field($_POST['form']['name']));
        $email = $wpdb->escape(sanitize_email($_POST['form']['email']));
        $user_id = 0;
    }
    $message = $wpdb->escape(sanitize_text_field($_POST['form']['message']));
    $comment_approved = $user_id == 1 ? 1 : 0;
    $comment_type = 'comment';
    $id = (int) $_POST['form']['id'];
    $time = current_time('mysql');
    $url = '';
    $user_ip = $_SERVER['REMOTE_ADDR'];
    $user_agent = $_SERVER['HTTP_USER_AGENT'];
    $akismet = new Akismet(URL, AKISMET_KEY);
    $akismet->setCommentAuthor($name);
    $akismet->setCommentAuthorEmail($email);
    $akismet->setCommentContent($message);
    $akismet->setPermalink($id);
    if ($akismet->isCommentSpam()) {
        $response['spam'] = 'yes';
    } else {
        $comment_check = check_comment($name, $email, $url, $message, $user_ip, $user_agent, $comment_type);
        $check = $comment_check ? 1 : 0;
        $data = array('comment_post_ID' => $id, 'comment_author' => $name, 'comment_author_email' => $email, 'comment_author_url' => $url, 'comment_content' => $message, 'comment_type' => $comment_type, 'comment_parent' => 0, 'user_id' => $user_id, 'comment_author_IP' => $user_ip, 'comment_agent' => $user_agent, 'comment_date' => $time, 'comment_approved' => $check);
        // Insert comment
        wp_insert_comment($data);
        if (!$comment_check) {
            // Send myself a message
            $to = get_bloginfo('admin_email');
            $subject = __('A new comment is awaiting moderation');
            $the_message = 'Get on that Sweeney :)';
            $mail_sent = wp_mail($to, $subject, $the_message);
        }
        // Create HTML to append new comment to the DOM
        $avatar = get_avatar($email, 80);
        $comment = '<li class="comment"><article>';
        $comment .= $avatar;
        $comment .= '<p class="who-wrote">' . $name . ' wrote</p>';
        $comment .= '<div class="comment-container">';
        $comment .= $comment_check ? '' : '<p><em>Your comment is awaiting moderation.</em></p>';
        $comment .= '<p>' . $message . '</p>';
        $comment .= '<footer><p class="post-meta">' . date('F jS, Y') . '</p></footer>';
        $comment .= '</div></article>';
        $response['comment_sent'] = 'yes';
        $response['comment'] = $comment;
    }
    $response = json_encode($response);
    header("Content-Type: application/json");
    echo $response;
    die;
}
开发者ID:richardsweeney,项目名称:rico-wp-theme,代码行数:61,代码来源:functions.php

示例13: wp_new_comment

function wp_new_comment($commentdata, $spam = false)
{
    global $wpdb;
    $commentdata = apply_filters('preprocess_comment', $commentdata);
    extract($commentdata);
    $comment_post_ID = (int) $comment_post_ID;
    $user_id = apply_filters('pre_user_id', $user_ID);
    $author = apply_filters('pre_comment_author_name', $comment_author);
    $email = apply_filters('pre_comment_author_email', $comment_author_email);
    $url = apply_filters('pre_comment_author_url', $comment_author_url);
    $comment = apply_filters('pre_comment_content', $comment_content);
    $comment = apply_filters('post_comment_text', $comment);
    // Deprecated
    $comment = apply_filters('comment_content_presave', $comment);
    // Deprecated
    $user_ip = apply_filters('pre_comment_user_ip', $_SERVER['REMOTE_ADDR']);
    $user_domain = apply_filters('pre_comment_user_domain', gethostbyaddr($user_ip));
    $user_agent = apply_filters('pre_comment_user_agent', $_SERVER['HTTP_USER_AGENT']);
    $now = current_time('mysql');
    $now_gmt = current_time('mysql', 1);
    if ($user_id) {
        $userdata = get_userdata($user_id);
        $post_author = $wpdb->get_var("SELECT post_author FROM {$wpdb->posts} WHERE ID = '{$comment_post_ID}' LIMIT 1");
    }
    // Simple duplicate check
    $dupe = "SELECT comment_ID FROM {$wpdb->comments} WHERE comment_post_ID = '{$comment_post_ID}' AND ( comment_author = '{$author}' ";
    if ($email) {
        $dupe .= "OR comment_author_email = '{$email}' ";
    }
    $dupe .= ") AND comment_content = '{$comment}' LIMIT 1";
    if ($wpdb->get_var($dupe)) {
        die(__('Duplicate comment detected; it looks as though you\'ve already said that!'));
    }
    // Simple flood-protection
    if ($lasttime = $wpdb->get_var("SELECT comment_date_gmt FROM {$wpdb->comments} WHERE comment_author_IP = '{$user_ip}' OR comment_author_email = '{$email}' ORDER BY comment_date DESC LIMIT 1")) {
        $time_lastcomment = mysql2date('U', $lasttime);
        $time_newcomment = mysql2date('U', $now_gmt);
        if ($time_newcomment - $time_lastcomment < 15) {
            do_action('comment_flood_trigger', $time_lastcomment, $time_newcomment);
            die(__('Sorry, you can only post a new comment once every 15 seconds. Slow down cowboy.'));
        }
    }
    if ($userdata && ($user_id == $post_author || $userdata->user_level >= 9)) {
        $approved = 1;
    } else {
        if (check_comment($author, $email, $url, $comment, $user_ip, $user_agent, $comment_type)) {
            $approved = 1;
        } else {
            $approved = 0;
        }
        if (wp_blacklist_check($author, $email, $url, $comment, $user_ip, $user_agent)) {
            $approved = 'spam';
        }
    }
    $approved = apply_filters('pre_comment_approved', $approved);
    $result = $wpdb->query("INSERT INTO {$wpdb->comments}\n\t(comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_date_gmt, comment_content, comment_approved, comment_agent, comment_type, user_id)\n\tVALUES\n\t('{$comment_post_ID}', '{$author}', '{$email}', '{$url}', '{$user_ip}', '{$now}', '{$now_gmt}', '{$comment}', '{$approved}', '{$user_agent}', '{$comment_type}', '{$user_id}')\n\t");
    $comment_id = $wpdb->insert_id;
    do_action('comment_post', $comment_id, $approved);
    if ('spam' !== $approved) {
        // If it's spam save it silently for later crunching
        if ('0' == $approved) {
            wp_notify_moderator($comment_id);
        }
        if (get_settings('comments_notify') && $approved) {
            wp_notify_postauthor($comment_id, $comment_type);
        }
    }
    return $result;
}
开发者ID:BackupTheBerlios,项目名称:steampress-svn,代码行数:69,代码来源:functions-post.php

示例14: header

         $redirect = "displayimage.php?pos=" . -$comment_data['pid'];
         header($header_location . $redirect);
         pageheader($lang_info, "<META http-equiv=\"refresh\" content=\"1;url={$redirect}\">");
         msg_box($lang_info, $lang_db_input_php['redirect_msg'], $lang_db_input_php['continue'], $redirect);
         pagefooter();
         ob_end_flush();
         exit;
     }
     break;
     // Comment
 // Comment
 case 'comment':
     if (!USER_CAN_POST_COMMENTS) {
         cpg_die(ERROR, $lang_errors['perm_denied'], __FILE__, __LINE__);
     }
     check_comment($HTTP_POST_VARS['msg_body']);
     $msg_author = addslashes(trim($HTTP_POST_VARS['msg_author']));
     $msg_body = addslashes(trim($HTTP_POST_VARS['msg_body']));
     $pid = (int) $HTTP_POST_VARS['pid'];
     if ($msg_author == '' || $msg_body == '') {
         cpg_die(ERROR, $lang_db_input_php['empty_name_or_com'], __FILE__, __LINE__);
     }
     $result = db_query("SELECT comments FROM {$CONFIG['TABLE_PICTURES']}, {$CONFIG['TABLE_ALBUMS']} WHERE {$CONFIG['TABLE_PICTURES']}.aid = {$CONFIG['TABLE_ALBUMS']}.aid AND pid='{$pid}'");
     if (!mysql_num_rows($result)) {
         cpg_die(ERROR, $lang_errors['non_exist_ap'], __FILE__, __LINE__);
     }
     $album_data = mysql_fetch_array($result);
     mysql_free_result($result);
     if ($album_data['comments'] != 'YES') {
         cpg_die(ERROR, $lang_errors['perm_denied'], __FILE__, __LINE__);
     }
开发者ID:BackupTheBerlios,项目名称:milaninegw-svn,代码行数:31,代码来源:db_input.php

示例15: wp_allow_comment

function wp_allow_comment($commentdata) {
	global $wpdb;
	extract($commentdata);

	$comment_user_domain = apply_filters('pre_comment_user_domain', gethostbyaddr($comment_author_IP) );

	// Simple duplicate check
	$dupe = "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = '$comment_post_ID' AND ( comment_author = '$comment_author' ";
	if ( $comment_author_email )
		$dupe .= "OR comment_author_email = '$comment_author_email' ";
	$dupe .= ") AND comment_content = '$comment_content' LIMIT 1";
	if ( $wpdb->get_var($dupe) )
		die( __('Duplicate comment detected; it looks as though you\'ve already said that!') );

	// Simple flood-protection
	if ( $lasttime = $wpdb->get_var("SELECT comment_date_gmt FROM $wpdb->comments WHERE comment_author_IP = '$comment_author_IP' OR comment_author_email = '$comment_author_email' ORDER BY comment_date DESC LIMIT 1") ) {
		$time_lastcomment = mysql2date('U', $lasttime);
		$time_newcomment  = mysql2date('U', $comment_date_gmt);
		if ( ($time_newcomment - $time_lastcomment) < 15 ) {
			do_action('comment_flood_trigger', $time_lastcomment, $time_newcomment);
			die( __('Sorry, you can only post a new comment once every 15 seconds. Slow down cowboy.') );
		}
	}

	if ( $user_id ) {
		$userdata = get_userdata($user_id);
		$user = new WP_User($user_id);
		$post_author = $wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = '$comment_post_ID' LIMIT 1");
	}

	// The author and the admins get respect.
	if ( $userdata && ( $user_id == $post_author || $user->has_cap('level_9') ) ) {
		$approved = 1;
	}

	// Everyone else's comments will be checked.
	else {
		if ( check_comment($comment_author, $comment_author_email, $comment_author_url, $comment_content, $comment_author_IP, $comment_agent, $comment_type) )
			$approved = 1;
		else
			$approved = 0;
		if ( wp_blacklist_check($comment_author, $comment_author_email, $comment_author_url, $comment_content, $comment_author_IP, $comment_agent) )
			$approved = 'spam';
	}

	$approved = apply_filters('pre_comment_approved', $approved);
	return $approved;
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:48,代码来源:comment-functions.php


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