Index: wp-admin/ms-admin.php
===================================================================
--- wp-admin/ms-admin.php	(revision 13945)
+++ wp-admin/ms-admin.php	(working copy)
@@ -1,23 +1,21 @@
 <?php
-require_once('admin.php');
+require_once( 'admin.php' );
 
 if ( !is_multisite() )
-	wp_die( __('Multisite support is not enabled.') );
+	wp_die( __( 'Multisite support is not enabled.' ) );
 
-$title = __('Network Admin');
-$parent_file = 'ms-admin.php';
+if ( ! current_user_can( 'manage_network' ) )
+	wp_die( __( 'You do not have permission to access this page.' ) );
 
 function index_css() {
 	wp_admin_css( 'css/dashboard' );
 }
 add_action( 'admin_head', 'index_css' );
 
-require_once('admin-header.php');
+$title = __( 'Network Admin' );
+$parent_file = 'ms-admin.php';
+require_once( 'admin-header.php' );
 
-if ( ! current_user_can( 'manage_network' ) )
-	wp_die( __('You do not have permission to access this page.') );
-
-global $wpdb;
 $c_users = get_user_count();
 $c_blogs = get_blog_count();
 
@@ -32,27 +30,27 @@
 	<h2><?php echo esc_html( $title ); ?></h2>
 
 	<ul class="subsubsub">
-	<li><a href="ms-sites.php#form-add-blog" class="rbutton"><strong><?php _e('Create a New Site'); ?></strong></a> | </li>
-	<li><a href="ms-users.php#form-add-user" class="rbutton"><?php _e('Create a New User'); ?></a></li>
+	<li><a href="<?php echo esc_url( admin_url( 'ms-sites.php#form-add-site' ) ); ?>" class="rbutton"><strong><?php _e( 'Create a New Site' ); ?></strong></a> | </li>
+	<li><a href="<?php echo esc_url( admin_url( 'ms-users.php#form-add-user' ) ); ?>" class="rbutton"><?php _e( 'Create a New User' ); ?></a></li>
 	</ul>
-	<br clear='all' />
+	<br clear="all" />
 
 	<p class="youhave"><?php echo $sentence; ?></p>
-	<?php do_action('wpmuadminresult', ''); ?>
+	<?php do_action( 'wpmuadminresult', '' ); ?>
 
-	<form name="searchform" action="ms-users.php" method="get">
+	<form name="searchform" action="<?php echo esc_url( admin_url( 'ms-users.php' ) ); ?>" method="get">
 		<p>
 			<input type="hidden" name="action" value="users" />
 			<input type="text" name="s" value="" size="17" />
-			<input class="button" type="submit" name="submit" value="<?php esc_attr_e("Search Users"); ?>" />
+			<input class="button" type="submit" name="submit" value="<?php esc_attr_e( 'Search Users' ); ?>" />
 		</p>
 	</form>
 
-	<form name="searchform" action="ms-sites.php" method="get">
+	<form name="searchform" action="<?php echo esc_url( admin_url( 'ms-sites.php' ) ); ?>" method="get">
 		<p>
 			<input type="hidden" name="action" value="blogs" />
 			<input type="text" name="s" value="" size="17" />
-			<input class="button" type="submit" name="blog_name" value="<?php esc_attr_e("Search Sites"); ?>" />
+			<input class="button" type="submit" name="blog_name" value="<?php esc_attr_e( 'Search Sites' ); ?>" />
 		</p>
 	</form>
 
@@ -61,4 +59,4 @@
 	</div><!-- rightnow -->
 </div>
 
-<?php include('admin-footer.php'); ?>
+<?php include( 'admin-footer.php' ); ?>
Index: wp-admin/ms-delete-site.php
===================================================================
--- wp-admin/ms-delete-site.php	(revision 13945)
+++ wp-admin/ms-delete-site.php	(working copy)
@@ -17,8 +17,6 @@
 	}
 }
 
-$action = isset( $_POST['action'] ) ? $_POST['action'] : 'splash';
-
 $title = __( 'Delete Site' );
 $parent_file = 'tools.php';
 require_once( './admin-header.php' );
Index: wp-admin/ms-edit.php
===================================================================
--- wp-admin/ms-edit.php	(revision 13945)
+++ wp-admin/ms-edit.php	(working copy)
@@ -465,7 +465,7 @@
 			nocache_headers();
 			header( 'Content-Type: text/html; charset=utf-8' );
 		}
-		if ( $current_site->blog_id == $id )	
+		if ( $current_site->blog_id == $id && 'matureblog' != $_GET['action2'] && 'unmatureblog' != $_GET['action2']  )	
 			wp_die( __( 'You are not allowed to change the current site.' ) );
 		?>
 		<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Index: wp-admin/ms-options.php
===================================================================
--- wp-admin/ms-options.php	(revision 13945)
+++ wp-admin/ms-options.php	(working copy)
@@ -4,14 +4,13 @@
 if ( !is_multisite() )
 	wp_die( __( 'Multisite support is not enabled.' ) );
 
+if ( ! current_user_can( 'manage_network_options' ) )
+    wp_die( __( 'You do not have permission to access this page.' ) );
+
 $title = __( 'Network Options' );
 $parent_file = 'ms-admin.php';
-
 include( './admin-header.php' );
 
-if ( ! current_user_can( 'manage_network_options' ) )
-    wp_die( __( 'You do not have permission to access this page.' ) );
-
 if (isset($_GET['updated'])) {
 	?>
 	<div id="message" class="updated fade"><p><?php _e( 'Options saved.' ) ?></p></div>
Index: wp-admin/ms-sites.php
===================================================================
--- wp-admin/ms-sites.php	(revision 13945)
+++ wp-admin/ms-sites.php	(working copy)
@@ -4,16 +4,15 @@
 if ( !is_multisite() )
 	wp_die( __( 'Multisite support is not enabled.' ) );
 
-$title = __( 'Sites' );
-$parent_file = 'ms-admin.php';
+if ( ! current_user_can( 'manage_sites' ) )
+	wp_die( __( 'You do not have permission to access this page.' ) );
 
 wp_enqueue_script( 'admin-forms' );
 
+$title = __( 'Sites' );
+$parent_file = 'ms-admin.php';
 require_once( './admin-header.php' );
 
-if ( ! current_user_can( 'manage_sites' ) )
-	wp_die( __( 'You do not have permission to access this page.' ) );
-
 $id = isset( $_GET['id'] ) ? intval( $_GET['id'] ) : 0;
 
 if ( isset( $_GET['updated'] ) && $_GET['updated'] == 'true' && ! empty( $_GET['action'] ) ) {
@@ -125,6 +124,7 @@
 								<label><input type="radio" style="width:20px;" name="blog[public]" value="0" <?php checked( $details->public, 0 ); ?> /> <?php _e( 'No' ) ?></label>
 							</td>
 						</tr>
+						<?php if ( !$is_main_site ) { ?>
 						<tr class="form-field">
 							<th scope="row"><?php _e( 'Archived' ); ?></th>
 							<td>
@@ -133,13 +133,6 @@
 							</td>
 						</tr>
 						<tr class="form-field">
-							<th scope="row"><?php _e( 'Mature' ); ?></th>
-							<td>
-								<label><input type="radio" style="width:20px;" name="blog[mature]" value="1" <?php checked( $details->mature, 1 ); ?> /> <?php _e( 'Yes' ) ?></label>
-								<label><input type="radio" style="width:20px;" name="blog[mature]" value="0" <?php checked( $details->mature, 0); ?> /> <?php _e( 'No' ) ?></label>
-							</td>
-						</tr>
-						<tr class="form-field">
 							<th scope="row"><?php _e( 'Spam' ); ?></th>
 							<td>
 								<label><input type="radio" style="width:20px;" name="blog[spam]" value="1" <?php checked( $details->spam, 1 ); ?> /> <?php _e( 'Yes' ) ?></label>
@@ -153,6 +146,14 @@
 								<label><input type="radio" style="width:20px;" name="blog[deleted]" value="0" <?php checked( $details->deleted, 0 ); ?> /> <?php _e( 'No' ) ?></label>
 							</td>
 						</tr>
+						<?php } ?>
+						<tr class="form-field">
+							<th scope="row"><?php _e( 'Mature' ); ?></th>
+							<td>
+								<label><input type="radio" style="width:20px;" name="blog[mature]" value="1" <?php checked( $details->mature, 1 ); ?> /> <?php _e( 'Yes' ) ?></label>
+								<label><input type="radio" style="width:20px;" name="blog[mature]" value="0" <?php checked( $details->mature, 0); ?> /> <?php _e( 'No' ) ?></label>
+							</td>
+						</tr>
 					</table>
 					<p class="submit" style="text-align:center;"><input type="submit" name="Submit" value="<?php esc_attr_e( 'Update Options' ) ?>" /></p>
 				</div>
@@ -557,25 +558,25 @@
 											$actions[]	= '<span class="activate"><a href="' . esc_url( admin_url( 'ms-edit.php?action=confirm&amp;action2=activateblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( "You are about to activate the site %s" ), $blogname ) ) ) ) . '">' . __( 'Activate' ) . '</a></span>';
 										else
 											$actions[]	= '<span class="activate"><a href="' . esc_url( admin_url( 'ms-edit.php?action=confirm&amp;action2=deactivateblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( "You are about to deactivate the site %s" ), $blogname ) ) ) ) . '">' . __( 'Deactivate' ) . '</a></span>';
-	
+
 										if ( get_blog_status( $blog['blog_id'], 'archived' ) == '1' )
 											$actions[]	= '<span class="archive"><a href="' . esc_url( admin_url( 'ms-edit.php?action=confirm&amp;action2=unarchiveblog&amp;id=' .  $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( "You are about to unarchive the site %s." ), $blogname ) ) ) ) . '">' . __( 'Unarchive' ) . '</a></span>';
 										else
 											$actions[]	= '<span class="archive"><a href="' . esc_url( admin_url( 'ms-edit.php?action=confirm&amp;action2=archiveblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( "You are about to archive the site %s." ), $blogname ) ) ) ) . '">' . __( 'Archive' ) . '</a></span>';
-	
+
 										if ( get_blog_status( $blog['blog_id'], 'spam' ) == '1' )
 											$actions[]	= '<span class="spam"><a href="' . esc_url( admin_url( 'ms-edit.php?action=confirm&amp;action2=unspamblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( "You are about to unspam the site %s." ), $blogname ) ) ) ) . '">' . __( 'Not Spam' ) . '</a></span>';
 										else
 											$actions[]	= '<span class="spam"><a href="' . esc_url( admin_url( 'ms-edit.php?action=confirm&amp;action2=spamblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( "You are about to mark the site %s as spam." ), $blogname ) ) ) ) . '">' . __( 'Spam' ) . '</a></span>';
-	
-										if ( get_blog_status( $blog['blog_id'], 'mature' ) == '1' )
-											$actions[]	= '<span class="mature"><a href="' . esc_url( admin_url( 'ms-edit.php?action=confirm&amp;action2=unmatureblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( "You are about to unmature the site %s." ), $blogname ) ) ) ) . '">' . __( 'Not Mature' ) . '</a></span>';
-										else
-											$actions[]	= '<span class="mature"><a href="' . esc_url( admin_url( 'ms-edit.php?action=confirm&amp;action2=matureblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( "You are about to mark the site %s as mature." ), $blogname ) ) ) ) . '">' . __( 'Mature' ) . '</a></span>';
-	
+
 										$actions[]	= '<span class="delete"><a href="' . esc_url( admin_url( 'ms-edit.php?action=confirm&amp;action2=deleteblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( "You are about to delete the site %s." ), $blogname ) ) ) ) . '">' . __( 'Delete' ) . '</a></span>';
 									}
 
+									if ( get_blog_status( $blog['blog_id'], 'mature' ) == '1' )
+										$actions[]	= '<span class="mature"><a href="' . esc_url( admin_url( 'ms-edit.php?action=confirm&amp;action2=unmatureblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( "You are about to unmature the site %s." ), $blogname ) ) ) ) . '">' . __( 'Not Mature' ) . '</a></span>';
+									else
+										$actions[]	= '<span class="mature"><a href="' . esc_url( admin_url( 'ms-edit.php?action=confirm&amp;action2=matureblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( "You are about to mark the site %s as mature." ), $blogname ) ) ) ) . '">' . __( 'Mature' ) . '</a></span>';
+
 									$actions[]	= "<span class='view'><a href='" . esc_url( get_home_url( $blog['blog_id'] ) ) . "' rel='permalink'>" . __( 'Visit' ) . '</a>';
 
 									if ( count( $actions ) ) : ?>
Index: wp-admin/ms-themes.php
===================================================================
--- wp-admin/ms-themes.php	(revision 13945)
+++ wp-admin/ms-themes.php	(working copy)
@@ -1,13 +1,13 @@
 <?php
 require_once( './admin.php' );
 
+if ( ! current_user_can( 'manage_network_themes' ) )
+	wp_die( __( 'You do not have permission to access this page.' ) );
+
 $title = __( 'Network Themes' );
 $parent_file = 'ms-admin.php';
 require_once( './admin-header.php' );
 
-if ( ! current_user_can( 'manage_network_themes' ) )
-	wp_die( __( 'You do not have permission to access this page.' ) );
-
 if ( isset( $_GET['updated'] ) ) {
 	?>
 	<div id="message" class="updated fade"><p><?php _e( 'Site themes saved.' ) ?></p></div>
Index: wp-admin/ms-users.php
===================================================================
--- wp-admin/ms-users.php	(revision 13945)
+++ wp-admin/ms-users.php	(working copy)
@@ -4,15 +4,15 @@
 if ( !is_multisite() )
 	wp_die( __( 'Multisite support is not enabled.' ) );
 
-$title = __( 'Users' );
-$parent_file = 'ms-admin.php';
+if ( ! current_user_can( 'manage_network_users' ) )
+	wp_die( __( 'You do not have permission to access this page.' ) );
 
 wp_enqueue_script( 'admin-forms' );
 
+$title = __( 'Users' );
+$parent_file = 'ms-admin.php';
 require_once( './admin-header.php' );
 
-if ( ! current_user_can( 'manage_network_users' ) )
-	wp_die( __( 'You do not have permission to access this page.' ) );
 
 if ( isset( $_GET['updated'] ) && $_GET['updated'] == 'true' && ! empty( $_GET['action'] ) ) {
 	?>
