| 88 | | if( is_array( $_POST['blog'] ) == true ) { |
|---|
| 89 | | $blog = $_POST['blog']; |
|---|
| 90 | | $domain = strtolower( wp_specialchars( $blog['domain'] ) ); |
|---|
| 91 | | $email = wp_specialchars( $blog['email'] ); |
|---|
| 92 | | if( !is_email( $email ) ) |
|---|
| 93 | | wp_die( __("<p>Invalid email address</p>") ); |
|---|
| 94 | | |
|---|
| 95 | | if( constant( "VHOST" ) == 'yes' ) { |
|---|
| 96 | | $newdomain = $domain.".".$current_site->domain; |
|---|
| 97 | | $path = $base; |
|---|
| | 88 | $blog = $_POST['blog']; |
|---|
| | 89 | $domain = strtolower( wp_specialchars( $blog['domain'] ) ); |
|---|
| | 90 | $email = wp_specialchars( $blog['email'] ); |
|---|
| | 91 | |
|---|
| | 92 | if ( empty($domain) || empty($email)) |
|---|
| | 93 | wp_die( __("<p>Missing blog address or email address.</p>") ); |
|---|
| | 94 | if( !is_email( $email ) ) |
|---|
| | 95 | wp_die( __("<p>Invalid email address</p>") ); |
|---|
| | 96 | |
|---|
| | 97 | if( constant( "VHOST" ) == 'yes' ) { |
|---|
| | 98 | $newdomain = $domain.".".$current_site->domain; |
|---|
| | 99 | $path = $base; |
|---|
| | 100 | } else { |
|---|
| | 101 | $newdomain = $current_site->domain; |
|---|
| | 102 | $path = $base.$domain.'/'; |
|---|
| | 103 | } |
|---|
| | 104 | |
|---|
| | 105 | $user_id = email_exists($email); |
|---|
| | 106 | if( !$user_id ) { |
|---|
| | 107 | $password = generate_random_password(); |
|---|
| | 108 | $user_id = wpmu_create_user( $domain, $password, $email ); |
|---|
| | 109 | if(false == $user_id) { |
|---|
| | 110 | wp_die( __("<p>There was an error creating the user</p>") ); |
|---|
| 99 | | $newdomain = $current_site->domain; |
|---|
| 100 | | $path = $base.$domain.'/'; |
|---|
| 101 | | } |
|---|
| 102 | | |
|---|
| 103 | | $user_id = email_exists($email); |
|---|
| 104 | | if( !$user_id ) { // I'm not sure what this check should be. |
|---|
| 105 | | $password = generate_random_password(); |
|---|
| 106 | | $user_id = wpmu_create_user( $domain, $password, $email ); |
|---|
| 107 | | if(false == $user_id) { |
|---|
| 108 | | wp_die( __("<p>There was an error creating the user</p>") ); |
|---|
| 109 | | } else { |
|---|
| 110 | | wp_new_user_notification($user_id, $password); |
|---|
| 111 | | } |
|---|
| 112 | | } |
|---|
| 113 | | |
|---|
| 114 | | $wpdb->hide_errors(); |
|---|
| 115 | | $blog_id = wpmu_create_blog($newdomain, $path, wp_specialchars( $blog['title'] ), $user_id ,'', $current_site->id); |
|---|
| 116 | | $wpdb->show_errors(); |
|---|
| 117 | | if( !is_wp_error($blog_id) ) { |
|---|
| 118 | | if( get_user_option( $user_id, 'primary_blog' ) == 1 ) |
|---|
| 119 | | update_user_option( $user_id, 'primary_blog', $blog_id, true ); |
|---|
| 120 | | $content_mail = sprintf(__("New blog created by %1s\n\nAddress: http://%2s\nName: %3s"), $current_user->user_login , $newdomain.$path, wp_specialchars($blog['title']) ); |
|---|
| 121 | | 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' ) . '>' ); |
|---|
| 122 | | wp_redirect( add_query_arg( array('updated' => 'true', 'action' => 'add-blog'), $_SERVER['HTTP_REFERER'] ) ); |
|---|
| 123 | | exit(); |
|---|
| 124 | | } else { |
|---|
| 125 | | die( $blog_id->get_error_message() ); |
|---|
| 126 | | } |
|---|
| | 112 | wp_new_user_notification($user_id, $password); |
|---|
| | 113 | } |
|---|
| | 114 | } |
|---|
| | 115 | |
|---|
| | 116 | $wpdb->hide_errors(); |
|---|
| | 117 | $blog_id = wpmu_create_blog($newdomain, $path, wp_specialchars( $blog['title'] ), $user_id ,'', $current_site->id); |
|---|
| | 118 | $wpdb->show_errors(); |
|---|
| | 119 | if( !is_wp_error($blog_id) ) { |
|---|
| | 120 | if( get_user_option( $user_id, 'primary_blog' ) == 1 ) |
|---|
| | 121 | update_user_option( $user_id, 'primary_blog', $blog_id, true ); |
|---|
| | 122 | $content_mail = sprintf(__("New blog created by %1s\n\nAddress: http://%2s\nName: %3s"), $current_user->user_login , $newdomain.$path, wp_specialchars($blog['title']) ); |
|---|
| | 123 | 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' ) . '>' ); |
|---|
| | 124 | wp_redirect( add_query_arg( array('updated' => 'true', 'action' => 'add-blog'), $_SERVER['HTTP_REFERER'] ) ); |
|---|
| | 125 | exit(); |
|---|
| | 126 | } else { |
|---|
| | 127 | die( $blog_id->get_error_message() ); |
|---|
| 405 | | if( is_array( $_POST['user'] ) == true ) { |
|---|
| 406 | | $user = $_POST['user']; |
|---|
| 407 | | if ( empty($user['username']) && empty($user['email']) ) { |
|---|
| 408 | | wp_die( __("<p>Missing username and email.</p>") ); |
|---|
| 409 | | } elseif ( empty($user['username']) ) { |
|---|
| 410 | | wp_die( __("<p>Missing username.</p>") ); |
|---|
| 411 | | } elseif ( empty($user['email']) ) { |
|---|
| 412 | | wp_die( __("<p>Missing email.</p>") ); |
|---|
| 413 | | } |
|---|
| 414 | | |
|---|
| 415 | | $password = generate_random_password(); |
|---|
| 416 | | $user_id = wpmu_create_user(wp_specialchars( strtolower( $user['username'] ) ), $password, wp_specialchars( $user['email'] ) ); |
|---|
| 417 | | if( false == $user_id ) { |
|---|
| 418 | | wp_die( __("<p>There was an error creating the user</p>") ); |
|---|
| 419 | | } else { |
|---|
| 420 | | wp_new_user_notification($user_id, $password); |
|---|
| 421 | | } |
|---|
| 422 | | } |
|---|
| | 406 | $user = $_POST['user']; |
|---|
| | 407 | if ( empty($user['username']) && empty($user['email']) ) { |
|---|
| | 408 | wp_die( __("<p>Missing username and email.</p>") ); |
|---|
| | 409 | } elseif ( empty($user['username']) ) { |
|---|
| | 410 | wp_die( __("<p>Missing username.</p>") ); |
|---|
| | 411 | } elseif ( empty($user['email']) ) { |
|---|
| | 412 | wp_die( __("<p>Missing email.</p>") ); |
|---|
| | 413 | } |
|---|
| | 414 | |
|---|
| | 415 | $password = generate_random_password(); |
|---|
| | 416 | $user_id = wpmu_create_user(wp_specialchars( strtolower( $user['username'] ) ), $password, wp_specialchars( $user['email'] ) ); |
|---|
| | 417 | |
|---|
| | 418 | if( false == $user_id ) { |
|---|
| | 419 | wp_die( __("<p>Duplicated username or email address.</p>") ); |
|---|
| | 420 | } else { |
|---|
| | 421 | wp_new_user_notification($user_id, $password); |
|---|
| | 422 | } |
|---|
| | 423 | |
|---|