Changeset 1237
- Timestamp:
- 05/07/2004 11:21:31 PM (21 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-comments-post.php
r1108 r1237 1 1 <?php 2 require( dirname(__FILE__) . '/wp-config.php');2 require( dirname(__FILE__) . '/wp-config.php' ); 3 3 4 4 function add_magic_quotes($array) { … … 14 14 15 15 if (!get_magic_quotes_gpc()) { 16 $_GET = add_magic_quotes($_GET);17 16 $_POST = add_magic_quotes($_POST); 18 17 $_COOKIE = add_magic_quotes($_COOKIE); … … 31 30 32 31 $comment = trim($_POST['comment']); 33 $original_comment = $comment;34 32 $comment_post_ID = intval($_POST['comment_post_ID']); 35 33 $user_ip = $_SERVER['REMOTE_ADDR']; 36 $user_domain = gethostbyaddr($user_ip);37 34 38 $commentstatus = $wpdb->get_var("SELECT comment_status FROM $tableposts WHERE ID = $comment_post_ID"); 39 if ('closed' == $commentstatus) 40 die('Sorry, comments are closed for this item.'); 35 if ( 'closed' == $wpdb->get_var("SELECT comment_status FROM $tableposts WHERE ID = '$comment_post_ID'") ) 36 die( __('Sorry, comments are closed for this item.') ); 41 37 42 if ( get_settings('require_name_email') && ($email == '' || $author == '')) { //original fix by Dodo, and then Drinyth43 die( 'Error: please fill the required fields (name, email).');44 } 45 if ( $comment == 'comment' || $comment == '') {46 die( 'Error: please type a comment.');47 } 38 if ( get_settings('require_name_email') && ('' == $email || '' == $author) ) 39 die( __('Error: please fill the required fields (name, email).') ); 40 41 if ( '' == $comment ) 42 die( __('Error: please type a comment.') ); 43 48 44 49 45 $now = current_time('mysql'); … … 53 49 $comment = balanceTags($comment, 1); 54 50 $comment = format_to_post($comment); 51 $comment = apply_filters('post_comment_text', $comment); 55 52 56 $comment_author = $author; 57 $comment_author_email = $email; 58 $comment_author_url = $url; 59 60 $author = addslashes($author); 61 $email = addslashes($email); 62 $url = addslashes($url); 63 64 /* Flood-protection */ 53 // Simple flood-protection 65 54 $lasttime = $wpdb->get_var("SELECT comment_date FROM $tablecomments WHERE comment_author_IP = '$user_ip' ORDER BY comment_date DESC LIMIT 1"); 66 $ok = true;67 55 if (!empty($lasttime)) { 68 56 $time_lastcomment= mysql2date('U', $lasttime); 69 $time_newcomment= mysql2date('U', "$now");57 $time_newcomment= mysql2date('U', $now); 70 58 if (($time_newcomment - $time_lastcomment) < 10) 71 $ok = false;59 die( __('Sorry, you can only post a new comment once every 10 seconds. Slow down cowboy.') ); 72 60 } 73 /* End flood-protection */74 61 75 62 63 // If we've made it this far, let's post. 76 64 77 if ($ok) { // if there was no comment from this IP in the last 10 seconds 78 $moderation_notify = get_settings('moderation_notify'); 79 $comments_notify = get_settings('comments_notify'); 65 if(check_comment($author, $email, $url, $comment, $user_ip)) { 66 $approved = 1; 67 } else { 68 $approved = 0; 69 } 80 70 81 if(check_comment($author, $email, $url, $comment, $user_ip)) { 82 $approved = 1; 83 } else { 84 $approved = 0; 85 } 71 $wpdb->query("INSERT INTO $tablecomments 72 (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_date_gmt, comment_content, comment_approved) 73 VALUES 74 ('$comment_post_ID', '$author', '$email', '$url', '$user_ip', '$now', '$now_gmt', '$comment', '$approved') 75 "); 86 76 87 $wpdb->query("INSERT INTO $tablecomments 88 (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_date_gmt, comment_content, comment_approved) 89 VALUES 90 ('$comment_post_ID', '$author', '$email', '$url', '$user_ip', '$now', '$now_gmt', '$comment', '$approved') 91 "); 77 $comment_ID = $wpdb->get_var('SELECT last_insert_id()'); 92 78 93 $comment_ID = $wpdb->get_var('SELECT last_insert_id()'); 79 if (!$approved) { 80 wp_notify_moderator($comment_ID); 81 } 94 82 95 if (($moderation_notify) && (!$approved)) { 96 wp_notify_moderator($comment_ID); 97 } 98 99 if ((get_settings('comments_notify')) && ($approved)) { 100 wp_notify_postauthor($comment_ID, 'comment'); 101 } 83 if ((get_settings('comments_notify')) && ($approved)) { 84 wp_notify_postauthor($comment_ID, 'comment'); 85 } 102 86 103 87 do_action('comment_post', $comment_ID); 104 88 105 if ($email == '') 106 $email = ' '; // this to make sure a cookie is set for 'no email' 89 setcookie('comment_author_' . $cookiehash, $author, time() + 30000000, COOKIEPATH); 90 setcookie('comment_author_email_' . $cookiehash, $email, time() + 30000000, COOKIEPATH); 91 setcookie('comment_author_url_' . $cookiehash, $url, time() + 30000000, COOKIEPATH); 107 92 108 if ($url == '') 109 $url = ' '; // this to make sure a cookie is set for 'no url' 110 111 setcookie('comment_author_'.$cookiehash, $author, time()+30000000); 112 setcookie('comment_author_email_'.$cookiehash, $email, time()+30000000); 113 setcookie('comment_author_url_'.$cookiehash, $url, time()+30000000); 114 115 header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); 116 header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); 117 header('Cache-Control: no-cache, must-revalidate'); 118 header('Pragma: no-cache'); 119 $location = (empty($_POST['redirect_to'])) ? $_SERVER["HTTP_REFERER"] : $_POST['redirect_to']; 120 if ($is_IIS) { 121 header("Refresh: 0;url=$location"); 122 } else { 123 header("Location: $location"); 124 } 93 header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); 94 header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); 95 header('Cache-Control: no-cache, must-revalidate'); 96 header('Pragma: no-cache'); 97 $location = (empty($_POST['redirect_to'])) ? $_SERVER["HTTP_REFERER"] : $_POST['redirect_to']; 98 if ($is_IIS) { 99 header("Refresh: 0;url=$location"); 125 100 } else { 126 die('Sorry, you can only post a new comment once every 10 seconds. Slow down cowboy.');101 header("Location: $location"); 127 102 } 128 103 -
trunk/wp-includes/vars.php
r1179 r1237 173 173 } 174 174 175 // Path for cookies 176 define('COOKIEPATH', preg_replace('|http://[^/]+|i', '', get_settings('home') . '/' ) ); 175 177 176 178 // Some default filters
Note: See TracChangeset
for help on using the changeset viewer.