[wp-cvs] wordpress wp-comments-post.php, 1.20, 1.21 wp-login.php, 1.45, 1.46 wp-pass.php, 1.6, 1.7 wp-register.php, 1.21, 1.22 wp-settings.php, 1.63, 1.64 wp-trackback.php, 1.26, 1.27 xmlrpc.php, 1.34, 1.35

Matthew Mullenweg saxmatt at users.sourceforge.net
Thu Dec 16 02:57:07 UTC 2004


Update of /cvsroot/cafelog/wordpress
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11810

Modified Files:
	wp-comments-post.php wp-login.php wp-pass.php wp-register.php 
	wp-settings.php wp-trackback.php xmlrpc.php 
Log Message:
Comments refactoring and cleanup

Index: wp-pass.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-pass.php,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** wp-pass.php	10 Oct 2004 17:46:50 -0000	1.6
--- wp-pass.php	16 Dec 2004 02:56:57 -0000	1.7
***************
*** 1,4 ****
  <?php
! require(dirname(__FILE__) . '/wp-config.php');
  
  if ( get_magic_quotes_gpc() )
--- 1,4 ----
  <?php
! require( dirname(__FILE__) . '/wp-config.php');
  
  if ( get_magic_quotes_gpc() )

Index: wp-settings.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-settings.php,v
retrieving revision 1.63
retrieving revision 1.64
diff -C2 -d -r1.63 -r1.64
*** wp-settings.php	14 Dec 2004 09:27:14 -0000	1.63
--- wp-settings.php	16 Dec 2004 02:56:57 -0000	1.64
***************
*** 102,105 ****
--- 102,112 ----
  define('TEMPLATEPATH', get_template_directory());
  
+ if ( !get_magic_quotes_gpc() ) {
+ 	$_GET    = add_magic_quotes($_GET   );
+ 	$_POST   = add_magic_quotes($_POST  );
+ 	$_COOKIE = add_magic_quotes($_COOKIE);
+ 	$_SERVER = add_magic_quotes($_SERVER);
+ }
+ 
  function shutdown_action_hook() {
  	do_action('shutdown', '');

Index: wp-comments-post.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-comments-post.php,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** wp-comments-post.php	15 Nov 2004 06:20:28 -0000	1.20
--- wp-comments-post.php	16 Dec 2004 02:56:57 -0000	1.21
***************
*** 2,49 ****
  require( dirname(__FILE__) . '/wp-config.php' );
  
! function add_magic_quotes($array) {
! 	foreach ($array as $k => $v) {
! 		if (is_array($v)) {
! 			$array[$k] = add_magic_quotes($v);
! 		} else {
! 			$array[$k] = addslashes($v);
! 		}
! 	}
! 	return $array;
! } 
! 
! if (!get_magic_quotes_gpc()) {
! 	$_POST   = add_magic_quotes($_POST);
! 	$_COOKIE = add_magic_quotes($_COOKIE);
! 	$_SERVER = add_magic_quotes($_SERVER);
! }
! 
! $author = trim(strip_tags($_POST['author']));
! 
! $email = trim(strip_tags($_POST['email']));
! if (strlen($email) < 6)
! 	$email = '';
! 
! $url = trim(strip_tags($_POST['url']));
! $url = ((!stristr($url, '://')) && ($url != '')) ? 'http://'.$url : $url;
! if (strlen($url) < 7)
! 	$url = '';
! 
! $user_agent = $_SERVER['HTTP_USER_AGENT'];
! 
! $comment = trim($_POST['comment']);
! $comment_post_ID = intval($_POST['comment_post_ID']);
! $user_ip = $_SERVER['REMOTE_ADDR'];
  
  $post_status = $wpdb->get_var("SELECT comment_status FROM $wpdb->posts WHERE ID = '$comment_post_ID'");
  
  if ( empty($post_status) ) {
! 	// Post does not exist.  Someone is trolling.  Die silently.
! 	// (Perhaps offer pluggable rebukes? Long delays, etc.)
! 	die();
! } else if ( 'closed' ==  $post_status ) {
  	die( __('Sorry, comments are closed for this item.') );
  }
  
  if ( get_settings('require_name_email') && ('' == $email || '' == $author) )
  	die( __('Error: please fill the required fields (name, email).') );
--- 2,26 ----
  require( dirname(__FILE__) . '/wp-config.php' );
  
! $comment_post_ID = (int) $_POST['comment_post_ID'];
  
  $post_status = $wpdb->get_var("SELECT comment_status FROM $wpdb->posts WHERE ID = '$comment_post_ID'");
  
  if ( empty($post_status) ) {
! 	do_action('comment_id_not_found', $comment_post_ID);
! 	exit;
! } elseif ( 'closed' ==  $post_status ) {
! 	do_action('comment_closed', $comment_post_ID);
  	die( __('Sorry, comments are closed for this item.') );
  }
  
+ $comment_author       = $_POST['author'];
+ $comment_author_email = $_POST['email'];
+ $comment_author_url   = $_POST['url'];
+ $comment_content      = $_POST['comment'];
+ 
+ $comment_type = '';
+ 
+ $user_ip    = apply_filters('pre_comment_user_ip', $_SERVER['REMOTE_ADDR']);
+ 
  if ( get_settings('require_name_email') && ('' == $email || '' == $author) )
  	die( __('Error: please fill the required fields (name, email).') );
***************
*** 52,97 ****
  	die( __('Error: please type a comment.') );
  
  
! $now = current_time('mysql');
! $now_gmt = current_time('mysql', 1);
! 
! $comment = format_to_post($comment);
! $comment = apply_filters('post_comment_text', $comment);
! 
! // Simple flood-protection
! $lasttime = $wpdb->get_var("SELECT comment_date FROM $wpdb->comments WHERE comment_author_IP = '$user_ip' ORDER BY comment_date DESC LIMIT 1");
! if (!empty($lasttime)) {
! 	$time_lastcomment= mysql2date('U', $lasttime);
! 	$time_newcomment= mysql2date('U', $now);
! 	if (($time_newcomment - $time_lastcomment) < 10)
! 		die( __('Sorry, you can only post a new comment once every 10 seconds. Slow down cowboy.') );
! }
! 
! 
! // If we've made it this far, let's post.
! 
! if( check_comment($author, $email, $url, $comment, $user_ip, $user_agent) ) {
! 	$approved = 1;
! } else {
! 	$approved = 0;
! }
! 
! $wpdb->query("INSERT INTO $wpdb->comments 
! (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) 
! VALUES 
! ('$comment_post_ID', '$author', '$email', '$url', '$user_ip', '$now', '$now_gmt', '$comment', '$approved', '$user_agent')
! ");
! 
! $comment_ID = $wpdb->insert_id;
! 
! do_action('comment_post', $comment_ID);
! 
! if (!$approved) {
! 	wp_notify_moderator($comment_ID);
! }
! 
! if ((get_settings('comments_notify')) && ($approved)) {
! 	wp_notify_postauthor($comment_ID, 'comment');
! }
  
  setcookie('comment_author_' . COOKIEHASH, stripslashes($author), time() + 30000000, COOKIEPATH);
--- 29,35 ----
  	die( __('Error: please type a comment.') );
  
+ $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type');
  
! wp_new_comment($commentdata);
  
  setcookie('comment_author_' . COOKIEHASH, stripslashes($author), time() + 30000000, COOKIEPATH);
***************
*** 99,103 ****
  setcookie('comment_author_url_' . COOKIEHASH, stripslashes($url), time() + 30000000, COOKIEPATH);
  
! header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
  header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
  header('Cache-Control: no-cache, must-revalidate');
--- 37,41 ----
  setcookie('comment_author_url_' . COOKIEHASH, stripslashes($url), time() + 30000000, COOKIEPATH);
  
! header('Expires: Mon, 11 Jan 1984 05:00:00 GMT');
  header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
  header('Cache-Control: no-cache, must-revalidate');
***************
*** 112,114 ****
  }
  
! ?>
--- 50,52 ----
  }
  
! ?>
\ No newline at end of file

Index: xmlrpc.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/xmlrpc.php,v
retrieving revision 1.34
retrieving revision 1.35
diff -C2 -d -r1.34 -r1.35
*** xmlrpc.php	13 Dec 2004 14:55:13 -0000	1.34
--- xmlrpc.php	16 Dec 2004 02:56:57 -0000	1.35
***************
*** 1219,1228 ****
  		$pagelinkedfrom = addslashes($pagelinkedfrom);
  		$original_title = $title;
- 		$title = addslashes(strip_tags(trim($title)));
  
! 		// Check if the entry allows pings
! 		if( !check_comment($title, '', $pagelinkedfrom, $context, $user_ip, $user_agent) ) {
! 	  		return new IXR_Error(49, 'Pingbacks not allowed on this entry.');
! 		}
  
  		$comment_post_ID = $post_ID;
--- 1219,1227 ----
  		$pagelinkedfrom = addslashes($pagelinkedfrom);
  		$original_title = $title;
  
! 		$pingstatus = $wpdb->get_var("SELECT ping_status FROM $wpdb->posts WHERE ID = $tb_id");
! 	
! 		if ('open' != $pingstatus)
! 			trackback_response(1, 'Sorry, trackbacks are closed for this item.');
  
  		$comment_post_ID = $post_ID;
***************
*** 1235,1242 ****
  
  		wp_new_comment($commentdata);
! 
! 		$comment_ID = $wpdb->insert_id;
! 
! 		do_action('pingback_post', $comment_ID);
  		
  		return "Pingback from $pagelinkedfrom to $pagelinkedto registered. Keep the web talking! :-)";
--- 1234,1238 ----
  
  		wp_new_comment($commentdata);
! 		do_action('pingback_post', $wpdb->insert_id);
  		
  		return "Pingback from $pagelinkedfrom to $pagelinkedto registered. Keep the web talking! :-)";

Index: wp-register.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-register.php,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** wp-register.php	4 Oct 2004 07:44:04 -0000	1.21
--- wp-register.php	16 Dec 2004 02:56:57 -0000	1.22
***************
*** 2,22 ****
  require('./wp-config.php');
  
- function add_magic_quotes($array) {
- 	foreach ($array as $k => $v) {
- 		if (is_array($v)) {
- 			$array[$k] = add_magic_quotes($v);
- 		} else {
- 			$array[$k] = addslashes($v);
- 		}
- 	}
- 	return $array;
- } 
- 
- if (!get_magic_quotes_gpc()) {
- 	$_GET    = add_magic_quotes($_GET);
- 	$_POST   = add_magic_quotes($_POST);
- 	$_COOKIE = add_magic_quotes($_COOKIE);
- }
- 
  $wpvarstoreset = array('action');
  for ($i=0; $i<count($wpvarstoreset); $i += 1) {
--- 2,5 ----

Index: wp-login.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-login.php,v
retrieving revision 1.45
retrieving revision 1.46
diff -C2 -d -r1.45 -r1.46
*** wp-login.php	4 Dec 2004 00:18:01 -0000	1.45
--- wp-login.php	16 Dec 2004 02:56:57 -0000	1.46
***************
*** 1,23 ****
  <?php
! require('./wp-config.php');
! 
! if (!function_exists('add_magic_quotes')) {
! 	function add_magic_quotes($array) {
! 		foreach ($array as $k => $v) {
! 			if (is_array($v)) {
! 				$array[$k] = add_magic_quotes($v);
! 			} else {
! 				$array[$k] = addslashes($v);
! 			}
! 		}
! 		return $array;
! 	} 
! }
! 
! if (!get_magic_quotes_gpc()) {
! 	$_GET    = add_magic_quotes($_GET);
! 	$_POST   = add_magic_quotes($_POST);
! 	$_COOKIE = add_magic_quotes($_COOKIE);
! }
  
  $wpvarstoreset = array('action');
--- 1,4 ----
  <?php
! require( dirname(__FILE__) . '/wp-config.php' );
  
  $wpvarstoreset = array('action');

Index: wp-trackback.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-trackback.php,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -d -r1.26 -r1.27
*** wp-trackback.php	12 Dec 2004 20:41:16 -0000	1.26
--- wp-trackback.php	16 Dec 2004 02:56:57 -0000	1.27
***************
*** 1,24 ****
  <?php
  
! function add_magic_quotes($array) {
! 	foreach ($array as $k => $v) {
! 		if (is_array($v)) {
! 			$array[$k] = add_magic_quotes($v);
! 		} else {
! 			$array[$k] = addslashes($v);
! 		}
! 	}
! 	return $array;
! }
! 
! if (!get_magic_quotes_gpc()) {
! 	$_GET    = add_magic_quotes($_GET);
! 	$_POST   = add_magic_quotes($_POST);
! 	$_COOKIE = add_magic_quotes($_COOKIE);
! }
! 
! if (empty($doing_trackback)) {
!     $doing_trackback = true;
!     require('wp-blog-header.php');
  }
  
--- 1,8 ----
  <?php
+ require_once( dirname(__FILE__) . '/wp-config.php' );
  
! if ( empty($doing_trackback) ) {
! 	$doing_trackback = true;
! 	require_once('wp-blog-header.php');
  }
  
***************
*** 42,54 ****
  // trackback is done by a POST
  $request_array = 'HTTP_POST_VARS';
  if (!$tb_id) {
  	$tb_id = explode('/', $_SERVER['REQUEST_URI']);
  	$tb_id = intval($tb_id[count($tb_id)-1]);
  }
! $tb_url = $_POST['url'];
! $title = $_POST['title'];
! $excerpt = $_POST['excerpt'];
  $blog_name = $_POST['blog_name'];
! $charset = $_POST['charset'];
  
  if ($charset)
--- 26,40 ----
  // trackback is done by a POST
  $request_array = 'HTTP_POST_VARS';
+ 
  if (!$tb_id) {
  	$tb_id = explode('/', $_SERVER['REQUEST_URI']);
  	$tb_id = intval($tb_id[count($tb_id)-1]);
  }
! 
! $tb_url    = $_POST['url'];
! $title     = $_POST['title'];
! $excerpt   = $_POST['excerpt'];
  $blog_name = $_POST['blog_name'];
! $charset   = $_POST['charset'];
  
  if ($charset)
***************
*** 57,63 ****
  	$charset = 'auto';
  
! if ( function_exists('mb_convert_encoding') ) {
! 	$title = mb_convert_encoding($title, get_settings('blog_charset'), $charset);
! 	$excerpt = mb_convert_encoding($excerpt, get_settings('blog_charset'), $charset);
  	$blog_name = mb_convert_encoding($blog_name, get_settings('blog_charset'), $charset);
  }
--- 43,49 ----
  	$charset = 'auto';
  
! if ( function_exists('mb_convert_encoding') ) { // For international trackbacks
! 	$title     = mb_convert_encoding($title, get_settings('blog_charset'), $charset);
! 	$excerpt   = mb_convert_encoding($excerpt, get_settings('blog_charset'), $charset);
  	$blog_name = mb_convert_encoding($blog_name, get_settings('blog_charset'), $charset);
  }
***************
*** 66,70 ****
      $tb_id = $posts[0]->ID;
  
! if ( !$tb_id)
  	trackback_response(1, 'I really need an ID for this to work.');
  
--- 52,56 ----
      $tb_id = $posts[0]->ID;
  
! if ( !$tb_id )
  	trackback_response(1, 'I really need an ID for this to work.');
  
***************
*** 80,84 ****
  	$pingstatus = $wpdb->get_var("SELECT ping_status FROM $wpdb->posts WHERE ID = $tb_id");
  
! 	if ('closed' == $pingstatus)
  		trackback_response(1, 'Sorry, trackbacks are closed for this item.');
  
--- 66,70 ----
  	$pingstatus = $wpdb->get_var("SELECT ping_status FROM $wpdb->posts WHERE ID = $tb_id");
  
! 	if ('open' != $pingstatus)
  		trackback_response(1, 'Sorry, trackbacks are closed for this item.');
  
***************
*** 87,92 ****
  	$excerpt = strip_tags($excerpt);
  	$excerpt = (strlen($excerpt) > 255) ? substr($excerpt, 0, 252) . '...' : $excerpt;
- 	$blog_name = wp_specialchars($blog_name);
- 	$blog_name = (strlen($blog_name) > 250) ? substr($blog_name, 0, 250) . '...' : $blog_name;
  
  	$comment_post_ID = $tb_id;
--- 73,76 ----




More information about the cvs mailing list