Index: wp-includes/functions-compat.php
===================================================================
--- wp-includes/functions-compat.php	(revision 3754)
+++ wp-includes/functions-compat.php	(working copy)
@@ -98,4 +98,17 @@
     }
 }
 
+// From php.net
+if(!function_exists('http_build_query')) {
+   function http_build_query( $formdata, $numeric_prefix = null, $key = null ) {
+       $res = array();
+       foreach ((array)$formdata as $k=>$v) {
+           $tmp_key = urlencode(is_int($k) ? $numeric_prefix.$k : $k);
+           if ($key) $tmp_key = $key.'['.$tmp_key.']';
+           $res[] = ( ( is_array($v) || is_object($v) ) ? http_build_query($v, null, $tmp_key) : $tmp_key."=".urlencode($v) );
+       }
+       $separator = ini_get('arg_separator.output');
+       return implode($separator, $res);
+   }
+}
 ?>
Index: wp-includes/functions.php
===================================================================
--- wp-includes/functions.php	(revision 3754)
+++ wp-includes/functions.php	(working copy)
@@ -1663,4 +1663,12 @@
 	return $installed;
 }
 
+function wp_nonce_url($actionurl, $action = -1) {
+	return add_query_arg('_wpnonce', wp_create_nonce($action), $actionurl);
+}
+
+function wp_nonce_field($action = -1) {
+	echo '<input type="hidden" name="_wpnonce" value="' . wp_create_nonce($action) . '" />';
+}
+
 ?>
Index: wp-includes/pluggable-functions.php
===================================================================
--- wp-includes/pluggable-functions.php	(revision 3754)
+++ wp-includes/pluggable-functions.php	(working copy)
@@ -228,14 +228,34 @@
 endif;
 
 if ( !function_exists('check_admin_referer') ) :
-function check_admin_referer() {
+function check_admin_referer($action = -1) {
+	global $pagenow;
 	$adminurl = strtolower(get_settings('siteurl')).'/wp-admin';
 	$referer = strtolower($_SERVER['HTTP_REFERER']);
-	if (!strstr($referer, $adminurl))
-		die(__('Sorry, you need to <a href="http://codex.wordpress.org/Enable_Sending_Referrers">enable sending referrers</a> for this feature to work.'));
+	if ( !wp_verify_nonce($_REQUEST['_wpnonce'], $action) ) {
+		$html  = "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>\n<html xmlns='http://www.w3.org/1999/xhtml' lang='en' xml:lang='en'>\n\n";
+		$html .= "<head>\n\t<title>" . __('WordPress Confirmation') . "</title>\n";
+		$html .= "</head>\n<body>\n";
+		if ( $_POST ) {
+			$q = http_build_query($_POST);
+			$q = explode( ini_get('arg_separator.output'), $q);
+			$html .= "\t<form method='post' action='$pagenow'>\n";
+			foreach ( (array) $q as $a ) {
+				$v = substr(strstr($a, '='), 1);
+				$k = substr($a, 0, -(strlen($v)+1));
+				$html .= "\t\t<input type='hidden' name='" . wp_specialchars( urldecode($k), 1 ) . "' value='" . wp_specialchars( urldecode($v), 1 ) . "' />\n";
+			}
+			$html .= "\t\t<input type='hidden' name='_wpnonce' value='" . wp_create_nonce($action) . "' />\n";
+			$html .= "\t\t<p>" . __('Are you sure you want to do this?') . "</p>\n\t\t<p><a href='$adminurl'>No</a> <input type='submit' value='" . __('Yes') . "' /></p>\n\t</form>\n";
+		} else {
+			$html .= "\t<p>" . __('Are you sure you want to do this?') . "</p>\n\t\t<p><a href='$adminurl'>No</a> <a href='" . add_query_arg( '_wpnonce', wp_create_nonce($action), $_SERVER['REQUEST_URI'] ) . "'>" . __('Yes') . "</a></p>\n";
+		}
+		$html .= "</body>\n</html>";
+
+		die($html);
+	}
 	do_action('check_admin_referer');
-}
-endif;
+}endif;
 
 if ( !function_exists('check_ajax_referer') ) :
 function check_ajax_referer() {
@@ -460,4 +480,29 @@
 }
 endif;
 
+if ( !function_exists('wp_verify_nonce') ) :
+function wp_verify_nonce($nonce, $action = -1) {
+	$user = wp_get_current_user();
+	$uid = $user->id;
+
+	$i = ceil(time() / 43200);
+
+	//Allow for expanding range, but only do one check if we can
+	if( substr(md5($i . DB_PASSWORD . $action . $uid), -12, 10) == $nonce || substr(md5(($i - 1) . DB_PASSWORD . $action . $uid), -12, 10) == $nonce )
+		return true;
+	return false;
+}
+endif;
+
+if ( !function_exists('wp_create_nonce') ) :
+function wp_create_nonce($action = -1) {
+	$user = wp_get_current_user();
+	$uid = $user->id;
+
+	$i = ceil(time() / 43200);
+	
+	return substr(md5($i . DB_PASSWORD . $action . $uid), -12, 10);
+}
+endif;
+
 ?>
Index: wp-admin/inline-uploading.php
===================================================================
--- wp-admin/inline-uploading.php	(revision 3754)
+++ wp-admin/inline-uploading.php	(working copy)
@@ -2,7 +2,7 @@
 
 require_once('admin.php');
 
-check_admin_referer();
+check_admin_referer('inlineuploading');
 
 header('Content-Type: text/html; charset=' . get_option('blog_charset'));
 
@@ -41,7 +41,7 @@
 
 wp_delete_attachment($attachment);
 
-header("Location: ".basename(__FILE__)."?post=$post&all=$all&action=view&start=$start");
+header("Location: ". wp_nonce_url(basename(__FILE__)."?post=$post&all=$all&action=view&start=$start", 'inlineuploading'));
 die;
 
 case 'save':
@@ -100,7 +100,7 @@
 	add_post_meta($id, '_wp_attachment_metadata', array());
 }
 
-header("Location: ".basename(__FILE__)."?post=$post&all=$all&action=view&start=0");
+header("Location: ". wp_nonce_url(basename(__FILE__)."?post=$post&all=$all&action=view&start=0", 'inlineuploading'));
 die();
 
 case 'upload':
@@ -139,7 +139,7 @@
 $attachments = $wpdb->get_results("SELECT ID, post_date, post_title, post_mime_type, guid FROM $wpdb->posts WHERE post_type = 'attachment' $and_type $and_post $and_user ORDER BY $sort LIMIT $start, $double", ARRAY_A);
 
 if ( count($attachments) == 0 ) {
-	header("Location: ".basename(__FILE__)."?post=$post&action=upload");
+	header("Location: ". wp_nonce_url(basename(__FILE__)."?post=$post&action=upload", 'inlineuploading') );
 	die;
 } elseif ( count($attachments) > $num ) {
 	$next = $start + count($attachments) - $num;
Index: wp-admin/edit-comments.php
===================================================================
--- wp-admin/edit-comments.php	(revision 3754)
+++ wp-admin/edit-comments.php	(working copy)
@@ -51,7 +51,7 @@
 <p><a href="?mode=view"><?php _e('View Mode') ?></a> | <a href="?mode=edit"><?php _e('Mass Edit Mode') ?></a></p>
 <?php
 if ( !empty( $_POST['delete_comments'] ) ) :
-	check_admin_referer();
+	check_admin_referer('bulk-comments');
 
 	$i = 0;
 	foreach ($_POST['delete_comments'] as $comment) : // Check the permissions on each
@@ -119,10 +119,10 @@
 <?php
 if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
 	echo " <a href='comment.php?action=editcomment&amp;comment=".$comment->comment_ID."\'>" .  __('Edit') . '</a>';
-	echo ' | <a href="comment.php?action=deletecomment&amp;p=' . $post->ID . '&amp;comment=' . $comment->comment_ID . '" onclick="return deleteSomething( \'comment\', ' . $comment->comment_ID . ', \'' . sprintf(__("You are about to delete this comment by &quot;%s&quot;.\\n&quot;Cancel&quot; to stop, &quot;OK&quot; to delete."), wp_specialchars($comment->comment_author, 1)) . "' );\">" . __('Delete') . '</a> ';
+	echo ' | <a href="' . wp_nonce_url('comment.php?action=deletecomment&amp;p=' . $post->ID . '&amp;comment=' . $comment->comment_ID, 'delete-comment' . $comment->comment_ID) . '" onclick="return deleteSomething( \'comment\', ' . $comment->comment_ID . ', \'' . sprintf(__("You are about to delete this comment by &quot;%s&quot;.\\n&quot;Cancel&quot; to stop, &quot;OK&quot; to delete."), wp_specialchars($comment->comment_author, 1)) . "' );\">" . __('Delete') . '</a> ';
 	if ( ('none' != $comment_status) && ( current_user_can('moderate_comments') ) ) {
-		echo '<span class="unapprove"> | <a href="comment.php?action=unapprovecomment&amp;p=' . $post->ID . '&amp;comment=' . $comment->comment_ID . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\' );">' . __('Unapprove') . '</a> </span>';
-		echo '<span class="approve"> | <a href="comment.php?action=approvecomment&amp;p=' . $post->ID . '&amp;comment=' . $comment->comment_ID . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\' );">' . __('Approve') . '</a> </span>';
+		echo '<span class="unapprove"> | <a href="' . wp_nonce_url('comment.php?action=unapprovecomment&amp;p=' . $post->ID . '&amp;comment=' . $comment->comment_ID, 'unapprove-comment' . $comment->comment_ID) . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\' );">' . __('Unapprove') . '</a> </span>';
+		echo '<span class="approve"> | <a href="' . wp_nonce_url('comment.php?action=approvecomment&amp;p=' . $post->ID . '&amp;comment=' . $comment->comment_ID, 'approve-comment' . $comment->comment_ID) . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\' );">' . __('Approve') . '</a> </span>';
 	}
 	echo " | <a href=\"comment.php?action=deletecomment&amp;delete_type=spam&amp;p=".$comment->comment_post_ID."&amp;comment=".$comment->comment_ID."\" onclick=\"return deleteSomething( 'comment-as-spam', $comment->comment_ID, '" . sprintf(__("You are about to mark as spam this comment by &quot;%s&quot;.\\n&quot;Cancel&quot; to stop, &quot;OK&quot; to mark as spam."), wp_specialchars( $comment->comment_author, 1 ))  . "' );\">" . __('Spam') . "</a> ";
 }
@@ -150,8 +150,9 @@
 } elseif ('edit' == $mode) {
 
 	if ($comments) {
-		echo '<form name="deletecomments" id="deletecomments" action="" method="post"> 
-		<table width="100%" cellpadding="3" cellspacing="3">
+		echo '<form name="deletecomments" id="deletecomments" action="" method="post"> ';
+		wp_nonce_field('bulk-comments');
+		echo '<table width="100%" cellpadding="3" cellspacing="3">
   <tr>
     <th scope="col">*</th>
     <th scope="col">' .  __('Name') . '</th>
Index: wp-admin/post.php
===================================================================
--- wp-admin/post.php	(revision 3754)
+++ wp-admin/post.php	(working copy)
@@ -24,7 +24,7 @@
 switch($action) {
 case 'postajaxpost':
 case 'post':
-	check_admin_referer();
+	check_admin_referer('add-post');
 	
 	$post_ID = 'post' == $action ? write_post() : edit_post();
 
@@ -78,10 +78,10 @@
 	break;
 
 case 'editattachment':
-	check_admin_referer();
-
 	$post_id = (int) $_POST['post_ID'];
 
+	check_admin_referer('update-attachment' . $post_id);
+
 	// Don't let these be changed
 	unset($_POST['guid']);
 	$_POST['post_type'] = 'attachment';
@@ -96,7 +96,8 @@
 		add_post_meta($post_id, '_wp_attachment_metadata', $newmeta);
 
 case 'editpost':
-	check_admin_referer();
+	$post_ID = (int) $_POST['post_ID'];
+	check_admin_referer('update-post' . $post_ID);
 	
 	$post_ID = edit_post();
 
@@ -121,9 +122,8 @@
 	break;
 
 case 'delete':
-	check_admin_referer();
-
 	$post_id = (isset($_GET['post']))  ? intval($_GET['post']) : intval($_POST['post_ID']);
+	check_admin_referer('delete-post' . $post_id);
 
 	$post = & get_post($post_id);
 
Index: wp-admin/admin-functions.php
===================================================================
--- wp-admin/admin-functions.php	(revision 3754)
+++ wp-admin/admin-functions.php	(working copy)
@@ -709,7 +709,7 @@
     <td><?php echo mysql2date('Y-m-d g:i a', $post->post_modified); ?></td> 
 	<td><a href="<?php the_permalink(); ?>" rel="permalink" class="edit"><?php _e('View'); ?></a></td>
     <td><?php if ( current_user_can('edit_page', $id) ) { echo "<a href='page.php?action=edit&amp;post=$id' class='edit'>" . __('Edit') . "</a>"; } ?></td> 
-    <td><?php if ( current_user_can('edit_page', $id) ) { echo "<a href='page.php?action=delete&amp;post=$id' class='delete' onclick=\"return deleteSomething( 'page', " . $id . ", '" . sprintf(__("You are about to delete the &quot;%s&quot; page.\\n&quot;OK&quot; to delete, &quot;Cancel&quot; to stop."), addslashes(wp_specialchars(get_the_title(),'double')) ) . "' );\">" . __('Delete') . "</a>"; } ?></td> 
+    <td><?php if ( current_user_can('edit_page', $id) ) { echo "<a href='" . wp_nonce_url("page.php?action=delete&amp;post=$id", 'delete-page' . $id) .  "' class='delete' onclick=\"return deleteSomething( 'page', " . $id . ", '" . sprintf(__("You are about to delete the &quot;%s&quot; page.\\n&quot;OK&quot; to delete, &quot;Cancel&quot; to stop."), addslashes(wp_specialchars(get_the_title(),'double')) ) . "' );\">" . __('Delete') . "</a>"; } ?></td> 
   </tr> 
 
 <?php
Index: wp-admin/edit-page-form.php
===================================================================
--- wp-admin/edit-page-form.php	(revision 3754)
+++ wp-admin/edit-page-form.php	(working copy)
@@ -5,10 +5,12 @@
 <?php
 if (0 == $post_ID) {
 	$form_action = 'post';
+	$nonce_action = 'add-page';
 	$temp_ID = -1 * time();
 	$form_extra = "<input type='hidden' id='post_ID' name='temp_ID' value='$temp_ID' />";
 } else {
 	$form_action = 'editpost';
+	$nonce_action = 'update-page' . $post_ID;
 	$form_extra = "<input type='hidden' id='post_ID' name='post_ID' value='$post_ID' />";
 }
 
@@ -23,6 +25,8 @@
 <form name="post" action="page.php" method="post" id="post">
 
 <?php
+wp_nonce_field($nonce_action);
+
 if (isset($mode) && 'bookmarklet' == $mode) {
     echo '<input type="hidden" name="mode" value="bookmarklet" />';
 }
@@ -150,7 +154,7 @@
 <?php
 if (current_user_can('upload_files')) {
 	$uploading_iframe_ID = (0 == $post_ID ? $temp_ID : $post_ID);
-	$uploading_iframe_src = "inline-uploading.php?action=view&amp;post=$uploading_iframe_ID";
+	$uploading_iframe_src = wp_nonce_url("inline-uploading.php?action=view&amp;post=$uploading_iframe_ID", 'inlineuploading');
 	$uploading_iframe_src = apply_filters('uploading_iframe_src', $uploading_iframe_src);
 	if ( false != $uploading_iframe_src )
 		echo '<iframe id="uploading" border="0" src="' . $uploading_iframe_src . '">' . __('This feature requires iframe support.') . '</iframe>';
Index: wp-admin/comment.php
===================================================================
--- wp-admin/comment.php	(revision 3754)
+++ wp-admin/comment.php	(working copy)
@@ -89,10 +89,9 @@
 	break;
 
 case 'deletecomment':
-
-	check_admin_referer();
-
 	$comment = (int) $_REQUEST['comment'];
+	check_admin_referer('delete-comment' . $comment);
+
 	$p = (int) $_REQUEST['p'];
 	if ( isset($_REQUEST['noredir']) ) {
 		$noredir = true;
@@ -123,10 +122,9 @@
 	break;
 
 case 'unapprovecomment':
-
-	check_admin_referer();
-
 	$comment = (int) $_GET['comment'];
+	check_admin_referer('unapprove-comment' . $comment);
+	
 	$p = (int) $_GET['p'];
 	if (isset($_GET['noredir'])) {
 		$noredir = true;
@@ -151,10 +149,9 @@
 	break;
 
 case 'approvecomment':
-
-	check_admin_referer();
-
 	$comment = (int) $_GET['comment'];
+	check_admin_referer('approve-comment' . $comment);
+
 	$p = (int) $_GET['p'];
 	if (isset($_GET['noredir'])) {
 		$noredir = true;
@@ -184,7 +181,7 @@
 
 case 'editedcomment':
 
-	check_admin_referer();
+	check_admin_referer('update-comment');
 
 	edit_comment();
 
Index: wp-admin/options-general.php
===================================================================
--- wp-admin/options-general.php	(revision 3754)
+++ wp-admin/options-general.php	(working copy)
@@ -10,6 +10,7 @@
 <div class="wrap">
 <h2><?php _e('General Options') ?></h2>
 <form method="post" action="options.php"> 
+<?php wp_nonce_field('update-options') ?>
 <table class="optiontable"> 
 <tr valign="top"> 
 <th scope="row"><?php _e('Weblog title:') ?></th> 
Index: wp-admin/edit-link-form.php
===================================================================
--- wp-admin/edit-link-form.php	(revision 3754)
+++ wp-admin/edit-link-form.php	(working copy)
@@ -2,11 +2,13 @@
 if ( ! empty($link_id) ) {
 	$heading = __('Edit Bookmark');
 	$submit_text = __('Save Changes &raquo;');
-	$form = '<form name="editlink" id="editlink" method="post" action="link.php">'; 
+	$form = '<form name="editlink" id="editlink" method="post" action="link.php">';
+	$nonce_action = 'update-bookmark' . $link_id;
 } else {
 	$heading = __('Create Bookmark');
 	$submit_text = __('Add Bookmark &raquo;');
 	$form = '<form name="addlink" id="addlink" method="post" action="link.php">';
+	$nonce_action = 'add-bookmark';
 }
 
 function xfn_check($class, $value = '', $type = 'check') {
@@ -31,7 +33,8 @@
 <div class="wrap"> 
 <h2><?php echo $heading ?></h2>
 <?php echo $form ?>
- 
+<?php wp_nonce_field($nonce_action); ?>
+
 <div id="poststuff">
 <div id="moremeta">
 <div id="grabit" class="dbx-group">
Index: wp-admin/options-misc.php
===================================================================
--- wp-admin/options-misc.php	(revision 3754)
+++ wp-admin/options-misc.php	(working copy)
@@ -11,7 +11,7 @@
 <div class="wrap"> 
 <h2><?php _e('Miscellaneous Options') ?></h2> 
 <form method="post" action="options.php">
-
+<?php wp_nonce_field('update-options') ?>
 <fieldset class="options">
 <legend><?php _e('Uploading'); ?></legend>
 <table class="editform optiontable">
Index: wp-admin/edit-form-comment.php
===================================================================
--- wp-admin/edit-form-comment.php	(revision 3754)
+++ wp-admin/edit-form-comment.php	(working copy)
@@ -6,6 +6,7 @@
 ?>
 
 <form name="post" action="comment.php" method="post" id="post">
+<?php wp_nonce_field('update-comment' . $comment->comment_ID) ?>
 <div class="wrap">
 <input type="hidden" name="user_ID" value="<?php echo $user_ID ?>" />
 <input type="hidden" name="action" value='<?php echo $form_action . $form_extra ?>' />
Index: wp-admin/edit-form-advanced.php
===================================================================
--- wp-admin/edit-form-advanced.php	(revision 3754)
+++ wp-admin/edit-form-advanced.php	(working copy)
@@ -22,9 +22,11 @@
 	$form_action = 'post';
 	$temp_ID = -1 * time();
 	$form_extra = "<input type='hidden' id='post_ID' name='temp_ID' value='$temp_ID' />";
+	wp_nonce_field('add-post');
 } else {
 	$form_action = 'editpost';
 	$form_extra = "<input type='hidden' id='post_ID' name='post_ID' value='$post_ID' />";
+	wp_nonce_field('update-post' .  $post_ID);
 }
 
 $form_pingback = '<input type="hidden" name="post_pingback" value="' . get_option('default_pingback_flag') . '" id="post_pingback" />';
@@ -173,7 +175,7 @@
 <?php
 if (current_user_can('upload_files')) {
 	$uploading_iframe_ID = (0 == $post_ID ? $temp_ID : $post_ID);
-	$uploading_iframe_src = "inline-uploading.php?action=view&amp;post=$uploading_iframe_ID";
+	$uploading_iframe_src = wp_nonce_url("inline-uploading.php?action=view&amp;post=$uploading_iframe_ID", 'inlineuploading');
 	$uploading_iframe_src = apply_filters('uploading_iframe_src', $uploading_iframe_src);
 	if ( false != $uploading_iframe_src )
 		echo '<iframe id="uploading" border="0" src="' . $uploading_iframe_src . '">' . __('This feature requires iframe support.') . '</iframe>';
Index: wp-admin/options-discussion.php
===================================================================
--- wp-admin/options-discussion.php	(revision 3754)
+++ wp-admin/options-discussion.php	(working copy)
@@ -21,6 +21,7 @@
 <div class="wrap"> 
 <h2><?php _e('Discussion Options') ?></h2> 
 <form method="post" action="options.php"> 
+<?php wp_nonce_field('update-options') ?>
 <fieldset class="options">
 <legend><?php _e('Usual settings for an article:<br /><small><em>(These settings may be overridden for individual articles.)</em></small>') ?></legend> 
 <ul> 
Index: wp-admin/edit.php
===================================================================
--- wp-admin/edit.php	(revision 3754)
+++ wp-admin/edit.php	(working copy)
@@ -211,7 +211,7 @@
 
 	case 'control_delete':
 		?>
-		<td><?php if ( current_user_can('delete_post',$post->ID) ) { echo "<a href='post.php?action=delete&amp;post=$id' class='delete' onclick=\"return deleteSomething( 'post', " . $id . ", '" . sprintf(__("You are about to delete this post &quot;%s&quot;.\\n&quot;OK&quot; to delete, &quot;Cancel&quot; to stop."), addslashes(wp_specialchars(get_the_title(),'double')) ) . "' );\">" . __('Delete') . "</a>"; } ?></td>
+		<td><?php if ( current_user_can('delete_post',$post->ID) ) { echo "<a href='" . wp_nonce_url("post.php?action=delete&amp;post=$id", 'delete-post' . $post->ID) . "' class='delete' onclick=\"return deleteSomething( 'post', " . $id . ", '" . sprintf(__("You are about to delete this post &quot;%s&quot;.\\n&quot;OK&quot; to delete, &quot;Cancel&quot; to stop."), addslashes(wp_specialchars(get_the_title(),'double')) ) . "' );\">" . __('Delete') . "</a>"; } ?></td>
 		<?php
 		break;
 
Index: wp-admin/options.php
===================================================================
--- wp-admin/options.php	(revision 3754)
+++ wp-admin/options.php	(working copy)
@@ -29,7 +29,7 @@
 case 'update':
 	$any_changed = 0;
 
-	check_admin_referer();
+	check_admin_referer('update-options');
 
 	if (!$_POST['page_options']) {
 		foreach ($_POST as $key => $value) {
@@ -89,6 +89,7 @@
 <div class="wrap">
   <h2><?php _e('All options'); ?></h2>
   <form name="form" action="options.php" method="post">
+  <?php wp_nonce_field('update-options') ?>
   <input type="hidden" name="action" value="update" />
   <table width="98%">
 <?php
Index: wp-admin/link.php
===================================================================
--- wp-admin/link.php	(revision 3754)
+++ wp-admin/link.php	(working copy)
@@ -29,7 +29,7 @@
 
 switch ($action) {
 		case 'deletebookmarks' :
-		check_admin_referer();
+		check_admin_referer('bulk-bookmarks');
 
 		// check the current user's level first.
 		if (!current_user_can('manage_links'))
@@ -53,7 +53,7 @@
 		break;
 
 	case 'move' :
-		check_admin_referer();
+		check_admin_referer('bulk-bookmarks');
 
 		// check the current user's level first.
 		if (!current_user_can('manage_links'))
@@ -72,7 +72,7 @@
 		break;
 
 	case 'add' :
-		check_admin_referer();
+		check_admin_referer('add-bookmark');
 
 		add_link();
 
@@ -80,9 +80,9 @@
 		break;
 
 	case 'save' :
-		check_admin_referer();
-
 		$link_id = (int) $_POST['link_id'];
+		check_admin_referer('update-bookmark' . $link_id);
+
 		edit_link($link_id);
 
 		wp_redirect($this_file);
@@ -90,13 +90,12 @@
 		break;
 
 	case 'delete' :
-		check_admin_referer();
+		$link_id = (int) $_GET['link_id'];
+		check_admin_referer('delete-bookmark' . $link_id);
 
 		if (!current_user_can('manage_links'))
 			die(__("Cheatin' uh ?"));
 
-		$link_id = (int) $_GET['link_id'];
-
 		wp_delete_link($link_id);
 
 		wp_redirect($this_file);
Index: wp-admin/options-reading.php
===================================================================
--- wp-admin/options-reading.php	(revision 3754)
+++ wp-admin/options-reading.php	(working copy)
@@ -10,6 +10,7 @@
 <div class="wrap"> 
 <h2><?php _e('Reading Options') ?></h2> 
 <form name="form1" method="post" action="options.php">
+<?php wp_nonce_field('update-options') ?>
 
 <?php if ( get_pages() ): ?>
 <fieldset class="options"> 
Index: wp-admin/link-manager.php
===================================================================
--- wp-admin/link-manager.php	(revision 3754)
+++ wp-admin/link-manager.php	(working copy)
@@ -110,6 +110,7 @@
 </form>
 
 <form id="links" method="post" action="link.php">
+<?php wp_nonce_field('bulk-bookmarks') ?>
 <input type="hidden" name="link_id" value="" />
 <input type="hidden" name="action" value="" />
 <input type="hidden" name="order_by" value="<?php echo wp_specialchars($order_by, 1); ?>" />
@@ -175,7 +176,7 @@
 <?php
 
 		echo '<td><a href="link.php?link_id='.$link->link_id.'&amp;action=edit" class="edit">'.__('Edit').'</a></td>';
-		echo '<td><a href="link.php?link_id='.$link->link_id.'&amp;action=delete"'." class='delete' onclick=\"return deleteSomething( 'link', $link->link_id , '".sprintf(__("You are about to delete the &quot;%s&quot; bookmark to %s.\\n&quot;Cancel&quot; to stop, &quot;OK&quot; to delete."), wp_specialchars($link->link_name, 1), wp_specialchars($link->link_url)).'\' );" class="delete">'.__('Delete').'</a></td>';
+		echo '<td><a href="' . wp_nonce_url('link.php?link_id='.$link->link_id.'&amp;action=delete', 'delete-bookmark' . $link->link_id ) . '"'." class='delete' onclick=\"return deleteSomething( 'link', $link->link_id , '".sprintf(__("You are about to delete the &quot;%s&quot; bookmark to %s.\\n&quot;Cancel&quot; to stop, &quot;OK&quot; to delete."), wp_specialchars($link->link_name, 1), wp_specialchars($link->link_url)).'\' );" class="delete">'.__('Delete').'</a></td>';
 		echo '<td align="center"><input type="checkbox" name="linkcheck[]" value="'.$link->link_id.'" /></td>';
 		echo "\n    </tr>\n";
 	}
Index: wp-admin/options-permalink.php
===================================================================
--- wp-admin/options-permalink.php	(revision 3754)
+++ wp-admin/options-permalink.php	(working copy)
@@ -57,8 +57,8 @@
 
 $home_path = get_home_path();
 
-if ( isset($_POST) ) {
-	check_admin_referer();
+if ( isset($_POST['permalink_structure']) || isset($_POST['category_base']) ) {
+	check_admin_referer('update-permalink');
 
 	if ( isset($_POST['permalink_structure']) ) {
 		$permalink_structure = $_POST['permalink_structure'];
@@ -117,6 +117,7 @@
 	);
 ?>
 <form name="form" action="options-permalink.php" method="post"> 
+<?php wp_nonce_field('update-permalink') ?>
 <h3><?php _e('Common options:'); ?></h3>
 <p>
 	<label>
@@ -165,6 +166,7 @@
 <?php if ( $permalink_structure && !$usingpi && !$writable ) : ?>
   <p><?php _e('If your <code>.htaccess</code> file were <a href="http://codex.wordpress.org/Make_a_Directory_Writable">writable</a>, we could do this automatically, but it isn&#8217;t so these are the mod_rewrite rules you should have in your <code>.htaccess</code> file. Click in the field and press <kbd>CTRL + a</kbd> to select all.') ?></p>
 <form action="options-permalink.php" method="post">
+<?php wp_nonce_field('update-permalink') ?>
    <p>
 <textarea rows="5" style="width: 98%;" name="rules"><?php echo $wp_rewrite->mod_rewrite_rules(); ?>
 </textarea>
Index: wp-admin/page.php
===================================================================
--- wp-admin/page.php	(revision 3754)
+++ wp-admin/page.php	(working copy)
@@ -24,7 +24,7 @@
 
 switch($action) {
 case 'post':
-
+	check_admin_referer('add-page');
 	$page_ID = write_post();
 
 	// Redirect.
@@ -76,6 +76,7 @@
 
 case 'editattachment':
 	$page_id = $post_ID = (int) $_POST['post_ID'];
+	check_admin_referer('update-attachment' . $page_id);
 
 	// Don't let these be changed
 	unset($_POST['guid']);
@@ -91,6 +92,9 @@
 		add_post_meta($page_id, '_wp_attachment_metadata', $newmeta);
 
 case 'editpost':
+	$page_ID = (int) $_POST['post_ID'];
+	check_admin_referer('update-page' . $page_ID);
+
 	$page_ID = edit_post();
 
 	if ($_POST['save']) {
@@ -114,9 +118,8 @@
 	break;
 
 case 'delete':
-	check_admin_referer();
-
 	$page_id = (isset($_GET['post']))  ? intval($_GET['post']) : intval($_POST['post_ID']);
+	check_admin_referer('delete-page' .  $page_id);
 
 	$page = & get_post($page_id);
 
Index: wp-admin/options-writing.php
===================================================================
--- wp-admin/options-writing.php	(revision 3754)
+++ wp-admin/options-writing.php	(working copy)
@@ -10,6 +10,7 @@
 <div class="wrap"> 
 <h2><?php _e('Writing Options') ?></h2> 
 <form method="post" action="options.php"> 
+<?php wp_nonce_field('update-options') ?>
 <table width="100%" cellspacing="2" cellpadding="5" class="editform"> 
 <tr valign="top"> 
 <th width="33%" scope="row"> <?php _e('Size of the post box:') ?></th> 
Index: wp-admin/categories.php
===================================================================
--- wp-admin/categories.php	(revision 3754)
+++ wp-admin/categories.php	(working copy)
@@ -24,7 +24,7 @@
 
 case 'addcat':
 
-	check_admin_referer();
+	check_admin_referer('add-category');
 
 	if ( !current_user_can('manage_categories') )
 		die (__('Cheatin&#8217; uh?'));
@@ -35,13 +35,12 @@
 break;
 
 case 'delete':
+	$cat_ID = (int) $_GET['cat_ID'];
+	check_admin_referer('delete-category' .  $cat_ID);
 
-	check_admin_referer();
-
 	if ( !current_user_can('manage_categories') )
 		die (__('Cheatin&#8217; uh?'));
 
-	$cat_ID = (int) $_GET['cat_ID'];
 	$cat_name = get_catname($cat_ID);
 
 	// Don't delete the default cats.
@@ -67,6 +66,7 @@
 <div class="wrap">
  <h2><?php _e('Edit Category') ?></h2>
  <form name="editcat" action="categories.php" method="post">
+	  <?php wp_nonce_field('update-category' .  $category->cat_ID); ?>
 	  <table class="editform" width="100%" cellspacing="2" cellpadding="5">
 		<tr>
 		  <th width="33%" scope="row" valign="top"><label for="cat_name"><?php _e('Category name:') ?></label></th>
@@ -99,7 +99,8 @@
 break;
 
 case 'editedcat':
-	check_admin_referer();
+	$cat_ID = (int) $_POST['cat_ID'];
+	check_admin_referer('update-category' . $cat_ID);
 
 	if ( !current_user_can('manage_categories') )
 		die (__('Cheatin&#8217; uh?'));
@@ -157,6 +158,7 @@
 <div class="wrap">
     <h2><?php _e('Add New Category') ?></h2>
     <form name="addcat" id="addcat" action="categories.php" method="post">
+    	<?php wp_nonce_field('add-category'); ?>
         <div class="alignleft"><?php _e('Name:') ?><br />
         <input type="text" name="cat_name" id="cat_name" value="" /></p>
         <p><?php _e('Category parent:') ?><br />

