Kitten's emergent registration / comment whitelisting patch.

git-svn-id: http://svn.automattic.com/wordpress/trunk@1737 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
saxmatt 2004-10-04 08:49:45 +00:00
parent 20f7041ac8
commit 73d33cce75
3 changed files with 19 additions and 8 deletions

View File

@ -57,7 +57,7 @@ if ($action == 'retrospam') {
<h2><?php _e('Discussion Options') ?></h2>
<form name="form1" method="post" action="options.php">
<input type="hidden" name="action" value="update" />
<input type="hidden" name="page_options" value="'default_pingback_flag','default_ping_status','default_comment_status','comments_notify','moderation_notify','comment_moderation','require_name_email','comment_max_links','moderation_keys'" />
<input type="hidden" name="page_options" value="'default_pingback_flag','default_ping_status','default_comment_status','comments_notify','moderation_notify','comment_moderation','require_name_email','comment_whitelist','comment_max_links','moderation_keys'" />
<fieldset class="options">
<legend><?php _e('Usual settings for an article: <em>(These settings may be overridden for individual articles.)</em>') ?></legend>
<ul>
@ -101,11 +101,8 @@ if ($action == 'retrospam') {
<input name="comment_moderation" type="checkbox" id="comment_moderation" value="1" <?php checked('1', get_settings('comment_moderation')); ?> />
<?php _e('An administrator must approve the comment (regardless of any matches below)') ?> </label>
</li>
<li>
<label for="require_name_email">
<input type="checkbox" name="require_name_email" id="require_name_email" value="1" <?php checked('1', get_settings('require_name_email')); ?> />
<?php _e('User must fill out name and e-mail') ?> </label>
</li>
<li><label for="require_name_email"><input type="checkbox" name="require_name_email" id="require_name_email" value="1" <?php checked('1', get_settings('require_name_email')); ?> /> <?php _e('Comment author must fill out name and e-mail') ?></label></li>
<li><label for="comment_whitelist"><input type="checkbox" name="comment_whitelist" id="comment_whitelist" value="1" <?php checked('1', get_settings('comment_whitelist')); ?> /> <?php _e('Comment author must have a previously approved comment') ?></label></li>
</ul>
</fieldset>
<fieldset class="options">

View File

@ -211,6 +211,7 @@ function populate_options() {
add_option('use_linksupdate', 0);
add_option('template', 'default');
add_option('stylesheet', 'default');
add_option('comment_whitelist', 0);
// Delete unused options
$unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'rss_language', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl');

View File

@ -1473,13 +1473,26 @@ function get_posts($args) {
}
function check_comment($author, $email, $url, $comment, $user_ip) {
global $wpdb;
if (1 == get_settings('comment_moderation')) return false; // If moderation is set to manual
if ( (count(explode('http:', $comment)) - 1) >= get_settings('comment_max_links') )
return false; // Check # of external links
if ('' == trim( get_settings('moderation_keys') ) ) return true; // If moderation keys are empty
$words = explode("\n", get_settings('moderation_keys') );
// Comment whitelisting:
if ( 1 == get_settings('comment_whitelist')) {
$ok_to_comment = $wpdb->get_var("SELECT comment_approved FROM $wpdb->comments WHERE comment_author_email = '$email' and comment_approved = '1' ");
if ( 1 == $ok_to_comment && false === strpos( $email, get_settings('moderation_keys')) )
return true
return false;
}
$mod_keys = trim( get_settings('moderation_keys') );
if ('' == $mod_keys )
return true; // If moderation keys are empty
$words = explode("\n", $mod_keys );
foreach ($words as $word) {
$word = trim($word);