diff --git a/b2-include/b2functions.php b/b2-include/b2functions.php
index 538fdd1a25..08658c10c8 100644
--- a/b2-include/b2functions.php
+++ b/b2-include/b2functions.php
@@ -64,7 +64,7 @@ function wptexturize($text) {
return $output;
}
-function wpautop($pee, $br=1) {
+function wpautop($pee, $br = 1) {
$pee = $pee . "\n"; // just to make things a little easier, pad the end
$pee = preg_replace('|
\s*
|', "\n\n", $pee);
$pee = preg_replace('!(<(?:table|ul|ol|li|pre|form|blockquote|h[1-6])[^>]*>)!', "\n$1", $pee); // Space things out a little
@@ -171,6 +171,18 @@ function mysql2date($dateformatstring, $mysqlstring, $use_b2configmonthsdays = 1
return $j;
}
+function current_time($type) {
+ $time_difference = get_settings('time_difference');
+ switch ($type) {
+ case 'mysql':
+ return date('Y-m-d H:i:s', (time() + ($time_difference * 3600) ) );
+ break;
+ case 'timestamp':
+ return (time() + ($time_difference * 3600) );
+ break;
+ }
+}
+
function addslashes_gpc($gpc) {
if (!get_magic_quotes_gpc()) {
$gpc = addslashes($gpc);
@@ -1394,23 +1406,23 @@ function wp_set_comment_status($comment_id, $comment_status) {
global $wpdb, $tablecomments;
switch($comment_status) {
- case 'hold':
- $query = "UPDATE $tablecomments SET comment_approved='0' WHERE comment_ID='$comment_id' LIMIT 1";
- break;
- case 'approve':
- $query = "UPDATE $tablecomments SET comment_approved='1' WHERE comment_ID='$comment_id' LIMIT 1";
- break;
- case 'delete':
- $query = "DELETE FROM $tablecomments WHERE comment_ID='$comment_id' LIMIT 1";
- break;
- default:
- return false;
+ case 'hold':
+ $query = "UPDATE $tablecomments SET comment_approved='0' WHERE comment_ID='$comment_id' LIMIT 1";
+ break;
+ case 'approve':
+ $query = "UPDATE $tablecomments SET comment_approved='1' WHERE comment_ID='$comment_id' LIMIT 1";
+ break;
+ case 'delete':
+ $query = "DELETE FROM $tablecomments WHERE comment_ID='$comment_id' LIMIT 1";
+ break;
+ default:
+ return false;
}
if ($wpdb->query($query)) {
- return true;
+ return true;
} else {
- return false;
+ return false;
}
}
diff --git a/b2comments.php b/b2comments.php
index bc26f98949..a473802dd4 100644
--- a/b2comments.php
+++ b/b2comments.php
@@ -19,32 +19,29 @@
-
RSS feed for comments on this post.
+RSS feed for comments on this post.
ping_status) { ?>The URI to TrackBack this entry is:
-No comments yet.
+ +Line and paragraph breaks automatic, website trumps email, HTML allowed:
- Please note:
- This blog uses comment moderation. In other words: your comment will need approval
- by the administrator before it will appear in the blog. Approval usually happens
- within the next 24 hours. Please send your comment only once. Thank you.
+ Please note: Comment moderation is currently enabled so there may be a delay between when you post your comment and when it shows up. Patience is a virtue; there’s no need to resubmit your comment.
RSS feed for comments on this post.
@@ -27,33 +27,29 @@ foreach ($posts as $post) { start_b2();The URI to TrackBack this entry is:
-No comments yet.
+ + +comment_status) { ?>Line and paragraph breaks automatic, website trumps email, HTML allowed:
Now on to step 2.
query("INSERT INTO `$tableoptions` (`option_id`, `blog_id`, `option_name` $wpdb->query("UPDATE $tableoptions SET option_description = 'accepted file types, separated by spaces. example: \'jpg gif png\'' WHERE option_id = 34"); echo ' .'; flush(); - // add link to date format help page - $wpdb->query("UPDATE $tableoptions SET option_description = 'see help for format characters' WHERE option_id = 52"); - $wpdb->query("UPDATE $tableoptions SET option_description = 'see help for format characters' WHERE option_id = 53"); + // add link to php date format. this could be to a wordpress.org page in the future + $wpdb->query("UPDATE $tableoptions SET option_description = 'see help for format characters' WHERE option_id = 52"); + $wpdb->query("UPDATE $tableoptions SET option_description = 'see help for format characters' WHERE option_id = 53"); echo ' .'; flush(); ?> - Done. -See, that didn’t hurt a bit. All done!
+ Done with the options updates. Now for a bit of comment action +query("ALTER TABLE $tablecomments ADD INDEX (comment_approved)"); + } +} + +// Insert new option "comment_moderation" to settings +if (!$wpdb->get_var("SELECT option_id FROM $tableoptions WHERE option_name = 'comment_moderation'")) { + $wpdb->query("INSERT INTO $tableoptions + (option_id, blog_id, option_name, option_can_override, option_type, option_value, option_width, option_height, option_description, option_admin_level) + VALUES + ('0', '0', 'comment_moderation', 'Y', '5',' none', 20, 8, 'If enabled, comments will only be shown after they have been approved.', 8)"); +} + +// attach option to group "General blog settings" +if ($continue) { + $oid = $wpdb->get_var("SELECT option_id FROM $tableoptions WHERE option_name = 'comment_moderation'"); + $gid = $wpdb->get_var("SELECT group_id FROM $tableoptiongroups WHERE group_name = 'General blog settings'"); + + $seq = $wpdb->get_var("SELECT MAX(seq) FROM $tableoptiongroup_options WHERE group_id = '$gid'"); + + ++$seq; + + $wpdb->query("INSERT INTO $tableoptiongroup_options + (group_id, option_id, seq) + VALUES + ('$gid', '$oid', '$seq')"); +} + +// Insert option values for new option "comment_moderation" +if ($continue) { + $ddl = array(); + $ddl[] = "INSERT INTO $tableoptionvalues + (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) + VALUES + ('$oid', 'none', 'None', NULL, NULL, 1)"; + $ddl[] = "INSERT INTO $tableoptionvalues + (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) + VALUES + ('$oid', 'manual', 'Manual', NULL, NULL, 2)"; + $ddl[] = "INSERT INTO $tableoptionvalues + (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) + VALUES + ('$oid','auto', 'Automatic', NULL, NULL, 3)"; + + foreach ($ddl as $query) { + $wpdb->query($query); + } + +} + +// Insert new option "moderation_notify" to settings +if (!$wpdb->get_var("SELECT option_id FROM $tableoptions WHERE option_name = 'moderation_notify'")) { + $wpdb->query("INSERT INTO $tableoptions + (option_id, blog_id, option_name, option_can_override, option_type, option_value, option_width, option_height, option_description, option_admin_level) + VALUES + ('0', '0', 'moderation_notify' , 'Y', '2', '1', 20, 8, 'Set this to true if you want to be notified about new comments that wait for approval', 8)"); +} + +// attach option to group "General blog settings" +if ($continue) { + $oid = $wpdb->get_var("SELECT option_id FROM $tableoptions WHERE option_name = 'moderation_notify'"); + $gid = $wpdb->get_var("SELECT group_id FROM $tableoptiongroups WHERE group_name = 'General blog settings'"); + + $seq = $wpdb->get_var("SELECT MAX(seq) FROM $tableoptiongroup_options WHERE group_id = '$gid'"); + + ++$seq; + $wpdb->query("INSERT INTO $tableoptiongroup_options + (group_id, option_id, seq) + VALUES + ('$gid', '$oid', '$seq')"); +} +?> +Comment spammers should now watch out for you.
+See, that didn’t hurt a bit (again). All done!
- - -This will upgrade your database in order to be able to use otaku42's comment -moderation hack.
-First of all: backup your database! This script will make -changes to it and it could happen that things aren't going the way they should. -You have been warned.
-What this hack does is simple: it introduces a new option for comment moderation.
-Comment moderation means that new comments won't show up in your blog until they
-have been approved. Approval happens either manually or automatically (not implemented
-yet). This all is a first step towards comment spam prevention.
-
You will have a simple panel in the admin section that shows you waiting
-comments. You can either approve or delete them, or hold them further for approval.
The procedure is easy: click on the next button and see if there -are any warnings popping up. If so, please report the problem(s) to me -(mrenzmann@otaku42.de) so that I can -fix it/them.
-The following passage (grey text) is of interest for you only if you are familiar -with WordPress development:
- -In order to have the patch working we need to extend the comment table with a -field that indicates whether the comment has been approved or not (comment_approved). -Its default value will be 1 so that comments are auto-approved when comment -moderation has been turned off by the admin.
-The next thing is that we need an option to turn comment moderation on/off. It will -be named comment_moderation and can be found in General blog -settings.
-Another option that gets inserted is moderation_notify. If turned on, a mail -will be sent to the admin to inform about the new (and possibly other) comment that is/are -waiting for his approval.
-This upgrade procedure tries to be as save as possible by not relying on any hardcoded -values. For example it retrieves the id for option group general blog settings -rather than assuming it has the same id as in my own blog. - -Ready? - -Let's go!
\n"; - break; // end case 0 - - case 1: - $result = ""; - $error_count = 0; - $continue = true; - - // insert new column "comment_approved" to $tablecomments - if ($continue) { - $tablename = $tablecomments; - $tablecol = "comment_approved"; - $ddl = "ALTER TABLE $tablecomments ADD COLUMN $tablecol ENUM('0','1') DEFAULT '1' NOT NULL"; - $result .= "Adding column $tablecol to table $tablename: "; - if (maybe_add_column($tablename, $tablecol, $ddl)) { - $result .= "okHmmm... there was some kind of error. If you cannot figure out -from the output above how to correct the problems please -contact me at mrenzmann@otaku42.de -and report your problem.
- - - -Seems that everything went fine. Great!
-Now you have two new options in your settings section General blog settings: -
Have fun!
- - - - -
by — @
+