| [ Root ] [ Search ] [ Index ] |
PHP Cross Reference of WordPress MU 2.9.2Provided by Yoast |
[Summary view] [Print] [Text view]
1 <?php 2 require_once ('admin.php'); 3 if( is_site_admin() == false ) { 4 wp_die( __('You do not have permission to access this page.') ); 5 } 6 7 do_action('wpmuadminedit', ''); 8 9 if( isset($_GET[ 'id' ]) ) { 10 $id = intval( $_GET[ 'id' ] ); 11 } elseif( isset($_POST[ 'id' ]) ) { 12 $id = intval( $_POST[ 'id' ] ); 13 } 14 15 if( isset( $_POST['ref'] ) == false && !empty($_SERVER['HTTP_REFERER']) ) { 16 $_POST['ref'] = $_SERVER['HTTP_REFERER']; 17 } 18 19 switch( $_GET['action'] ) { 20 case "siteoptions": 21 check_admin_referer('siteoptions'); 22 if( empty( $_POST ) ) 23 wp_die( __("You probably need to go back to the <a href='wpmu-options.php'>options page</a>") ); 24 25 update_site_option( "WPLANG", $_POST['WPLANG'] ); 26 27 if( is_email( $_POST['admin_email'] ) ) 28 update_site_option( "admin_email", $_POST['admin_email'] ); 29 30 $illegal_names = split( ' ', $_POST['illegal_names'] ); 31 foreach( (array) $illegal_names as $name ) { 32 $name = trim( $name ); 33 if( $name != '' ) 34 $names[] = trim( $name ); 35 } 36 update_site_option( "illegal_names", $names ); 37 38 if( $_POST['limited_email_domains'] != '' ) { 39 $limited_email_domains = str_replace( ' ', "\n", $_POST[ 'limited_email_domains' ] ); 40 $limited_email_domains = split( "\n", stripslashes( $limited_email_domains ) ); 41 foreach( (array) $limited_email_domains as $domain ) { 42 $limited_email[] = trim( $domain ); 43 } 44 update_site_option( "limited_email_domains", $limited_email ); 45 } else { 46 update_site_option( "limited_email_domains", '' ); 47 } 48 49 if( $_POST['banned_email_domains'] != '' ) { 50 $banned_email_domains = split( "\n", stripslashes( $_POST[ 'banned_email_domains' ] ) ); 51 foreach( (array) $banned_email_domains as $domain ) { 52 $banned[] = trim( $domain ); 53 } 54 update_site_option( "banned_email_domains", $banned ); 55 } else { 56 update_site_option( "banned_email_domains", '' ); 57 } 58 update_site_option( 'default_user_role', $_POST[ 'default_user_role' ] ); 59 if( trim( $_POST[ 'dashboard_blog_orig' ] ) == '' ) 60 $_POST[ 'dashboard_blog_orig' ] = $current_site->blog_id; 61 if( trim( $_POST[ 'dashboard_blog' ] ) == '' ) { 62 $_POST[ 'dashboard_blog' ] = $current_site->blog_id; 63 $dashboard_blog_id = $current_site->blog_id; 64 } else { 65 $dashboard_blog = untrailingslashit( sanitize_user( str_replace( '.', '', str_replace( $current_site->domain . $current_site->path, '', $_POST[ 'dashboard_blog' ] ) ) ) ); 66 $blog_details = get_blog_details( $dashboard_blog ); 67 if ( false === $blog_details ) { 68 if ( is_numeric( $dashboard_blog ) ) 69 wp_die( __( 'Dashboard blog_id must be a blog that already exists' ) ); 70 if ( constant( 'VHOST' ) == 'yes' ) { 71 $domain = $dashboard_blog . '.' . $current_site->domain; 72 $path = $current_site->path; 73 } else { 74 $domain = $current_site->domain; 75 $path = trailingslashit( $current_site->path . $dashboard_blog ); 76 } 77 $wpdb->hide_errors(); 78 $dashboard_blog_id = wpmu_create_blog( $domain, $path, __( 'My Dashboard' ), $current_user->id , array( "public" => 0 ), $current_site->id ); 79 $wpdb->show_errors(); 80 } else { 81 $dashboard_blog_id = $blog_details->blog_id; 82 } 83 } 84 if ( is_wp_error( $dashboard_blog_id ) ) { 85 wp_die( __( 'Problem creating dashboard blog: ' ) . $dashboard_blog_id->get_error_message() ); 86 } 87 if( $_POST[ 'dashboard_blog_orig' ] != $_POST[ 'dashboard_blog' ] ) { 88 $users = get_users_of_blog( get_site_option( 'dashboard_blog' ) ); 89 $move_users = array(); 90 foreach ( (array)$users as $user ) { 91 if( array_pop( array_keys( unserialize( $user->meta_value ) ) ) == 'subscriber' ) 92 $move_users[] = $user->user_id; 93 } 94 if ( false == empty( $move_users ) ) { 95 foreach ( (array)$move_users as $user_id ) { 96 remove_user_from_blog($user_id, get_site_option( 'dashboard_blog' ) ); 97 add_user_to_blog( $dashboard_blog_id, $user_id, get_site_option( 'default_user_role', 'subscriber' ) ); 98 update_usermeta( $user_id, 'primary_blog', $dashboard_blog_id ); 99 } 100 } 101 } 102 update_site_option( "dashboard_blog", $dashboard_blog_id ); 103 $options = array( 'registrationnotification', 'registration', 'add_new_users', 'menu_items', 'mu_media_buttons', 'upload_space_check_disabled', 'blog_upload_space', 'upload_filetypes', 'site_name', 'first_post', 'first_page', 'first_comment', 'first_comment_url', 'first_comment_author', 'welcome_email', 'welcome_user_email', 'fileupload_maxk', 'admin_notice_feed' ); 104 foreach( $options as $option_name ) { 105 $value = stripslashes_deep( $_POST[ $option_name ] ); 106 update_site_option( $option_name, $value ); 107 } 108 109 $site_admins = explode( ' ', str_replace( ",", " ", $_POST['site_admins'] ) ); 110 if ( is_array( $site_admins ) ) { 111 $mainblog_id = $wpdb->get_var( "SELECT blog_id FROM {$wpdb->blogs} WHERE domain='{$current_site->domain}' AND path='{$current_site->path}'" ); 112 if( $mainblog_id ) { 113 reset( $site_admins ); 114 foreach( (array) $site_admins as $site_admin ) { 115 $uid = $wpdb->get_var( "SELECT ID FROM {$wpdb->users} WHERE user_login='{$site_admin}'" ); 116 if( $uid ) 117 add_user_to_blog( $mainblog_id, $uid, 'administrator' ); 118 } 119 } 120 update_site_option( 'site_admins' , $site_admins ); 121 } 122 123 // Update more options here 124 do_action( 'update_wpmu_options' ); 125 126 wp_redirect( add_query_arg( "updated", "true", 'wpmu-options.php' ) ); 127 exit(); 128 break; 129 case "addblog": 130 check_admin_referer('add-blog'); 131 132 if( is_array( $_POST[ 'blog' ] ) == false ) { 133 wp_die( "Can't create an empty blog." ); 134 } 135 $blog = $_POST['blog']; 136 $domain = sanitize_user( str_replace( '/', '', $blog[ 'domain' ] ) ); 137 $email = sanitize_email( $blog[ 'email' ] ); 138 $title = $blog[ 'title' ]; 139 140 if ( empty($domain) || empty($email)) 141 wp_die( __('Missing blog address or email address.') ); 142 if( !is_email( $email ) ) 143 wp_die( __('Invalid email address') ); 144 145 if( constant( 'VHOST' ) == 'yes' ) { 146 $newdomain = $domain.".".$current_site->domain; 147 $path = $base; 148 } else { 149 $newdomain = $current_site->domain; 150 $path = $base.$domain.'/'; 151 } 152 153 $password = 'N/A'; 154 $user_id = email_exists($email); 155 if( !$user_id ) { // Create a new user with a random password 156 $password = generate_random_password(); 157 $user_id = wpmu_create_user( $domain, $password, $email ); 158 if(false == $user_id) { 159 wp_die( __('There was an error creating the user') ); 160 } else { 161 wp_new_user_notification($user_id, $password); 162 } 163 } 164 165 $wpdb->hide_errors(); 166 $id = wpmu_create_blog($newdomain, $path, $title, $user_id , array( "public" => 1 ), $current_site->id); 167 $wpdb->show_errors(); 168 if( !is_wp_error($id) ) { 169 $dashboard_blog = get_dashboard_blog(); 170 if( get_user_option( 'primary_blog', $user_id ) == $dashboard_blog->blog_id ) 171 update_user_option( $user_id, 'primary_blog', $id, true ); 172 $content_mail = sprintf( __( "New blog created by %1s\n\nAddress: http://%2s\nName: %3s"), $current_user->user_login , $newdomain.$path, stripslashes( $title ) ); 173 wp_mail( get_site_option('admin_email'), sprintf(__('[%s] New Blog Created'), $current_site->site_name), $content_mail, 'From: "Site Admin" <' . get_site_option( 'admin_email' ) . '>' ); 174 wpmu_welcome_notification( $id, $user_id, $password, $title, array( "public" => 1 ) ); 175 wp_redirect( add_query_arg( array('updated' => 'true', 'action' => 'add-blog'), $_SERVER['HTTP_REFERER'] ) ); 176 exit(); 177 } else { 178 wp_die( $id->get_error_message() ); 179 } 180 break; 181 182 case "updateblog": 183 check_admin_referer('editblog'); 184 if( empty( $_POST ) ) 185 wp_die( __('You probably need to go back to the <a href="wpmu-blogs.php">blogs page</a>') ); 186 187 // themes 188 if( is_array( $_POST[ 'theme' ] ) ) { 189 $_POST[ 'option' ][ 'allowedthemes' ] = $_POST[ 'theme' ]; 190 } else { 191 $_POST[ 'option' ][ 'allowedthemes' ] = ''; 192 } 193 194 switch_to_blog( $id ); 195 if( is_array( $_POST[ 'option' ] ) ) { 196 $c = 1; 197 $count = count( $_POST[ 'option' ] ); 198 foreach ( (array) $_POST['option'] as $key => $val ) { 199 if( $key === 0 ) 200 continue; // Avoids "0 is a protected WP option and may not be modified" error when edit blog options 201 if( $c == $count ) { 202 update_option( $key, $val ); 203 } else { 204 update_option( $key, $val, false ); // no need to refresh blog details yet 205 } 206 $c++; 207 } 208 } 209 210 if( $_POST['update_home_url'] == 'update' ) { 211 if( get_option( 'siteurl' ) != 'http://' . $_POST['blog']['domain'] . $_POST['blog']['path'] ) 212 update_option( 'siteurl', 'http://' . $_POST['blog']['domain'] . $_POST['blog']['path'] ); 213 214 if( get_option( 'home' ) != 'http://' . $_POST['blog']['domain'] . $_POST['blog']['path'] ) 215 update_option( 'home', 'http://' . $_POST['blog']['domain'] . $_POST['blog']['path'] ); 216 } 217 218 $wp_rewrite->flush_rules(); 219 220 // update blogs table 221 $result = $wpdb->query( "UPDATE {$wpdb->blogs} SET 222 domain = '".$_POST[ 'blog' ][ 'domain' ]."', 223 path = '".$_POST[ 'blog' ][ 'path' ]."', 224 registered = '".$_POST[ 'blog' ][ 'registered' ]."', 225 public = '".$_POST[ 'blog' ][ 'public' ]."', 226 archived = '".$_POST[ 'blog' ][ 'archived' ]."', 227 mature = '".$_POST[ 'blog' ][ 'mature' ]."', 228 deleted = '".$_POST[ 'blog' ][ 'deleted' ]."', 229 spam = '".$_POST[ 'blog' ][ 'spam' ]."' 230 WHERE blog_id = '$id'" ); 231 232 update_blog_status( $id, 'spam', $_POST[ 'blog' ][ 'spam' ] ); 233 update_option( 'blog_public', $_POST[ 'blog' ][ 'public' ] ); 234 235 // get blog prefix 236 $blog_prefix = $wpdb->get_blog_prefix( $id ); 237 // user roles 238 if( is_array( $_POST[ 'role' ] ) == true ) { 239 $newroles = $_POST[ 'role' ]; 240 reset( $newroles ); 241 foreach ( (array) $newroles as $userid => $role ) { 242 $role_len = strlen( $role ); 243 $existing_role = $wpdb->get_var( "SELECT meta_value FROM $wpdb->usermeta WHERE user_id = '$userid' AND meta_key = '" . $blog_prefix. "capabilities'" ); 244 if( false == $existing_role ) { 245 $wpdb->query( "INSERT INTO " . $wpdb->usermeta . "( `umeta_id` , `user_id` , `meta_key` , `meta_value` ) VALUES ( NULL, '$userid', '" . $blog_prefix . "capabilities', 'a:1:{s:" . strlen( $role ) . ":\"" . $role . "\";b:1;}')" ); 246 } elseif( $existing_role != "a:1:{s:" . strlen( $role ) . ":\"" . $role . "\";b:1;}" ) { 247 $wpdb->query( "UPDATE $wpdb->usermeta SET meta_value = 'a:1:{s:" . strlen( $role ) . ":\"" . $role . "\";b:1;}' WHERE user_id = '$userid' AND meta_key = '" . $blog_prefix . "capabilities'" ); 248 } 249 250 } 251 } 252 253 // remove user 254 if( is_array( $_POST[ 'blogusers' ] ) ) { 255 reset( $_POST[ 'blogusers' ] ); 256 foreach ( (array) $_POST[ 'blogusers' ] as $key => $val ) 257 remove_user_from_blog( $key, $id ); 258 } 259 260 // change password 261 if( is_array( $_POST[ 'user_password' ] ) ) { 262 reset( $_POST[ 'user_password' ] ); 263 $newroles = $_POST[ 'role' ]; 264 foreach ( (array) $_POST[ 'user_password' ] as $userid => $pass ) { 265 unset( $_POST[ 'role' ] ); 266 $_POST[ 'role' ] = $newroles[ $userid ]; 267 if( $pass != '' ) { 268 $cap = $wpdb->get_var( "SELECT meta_value FROM {$wpdb->usermeta} WHERE user_id = '{$userid}' AND meta_key = '{$blog_prefix}capabilities' AND meta_value = 'a:0:{}'" ); 269 $userdata = get_userdata($userid); 270 $_POST[ 'pass1' ] = $_POST[ 'pass2' ] = $pass; 271 $_POST[ 'email' ] = $userdata->user_email; 272 $_POST[ 'rich_editing' ] = $userdata->rich_editing; 273 edit_user( $userid ); 274 if( $cap == null ) 275 $wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE user_id = '{$userid}' AND meta_key = '{$blog_prefix}capabilities' AND meta_value = 'a:0:{}'" ); 276 } 277 } 278 unset( $_POST[ 'role' ] ); 279 $_POST[ 'role' ] = $newroles; 280 } 281 282 // add user? 283 if( $_POST[ 'newuser' ] != '' ) { 284 $newuser = $_POST[ 'newuser' ]; 285 $userid = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . $wpdb->users . " WHERE user_login = %s", $newuser ) ); 286 if( $userid ) { 287 $user = $wpdb->get_var( "SELECT user_id FROM " . $wpdb->usermeta . " WHERE user_id='$userid' AND meta_key='wp_" . $id . "_capabilities'" ); 288 if( $user == false ) 289 add_user_to_blog($id, $userid, $_POST[ 'new_role' ]); 290 } 291 } 292 do_action( 'wpmu_update_blog_options' ); 293 restore_current_blog(); 294 wpmu_admin_do_redirect( "wpmu-blogs.php?action=editblog&updated=true&id=".$id ); 295 break; 296 297 case "deleteblog": 298 check_admin_referer('deleteblog'); 299 if( $id != '0' && $id != $current_site->blog_id ) 300 wpmu_delete_blog( $id, true ); 301 302 wp_redirect( add_query_arg( array('updated' => 'true', 'action' => 'delete'), $_POST[ 'ref' ] ) ); 303 exit(); 304 break; 305 306 case "allblogs": 307 check_admin_referer('allblogs'); 308 foreach ( (array) $_POST[ 'allblogs' ] as $key => $val ) { 309 if( $val != '0' && $val != $current_site->blog_id ) { 310 if ( isset($_POST['allblog_delete']) ) { 311 $blogfunction = 'all_delete'; 312 wpmu_delete_blog( $val, true ); 313 } elseif ( isset($_POST['allblog_spam']) ) { 314 $blogfunction = 'all_spam'; 315 update_blog_status( $val, "spam", '1', 0 ); 316 set_time_limit(60); 317 } elseif ( isset($_POST['allblog_notspam']) ) { 318 $blogfunction = 'all_notspam'; 319 update_blog_status( $val, "spam", '0', 0 ); 320 set_time_limit(60); 321 } 322 } 323 } 324 325 wp_redirect( add_query_arg( array('updated' => 'true', 'action' => $blogfunction), $_SERVER['HTTP_REFERER'] ) ); 326 exit(); 327 break; 328 329 case "archiveblog": 330 check_admin_referer('archiveblog'); 331 update_blog_status( $id, "archived", '1' ); 332 do_action( "archive_blog", $id ); 333 wp_redirect( add_query_arg( array('updated' => 'true', 'action' => 'archive'), $_POST['ref'] ) ); 334 exit(); 335 break; 336 337 case "unarchiveblog": 338 check_admin_referer('unarchiveblog'); 339 do_action( "unarchive_blog", $id ); 340 update_blog_status( $id, "archived", '0' ); 341 wp_redirect( add_query_arg( array('updated' => 'true', 'action' => 'unarchive'), $_POST['ref'] ) ); 342 exit(); 343 break; 344 345 case "activateblog": 346 check_admin_referer('activateblog'); 347 update_blog_status( $id, "deleted", '0' ); 348 do_action( "activate_blog", $id ); 349 wp_redirect( add_query_arg( "updated", array('updated' => 'true', 'action' => 'activate'), $_POST['ref'] ) ); 350 exit(); 351 break; 352 353 case "deactivateblog": 354 check_admin_referer('deactivateblog'); 355 do_action( "deactivate_blog", $id ); 356 update_blog_status( $id, "deleted", '1' ); 357 wp_redirect( add_query_arg( array('updated' => 'true', 'action' => 'deactivate'), $_POST['ref'] ) ); 358 exit(); 359 break; 360 361 case "unspamblog": 362 check_admin_referer('unspamblog'); 363 update_blog_status( $id, "spam", '0' ); 364 wp_redirect( add_query_arg( array('updated' => 'true', 'action' => 'unspam'), $_POST['ref'] ) ); 365 exit(); 366 break; 367 368 case "spamblog": 369 check_admin_referer('spamblog'); 370 update_blog_status( $id, "spam", '1' ); 371 wp_redirect( add_query_arg( array('updated' => 'true', 'action' => 'spam'), $_POST['ref'] ) ); 372 exit(); 373 break; 374 375 case "mature": 376 update_blog_status( $id, 'mature', '1' ); 377 do_action( 'mature_blog', $id ); 378 wp_redirect( add_query_arg( array('updated' => 'true', 'action' => 'mature'), $_POST['ref'] ) ); 379 exit(); 380 break; 381 382 case "unmature": 383 update_blog_status( $id, 'mature', '0' ); 384 do_action( 'unmature_blog', $id ); 385 386 wp_redirect( add_query_arg( array('updated' => 'true', 'action' => 'umature'), $_POST['ref'] ) ); 387 exit(); 388 break; 389 390 // Themes 391 case "updatethemes": 392 if( is_array( $_POST['theme'] ) ) { 393 $themes = get_themes(); 394 reset( $themes ); 395 foreach( (array) $themes as $key => $theme ) { 396 if( $_POST['theme'][ wp_specialchars( $theme['Stylesheet'] ) ] == 'enabled' ) 397 $allowed_themes[ wp_specialchars( $theme['Stylesheet'] ) ] = true; 398 } 399 update_site_option( 'allowedthemes', $allowed_themes ); 400 } 401 wp_redirect( add_query_arg( array('updated' => 'true', 'action' => 'themes'), $_SERVER['HTTP_REFERER'] ) ); 402 exit(); 403 break; 404 405 // Common 406 case "confirm": 407 $referrer = ( isset($_GET['ref']) ) ? stripslashes($_GET['ref']) : $_SERVER['HTTP_REFERER']; 408 $referrer = clean_url($referrer); 409 if( !headers_sent() ){ 410 nocache_headers(); 411 header( 'Content-Type: text/html; charset=utf-8' ); 412 } 413 $blog_details = get_blog_details( $_GET[ 'id' ] ); 414 $confirmation_messages = array( "activateblog" => __( "You are about to activate the blog %s" ), 415 "deactivateblog" => __( "You are about to deactivate the blog %s" ), 416 "unarchiveblog" => __( "You are about to unarchive the blog %s" ), 417 "archiveblog" => __( "You are about to archive the blog %s" ), 418 "unspamblog" => __( "You are about to unspam the blog %s" ), 419 "spamblog" => __( "You are about to mark the blog %s as spam" ), 420 "deleteblog" => __( "You are about to delete the blog %s" ), 421 ); 422 423 ?> 424 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 425 <html xmlns="http://www.w3.org/1999/xhtml" <?php if ( function_exists('language_attributes') ) language_attributes(); ?>> 426 <head> 427 <title><?php _e("WordPress MU › Confirm your action"); ?></title> 428 429 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 430 <?php wp_admin_css( 'install', true ); ?> 431 </head> 432 <body id="error-page"> 433 <h1 id="logo"><img alt="WordPress" src="images/wordpress-logo.png" /></h1> 434 <form action='wpmu-edit.php?action=<?php echo wp_specialchars( $_GET[ 'action2' ] ) ?>' method='post'> 435 <input type='hidden' name='action' value='<?php echo esc_attr( $_GET['action2'] ) ?>' /> 436 <input type='hidden' name='id' value='<?php echo intval( $id ); ?>' /> 437 <input type='hidden' name='ref' value='<?php echo $referrer; ?>' /> 438 <?php wp_nonce_field( $_GET['action2'] ) ?> 439 <p><?php printf( __( $confirmation_messages[ $_GET[ 'action2' ] ] ), $blog_details->siteurl ); ?></p> 440 <p class="submit"><input class="button" type='submit' value='<?php _e("Confirm"); ?>' /></p> 441 </form> 442 </body> 443 </html> 444 <?php 445 break; 446 447 // Users (not used any more) 448 case "deleteuser": 449 check_admin_referer('deleteuser'); 450 if( $id != '0' && $id != '1' ) 451 wpmu_delete_user($id); 452 453 wp_redirect( add_query_arg( array('updated' => 'true', 'action' => 'delete'), $_POST['ref'] ) ); 454 exit(); 455 break; 456 457 case "allusers": 458 check_admin_referer('allusers'); 459 if ( isset($_POST['alluser_delete']) ) { 460 require_once ('admin-header.php'); 461 echo '<div class="wrap" style="position:relative;">'; 462 confirm_delete_users( $_POST['allusers'] ); 463 echo '</div>'; 464 } elseif( isset( $_POST[ 'alluser_transfer_delete' ] ) ) { 465 if( is_array( $_POST[ 'blog' ] ) && !empty( $_POST[ 'blog' ] ) ) { 466 foreach( $_POST[ 'blog' ] as $id => $users ) { 467 foreach( $users as $blogid => $user_id ) { 468 remove_user_from_blog( $id, $blogid, $user_id ); 469 } 470 } 471 } 472 if( is_array( $_POST[ 'user' ] ) && !empty( $_POST[ 'user' ] ) ) 473 foreach( $_POST[ 'user' ] as $id ) 474 wpmu_delete_user( $id ); 475 476 wp_redirect( add_query_arg( array('updated' => 'true', 'action' => 'all_delete'), 'wpmu-users.php' ) ); 477 } else { 478 foreach ( (array) $_POST['allusers'] as $key => $val ) { 479 if( $val == '' || $val == '0' ) { 480 continue; 481 } 482 $user = new WP_User( $val ); 483 if ( in_array( $user->user_login, get_site_option( 'site_admins', array( 'admin' ) ) ) ) { 484 wp_die( sprintf( __( 'Warning! User cannot be modified. The user %s is a site admnistrator.' ), $user->user_login ) ); 485 } 486 if ( isset($_POST['alluser_spam']) ) { 487 $userfunction = 'all_spam'; 488 $blogs = get_blogs_of_user( $val, true ); 489 foreach ( (array) $blogs as $key => $details ) { 490 if ( $details->userblog_id == $current_site->blog_id ) { continue; } // main blog not a spam ! 491 update_blog_status( $details->userblog_id, "spam", '1' ); 492 } 493 update_user_status( $val, "spam", '1', 1 ); 494 } elseif ( isset($_POST['alluser_notspam']) ) { 495 $userfunction = 'all_notspam'; 496 $blogs = get_blogs_of_user( $val, true ); 497 foreach ( (array) $blogs as $key => $details ) { 498 update_blog_status( $details->userblog_id, "spam", '0' ); 499 } 500 update_user_status( $val, "spam", '0', 1 ); 501 } 502 } 503 wp_redirect( add_query_arg( array('updated' => 'true', 'action' => $userfunction), $_SERVER['HTTP_REFERER'] ) ); 504 } 505 exit(); 506 break; 507 508 case "adduser": 509 check_admin_referer('add-user'); 510 511 if( is_array( $_POST[ 'user' ] ) == false ) { 512 wp_die( __( "Cannot create an empty user." ) ); 513 } 514 $user = $_POST['user']; 515 if ( empty($user['username']) && empty($user['email']) ) { 516 wp_die( __('Missing username and email.') ); 517 } elseif ( empty($user['username']) ) { 518 wp_die( __('Missing username.') ); 519 } elseif ( empty($user['email']) ) { 520 wp_die( __('Missing email.') ); 521 } 522 523 $password = generate_random_password(); 524 $user_id = wpmu_create_user(wp_specialchars( strtolower( $user['username'] ) ), $password, wp_specialchars( $user['email'] ) ); 525 526 if( false == $user_id ) { 527 wp_die( __('Duplicated username or email address.') ); 528 } else { 529 wp_new_user_notification($user_id, $password); 530 } 531 if ( get_site_option( 'dashboard_blog' ) == false ) { 532 add_user_to_blog( $current_site->blog_id, $user_id, get_site_option( 'default_user_role', 'subscriber' ) ); 533 } else { 534 add_user_to_blog( get_site_option( 'dashboard_blog' ), $user_id, get_site_option( 'default_user_role', 'subscriber' ) ); 535 } 536 537 wp_redirect( add_query_arg( array('updated' => 'true', 'action' => 'add'), $_SERVER['HTTP_REFERER'] ) ); 538 exit(); 539 break; 540 541 default: 542 wpmu_admin_do_redirect( "wpmu-admin.php" ); 543 break; 544 } 545 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon May 3 12:25:32 2010 | Cross-referenced by PHPXref 0.7 |