⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 akismet.php

📁 WordPress是一个Blog程序,用它你可以架设完全属于你自己的Blog. 而WordPress现在的应用又不仅仅只是在Blog方面,因为其强大的扩展性,部分网站甚至已经开始使用WordPress
💻 PHP
📖 第 1 页 / 共 3 页
字号:
	$response = akismet_http_post($query_string, $akismet_api_host, "/1.1/submit-spam", $akismet_api_port);}add_action('wp_set_comment_status', 'akismet_submit_spam_comment');add_action('edit_comment', 'akismet_submit_spam_comment');add_action('preprocess_comment', 'akismet_auto_check_comment', 1);function akismet_spamtoham( $comment ) { akismet_submit_nonspam_comment( $comment->comment_ID ); }add_filter( 'comment_spam_to_approved', 'akismet_spamtoham' );// Total spam in queue// get_option( 'akismet_spam_count' ) is the total caught everfunction akismet_spam_count( $type = false ) {	global $wpdb;	if ( !$type ) { // total		$count = wp_cache_get( 'akismet_spam_count', 'widget' );		if ( false === $count ) {			if ( function_exists('wp_count_comments') ) {				$count = wp_count_comments();				$count = $count->spam;			} else {				$count = (int) $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_approved = 'spam'");			}			wp_cache_set( 'akismet_spam_count', $count, 'widget', 3600 );		}		return $count;	} elseif ( 'comments' == $type || 'comment' == $type ) { // comments		$type = '';	} else { // pingback, trackback, ...		$type  = $wpdb->escape( $type );	}	return (int) $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_approved = 'spam' AND comment_type='$type'");}function akismet_spam_comments( $type = false, $page = 1, $per_page = 50 ) {	global $wpdb;	$page = (int) $page;	if ( $page < 2 )		$page = 1;	$per_page = (int) $per_page;	if ( $per_page < 1 )		$per_page = 50;	$start = ( $page - 1 ) * $per_page;	$end = $start + $per_page;	if ( $type ) {		if ( 'comments' == $type || 'comment' == $type )			$type = '';		else			$type = $wpdb->escape( $type );		return $wpdb->get_results( "SELECT * FROM $wpdb->comments WHERE comment_approved = 'spam' AND comment_type='$type' ORDER BY comment_date DESC LIMIT $start, $end");	}	// All	return $wpdb->get_results( "SELECT * FROM $wpdb->comments WHERE comment_approved = 'spam' ORDER BY comment_date DESC LIMIT $start, $end");}// Totals for each comment type// returns array( type => count, ... )function akismet_spam_totals() {	global $wpdb;	$totals = $wpdb->get_results( "SELECT comment_type, COUNT(*) AS cc FROM $wpdb->comments WHERE comment_approved = 'spam' GROUP BY comment_type" );	$return = array();	foreach ( $totals as $total )		$return[$total->comment_type ? $total->comment_type : 'comment'] = $total->cc;	return $return;}function akismet_manage_page() {	global $wpdb, $submenu, $wp_db_version;	// WP 2.7 has its own spam management page	if ( 8645 <= $wp_db_version )		return;	$count = sprintf(__('Akismet Spam (%s)'), akismet_spam_count());	if ( isset( $submenu['edit-comments.php'] ) )		add_submenu_page('edit-comments.php', __('Akismet Spam'), $count, 'moderate_comments', 'akismet-admin', 'akismet_caught' );	elseif ( function_exists('add_management_page') )		add_management_page(__('Akismet Spam'), $count, 'moderate_comments', 'akismet-admin', 'akismet_caught');}function akismet_caught() {	global $wpdb, $comment, $akismet_caught, $akismet_nonce;	akismet_recheck_queue();	if (isset($_POST['submit']) && 'recover' == $_POST['action'] && ! empty($_POST['not_spam'])) {		check_admin_referer( $akismet_nonce );		if ( function_exists('current_user_can') && !current_user_can('moderate_comments') )			die(__('You do not have sufficient permission to moderate comments.'));		$i = 0;		foreach ($_POST['not_spam'] as $comment):			$comment = (int) $comment;			if ( function_exists('wp_set_comment_status') )				wp_set_comment_status($comment, 'approve');			else				$wpdb->query("UPDATE $wpdb->comments SET comment_approved = '1' WHERE comment_ID = '$comment'");			akismet_submit_nonspam_comment($comment);			++$i;		endforeach;		$to = add_query_arg( 'recovered', $i, $_SERVER['HTTP_REFERER'] );		wp_redirect( $to );		exit;	}	if ('delete' == $_POST['action']) {		check_admin_referer( $akismet_nonce );		if ( function_exists('current_user_can') && !current_user_can('moderate_comments') )			die(__('You do not have sufficient permission to moderate comments.'));		$delete_time = $wpdb->escape( $_POST['display_time'] );		$nuked = $wpdb->query( "DELETE FROM $wpdb->comments WHERE comment_approved = 'spam' AND '$delete_time' > comment_date_gmt" );		wp_cache_delete( 'akismet_spam_count', 'widget' );		$to = add_query_arg( 'deleted', 'all', $_SERVER['HTTP_REFERER'] );		wp_redirect( $to );		exit;	}if ( isset( $_GET['recovered'] ) ) {	$i = (int) $_GET['recovered'];	echo '<div class="updated"><p>' . sprintf(__('%1$s comments recovered.'), $i) . "</p></div>";}if (isset( $_GET['deleted'] ) )	echo '<div class="updated"><p>' . __('All spam deleted.') . '</p></div>';if ( isset( $GLOBALS['submenu']['edit-comments.php'] ) )	$link = 'edit-comments.php';else	$link = 'edit.php';?><style type="text/css">.akismet-tabs {	list-style: none;	margin: 0;	padding: 0;	clear: both;	border-bottom: 1px solid #ccc;	height: 31px;	margin-bottom: 20px;	background: #ddd;	border-top: 1px solid #bdbdbd;}.akismet-tabs li {	float: left;	margin: 5px 0 0 20px;}.akismet-tabs a {	display: block;	padding: 4px .5em 3px;	border-bottom: none;	color: #036;}.akismet-tabs .active a {	background: #fff;	border: 1px solid #ccc;	border-bottom: none;	color: #000;	font-weight: bold;	padding-bottom: 4px;}#akismetsearch {	float: right;	margin-top: -.5em;}#akismetsearch p {	margin: 0;	padding: 0;}</style><div class="wrap"><h2><?php _e('Caught Spam') ?></h2><?php$count = get_option( 'akismet_spam_count' );if ( $count ) {?><p><?php printf(__('Akismet has caught <strong>%1$s spam</strong> for you since you first installed it.'), number_format_i18n($count) ); ?></p><?php}$spam_count = akismet_spam_count();if ( 0 == $spam_count ) {	echo '<p>'.__('You have no spam currently in the queue. Must be your lucky day. :)').'</p>';	echo '</div>';} else {	echo '<p>'.__('You can delete all of the spam from your database with a single click. This operation cannot be undone, so you may wish to check to ensure that no legitimate comments got through first. Spam is automatically deleted after 15 days, so don&#8217;t sweat it.').'</p>';?><?php if ( !isset( $_POST['s'] ) ) { ?><form method="post" action="<?php echo attribute_escape( add_query_arg( 'noheader', 'true' ) ); ?>"><?php akismet_nonce_field($akismet_nonce) ?><input type="hidden" name="action" value="delete" /><?php printf(__('There are currently %1$s comments identified as spam.'), $spam_count); ?>&nbsp; &nbsp; <input type="submit" class="button delete" name="Submit" value="<?php _e('Delete all'); ?>" /><input type="hidden" name="display_time" value="<?php echo current_time('mysql', 1); ?>" /></form><?php } ?></div><div class="wrap"><?php if ( isset( $_POST['s'] ) ) { ?><h2><?php _e('Search'); ?></h2><?php } else { ?><?php echo '<p>'.__('These are the latest comments identified as spam by Akismet. If you see any mistakes, simply mark the comment as "not spam" and Akismet will learn from the submission. If you wish to recover a comment from spam, simply select the comment, and click Not Spam. After 15 days we clean out the junk for you.').'</p>'; ?><?php } ?><?phpif ( isset( $_POST['s'] ) ) {	$s = $wpdb->escape($_POST['s']);	$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments  WHERE		(comment_author LIKE '%$s%' OR		comment_author_email LIKE '%$s%' OR		comment_author_url LIKE ('%$s%') OR		comment_author_IP LIKE ('%$s%') OR		comment_content LIKE ('%$s%') ) AND		comment_approved = 'spam'		ORDER BY comment_date DESC");} else {	if ( isset( $_GET['apage'] ) )		$page = (int) $_GET['apage'];	else		$page = 1;	if ( $page < 2 )		$page = 1;	$current_type = false;	if ( isset( $_GET['ctype'] ) )		$current_type = preg_replace( '|[^a-z]|', '', $_GET['ctype'] );	$comments = akismet_spam_comments( $current_type, $page );	$total = akismet_spam_count( $current_type );	$totals = akismet_spam_totals();?><ul class="akismet-tabs"><li <?php if ( !isset( $_GET['ctype'] ) ) echo ' class="active"'; ?>><a href="edit-comments.php?page=akismet-admin"><?php _e('All'); ?></a></li><?phpforeach ( $totals as $type => $type_count ) {	if ( 'comment' == $type ) {		$type = 'comments';		$show = __('Comments');	} else {		$show = ucwords( $type );	}	$type_count = number_format_i18n( $type_count );	$extra = $current_type === $type ? ' class="active"' : '';	echo "<li $extra><a href='edit-comments.php?page=akismet-admin&amp;ctype=$type'>$show ($type_count)</a></li>";}do_action( 'akismet_tabs' ); // so plugins can add more tabs easily?></ul><?php}if ($comments) {?><form method="post" action="<?php echo attribute_escape("$link?page=akismet-admin"); ?>" id="akismetsearch"><p>  <input type="text" name="s" value="<?php if (isset($_POST['s'])) echo attribute_escape($_POST['s']); ?>" size="17" />  <input type="submit" class="button" name="submit" value="<?php echo attribute_escape(__('Search Spam &raquo;')) ?>"  />  </p></form><?php if ( $total > 50 ) {$total_pages = ceil( $total / 50 );$r = '';if ( 1 < $page ) {	$args['apage'] = ( 1 == $page - 1 ) ? '' : $page - 1;	$r .=  '<a class="prev" href="' . clean_url(add_query_arg( $args )) . '">'. __('&laquo; Previous Page') .'</a>' . "\n";}if ( ( $total_pages = ceil( $total / 50 ) ) > 1 ) {	for ( $page_num = 1; $page_num <= $total_pages; $page_num++ ) :		if ( $page == $page_num ) :			$r .=  "<strong>$page_num</strong>\n";		else :			$p = false;			if ( $page_num < 3 || ( $page_num >= $page - 3 && $page_num <= $page + 3 ) || $page_num > $total_pages - 3 ) :				$args['apage'] = ( 1 == $page_num ) ? '' : $page_num;				$r .= '<a class="page-numbers" href="' . clean_url(add_query_arg($args)) . '">' . ( $page_num ) . "</a>\n";				$in = true;			elseif ( $in == true ) :				$r .= "...\n";				$in = false;			endif;		endif;	endfor;}if ( ( $page ) * 50 < $total || -1 == $total ) {	$args['apage'] = $page + 1;	$r .=  '<a class="next" href="' . clean_url(add_query_arg($args)) . '">'. __('Next Page &raquo;') .'</a>' . "\n";}echo "<p>$r</p>";?><?php } ?><form style="clear: both;" method="post" action="<?php echo attribute_escape( add_query_arg( 'noheader', 'true' ) ); ?>"><?php akismet_nonce_field($akismet_nonce) ?><input type="hidden" name="action" value="recover" /><ul id="spam-list" class="commentlist" style="list-style: none; margin: 0; padding: 0;"><?php$i = 0;foreach($comments as $comment) {	$i++;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -