2010-01-06 05:02:57 +01:00
< ? php
require_once ( 'admin.php' );
2010-01-06 21:19:35 +01:00
if ( ! is_multisite () )
wp_die ( __ ( 'Multisite support is not enabled.' ) );
2010-01-07 04:43:54 +01:00
$title = __ ( 'Blogs' );
2010-01-07 01:30:53 +01:00
$parent_file = 'ms-admin.php' ;
2010-01-06 05:02:57 +01:00
wp_enqueue_script ( 'admin-forms' );
require_once ( 'admin-header.php' );
2010-01-07 16:52:22 +01:00
if ( ! is_super_admin () )
wp_die ( __ ( 'You do not have permission to access this page.' ) );
2010-01-21 00:01:09 +01:00
$id = isset ( $_GET [ 'id' ]) ? intval ( $_GET [ 'id' ] ) : 0 ;
2010-01-06 05:02:57 +01:00
$protocol = is_ssl () ? 'https://' : 'http://' ;
2010-01-21 00:01:09 +01:00
if ( isset ( $_GET [ 'updated' ]) && $_GET [ 'updated' ] == 'true' ) {
2010-01-06 05:02:57 +01:00
?>
< div id = " message " class = " updated fade " >< p >
< ? php
switch ( $_GET [ 'action' ]) {
case 'all_notspam' :
_e ( 'Blogs mark as not spam !' );
break ;
case 'all_spam' :
_e ( 'Blogs mark as spam !' );
break ;
case 'all_delete' :
_e ( 'Blogs deleted !' );
break ;
case 'delete' :
_e ( 'Blog deleted !' );
break ;
case 'add-blog' :
_e ( 'Blog added !' );
break ;
case 'archive' :
_e ( 'Blog archived !' );
break ;
case 'unarchive' :
_e ( 'Blog unarchived !' );
break ;
case 'activate' :
_e ( 'Blog activated !' );
break ;
case 'deactivate' :
_e ( 'Blog deactivated !' );
break ;
case 'unspam' :
_e ( 'Blog mark as not spam !' );
break ;
case 'spam' :
_e ( 'Blog mark as spam !' );
break ;
case 'umature' :
_e ( 'Blog mark as not mature !' );
break ;
case 'mature' :
_e ( 'Blog mark as mature !' );
break ;
default :
_e ( 'Options saved !' );
break ;
}
?>
</ p ></ div >
< ? php
}
2010-01-21 00:01:09 +01:00
$action = isset ( $_GET [ 'action' ]) ? $_GET [ 'action' ] : 'list' ;
switch ( $action ) {
2010-01-06 05:02:57 +01:00
// Edit blog
case " editblog " :
$blog_prefix = $wpdb -> get_blog_prefix ( $id );
$options = $wpdb -> get_results ( " SELECT * FROM { $blog_prefix } options WHERE option_name NOT LIKE '_transient_rss%' AND option_name NOT LIKE '%user_roles' " , ARRAY_A );
$details = $wpdb -> get_row ( " SELECT * FROM { $wpdb -> blogs } WHERE blog_id = ' { $id } ' " , ARRAY_A );
$editblog_roles = get_blog_option ( $id , " { $blog_prefix } user_roles " );
?>
< div class = " wrap " >
2010-01-20 23:35:21 +01:00
< ? php screen_icon (); ?>
2010-01-06 05:02:57 +01:00
< h2 >< ? php _e ( 'Edit Blog' ); ?> - <a href='http://<?php echo $details['domain'].$details['path']; ?>'>http://<?php echo $details['domain'].$details['path']; ?></a></h2>
2010-01-07 01:24:03 +01:00
< form method = " post " action = " ms-edit.php?action=updateblog " >
2010-01-06 05:02:57 +01:00
< ? php wp_nonce_field ( 'editblog' ); ?>
2010-01-07 05:27:46 +01:00
< input type = " hidden " name = " id " value = " <?php echo esc_attr( $id ) ?> " />
2010-01-06 05:02:57 +01:00
< div class = 'metabox-holder' style = 'width:49%;float:left;' >
< div id = " blogedit_bloginfo " class = " postbox " >
< h3 class = 'hndle' >< span >< ? php _e ( 'Blog info (wp_blogs)' ); ?> </span></h3>
< div class = " inside " >
< table class = " form-table " >
< tr class = " form-field form-required " >
2010-01-07 05:27:46 +01:00
< th scope = " row " >< ? php _e ( 'Domain' ) ?> </th>
2010-01-06 05:02:57 +01:00
< td > http ://< input name = " blog[domain] " type = " text " id = " domain " value = " <?php echo $details['domain'] ?> " size = " 33 " /></ td >
2010-01-07 05:27:46 +01:00
</ tr >
2010-01-06 05:02:57 +01:00
< tr class = " form-field form-required " >
2010-01-07 05:27:46 +01:00
< th scope = " row " >< ? php _e ( 'Path' ) ?> </th>
2010-01-07 01:13:35 +01:00
< td >< input name = " blog[path] " type = " text " id = " path " value = " <?php echo esc_attr( $details['path'] ) ?> " size = " 40 " style = 'margin-bottom:5px;' />
2010-01-18 21:34:48 +01:00
< br />< input type = 'checkbox' style = 'width:20px;' name = 'update_home_url' value = 'update' < ? php if ( get_blog_option ( $id , 'siteurl' ) == preg_replace ( '|/+$|' , '' , 'http://' . $details [ 'domain' ] . $details [ 'path' ]) || get_blog_option ( $id , 'home' ) == preg_replace ( '|/+$|' , '' , 'http://' . $details [ 'domain' ] . $details [ 'path' ]) ) echo 'checked="checked"' ; ?> /> <?php _e( "Update 'siteurl' and 'home' as well." ); ?></td>
2010-01-07 05:27:46 +01:00
</ tr >
2010-01-06 05:02:57 +01:00
< tr class = " form-field " >
2010-01-07 05:27:46 +01:00
< th scope = " row " >< ? php _e ( 'Registered' ) ?> </th>
< td >< input name = " blog[registered] " type = " text " id = " blog_registered " value = " <?php echo esc_attr( $details['registered'] ) ?> " size = " 40 " /></ td >
</ tr >
2010-01-06 05:02:57 +01:00
< tr class = " form-field " >
2010-01-07 05:27:46 +01:00
< th scope = " row " >< ? php _e ( 'Last Updated' ) ?> </th>
< td >< input name = " blog[last_updated] " type = " text " id = " blog_last_updated " value = " <?php echo esc_attr( $details['last_updated'] ) ?> " size = " 40 " /></ td >
</ tr >
2010-01-06 05:02:57 +01:00
< tr class = " form-field " >
2010-01-07 05:27:46 +01:00
< th scope = " row " >< ? php _e ( 'Public' ) ?> </th>
2010-01-06 05:02:57 +01:00
< td >
2010-01-18 21:34:48 +01:00
< input type = 'radio' style = 'width:20px;' name = 'blog[public]' value = '1' < ? php if ( $details [ 'public' ] == '1' ) echo 'checked="checked"' ; ?> /> <?php _e('Yes') ?>
< input type = 'radio' style = 'width:20px;' name = 'blog[public]' value = '0' < ? php if ( $details [ 'public' ] == '0' ) echo 'checked="checked"' ; ?> /> <?php _e('No') ?>
2010-01-07 05:27:46 +01:00
</ td >
</ tr >
2010-01-06 05:02:57 +01:00
< tr class = " form-field " >
2010-01-07 05:27:46 +01:00
< th scope = " row " >< ? php _e ( 'Archived' ); ?> </th>
2010-01-06 05:02:57 +01:00
< td >
2010-01-18 21:34:48 +01:00
< input type = 'radio' style = 'width:20px;' name = 'blog[archived]' value = '1' < ? php if ( $details [ 'archived' ] == '1' ) echo 'checked="checked"' ; ?> /> <?php _e('Yes') ?>
< input type = 'radio' style = 'width:20px;' name = 'blog[archived]' value = '0' < ? php if ( $details [ 'archived' ] == '0' ) echo 'checked="checked"' ; ?> /> <?php _e('No') ?>
2010-01-07 05:27:46 +01:00
</ td >
</ tr >
2010-01-06 05:02:57 +01:00
< tr class = " form-field " >
2010-01-07 05:27:46 +01:00
< th scope = " row " >< ? php _e ( 'Mature' ); ?> </th>
2010-01-06 05:02:57 +01:00
< td >
2010-01-18 21:34:48 +01:00
< input type = 'radio' style = 'width:20px;' name = 'blog[mature]' value = '1' < ? php if ( $details [ 'mature' ] == '1' ) echo 'checked="checked"' ; ?> /> <?php _e('Yes') ?>
< input type = 'radio' style = 'width:20px;' name = 'blog[mature]' value = '0' < ? php if ( $details [ 'mature' ] == '0' ) echo 'checked="checked"' ; ?> /> <?php _e('No') ?>
2010-01-07 05:27:46 +01:00
</ td >
</ tr >
2010-01-06 05:02:57 +01:00
< tr class = " form-field " >
2010-01-07 05:27:46 +01:00
< th scope = " row " >< ? php _e ( 'Spam' ); ?> </th>
2010-01-06 05:02:57 +01:00
< td >
2010-01-18 21:34:48 +01:00
< input type = 'radio' style = 'width:20px;' name = 'blog[spam]' value = '1' < ? php if ( $details [ 'spam' ] == '1' ) echo 'checked="checked"' ; ?> /> <?php _e('Yes') ?>
< input type = 'radio' style = 'width:20px;' name = 'blog[spam]' value = '0' < ? php if ( $details [ 'spam' ] == '0' ) echo 'checked="checked"' ; ?> /> <?php _e('No') ?>
2010-01-07 05:27:46 +01:00
</ td >
</ tr >
2010-01-06 05:02:57 +01:00
< tr class = " form-field " >
2010-01-07 05:27:46 +01:00
< th scope = " row " >< ? php _e ( 'Deleted' ); ?> </th>
2010-01-06 05:02:57 +01:00
< td >
2010-01-18 21:34:48 +01:00
< input type = 'radio' style = 'width:20px;' name = 'blog[deleted]' value = '1' < ? php if ( $details [ 'deleted' ] == '1' ) echo 'checked="checked"' ; ?> /> <?php _e('Yes') ?>
< input type = 'radio' style = 'width:20px;' name = 'blog[deleted]' value = '0' < ? php if ( $details [ 'deleted' ] == '0' ) echo 'checked="checked"' ; ?> /> <?php _e('No') ?>
2010-01-07 05:27:46 +01:00
</ td >
</ tr >
2010-01-06 05:02:57 +01:00
</ table >
2010-01-07 04:40:03 +01:00
< p class = " submit " style = " margin:-15px 0 -5px 230px; " >< input type = " submit " name = " Submit " value = " <?php esc_attr_e('Update Options') ?> " /></ p >
2010-01-06 05:02:57 +01:00
</ div ></ div >
2010-01-07 05:27:46 +01:00
2010-01-06 05:02:57 +01:00
< div id = " blogedit_blogoptions " class = " postbox " >
2010-01-14 20:42:55 +01:00
< h3 class = 'hndle' >< span >< ? php printf ( __ ( 'Blog options (%soptions)' ), $blog_prefix ); ?> </span></h3>
2010-01-06 05:02:57 +01:00
< div class = " inside " >
< table class = " form-table " >
< ? php
$editblog_default_role = 'subscriber' ;
foreach ( $options as $key => $val ) {
2010-01-18 21:34:48 +01:00
if ( $val [ 'option_name' ] == 'default_role' ) {
2010-01-06 05:02:57 +01:00
$editblog_default_role = $val [ 'option_value' ];
}
$disabled = '' ;
if ( is_serialized ( $val [ 'option_value' ]) ) {
if ( is_serialized_string ( $val [ 'option_value' ]) ) {
$val [ 'option_value' ] = wp_specialchars ( maybe_unserialize ( $val [ 'option_value' ]), 'single' );
} else {
$val [ 'option_value' ] = " SERIALIZED DATA " ;
$disabled = ' disabled="disabled"' ;
}
}
if ( stristr ( $val [ 'option_value' ], " \r " ) || stristr ( $val [ 'option_value' ], " \n " ) || stristr ( $val [ 'option_value' ], " \r \n " ) ) {
?>
< tr class = " form-field " >
2010-01-07 05:27:46 +01:00
< th scope = " row " >< ? php echo ucwords ( str_replace ( " _ " , " " , $val [ 'option_name' ] ) ) ?> </th>
2010-01-06 05:02:57 +01:00
< td >< textarea rows = " 5 " cols = " 40 " name = " option[<?php echo $val['option_name'] ?>] " type = " text " id = " <?php echo $val['option_name'] ?> " < ? php echo $disabled ?> ><?php echo wp_specialchars( stripslashes( $val['option_value'] ), 1 ) ?></textarea></td>
</ tr >
< ? php
} else {
?>
< tr class = " form-field " >
2010-01-07 05:27:46 +01:00
< th scope = " row " >< ? php echo ucwords ( str_replace ( " _ " , " " , $val [ 'option_name' ] ) ) ?> </th>
< td >< input name = " option[<?php echo $val['option_name'] ?>] " type = " text " id = " <?php echo $val['option_name'] ?> " value = " <?php echo esc_attr( stripslashes( $val['option_value'] ), 1 ) ?> " size = " 40 " < ? php echo $disabled ?> /></td>
</ tr >
2010-01-06 05:02:57 +01:00
< ? php
}
} // End foreach
?>
</ table >
2010-01-07 04:40:03 +01:00
< p class = " submit " style = " margin:-15px 0 -5px 230px; " >< input type = " submit " name = " Submit " value = " <?php esc_attr_e('Update Options') ?> " /></ p >
2010-01-06 05:02:57 +01:00
</ div ></ div >
</ div >
2010-01-07 05:27:46 +01:00
2010-01-06 05:02:57 +01:00
< div class = 'metabox-holder' style = 'width:49%;float:right;' >
< ? php
// Blog Themes
$themes = get_themes ();
$blog_allowed_themes = wpmu_get_blog_allowedthemes ( $id );
$allowed_themes = get_site_option ( " allowedthemes " );
2010-01-18 21:34:48 +01:00
if ( $allowed_themes == false ) {
2010-01-06 05:02:57 +01:00
$allowed_themes = array_keys ( $themes );
}
$out = '' ;
foreach ( $themes as $key => $theme ) {
$theme_key = wp_specialchars ( $theme [ 'Stylesheet' ] );
2010-01-18 21:34:48 +01:00
if ( isset ( $allowed_themes [ $theme_key ] ) == false ) {
2010-01-06 05:02:57 +01:00
$checked = ( isset ( $blog_allowed_themes [ $theme_key ]) ) ? 'checked="checked"' : '' ;
$out .= ' < tr class = " form-field form-required " >
2010-01-07 05:27:46 +01:00
< th title = " '.htmlspecialchars( $theme["Description"] ).' " scope = " row " > '.$key.' </ th >
< td >< input name = " theme['. $theme_key .'] " type = " checkbox " style = " width:20px; " value = " on " '.$checked.' /> ' . __( ' Active ' ) . ' </ td >
2010-01-06 05:02:57 +01:00
</ tr > ' ;
}
}
2010-01-07 05:27:46 +01:00
2010-01-06 05:02:57 +01:00
if ( $out != '' ) {
?>
< div id = " blogedit_blogthemes " class = " postbox " >
< h3 class = 'hndle' >< span >< ? php _e ( 'Blog Themes' ); ?> </span></h3>
< div class = " inside " >
< table class = " form-table " >
< tr >< th style = " font-weight:bold; " >< ? php _e ( 'Theme' ); ?> </th></tr>
< ? php echo $out ; ?>
</ table >
2010-01-07 04:40:03 +01:00
< p class = " submit " style = " margin:-15px 0 -5px 230px; " >< input type = " submit " name = " Submit " value = " <?php esc_attr_e('Update Options') ?> " /></ p >
2010-01-06 05:02:57 +01:00
</ div ></ div >
< ? php } ?>
2010-01-07 05:27:46 +01:00
2010-01-06 05:02:57 +01:00
< ? php
// Blog users
$blogusers = get_users_of_blog ( $id );
2010-01-18 21:34:48 +01:00
if ( is_array ( $blogusers ) ) {
2010-01-06 05:02:57 +01:00
echo '<div id="blogedit_blogusers" class="postbox"><h3 class="hndle"><span>' . __ ( 'Blog Users' ) . '</span></h3><div class="inside">' ;
echo '<table class="form-table">' ;
echo " <tr><th> " . __ ( 'User' ) . " </th><th> " . __ ( 'Role' ) . " </th><th> " . __ ( 'Password' ) . " </th><th> " . __ ( 'Remove' ) . " </th></tr> " ;
reset ( $blogusers );
foreach ( ( array ) $blogusers as $key => $val ) {
$t = @ unserialize ( $val -> meta_value );
2010-01-18 21:34:48 +01:00
if ( is_array ( $t ) ) {
2010-01-06 05:02:57 +01:00
reset ( $t );
$existing_role = key ( $t );
}
echo '<tr><td><a href="user-edit.php?user_id=' . $val -> user_id . '">' . $val -> user_login . '</a></td>' ;
2010-01-18 21:34:48 +01:00
if ( $val -> user_id != $current_user -> data -> ID ) {
2010-01-06 05:02:57 +01:00
?>
< td >
2010-01-07 05:27:46 +01:00
< select name = " role[<?php echo $val->user_id ?>] " id = " new_role " >< ? php
2010-01-06 05:02:57 +01:00
foreach ( $editblog_roles as $role => $role_assoc ){
$name = translate_with_context ( $role_assoc [ 'name' ]);
$selected = ( $role == $existing_role ) ? 'selected="selected"' : '' ;
2010-01-07 01:13:35 +01:00
echo " <option { $selected } value= \" " . esc_attr ( $role ) . " \" > { $name } </option> " ;
2010-01-06 05:02:57 +01:00
}
?>
</ select >
</ td >
< td >
< input type = 'text' name = 'user_password[<?php echo $val->user_id ?>]' />
</ td >
< ? php
echo '<td><input title="' . __ ( 'Click to remove user' ) . '" type="checkbox" name="blogusers[' . $val -> user_id . ']" /></td>' ;
} else {
echo " <td><strong> " . __ ( 'N/A' ) . " </strong></td><td><strong> " . __ ( 'N/A' ) . " </strong></td><td><strong> " . __ ( 'N/A' ) . " </strong></td> " ;
}
echo '</tr>' ;
}
echo " </table> " ;
2010-01-07 04:40:03 +01:00
echo '<p class="submit" style="margin:-15px 0 -5px 230px;"><input type="submit" name="Submit" value="' . esc_attr__ ( 'Update Options' ) . '" /></p>' ;
2010-01-06 05:02:57 +01:00
echo " </div></div> " ;
}
?>
2010-01-07 05:27:46 +01:00
2010-01-06 05:02:57 +01:00
< div id = " blogedit_blogadduser " class = " postbox " >
< h3 class = 'hndle' >< span >< ? php _e ( 'Add a new user' ); ?> </span></h3>
< div class = " inside " >
< p style = " margin:10px 0 0px;padding:0px 10px 10px;border-bottom:1px solid #DFDFDF; " >< ? php _e ( 'Enter the username of an existing user and hit <em>Update Options</em> to add the user.' ) ?> </p>
< table class = " form-table " >
< tr >
< th scope = " row " >< ? php _e ( 'User Login:' ) ?> </th>
< td >< input type = " text " name = " newuser " id = " newuser " /></ td >
</ tr >
< tr >
< th scope = " row " >< ? php _e ( 'Role:' ) ?> </th>
< td >
< select name = " new_role " id = " new_role " >
2010-01-07 05:27:46 +01:00
< ? php
2010-01-06 05:02:57 +01:00
reset ( $editblog_roles );
2010-01-19 18:01:39 +01:00
foreach ( $editblog_roles as $role => $role_assoc ){
2010-01-06 05:02:57 +01:00
$name = translate_with_context ( $role_assoc [ 'name' ]);
$selected = ( $role == $editblog_default_role ) ? 'selected="selected"' : '' ;
2010-01-07 01:13:35 +01:00
echo " <option { $selected } value= \" " . esc_attr ( $role ) . " \" > { $name } </option> " ;
2010-01-06 05:02:57 +01:00
}
?>
</ select >
</ td >
</ tr >
</ table >
2010-01-07 04:40:03 +01:00
< p class = " submit " style = " margin:-15px 0 -5px 230px; " >< input type = " submit " name = " Submit " value = " <?php esc_attr_e('Update Options') ?> " /></ p >
2010-01-06 05:02:57 +01:00
</ div ></ div >
2010-01-07 05:27:46 +01:00
2010-01-06 05:02:57 +01:00
< div id = " blogedit_miscoptions " class = " postbox " >
< h3 class = 'hndle' >< span >< ? php _e ( 'Misc Blog Actions' ) ?> </span></h3>
< div class = " inside " >
< table class = " form-table " >
< ? php do_action ( 'wpmueditblogaction' , $id ); ?>
</ table >
2010-01-07 04:40:03 +01:00
< p class = " submit " style = " margin:-15px 0 -5px 230px; " >< input type = " submit " name = " Submit " value = " <?php esc_attr_e('Update Options') ?> " /></ p >
2010-01-06 05:02:57 +01:00
</ div ></ div >
2010-01-07 05:27:46 +01:00
2010-01-06 05:02:57 +01:00
</ div >
2010-01-07 05:27:46 +01:00
2010-01-06 05:02:57 +01:00
< div style = " clear:both; " ></ div >
</ form >
</ div >
< ? php
break ;
// List blogs
2010-01-21 00:01:09 +01:00
case 'list' :
2010-01-06 05:02:57 +01:00
default :
2010-01-15 23:11:12 +01:00
$apage = ( isset ( $_GET [ 'apage' ] ) && intval ( $_GET [ 'apage' ] ) ) ? absint ( $_GET [ 'apage' ] ) : 1 ;
$num = ( isset ( $_GET [ 'num' ] ) && intval ( $_GET [ 'num' ] ) ) ? absint ( $_GET [ 'num' ] ) : 15 ;
2010-01-22 23:14:22 +01:00
$s = isset ( $_GET [ 's' ]) ? esc_attr ( trim ( $_GET [ 's' ] ) ) : '' ;
2010-01-07 09:02:52 +01:00
$like_s = like_escape ( $s );
2010-01-15 23:11:12 +01:00
2010-01-06 05:02:57 +01:00
$query = " SELECT * FROM { $wpdb -> blogs } WHERE site_id = ' { $wpdb -> siteid } ' " ;
2010-01-18 21:34:48 +01:00
if ( isset ( $_GET [ 'blog_name' ]) ) {
2010-01-07 09:02:52 +01:00
$query .= " AND ( { $wpdb -> blogs } .domain LIKE '% { $like_s } %' OR { $wpdb -> blogs } .path LIKE '% { $like_s } %' ) " ;
2010-01-18 21:34:48 +01:00
} elseif ( isset ( $_GET [ 'blog_id' ]) ) {
2010-01-07 08:58:04 +01:00
$query .= " AND blog_id = ' " . absint ( $_GET [ 'blog_id' ] ) . " ' " ;
2010-01-18 21:34:48 +01:00
} elseif ( isset ( $_GET [ 'blog_ip' ]) ) {
2010-01-06 05:02:57 +01:00
$query = " SELECT *
FROM { $wpdb -> blogs }, { $wpdb -> registration_log }
WHERE site_id = '{$wpdb->siteid}'
AND { $wpdb -> blogs } . blog_id = { $wpdb -> registration_log } . blog_id
2010-01-07 09:02:52 +01:00
AND { $wpdb -> registration_log } . IP LIKE ( '%{$like_s}%' ) " ;
2010-01-07 05:27:46 +01:00
}
2010-01-06 05:02:57 +01:00
2010-01-22 23:14:22 +01:00
$order_by = isset ( $_GET [ 'sortby' ] ) ? $_GET [ 'sortby' ] : 'id' ;
2010-01-06 05:02:57 +01:00
2010-01-22 23:14:22 +01:00
if ( $order_by == 'registered' ) {
2010-01-06 05:02:57 +01:00
$query .= ' ORDER BY registered ' ;
2010-01-22 23:14:22 +01:00
} elseif ( $order_by == 'lastupdated' ) {
2010-01-06 05:02:57 +01:00
$query .= ' ORDER BY last_updated ' ;
2010-01-22 23:14:22 +01:00
} elseif ( $order_by == 'blogname' ) {
2010-01-06 05:02:57 +01:00
$query .= ' ORDER BY domain ' ;
2010-01-22 23:14:22 +01:00
} else {
$order_by = 'id' ;
$query .= ' ORDER BY ' . $wpdb -> blogs . '.blog_id ' ;
2010-01-06 05:02:57 +01:00
}
2010-01-22 23:14:22 +01:00
$order = isset ( $_GET [ 'order' ]) ? $_GET [ 'order' ] : 'ASC' ;
$order = ( 'DESC' == $order ) ? 'DESC' : 'ASC' ;
$query .= $order ;
2010-01-06 05:02:57 +01:00
2010-01-22 23:14:22 +01:00
if ( ! empty ( $s ) )
2010-01-06 05:02:57 +01:00
$total = $wpdb -> get_var ( str_replace ( 'SELECT *' , 'SELECT COUNT(blog_id)' , $query ) );
2010-01-22 23:14:22 +01:00
else
2010-01-06 05:02:57 +01:00
$total = $wpdb -> get_var ( " SELECT COUNT(blog_id) FROM { $wpdb -> blogs } WHERE site_id = ' { $wpdb -> siteid } ' " );
$query .= " LIMIT " . intval ( ( $apage - 1 ) * $num ) . " , " . intval ( $num );
$blog_list = $wpdb -> get_results ( $query , ARRAY_A );
// Pagination
2010-01-22 23:14:22 +01:00
$url2 = " &order= " . $order . " &sortby= " . $order_by . " &s= " ;
if ( ! empty ( $_GET [ 'blog_ip' ]) )
2010-01-06 05:02:57 +01:00
$url2 .= " &ip_address= " . urlencode ( $s );
2010-01-22 23:14:22 +01:00
else
2010-01-06 05:02:57 +01:00
$url2 .= $s . " &ip_address= " . urlencode ( $s );
2010-01-22 23:14:22 +01:00
2010-01-06 05:02:57 +01:00
$blog_navigation = paginate_links ( array (
'base' => add_query_arg ( 'apage' , '%#%' ) . $url2 ,
'format' => '' ,
'total' => ceil ( $total / $num ),
'current' => $apage
));
?>
< div class = " wrap " style = " position:relative; " >
2010-01-20 23:35:21 +01:00
< ? php screen_icon (); ?>
2010-01-06 05:02:57 +01:00
< h2 >< ? php _e ( 'Blogs' ) ?> </h2>
2010-01-14 20:42:55 +01:00
< form action = " ms-sites.php " method = " get " id = " ms-search " >
2010-01-06 05:02:57 +01:00
< input type = " hidden " name = " action " value = " blogs " />
2010-01-22 23:27:26 +01:00
< input type = " text " name = " s " value = " <?php echo( $s ); ?> " size = " 17 " />
2010-01-07 01:13:35 +01:00
< input type = " submit " class = " button " name = " blog_name " value = " <?php esc_attr_e('Search blogs by name') ?> " />
< input type = " submit " class = " button " name = " blog_id " value = " <?php esc_attr_e('by blog ID') ?> " />
< input type = " submit " class = " button " name = " blog_ip " value = " <?php esc_attr_e('by IP address') ?> " />
2010-01-06 05:02:57 +01:00
</ form >
2010-01-07 01:24:03 +01:00
< form id = " form-blog-list " action = " ms-edit.php?action=allblogs " method = " post " >
2010-01-06 05:02:57 +01:00
< div class = " tablenav " >
< ? php if ( $blog_navigation ) echo " <div class='tablenav-pages'> $blog_navigation </div> " ; ?>
< div class = " alignleft " >
2010-01-07 01:13:35 +01:00
< input type = " submit " value = " <?php esc_attr_e('Delete') ?> " name = " allblog_delete " class = " button-secondary delete " />
< input type = " submit " value = " <?php esc_attr_e('Mark as Spam') ?> " name = " allblog_spam " class = " button-secondary " />
< input type = " submit " value = " <?php esc_attr_e('Not Spam') ?> " name = " allblog_notspam " class = " button-secondary " />
2010-01-06 05:02:57 +01:00
< ? php wp_nonce_field ( 'allblogs' ); ?>
< br class = " clear " />
</ div >
</ div >
< br class = " clear " />
2010-01-18 21:34:48 +01:00
< ? php if ( isset ( $_GET [ 's' ]) && ! empty ( $_GET [ 's' ]) ) : ?>
2010-01-07 01:30:53 +01:00
< p >< a href = " ms-users.php?action=users&s=<?php echo urlencode( stripslashes( $s ) ) ?> " >< ? php _e ( 'Search Users:' ) ?> <strong><?php echo stripslashes( $s ); ?></strong></a></p>
2010-01-06 05:02:57 +01:00
< ? php endif ; ?>
< ? php
// define the columns to display, the syntax is 'internal name' => 'display name'
2010-01-08 22:25:01 +01:00
$blogname_columns = ( is_subdomain_install () ) ? __ ( 'Domain' ) : __ ( 'Path' );
2010-01-06 05:02:57 +01:00
$posts_columns = array (
'id' => __ ( 'ID' ),
'blogname' => $blogname_columns ,
'lastupdated' => __ ( 'Last Updated' ),
'registered' => __ ( 'Registered' ),
'users' => __ ( 'Users' )
);
2010-01-07 05:27:46 +01:00
2010-01-18 21:34:48 +01:00
if ( has_filter ( 'wpmublogsaction' ) )
2010-01-06 05:02:57 +01:00
$posts_columns [ 'plugins' ] = __ ( 'Actions' );
2010-01-07 05:27:46 +01:00
2010-01-06 05:02:57 +01:00
$posts_columns = apply_filters ( 'wpmu_blogs_columns' , $posts_columns );
$sortby_url = " s= " ;
2010-01-22 23:14:22 +01:00
if ( ! empty ( $_GET [ 'blog_ip' ]) )
2010-01-06 05:02:57 +01:00
$sortby_url .= " &ip_address= " . urlencode ( $s );
2010-01-22 23:14:22 +01:00
else
2010-01-06 05:02:57 +01:00
$sortby_url .= urlencode ( $s ) . " &ip_address= " . urlencode ( $s );
?>
< table width = " 100% " cellpadding = " 3 " cellspacing = " 3 " class = " widefat " >
< thead >
< tr >
< th scope = " col " class = " check-column " ></ th >
< ? php foreach ( $posts_columns as $column_id => $column_display_name ) {
2010-01-14 20:42:55 +01:00
$column_link = " <a href='ms-sites.php? { $sortby_url } &sortby= { $column_id } & " ;
2010-01-22 23:14:22 +01:00
if ( $order_by == $column_id ) {
$column_link .= ( $order_by == 'DESC' ) ? 'order=ASC&' : 'order=DESC&' ;
2010-01-06 05:02:57 +01:00
}
$column_link .= " apage= { $apage } '> { $column_display_name } </a> " ;
$col_url = ( $column_id == 'users' || $column_id == 'plugins' ) ? $column_display_name : $column_link ;
?>
< th scope = " col " >< ? php echo $col_url ?> </th>
< ? php } ?>
</ tr >
</ thead >
< tbody id = " the-list " >
< ? php
2010-01-19 18:01:39 +01:00
if ( $blog_list ) {
2010-01-06 05:02:57 +01:00
$bgcolor = $class = '' ;
$status_list = array ( " archived " => " #fee " , " spam " => " #faa " , " deleted " => " #f55 " );
2010-01-19 18:01:39 +01:00
foreach ( $blog_list as $blog ) {
2010-01-06 05:02:57 +01:00
$class = ( 'alternate' == $class ) ? '' : 'alternate' ;
reset ( $status_list );
$bgcolour = " " ;
foreach ( $status_list as $status => $col ) {
2010-01-18 21:34:48 +01:00
if ( get_blog_status ( $blog [ 'blog_id' ], $status ) == 1 ) {
2010-01-06 05:02:57 +01:00
$bgcolour = " style='background: $col ' " ;
}
}
echo " <tr $bgcolour class=' $class '> " ;
2010-01-08 22:25:01 +01:00
$blogname = ( is_subdomain_install () ) ? str_replace ( '.' . $current_site -> domain , '' , $blog [ 'domain' ]) : $blog [ 'path' ];
2010-01-19 18:01:39 +01:00
foreach ( $posts_columns as $column_name => $column_display_name ) {
2010-01-06 05:02:57 +01:00
switch ( $column_name ) {
case 'id' : ?>
< th scope = " row " class = " check-column " >
2010-01-07 01:13:35 +01:00
< input type = 'checkbox' id = 'blog_<?php echo $blog[' blog_id '] ?>' name = 'allblogs[]' value = '<?php echo esc_attr($blog[' blog_id ']) ?>' />
2010-01-06 05:02:57 +01:00
</ th >
< th scope = " row " >
< ? php echo $blog [ 'blog_id' ] ?>
</ th >
< ? php
break ;
2010-01-07 05:27:46 +01:00
2010-01-06 05:02:57 +01:00
case 'blogname' : ?>
< td valign = " top " >
2010-01-14 20:42:55 +01:00
< a href = " ms-sites.php?action=editblog&id=<?php echo $blog['blog_id'] ?> " class = " edit " >< ? php echo $blogname ; ?> </a>
2010-01-06 05:02:57 +01:00
< br />
< ? php
$controlActions = array ();
2010-01-14 20:42:55 +01:00
$controlActions [] = '<a href="ms-sites.php?action=editblog&id=' . $blog [ 'blog_id' ] . '" class="edit">' . __ ( 'Edit' ) . '</a>' ;
2010-01-06 05:02:57 +01:00
$controlActions [] = " <a href=' { $protocol } { $blog [ 'domain' ] } { $blog [ 'path' ] } wp-admin/' class='edit'> " . __ ( 'Backend' ) . '</a>' ;
2010-01-07 05:27:46 +01:00
2010-01-18 21:34:48 +01:00
if ( get_blog_status ( $blog [ 'blog_id' ], " deleted " ) == '1' )
2010-01-07 01:24:03 +01:00
$controlActions [] = '<a class="delete" href="ms-edit.php?action=confirm&action2=activateblog&ref=' . urlencode ( $_SERVER [ 'REQUEST_URI' ] ) . '&id=' . $blog [ 'blog_id' ] . '&msg=' . urlencode ( sprintf ( __ ( " You are about to activate the blog %s " ), $blogname ) ) . '">' . __ ( 'Activate' ) . '</a>' ;
2010-01-06 05:02:57 +01:00
else
2010-01-07 01:24:03 +01:00
$controlActions [] = '<a class="delete" href="ms-edit.php?action=confirm&action2=deactivateblog&ref=' . urlencode ( $_SERVER [ 'REQUEST_URI' ] ) . '&id=' . $blog [ 'blog_id' ] . '&msg=' . urlencode ( sprintf ( __ ( " You are about to deactivate the blog %s " ), $blogname ) ) . '">' . __ ( 'Deactivate' ) . '</a>' ;
2010-01-07 05:27:46 +01:00
2010-01-18 21:34:48 +01:00
if ( get_blog_status ( $blog [ 'blog_id' ], " archived " ) == '1' )
2010-01-07 01:24:03 +01:00
$controlActions [] = '<a class="delete" href="ms-edit.php?action=confirm&action2=unarchiveblog&id=' . $blog [ 'blog_id' ] . '&msg=' . urlencode ( sprintf ( __ ( " You are about to unarchive the blog %s " ), $blogname ) ) . '">' . __ ( 'Unarchive' ) . '</a>' ;
2010-01-06 05:02:57 +01:00
else
2010-01-07 01:24:03 +01:00
$controlActions [] = '<a class="delete" href="ms-edit.php?action=confirm&action2=archiveblog&id=' . $blog [ 'blog_id' ] . '&msg=' . urlencode ( sprintf ( __ ( " You are about to archive the blog %s " ), $blogname ) ) . '">' . __ ( 'Archive' ) . '</a>' ;
2010-01-07 05:27:46 +01:00
2010-01-18 21:34:48 +01:00
if ( get_blog_status ( $blog [ 'blog_id' ], " spam " ) == '1' )
2010-01-07 01:24:03 +01:00
$controlActions [] = '<a class="delete" href="ms-edit.php?action=confirm&action2=unspamblog&id=' . $blog [ 'blog_id' ] . '&msg=' . urlencode ( sprintf ( __ ( " You are about to unspam the blog %s " ), $blogname ) ) . '">' . __ ( 'Not Spam' ) . '</a>' ;
2010-01-06 05:02:57 +01:00
else
2010-01-07 01:24:03 +01:00
$controlActions [] = '<a class="delete" href="ms-edit.php?action=confirm&action2=spamblog&id=' . $blog [ 'blog_id' ] . '&msg=' . urlencode ( sprintf ( __ ( " You are about to mark the blog %s as spam " ), $blogname ) ) . '">' . __ ( " Spam " ) . '</a>' ;
2010-01-07 05:27:46 +01:00
2010-01-07 01:24:03 +01:00
$controlActions [] = '<a class="delete" href="ms-edit.php?action=confirm&action2=deleteblog&id=' . $blog [ 'blog_id' ] . '&msg=' . urlencode ( sprintf ( __ ( " You are about to delete the blog %s " ), $blogname ) ) . '">' . __ ( " Delete " ) . '</a>' ;
2010-01-07 05:27:46 +01:00
2010-01-06 05:02:57 +01:00
$controlActions [] = " <a href='http:// { $blog [ 'domain' ] } { $blog [ 'path' ] } ' rel='permalink'> " . __ ( 'Visit' ) . '</a>' ;
?>
2010-01-07 05:27:46 +01:00
2010-01-06 05:02:57 +01:00
< ? php if ( count ( $controlActions )) : ?>
< div class = " row-actions " >
< ? php echo implode ( ' | ' , $controlActions ); ?>
</ div >
< ? php endif ; ?>
</ td >
< ? php
break ;
2010-01-07 05:27:46 +01:00
2010-01-06 05:02:57 +01:00
case 'lastupdated' : ?>
< td valign = " top " >
< ? php echo ( $blog [ 'last_updated' ] == '0000-00-00 00:00:00' ) ? __ ( " Never " ) : mysql2date ( __ ( 'Y-m-d \<\b\r \/\> g:i:s a' ), $blog [ 'last_updated' ]); ?>
</ td >
< ? php
break ;
case 'registered' : ?>
< td valign = " top " >
< ? php echo mysql2date ( __ ( 'Y-m-d \<\b\r \/\> g:i:s a' ), $blog [ 'registered' ]); ?>
</ td >
< ? php
break ;
case 'users' : ?>
< td valign = " top " >
< ? php
2010-01-07 05:27:46 +01:00
$blogusers = get_users_of_blog ( $blog [ 'blog_id' ] );
2010-01-06 05:02:57 +01:00
if ( is_array ( $blogusers ) ) {
$blogusers_warning = '' ;
if ( count ( $blogusers ) > 5 ) {
$blogusers = array_slice ( $blogusers , 0 , 5 );
$blogusers_warning = __ ( 'Only showing first 5 users.' ) . ' <a href="' . $protocol . $blog [ 'domain' ] . $blog [ 'path' ] . 'wp-admin/users.php">' . __ ( 'More' ) . '</a>' ;
}
foreach ( $blogusers as $key => $val ) {
2010-01-07 05:27:46 +01:00
echo '<a href="user-edit.php?user_id=' . $val -> user_id . '">' . $val -> user_login . '</a> (' . $val -> user_email . ')<br />' ;
2010-01-06 05:02:57 +01:00
}
2010-01-18 21:34:48 +01:00
if ( $blogusers_warning != '' ) {
2010-01-06 05:02:57 +01:00
echo '<strong>' . $blogusers_warning . '</strong><br />' ;
}
}
?>
</ td >
< ? php
break ;
case 'plugins' : ?>
2010-01-18 21:34:48 +01:00
< ? php if ( has_filter ( 'wpmublogsaction' ) ) { ?>
2010-01-06 05:02:57 +01:00
< td valign = " top " >
< ? php do_action ( " wpmublogsaction " , $blog [ 'blog_id' ] ); ?>
</ td >
< ? php } ?>
< ? php break ;
2010-01-07 05:27:46 +01:00
2010-01-06 05:02:57 +01:00
default : ?>
2010-01-18 21:34:48 +01:00
< ? php if ( has_filter ( 'manage_blogs_custom_column' ) ) { ?>
2010-01-06 05:02:57 +01:00
< td valign = " top " >
< ? php do_action ( 'manage_blogs_custom_column' , $column_name , $blog [ 'blog_id' ]); ?>
</ td >
< ? php } ?>
< ? php break ;
}
}
?>
</ tr >
< ? php
}
} else { ?>
2010-01-07 05:27:46 +01:00
< tr style = 'background-color: <?php echo $bgcolor; ?>' >
< td colspan = " 8 " >< ? php _e ( 'No blogs found.' ) ?> </td>
</ tr >
2010-01-06 05:02:57 +01:00
< ? php
} // end if ($blogs)
?>
</ tbody >
</ table >
</ form >
</ div >
< div class = " wrap " >
< a name = " form-add-blog " ></ a >
2010-01-20 23:35:21 +01:00
< ? php screen_icon (); ?>
2010-01-06 05:02:57 +01:00
< h2 >< ? php _e ( 'Add Blog' ) ?> </h2>
2010-01-07 01:24:03 +01:00
< form method = " post " action = " ms-edit.php?action=addblog " >
2010-01-06 05:02:57 +01:00
< ? php wp_nonce_field ( 'add-blog' ) ?>
< table class = " form-table " >
< tr class = " form-field form-required " >
< th style = " text-align:center; " scope = 'row' >< ? php _e ( 'Blog Address' ) ?> </th>
< td >
2010-01-08 22:25:01 +01:00
< ? php if ( is_subdomain_install () ) { ?>
2010-01-07 05:27:46 +01:00
< input name = " blog[domain] " type = " text " title = " <?php _e('Domain') ?> " />.< ? php echo $current_site -> domain ; ?>
2010-01-06 05:02:57 +01:00
< ? php } else {
echo $current_site -> domain . $current_site -> path ?> <input name="blog[domain]" type="text" title="<?php _e('Domain') ?>"/>
2010-01-07 05:27:46 +01:00
< ? php }
2010-01-06 05:02:57 +01:00
echo " <p> " . __ ( 'Only the characters a-z and 0-9 recommended.' ) . " </p> " ;
?>
</ td >
</ tr >
< tr class = " form-field form-required " >
< th style = " text-align:center; " scope = 'row' >< ? php _e ( 'Blog Title' ) ?> </th>
< td >< input name = " blog[title] " type = " text " size = " 20 " title = " <?php _e('Title') ?> " /></ td >
</ tr >
< tr class = " form-field form-required " >
< th style = " text-align:center; " scope = 'row' >< ? php _e ( 'Admin Email' ) ?> </th>
< td >< input name = " blog[email] " type = " text " size = " 20 " title = " <?php _e('Email') ?> " /></ td >
</ tr >
< tr class = " form-field " >
< td colspan = '2' >< ? php _e ( 'A new user will be created if the above email address is not in the database.' ) ?> <br /><?php _e('The username and password will be mailed to this email address.') ?></td>
</ tr >
</ table >
< p class = " submit " >
2010-01-07 01:13:35 +01:00
< input class = " button " type = " submit " name = " go " value = " <?php esc_attr_e('Add Blog') ?> " /></ p >
2010-01-06 05:02:57 +01:00
</ form >
</ div >
< ? php
break ;
} // end switch( $action )
include ( 'admin-footer.php' ); ?>