├── .gitmodules ├── sql.txt ├── changelog.txt ├── README.md ├── blog-user-creator-files └── languages │ └── blog-user-creator.pot └── blog-user-creator.php /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "dash-notice"] 2 | path = dash-notice 3 | url = git@bitbucket.org:incsub/wpmudev-dashboard-notification.git 4 | branch = master 5 | -------------------------------------------------------------------------------- /sql.txt: -------------------------------------------------------------------------------- 1 | CREATE TABLE IF NOT EXISTS `wp_blog_user_creator_queue` ( 2 | `blog_user_creator_ID` bigint(20) unsigned NOT NULL auto_increment, 3 | `blog_user_creator_site_ID` bigint(20), 4 | `blog_user_creator_blog_ID` bigint(20), 5 | `blog_user_creator_batch_ID` varchar(255), 6 | `blog_user_creator_user_name` varchar(255), 7 | `blog_user_creator_user_pass` varchar(255), 8 | `blog_user_creator_user_email` varchar(255), 9 | `blog_user_creator_blog_name` varchar(255), 10 | `blog_user_creator_blog_title` varchar(255), 11 | `blog_user_creator_blog_types` TEXT, 12 | `blog_user_creator_add_admin` tinyint(1), 13 | `blog_user_creator_admin_uid` varchar(255), 14 | `blog_user_creator_stamp` bigint(20), 15 | `blog_user_creator_error` tinyint(1), 16 | `blog_user_creator_error_msg` varchar(255), 17 | PRIMARY KEY (`blog_user_creator_ID`) 18 | ) ENGINE=MyISAM; -------------------------------------------------------------------------------- /changelog.txt: -------------------------------------------------------------------------------- 1 | Plugin Name: Blog & User Creator 2 | Author: Andrew Billits, Ulrich Sossou 3 | 4 | Change Log: 5 | ---------------------------------------------------------------------- 6 | ---------------------------------------------------------------------- 7 | 8 | 1.1.9 - 01/10/2011 9 | ---------------------------------------------------------------------- 10 | - 3.1+ compatibility update 11 | - Bug fixes 12 | - Internationalization 13 | 14 | 1.1.8 - 06/01/2010 15 | ---------------------------------------------------------------------- 16 | - 3.0+ compatibility update 17 | 18 | 1.1.7 - 06/16/2009 19 | ---------------------------------------------------------------------- 20 | - Fixed typo. 21 | 22 | 1.1.6 - 06/15/2009 23 | ---------------------------------------------------------------------- 24 | - Fixed url typo. 25 | 26 | 1.1.5 - 06/09/2009 27 | ---------------------------------------------------------------------- 28 | - Initial Premium Release. 29 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Blog & user creator 2 | 3 | 4 | **INACTIVE NOTICE: This plugin is unsupported by WPMUDEV, we've published it here for those technical types who might want to fork and maintain it for their needs.** 5 | 6 | ## Translations 7 | 8 | Translation files can be found at https://github.com/wpmudev/translations 9 | 10 | ## About 11 | 12 | Blog & User Creator is the quickest and easiest way for you, and your users to bulk create blogs and users and email out their passwords. 13 | 14 | Bulk create new users, batch add existing users to a blog and mass create blogs – all combined into one powerful plugin. Every day this plugin makes life easier for educators and their students on [Edublogs.](http://edublogs.org/) 15 | 16 | ### Incredibly easy 17 | 18 | Install and activate for a nice new 'Blog & User Creator' menu item to appear under Users in the site admin dashboard. 19 | 20 | ![Blog and user creator](http://premium.wpmudev.org/wp-content/uploads/2011/09/bua61.jpg) 21 | 22 | Seamless integration with WordPress 23 | 24 | Access a beautiful form for adding new users, adding existing users or creating blogs in batches of 5, 10,...or more 25 | 26 | ![Add new users interface](http://premium.wpmudev.org/wp-content/uploads/2011/09/bau62.jpg) 27 | 28 | Save countless hours adding multiple users 29 | 30 | Blog & User Creator is the ultimate time saver for adding new users, existing users and creating blogs – built for Multisite and BuddyPress. 31 | 32 | ## Usage 33 | 34 | ### To install: 35 | 36 | 1. Download the plugin file 37 | 2. Unzip the file into a folder on your hard drive 38 | 3. Upload **/blog-user-creator/** folder to **/wp-content/plugins/** folder on your site 39 | 4. Visit **Network Admin -> Plugins** and **Network Activate** it there. 40 | 41 | _Note: If you have an older version of the plugin installed in /mu-plugins/ please delete it._ 42 | 43 | * **That's it! No configuration necessary!** 44 | 45 | ### To Use: 46 | 47 | Once activated go **Settings > Blog & User creator** in the network admin dashboard and enable the components you want your different users to be able to access. 48 | 49 | ![Confirugre your Blog and user creator network setting](https://premium.wpmudev.org/wp-content/uploads/2011/09/bau63.jpg) 50 | 51 | This controls what your users will be able to see under each tab in the 'Blog & User Creator' in their site admin dashboard. 52 | 53 | ### To add a new user 54 | 55 | 1\.  Go to **Users > Blog & User Creator ** 56 | 57 | 2\.  Click on the **Add New Users** tab 58 | 59 | ![Add new users tab](https://premium.wpmudev.org/wp-content/uploads/2011/09/users69.jpg) 60 | 61 | 3\.  Add suitable usernames. 62 | 63 | 4\.  Add their email address 64 | 65 | 5\.  Add their password 66 | 67 | * leave this blank if you want to let the system automatically create the password 68 | 69 | 6\.  Select their role (learn more about [user role’s](https://premium.wpmudev.org/wpmu-manual/introduction-to-super-admin-user/) here) 70 | 71 | 7\.   Click **Submit** to create and add them to your blog. 72 | 73 | ![Adding new users](https://premium.wpmudev.org/wp-content/uploads/2011/09/users68.jpg) 74 | 75 | ### To add a new user 76 | 77 | 1\.  Go to **Users > Blog & User Creator ** 78 | 79 | 2\.  Click on the **Add Existing Users** tab 80 | 81 | ![Existing user tab](https://premium.wpmudev.org/wp-content/uploads/2011/09/users70.jpg) 82 | 83 | 3\.  Add their existing usernames or the email addresses attached to their usernames 84 | 85 | 4\.  Select their roles (learn more about [user role’s](../wpmu-manual/introduction-to-super-admin-user/) here) 86 | 87 | 5\.  Click **Submit** ** 88 | 89 | ![Adding existing users](https://premium.wpmudev.org/wp-content/uploads/2011/09/users68.jpg) 90 | 91 | ** 92 | 93 | ### To create new blogs 94 | 95 | 1.  Go to **Users** > **Blog & User Creator ** 96 | 97 | 2\.  Click on the **Create Blogs** tab 98 | 99 | 3\.  Select their role on their new blog, their role on your blog, your role on their blog (learn more about [user role’s](../wpmu-manual/introduction-to-super-admin-user/) here) 100 | 101 | ![Select their roles](https://premium.wpmudev.org/wp-content/uploads/2011/09/bau64.jpg) 102 | 103 | 4\.  Add suitable usernames. 104 | 105 | 5\.  Add their email address 106 | 107 | 6\.  Add their password 108 | 109 | * leave this blank if you want to let the system automatically create the password 110 | 111 | 7\.  Add their blog urls 112 | 113 | 8\.  Add Blog title 114 | 115 | * This can be changed later in Settings > General 116 | 117 | 9.  Click **Submit** at the bottom of the page 118 | 119 | * Click on **Add More** if you want to create in batches more than 5 blogs. 120 | 121 | ![Add blog details](https://premium.wpmudev.org/wp-content/uploads/2011/09/blogs63.jpg) 122 | 123 | 124 | -------------------------------------------------------------------------------- /blog-user-creator-files/languages/blog-user-creator.pot: -------------------------------------------------------------------------------- 1 | # Translation of the WordPress plugin Blog And User Creator 1.1.9 by Andrew Billits, Ulrich Sossou. 2 | # Copyright (C) 2011 Andrew Billits, Ulrich Sossou 3 | # This file is distributed under the same license as the Blog And User Creator package. 4 | # FIRST AUTHOR , 2011. 5 | # 6 | #, fuzzy 7 | msgid "" 8 | msgstr "" 9 | "Project-Id-Version: Blog And User Creator 1.1.9\n" 10 | "Report-Msgid-Bugs-To: http://wordpress.org/tag/blog-user-creator\n" 11 | "POT-Creation-Date: 2011-01-10 08:52+0100\n" 12 | "PO-Revision-Date: 2011-MO-DA HO:MI+ZONE\n" 13 | "Last-Translator: FULL NAME \n" 14 | "Language-Team: LANGUAGE \n" 15 | "Language: \n" 16 | "MIME-Version: 1.0\n" 17 | "Content-Type: text/plain; charset=utf-8\n" 18 | "Content-Transfer-Encoding: 8bit\n" 19 | 20 | #: blog-user-creator.php:124 21 | msgid "" 22 | "We have problem finding your '/wp-admin/upgrade-functions.php' and '/wp-" 23 | "admin/includes/upgrade.php'" 24 | msgstr "" 25 | 26 | #: blog-user-creator.php:164 blog-user-creator.php:285 27 | #: blog-user-creator.php:399 blog-user-creator.php:791 28 | #: blog-user-creator.php:1237 29 | msgid "Blog & User Creator" 30 | msgstr "" 31 | 32 | #: blog-user-creator.php:238 33 | #, php-format 34 | msgid "New blog created by %1s\\n\\nAddress: http://%2s\\nName: %3s" 35 | msgstr "" 36 | 37 | #: blog-user-creator.php:239 38 | #, php-format 39 | msgid "[%s] New Blog Created" 40 | msgstr "" 41 | 42 | #: blog-user-creator.php:251 43 | #, php-format 44 | msgid "Error creating blog: %1$s - %2$s" 45 | msgstr "" 46 | 47 | #: blog-user-creator.php:270 48 | msgid "You do not have permission to access this page" 49 | msgstr "" 50 | 51 | #: blog-user-creator.php:285 52 | msgid "Simple" 53 | msgstr "" 54 | 55 | #: blog-user-creator.php:287 blog-user-creator.php:401 56 | msgid "" 57 | "Fill out the details below to easily create multiple users and blogs and add " 58 | "yourself as admin to them (if you wish).

You can create up to 15 " 59 | "different users and blogs at one time and new users will be emailed their " 60 | "usernames and passwords automatically. If you need more than 15 please " 61 | "simply process this form and then start again.

Please try to use " 62 | "unique usernames and blog URLs as this will make the process a lot quicker " 63 | "for you. An easy way to do this is to add numbers and letters after a " 64 | "regular name - for example 'James' at 'Kings Heath School' in year 10 could " 65 | "be 'jameskh10'." 66 | msgstr "" 67 | 68 | #: blog-user-creator.php:305 blog-user-creator.php:831 69 | msgid "User Name" 70 | msgstr "" 71 | 72 | #: blog-user-creator.php:308 blog-user-creator.php:834 73 | msgid "" 74 | "This will be the name used to log in, try to choose something that will be " 75 | "unique - e.g. jamesqt3" 76 | msgstr "" 77 | 78 | #: blog-user-creator.php:309 blog-user-creator.php:480 79 | #: blog-user-creator.php:835 blog-user-creator.php:1332 80 | msgid "" 81 | "For existing users, leave this field blank and just enter the user email " 82 | "below." 83 | msgstr "" 84 | 85 | #: blog-user-creator.php:312 blog-user-creator.php:483 86 | #: blog-user-creator.php:838 blog-user-creator.php:1335 87 | msgid "User Email" 88 | msgstr "" 89 | 90 | #: blog-user-creator.php:315 blog-user-creator.php:486 91 | #: blog-user-creator.php:841 blog-user-creator.php:1338 92 | msgid "" 93 | "Required - if a user already exists with this email address, that user will " 94 | "be added to the blog you are creating." 95 | msgstr "" 96 | 97 | #: blog-user-creator.php:318 blog-user-creator.php:844 98 | msgid "User Password" 99 | msgstr "" 100 | 101 | #: blog-user-creator.php:321 blog-user-creator.php:847 102 | msgid "" 103 | "Leave this blank for a random password to be automatically generated and " 104 | "emailed to the user." 105 | msgstr "" 106 | 107 | #: blog-user-creator.php:324 blog-user-creator.php:850 108 | msgid "Blog Url" 109 | msgstr "" 110 | 111 | #: blog-user-creator.php:327 blog-user-creator.php:853 112 | msgid "" 113 | "You must fill this in for a blog to be created - try to choose something " 114 | "unique - e.g. myblog1aq will create http://myblog1aq." 115 | msgstr "" 116 | 117 | #: blog-user-creator.php:330 blog-user-creator.php:856 118 | msgid "Blog Title" 119 | msgstr "" 120 | 121 | #: blog-user-creator.php:333 blog-user-creator.php:859 122 | msgid "" 123 | "Required if you are creating a blog - this will appear as the title and can " 124 | "easily be changed later on - e.g. My School Blog" 125 | msgstr "" 126 | 127 | #: blog-user-creator.php:375 blog-user-creator.php:460 128 | #: blog-user-creator.php:916 blog-user-creator.php:1294 129 | msgid "Add Admin" 130 | msgstr "" 131 | 132 | #: blog-user-creator.php:378 blog-user-creator.php:463 133 | #: blog-user-creator.php:918 blog-user-creator.php:1296 134 | msgid "No" 135 | msgstr "" 136 | 137 | #: blog-user-creator.php:379 blog-user-creator.php:464 138 | #: blog-user-creator.php:919 blog-user-creator.php:1297 139 | msgid "Yes" 140 | msgstr "" 141 | 142 | #: blog-user-creator.php:383 blog-user-creator.php:467 143 | #: blog-user-creator.php:922 blog-user-creator.php:1300 144 | msgid "" 145 | "This will add you as a co-administrator of the blog so you can log into it " 146 | "and edit settings / make posts." 147 | msgstr "" 148 | 149 | #: blog-user-creator.php:392 blog-user-creator.php:414 150 | #: blog-user-creator.php:493 blog-user-creator.php:811 151 | #: blog-user-creator.php:931 blog-user-creator.php:1308 152 | #: blog-user-creator.php:1347 153 | msgid "Create" 154 | msgstr "" 155 | 156 | #: blog-user-creator.php:394 blog-user-creator.php:416 157 | #: blog-user-creator.php:495 blog-user-creator.php:814 158 | #: blog-user-creator.php:934 blog-user-creator.php:1311 159 | #: blog-user-creator.php:1350 160 | msgid "This may take some time so please be patient." 161 | msgstr "" 162 | 163 | #: blog-user-creator.php:399 164 | msgid "Advanced" 165 | msgstr "" 166 | 167 | #: blog-user-creator.php:417 blog-user-creator.php:1252 168 | msgid "Common Options" 169 | msgstr "" 170 | 171 | #: blog-user-creator.php:473 172 | msgid ":" 173 | msgstr "" 174 | 175 | #: blog-user-creator.php:476 blog-user-creator.php:1328 176 | msgid "Blog/User Name" 177 | msgstr "" 178 | 179 | #: blog-user-creator.php:479 180 | msgid "" 181 | "This will be the name used to log in and the name of the blog (ex: name." 182 | msgstr "" 183 | 184 | #: blog-user-creator.php:560 blog-user-creator.php:1018 185 | msgid "Only lowercase letters and numbers allowed" 186 | msgstr "" 187 | 188 | #: blog-user-creator.php:573 blog-user-creator.php:1031 189 | msgid "Sorry, that name is not allowed" 190 | msgstr "" 191 | 192 | #: blog-user-creator.php:580 193 | msgid "Sorry, blog name must be at least 4 characters" 194 | msgstr "" 195 | 196 | #: blog-user-creator.php:588 197 | msgid "Sorry, blog names may not contain the character '_'" 198 | msgstr "" 199 | 200 | #: blog-user-creator.php:598 201 | msgid "Sorry, blog names must have letters too" 202 | msgstr "" 203 | 204 | #: blog-user-creator.php:619 205 | msgid "Sorry, that blog name already exists" 206 | msgstr "" 207 | 208 | #: blog-user-creator.php:627 209 | msgid "Please provide a blog title" 210 | msgstr "" 211 | 212 | #: blog-user-creator.php:639 blog-user-creator.php:647 213 | #: blog-user-creator.php:1086 blog-user-creator.php:1094 214 | msgid "You must provide a valid email address" 215 | msgstr "" 216 | 217 | #: blog-user-creator.php:661 218 | msgid "Sorry, that username already exists" 219 | msgstr "" 220 | 221 | #: blog-user-creator.php:679 222 | msgid "" 223 | "That username is currently reserved but may be available in a couple of days" 224 | msgstr "" 225 | 226 | #: blog-user-creator.php:688 blog-user-creator.php:1136 227 | msgid "Only lowercase letters and numbers allowed in usernames" 228 | msgstr "" 229 | 230 | #: blog-user-creator.php:700 231 | msgid "You must provide a username" 232 | msgstr "" 233 | 234 | #: blog-user-creator.php:709 235 | msgid "Sorry, usernames must have letters too" 236 | msgstr "" 237 | 238 | #: blog-user-creator.php:716 239 | msgid "Username must be at least 4 characters" 240 | msgstr "" 241 | 242 | #: blog-user-creator.php:723 243 | msgid "Sorry, usernames may not contain the character '_'" 244 | msgstr "" 245 | 246 | #: blog-user-creator.php:736 247 | msgid "That username is not allowed" 248 | msgstr "" 249 | 250 | #: blog-user-creator.php:748 blog-user-creator.php:1196 251 | msgid "" 252 | "You cannot use that email address. We are having problems with them blocking " 253 | "some of our email. Please use another email provider." 254 | msgstr "" 255 | 256 | #: blog-user-creator.php:755 blog-user-creator.php:1203 257 | msgid "Please enter a correct email address" 258 | msgstr "" 259 | 260 | #: blog-user-creator.php:765 blog-user-creator.php:1213 261 | msgid "Sorry, that email address is not allowed" 262 | msgstr "" 263 | 264 | #: blog-user-creator.php:793 blog-user-creator.php:1239 265 | msgid "Errors were found. Please fix the errors and hit Create." 266 | msgstr "" 267 | 268 | #: blog-user-creator.php:812 blog-user-creator.php:932 269 | #: blog-user-creator.php:1309 blog-user-creator.php:1348 270 | msgid "Cancel" 271 | msgstr "" 272 | 273 | #: blog-user-creator.php:941 blog-user-creator.php:1357 274 | #: blog-user-creator.php:1384 275 | msgid "Creatings blogs..." 276 | msgstr "" 277 | 278 | #: blog-user-creator.php:993 279 | #, php-format 280 | msgid "%s 's Blog" 281 | msgstr "" 282 | 283 | #: blog-user-creator.php:1038 blog-user-creator.php:1164 284 | msgid "Sorry, blog/user names must be at least 4 characters" 285 | msgstr "" 286 | 287 | #: blog-user-creator.php:1046 blog-user-creator.php:1171 288 | msgid "Sorry, blog/user names may not contain the character '_'" 289 | msgstr "" 290 | 291 | #: blog-user-creator.php:1056 blog-user-creator.php:1157 292 | msgid "Sorry, blog/user names must have letters too" 293 | msgstr "" 294 | 295 | #: blog-user-creator.php:1077 blog-user-creator.php:1108 296 | msgid "Sorry, that blog/user name already exists" 297 | msgstr "" 298 | 299 | #: blog-user-creator.php:1126 300 | msgid "" 301 | "That blog/user name is currently reserved but may be available in a couple " 302 | "of days" 303 | msgstr "" 304 | 305 | #: blog-user-creator.php:1148 306 | msgid "You must provide a blog/user name" 307 | msgstr "" 308 | 309 | #: blog-user-creator.php:1184 310 | msgid "Sorry, that blog/user name is not allowed" 311 | msgstr "" 312 | 313 | #: blog-user-creator.php:1331 314 | #, php-format 315 | msgid "" 316 | "This will be the name used to log in and the name of the blog (ex: name.%1$s" 317 | "%2$s), try to choose something that will be unique - e.g. jamesqt3" 318 | msgstr "" 319 | 320 | #: blog-user-creator.php:1397 321 | msgid "Blogs and users created." 322 | msgstr "" 323 | 324 | #: blog-user-creator.php:1419 325 | msgid "" 326 | "Please install the latest version of our free " 328 | "Update Notifications plugin which helps you stay up-to-date with the " 329 | "most stable, secure versions of WPMU DEV themes and plugins. More information »" 332 | msgstr "" 333 | 334 | #. Plugin Name of the plugin/theme 335 | msgid "Blog And User Creator" 336 | msgstr "" 337 | 338 | #. Plugin URI of the plugin/theme 339 | msgid "http://premium.wpmudev.org/project/blog-and-user-creator" 340 | msgstr "" 341 | 342 | #. Description of the plugin/theme 343 | msgid "" 344 | "The blog and user creator plugin is an amazing powerful feature that allows " 345 | "you, and your users, to batch create gazillions of blogs and/or users while " 346 | "setting passwords, urls, titles and more!" 347 | msgstr "" 348 | 349 | #. Author of the plugin/theme 350 | msgid "Andrew Billits, Ulrich Sossou" 351 | msgstr "" 352 | 353 | #. Author URI of the plugin/theme 354 | msgid "http://premium.wpmudev.org/project/" 355 | msgstr "" 356 | -------------------------------------------------------------------------------- /blog-user-creator.php: -------------------------------------------------------------------------------- 1 | fields = isset( $_GET['fields'] ) ? $_GET['fields'] : ''; 73 | 74 | // default to 15 field sets 75 | if ( $this->fields == '' ) 76 | $this->fields = 15; 77 | 78 | // no more than 50 fields sets 79 | if ( $this->fields > 50 ) 80 | $this->fields = 50; 81 | 82 | // load text domain 83 | if ( defined( 'WPMU_PLUGIN_DIR' ) && file_exists( WPMU_PLUGIN_DIR . '/blog-user-creator.php' ) ) { 84 | load_muplugin_textdomain( 'blog_user_creator', 'blog-user-creator-files/languages' ); 85 | } else { 86 | load_plugin_textdomain( 'blog_user_creator', false, dirname( plugin_basename( __FILE__ ) ) . '/blog-user-creator-files/languages' ); 87 | } 88 | } 89 | 90 | /** 91 | * Update database 92 | **/ 93 | function make_current() { 94 | global $plugin_page; 95 | 96 | if( 'blog-user-creator' !== $plugin_page ) 97 | return; 98 | 99 | if ( get_site_option( 'blog_user_creator_version' ) == '' ) 100 | add_site_option( 'blog_user_creator_version', '0.0.0' ); 101 | 102 | if ( get_site_option( 'blog_user_creator_version' ) !== $this->version ) { 103 | update_site_option( 'blog_user_creator_version', $this->version ); 104 | update_site_option( 'blog_user_creator_installed', 'no' ); 105 | } 106 | 107 | $this->global_install(); 108 | 109 | if ( get_option( 'blog_user_creator_version' ) == '' ) 110 | add_option( 'blog_user_creator_version', $this->version ); 111 | 112 | if ( get_option( 'blog_user_creator_version' ) !== $this->version ) 113 | update_option( 'blog_user_creator_version', $this->version ); 114 | } 115 | 116 | function global_install() { 117 | global $wpdb; 118 | 119 | if ( get_site_option( 'blog_user_creator_installed' ) == '' ) 120 | add_site_option( 'blog_user_creator_installed', 'no' ); 121 | 122 | if ( get_site_option( 'blog_user_creator_installed' ) !== 'yes' ) { 123 | 124 | if( @is_file( ABSPATH . '/wp-admin/includes/upgrade.php' ) ) 125 | include_once( ABSPATH . '/wp-admin/includes/upgrade.php' ); 126 | else 127 | die( __( 'We have problem finding your \'/wp-admin/upgrade-functions.php\' and \'/wp-admin/includes/upgrade.php\'', 'blog_user_creator' ) ); 128 | 129 | $charset_collate = ''; 130 | if( $wpdb->supports_collation() ) { 131 | if( !empty( $wpdb->charset ) ) { 132 | $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset"; 133 | } 134 | if( !empty( $wpdb->collate ) ) { 135 | $charset_collate .= " COLLATE $wpdb->collate"; 136 | } 137 | } 138 | 139 | $blog_user_creator_table = "CREATE TABLE `{$wpdb->base_prefix}blog_user_creator_queue` ( 140 | `blog_user_creator_ID` bigint(20) unsigned NOT NULL auto_increment, 141 | `blog_user_creator_site_ID` bigint(20), 142 | `blog_user_creator_blog_ID` bigint(20), 143 | `blog_user_creator_batch_ID` varchar(255), 144 | `blog_user_creator_user_name` varchar(255), 145 | `blog_user_creator_user_pass` varchar(255), 146 | `blog_user_creator_user_email` varchar(255), 147 | `blog_user_creator_blog_name` varchar(255), 148 | `blog_user_creator_blog_title` varchar(255), 149 | `blog_user_creator_blog_types` TEXT, 150 | `blog_user_creator_add_admin` tinyint(1), 151 | `blog_user_creator_admin_uid` varchar(255), 152 | `blog_user_creator_stamp` bigint(20), 153 | `blog_user_creator_error` tinyint(1), 154 | `blog_user_creator_error_msg` varchar(255), 155 | PRIMARY KEY (`blog_user_creator_ID`) 156 | ) $charset_collate;"; 157 | 158 | maybe_create_table( "{$wpdb->base_prefix}blog_user_creator_queue", $blog_user_creator_table ); 159 | 160 | update_site_option( 'blog_user_creator_installed', 'yes' ); 161 | 162 | } 163 | 164 | } 165 | 166 | function plug_pages() { 167 | add_submenu_page( 'users.php', __( 'Blog & User Creator', 'blog_user_creator' ), __( 'Blog & User Creator', 'blog_user_creator' ), 'manage_options', 'blog-user-creator', array( &$this, 'page_output' ) ); 168 | } 169 | 170 | function queue_insert( $batch_ID, $stamp, $blog_name, $blog_title, $blog_types, $add_admin, $admin_uid, $user_name, $user_pass, $user_email ) { 171 | global $wpdb; 172 | $wpdb->query( $wpdb->prepare( "INSERT INTO {$wpdb->base_prefix}blog_user_creator_queue ( blog_user_creator_site_ID, blog_user_creator_blog_ID, blog_user_creator_batch_ID, blog_user_creator_user_name, blog_user_creator_user_pass, blog_user_creator_user_email, blog_user_creator_blog_name, blog_user_creator_blog_title, blog_user_creator_blog_types, blog_user_creator_add_admin, blog_user_creator_admin_uid, blog_user_creator_stamp ) VALUES ( %d, %d, %d, %s, %s, %s, %s, %s, %s, %d, %d, %s )", $wpdb->siteid, $wpdb->blogid, $batch_ID, $user_name, $user_pass, $user_email, $blog_name, $blog_title, $blog_types, $add_admin, $admin_uid, $stamp ) ); 173 | } 174 | 175 | function queue_process( $tmp_blog_ID, $tmp_site_ID ) { 176 | global $wpdb, $current_site, $current_user, $base; 177 | 178 | $blog_user_creator_enable_blog_types = $this->enable_blog_types; 179 | 180 | if ( '' == $base ) 181 | $base = '/'; 182 | 183 | $query = "SELECT * FROM " . $wpdb->base_prefix . "blog_user_creator_queue WHERE blog_user_creator_site_ID = '" . $tmp_site_ID . "' AND blog_user_creator_blog_ID = '" . $tmp_blog_ID . "' LIMIT 1"; 184 | $tmp_creator_items = $wpdb->get_results( $query, ARRAY_A ); 185 | 186 | if (count($tmp_creator_items) > 0){ 187 | foreach ($tmp_creator_items as $tmp_creator_item){ 188 | 189 | if ($tmp_creator_item['blog_user_creator_blog_name'] == ''){ 190 | $tmp_create_blog = 'no'; 191 | } else { 192 | $tmp_create_blog = 'yes'; 193 | } 194 | if ($tmp_create_blog == 'yes'){ 195 | //setup domain / path 196 | $tmp_domain = strtolower( esc_html( $tmp_creator_item['blog_user_creator_blog_name'] ) ); 197 | $tmp_blog_title = stripslashes($tmp_creator_item['blog_user_creator_blog_title']); 198 | if( constant( "VHOST" ) == 'yes' ) { 199 | $tmp_blog_domain = $tmp_domain.".".$current_site->domain; 200 | $tmp_blog_path = $base; 201 | } else { 202 | $tmp_blog_domain = $current_site->domain; 203 | $tmp_blog_path = $base.$tmp_domain.'/'; 204 | } 205 | } 206 | //user bits 207 | $tmp_user_email = trim( esc_html( stripslashes( $tmp_creator_item['blog_user_creator_user_email'] ) ) ); 208 | $tmp_user_email_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->base_prefix . "users WHERE user_email = '" . $tmp_user_email . "'"); 209 | if ($tmp_user_email_count > 0){ 210 | //user already exists for email - use it! 211 | $user_id = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_email = '" . $tmp_user_email . "'"); 212 | //no new password: 213 | $tmp_user_pass = ''; 214 | } else { 215 | if ($tmp_creator_item['blog_user_creator_user_pass'] == '' || $tmp_creator_item['blog_user_creator_user_pass'] == strtolower('null')){ 216 | $tmp_user_pass = wp_generate_password(); 217 | } else { 218 | $tmp_user_pass = $tmp_creator_item['blog_user_creator_user_pass']; 219 | } 220 | $tmp_user_name = $tmp_creator_item['blog_user_creator_user_name']; 221 | $user_id = wpmu_create_user($tmp_user_name,$tmp_user_pass,$tmp_user_email); 222 | 223 | if( false !== $user_id ) 224 | wp_new_user_notification( $user_id, $tmp_user_pass ); 225 | } 226 | //blog bits 227 | $wpdb->hide_errors(); 228 | if ($tmp_create_blog == 'yes'){ 229 | //double check username 230 | if ($user_id == ''){ 231 | $user_id = $wpdb->get_var("SELECT ID FROM " . $wpdb->users . " WHERE user_email = '" . trim( esc_html( stripslashes( $tmp_creator_item['blog_user_creator_user_email'] ) ) ) . "'" ); 232 | } 233 | //double check password 234 | if ($tmp_user_pass == ''){ 235 | $tmp_user_pass = ''; 236 | } 237 | $blog_id = wpmu_create_blog( $tmp_blog_domain, $tmp_blog_path, esc_html( $tmp_blog_title ), $user_id, 1, $current_site->id ); 238 | //$wpdb->show_errors(); 239 | $wpdb->hide_errors(); 240 | if( !is_wp_error($blog_id) ) { 241 | $content_mail = sprintf( __( 'New blog created by %1s\n\nAddress: http://%2s\nName: %3s', 'blog_user_creator' ), $current_user->user_login , $tmp_blog_domain.$tmp_blog_path, esc_html( $tmp_blog_title ) ); 242 | @wp_mail( get_option('admin_email'), sprintf(__( '[%s] New Blog Created', 'blog_user_creator' ), $current_site->site_name), $content_mail ); 243 | //wp_redirect( add_query_arg( "updated", "blogadded", $_SERVER[ 'HTTP_REFERER' ] ) ); 244 | 245 | if ($tmp_creator_item['blog_user_creator_add_admin'] == 1){ 246 | add_user_to_blog($blog_id, $tmp_creator_item['blog_user_creator_admin_uid'], 'administrator'); 247 | } 248 | if ( '1' == $blog_user_creator_enable_blog_types && !empty( $blog_types ) ){ 249 | update_blog_option( $blog_id, 'blog_types', $tmp_creator_item['blog_user_creator_blog_types'] ); 250 | } 251 | //send email 252 | wpmu_welcome_notification($blog_id, $user_id, $tmp_user_pass, esc_html( $tmp_blog_title ), ''); 253 | } else { 254 | echo sprintf( __( 'Error creating blog: %1$s - %2$s', 'blog_user_creator' ), $tmp_add_blog_domain, $blog_id->get_error_message() ) . '
'; 255 | } 256 | } 257 | //=====================================================================// 258 | //=====================================================================// 259 | $wpdb->query( "DELETE FROM " . $wpdb->base_prefix . "blog_user_creator_queue WHERE blog_user_creator_blog_ID = '" . $wpdb->blogid . "' AND blog_user_creator_site_ID = '" . $wpdb->siteid . "' AND blog_user_creator_ID = '" . $tmp_creator_item['blog_user_creator_ID'] . "'" ); 260 | } 261 | } 262 | } 263 | 264 | function page_output() { 265 | global $wpdb, $wp_roles, $current_user, $user_ID, $current_site, $blog_types, $blog_types_selection, $blog_types_branding_singular, $blog_types_branding_plural, $base; 266 | 267 | $blog_user_creator_fields = $this->fields; 268 | $blog_user_creator_enable_blog_types = $this->enable_blog_types; 269 | $default_blog_type = $this->default_blog_type; 270 | 271 | if(!current_user_can('manage_options')) { 272 | ?> 273 |

274 |

'; 282 | $action = isset( $_GET[ 'action' ] ) ? $_GET[ 'action' ] : ''; 283 | switch( $action ) { 284 | //---------------------------------------------------// 285 | default: 286 | if ( isset( $_GET['advanced'] ) && 'true' == $_GET['advanced'] ) { 287 | ?> 288 |

()

289 | 290 |


You can create up to 15 different users and blogs at one time and new users will be emailed their usernames and passwords automatically. If you need more than 15 please simply process this form and then start again.

Please try to use unique usernames and blog URLs as this will make the process a lot quicker for you. An easy way to do this is to add numbers and letters after a regular name - for example \'James\' at \'Kings Heath School\' in year 10 could be \'jameskh10\'.', 'blog_user_creator' ) ?>

291 | 294 |
295 | 298 | 299 | 302 | 305 |

306 | 307 | 308 | 309 | 313 | 314 | 315 | 316 | 319 | 320 | 321 | 322 | 325 | 326 | 327 | 328 | 331 | 332 | 333 | 334 | 337 | 338 | 1){ 341 | if ($blog_types_selection == 'single' || $blog_types_selection == ''){ 342 | ?> 343 | 344 | 345 | 352 | 353 | 356 | 357 | 358 | 365 | 366 | 371 | 372 | 377 | 378 | 379 | 387 | 388 |
310 |
311 |
312 |
317 |
318 |
323 |
324 |
329 |
330 | domain . $current_site->path; ?>
335 |
336 |
385 |
386 |
389 | 394 |

395 | 396 |

397 |

398 |
399 | 402 |

()

403 | 404 |


You can create up to 15 different users and blogs at one time and new users will be emailed their usernames and passwords automatically. If you need more than 15 please simply process this form and then start again.

Please try to use unique usernames and blog URLs as this will make the process a lot quicker for you. An easy way to do this is to add numbers and letters after a regular name - for example \'James\' at \'Kings Heath School\' in year 10 could be \'jameskh10\'.', 'blog_user_creator' ) ?>

405 | 408 |
409 | 412 | 413 | 416 |

417 | 418 |

419 |

420 |

421 | 422 | 1){ 425 | if ($blog_types_selection == 'single' || $blog_types_selection == ''){ 426 | ?> 427 | 428 | 429 | 437 | 438 | 441 | 442 | 443 | 450 | 451 | 456 | 457 | 462 | 463 | 464 | 471 | 472 |
469 |
470 |
473 | 476 |

477 | 478 | 479 | 480 | 484 | 485 | 486 | 487 | 490 | 491 |
481 |
482 | domain . $current_site->path . '), try to choose something that will be unique - e.g. jamesqt3', 'blog_user_creator' ) ?>
483 |
488 |
489 |
492 | 495 |

496 | 497 |

498 |

499 |
500 | 501 | 509 | window.location='users.php?page=blog-user-creator&advanced=true'; 510 | 511 | "; 512 | } 513 | $tmp_batch_ID = md5($wpdb->blogid . time() . '0420i203zm'); 514 | $tmp_admin_uid = $user_ID; 515 | $tmp_stamp = time(); 516 | $tmp_errors = ''; 517 | $tmp_error_fields = ''; 518 | $tmp_error_messages = ''; 519 | $tmp_global_errors = 0; 520 | $tmp_creator_items = ''; 521 | 522 | for ( $counter = 1; $counter <= $blog_user_creator_fields; $counter += 1) { 523 | $tmp_user_name = $_POST['user_name_' . $counter]; 524 | $tmp_user_pass = $_POST['user_pass_' . $counter]; 525 | $tmp_user_email = $_POST['user_email_' . $counter]; 526 | $tmp_blog_name = $_POST['blog_url_' . $counter]; 527 | //=============================================// 528 | $tmp_blog_name = str_replace($current_site->domain,'',$tmp_blog_name); 529 | $tmp_blog_name = str_replace($current_site->path,'',$tmp_blog_name); 530 | $tmp_blog_name = str_replace("http://",'',$tmp_blog_name); 531 | //============================================// 532 | $tmp_blog_title = $_POST['blog_title_' . $counter]; 533 | $tmp_blog_title = stripslashes( $tmp_blog_title); 534 | //============================================// 535 | $tmp_blog_types = ''; 536 | if (count($blog_types) > 1){ 537 | if ($blog_types_selection == 'single' || $blog_types_selection == ''){ 538 | $tmp_blog_types = '|' . $_POST['blog_type_' . $counter] . '|'; 539 | } else if ($blog_types_selection == 'multiple') { 540 | $tmp_blog_types = '|' . join("|", $_POST['blog_types_' . $counter]) . '|'; 541 | } 542 | } else { 543 | $tmp_blog_types = isset( $_POST['blog_type'] ) ? '|' . $_POST['blog_type'] . '|' : ''; 544 | } 545 | //============================================// 546 | $tmp_add_admin = $_POST['add_admin_' . $counter]; 547 | $tmp_error = 0; 548 | $tmp_error_field = ''; 549 | $tmp_error_msg = ''; 550 | 551 | if ($tmp_user_name == '' && $tmp_user_pass == '' && $tmp_user_email == '' && $tmp_blog_name == '' && $tmp_blog_title == ''){ 552 | //nothing entered into any box so skip this one 553 | } else { 554 | //Check Blog 555 | //========================================// 556 | if ($tmp_blog_name != ''){ 557 | 558 | preg_match( "/[a-z0-9]+/", $tmp_blog_name, $maybe ); 559 | if( $tmp_blog_name != $maybe[0] ) { 560 | if ($tmp_error == ''){ 561 | $tmp_error = 1; 562 | $tmp_error_field = 'blog_url'; 563 | $tmp_error_msg = __( 'Only lowercase letters and numbers allowed', 'blog_user_creator' ); 564 | } 565 | } 566 | 567 | $illegal_names = get_site_option( "illegal_names" ); 568 | if( $illegal_names == false ) { 569 | $illegal_names = array( "www", "web", "root", "admin", "main", "invite", "administrator" ); 570 | add_site_option( "illegal_names", $illegal_names ); 571 | } 572 | if( in_array( $tmp_blog_name, $illegal_names ) == true ) { 573 | if ($tmp_error == ''){ 574 | $tmp_error = 1; 575 | $tmp_error_field = 'blog_url'; 576 | $tmp_error_msg = __( 'Sorry, that name is not allowed', 'blog_user_creator' ); 577 | } 578 | } 579 | if( strlen( $tmp_blog_name ) < 4 && !is_super_admin() ) { 580 | if ($tmp_error == ''){ 581 | $tmp_error = 1; 582 | $tmp_error_field = 'blog_url'; 583 | $tmp_error_msg = __( 'Sorry, blog name must be at least 4 characters', 'blog_user_creator' ); 584 | } 585 | } 586 | 587 | if ( strpos( ' ' . $tmp_blog_name, '_' ) != false ){ 588 | if ($tmp_error == ''){ 589 | $tmp_error = 1; 590 | $tmp_error_field = 'blog_url'; 591 | $tmp_error_msg = __( 'Sorry, blog names may not contain the character \'_\'', 'blog_user_creator' ); 592 | } 593 | } 594 | 595 | // all numeric? 596 | preg_match( '/[0-9]*/', $tmp_blog_name, $match ); 597 | if ( $match[0] == $tmp_blog_name ){ 598 | if ($tmp_error == ''){ 599 | $tmp_error = 1; 600 | $tmp_error_field = 'blog_url'; 601 | $tmp_error_msg = __( 'Sorry, blog names must have letters too', 'blog_user_creator' ); 602 | } 603 | } 604 | 605 | // taken? 606 | if ($base == ''){ 607 | $base = '/'; 608 | } 609 | $tmp_domain = strtolower( esc_html( $tmp_blog_name ) ); 610 | if( constant( "VHOST" ) == 'yes' ) { 611 | $tmp_blog_domain = $tmp_domain.".".$current_site->domain; 612 | $tmp_blog_path = $base; 613 | } else { 614 | $tmp_blog_domain = $current_site->domain; 615 | $tmp_blog_path = $base.$tmp_domain.'/'; 616 | } 617 | $tmp_blog_count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->blogs WHERE domain = '" . $tmp_blog_domain . "' AND path = '" . $tmp_blog_path . "'" ); 618 | if ( $tmp_blog_count > 0 ){ 619 | if ($tmp_error == ''){ 620 | $tmp_error = 1; 621 | $tmp_error_field = 'blog_url'; 622 | $tmp_error_msg = __( 'Sorry, that blog name already exists', 'blog_user_creator' ); 623 | } 624 | } 625 | 626 | if (empty($tmp_blog_title)) 627 | if ($tmp_error == ''){ 628 | $tmp_error = 1; 629 | $tmp_error_field = 'blog_title'; 630 | $tmp_error_msg = __( 'Please provide a blog title', 'blog_user_creator' ); 631 | } 632 | } 633 | //========================================// 634 | 635 | //Check User / Email 636 | //========================================// 637 | //no username and no email 638 | if ($tmp_user_name == '' && $tmp_user_email == ''){ 639 | if ($tmp_error == ''){ 640 | $tmp_error = 1; 641 | $tmp_error_field = 'user_email'; 642 | $tmp_error_msg = __( 'You must provide a valid email address', 'blog_user_creator' ); 643 | } 644 | } 645 | //username but no email 646 | if ($tmp_user_name != '' && $tmp_user_email == ''){ 647 | if ($tmp_error == ''){ 648 | $tmp_error = 1; 649 | $tmp_error_field = 'user_email'; 650 | $tmp_error_msg = __( 'You must provide a valid email address', 'blog_user_creator' ); 651 | } 652 | } 653 | //check user name exists 654 | $tmp_user_count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->users WHERE user_login = '" . $tmp_user_name . "'" ); 655 | if ($tmp_user_count > 0){ 656 | $tmp_user_email_count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->users WHERE user_login = '" . $tmp_user_name . "' AND user_email = '" . $tmp_user_email . "'" ); 657 | if ($tmp_user_email_count > 0){ 658 | //they just entered the username as well 659 | } else { 660 | //user exists and emails don't match 661 | if ($tmp_error == ''){ 662 | $tmp_error = 1; 663 | $tmp_error_field = 'user_name'; 664 | $tmp_error_msg = __( 'Sorry, that username already exists', 'blog_user_creator' ); 665 | } 666 | } 667 | } 668 | 669 | // Has someone already signed up for this username? 670 | $signup = $wpdb->get_row("SELECT * FROM $wpdb->signups WHERE user_login = '" . $tmp_user_name . "'"); 671 | if ( $signup != null ) { 672 | $registered_at = mysql2date('U', $signup->registered); 673 | $now = current_time( 'timestamp', true ); 674 | $diff = $now - $registered_at; 675 | // If registered more than two days ago, cancel registration and let this signup go through. 676 | if ( $diff > 172800 ) { 677 | $wpdb->query("DELETE FROM $wpdb->signups WHERE user_login = '" . $tmp_user_name . "'"); 678 | } else { 679 | if ($tmp_error == ''){ 680 | $tmp_error = 1; 681 | $tmp_error_field = 'user_name'; 682 | $tmp_error_msg = __( 'That username is currently reserved but may be available in a couple of days', 'blog_user_creator' ); 683 | } 684 | } 685 | } 686 | preg_match( '/[a-z0-9]+/', $tmp_user_name, $maybe ); 687 | if( $tmp_user_name != $maybe[0] ) { 688 | if ($tmp_error == ''){ 689 | $tmp_error = 1; 690 | $tmp_error_field = 'user_name'; 691 | $tmp_error_msg = __( 'Only lowercase letters and numbers allowed in usernames', 'blog_user_creator' ); 692 | } 693 | } 694 | $tmp_email_count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->users WHERE user_email = '" . $tmp_user_email . "'" ); 695 | if ($tmp_email_count > 0){ 696 | //bypass 697 | } else { 698 | //no username? 699 | if ( $tmp_user_name == '' ){ 700 | if ($tmp_error == ''){ 701 | $tmp_error = 1; 702 | $tmp_error_field = 'user_name'; 703 | $tmp_error_msg = __( 'You must provide a username', 'blog_user_creator' ); 704 | } 705 | } 706 | // all numeric? 707 | preg_match( '/[0-9]*/', $tmp_user_name, $match ); 708 | if ( $match[0] == $tmp_user_name ){ 709 | if ($tmp_error == ''){ 710 | $tmp_error = 1; 711 | $tmp_error_field = 'user_name'; 712 | $tmp_error_msg = __( 'Sorry, usernames must have letters too', 'blog_user_creator' ); 713 | } 714 | } 715 | if( strlen( $tmp_user_name ) < 4 ) { 716 | if ($tmp_error == ''){ 717 | $tmp_error = 1; 718 | $tmp_error_field = 'user_name'; 719 | $tmp_error_msg = __( 'Username must be at least 4 characters', 'blog_user_creator' ); 720 | } 721 | } 722 | if ( strpos( ' ' . $tmp_user_name, '_' ) != false ){ 723 | if ($tmp_error == ''){ 724 | $tmp_error = 1; 725 | $tmp_error_field = 'user_name'; 726 | $tmp_error_msg = __( 'Sorry, usernames may not contain the character \'_\'', 'blog_user_creator' ); 727 | } 728 | } 729 | 730 | $illegal_names = get_site_option( 'illegal_names' ); 731 | if( is_array( $illegal_names ) == false ) { 732 | $illegal_names = array( 'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator' ); 733 | add_site_option( 'illegal_names', $illegal_names ); 734 | } 735 | if( in_array( $tmp_user_name, $illegal_names ) == true ) { 736 | if ($tmp_error == ''){ 737 | $tmp_error = 1; 738 | $tmp_error_field = 'user_name'; 739 | $tmp_error_msg = __( 'That username is not allowed', 'blog_user_creator' ); 740 | } 741 | } 742 | } 743 | $tmp_email_count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->users WHERE user_email = '" . $tmp_user_email . "'" ); 744 | if ($tmp_email_count > 0){ 745 | //email already in system, let it through 746 | } else { 747 | if (is_email_address_unsafe($tmp_user_email)){ 748 | if ($tmp_error == ''){ 749 | $tmp_error = 1; 750 | $tmp_error_field = 'user_email'; 751 | $tmp_error_msg = __( 'You cannot use that email address. We are having problems with them blocking some of our email. Please use another email provider.', 'blog_user_creator' ); 752 | } 753 | } 754 | if ( !is_email( $tmp_user_email ) ) { 755 | if ($tmp_error == ''){ 756 | $tmp_error = 1; 757 | $tmp_error_field = 'user_email'; 758 | $tmp_error_msg = __( 'Please enter a correct email address', 'blog_user_creator' ); 759 | } 760 | } 761 | $limited_email_domains = get_site_option( 'limited_email_domains' ); 762 | if ( is_array( $limited_email_domains ) && empty( $limited_email_domains ) == false ) { 763 | $emaildomain = substr( $tmp_user_email, 1 + strpos( $tmp_user_email, '@' ) ); 764 | if( in_array( $emaildomain, $limited_email_domains ) == false ) { 765 | if ($tmp_error == ''){ 766 | $tmp_error = 1; 767 | $tmp_error_field = 'user_email'; 768 | $tmp_error_msg = __( 'Sorry, that email address is not allowed', 'blog_user_creator' ); 769 | } 770 | } 771 | } 772 | } 773 | //========================================// 774 | $tmp_creator_items[$counter]['user_name'] = $tmp_user_name; 775 | $tmp_creator_items[$counter]['user_email'] = $tmp_user_email; 776 | $tmp_creator_items[$counter]['user_pass'] = $tmp_user_pass; 777 | $tmp_creator_items[$counter]['blog_name'] = $tmp_blog_name; 778 | $tmp_creator_items[$counter]['blog_title'] = $tmp_blog_title; 779 | $tmp_creator_items[$counter]['blog_types'] = $tmp_blog_types; 780 | $tmp_creator_items[$counter]['add_admin'] = $tmp_add_admin; 781 | 782 | $tmp_errors[$counter] = $tmp_error; 783 | $tmp_error_fields[$counter] = $tmp_error_field; 784 | $tmp_error_messages[$counter] = $tmp_error_msg; 785 | if ($tmp_error == 1){ 786 | $tmp_global_errors = $tmp_global_errors + 1; 787 | } 788 | } 789 | } 790 | if ($tmp_global_errors > 0){ 791 | //========================================// 792 | //houston... we have error(s) 793 | ?> 794 |

795 | 796 |

797 | 798 | 801 |
802 | 805 | 806 | 809 | 813 |

814 | 815 | 816 |

817 |

818 | 824 |

825 | 828 |

829 | 832 | 833 | 834 | 835 | 839 | 840 | 841 | 842 | 845 | 846 | 847 | 848 | 851 | 852 | 853 | 854 | 857 | 858 | 859 | 860 | 863 | 864 | 1){ 867 | if ($blog_types_selection == 'single' || $blog_types_selection == ''){ 868 | $tmp_blog_type = $_POST['blog_type_' . $counter]; 869 | ?> 870 | 871 | 872 | 879 | 880 | 883 | 884 | 885 | 904 | 905 | 912 | 913 | 918 | 919 | 920 | 926 | 927 |
836 |
837 |
838 |
843 |
844 |
849 |
850 |
855 |
856 | domain . $current_site->path; ?>
861 |
862 |
924 |
925 |
928 | 933 |

934 | 935 | 936 |

937 |

938 |
939 | ' . __( 'Creatings blogs...', 'blog_user_creator' ) . '

'; 945 | 946 | if( $tmp_creator_items ) { 947 | foreach ( $tmp_creator_items as $tmp_creator_item ) { 948 | $this->queue_insert( $tmp_batch_ID, $tmp_stamp, $tmp_creator_item['blog_name'], addslashes( $tmp_creator_item['blog_title'] ),$tmp_creator_item['blog_types'], $tmp_creator_item['add_admin'], $tmp_admin_uid, $tmp_creator_item['user_name'],$tmp_creator_item['user_pass'], addslashes( $tmp_creator_item['user_email'] ) ); 949 | } 950 | } 951 | $tmp_queue_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->base_prefix . "blog_user_creator_queue WHERE blog_user_creator_site_ID = '" . $wpdb->siteid . "' AND blog_user_creator_blog_ID = '" . $wpdb->blogid . "'" ); 952 | if ($tmp_queue_count > 0){ 953 | echo " 954 | 957 | "; 958 | } else { 959 | echo " 960 | 963 | "; 964 | } 965 | 966 | //========================================// 967 | } 968 | break; 969 | //---------------------------------------------------// 970 | case "simple_process": 971 | if ( isset($_POST['Cancel']) ) { 972 | echo " 973 | 976 | "; 977 | } 978 | $tmp_batch_ID = 'sp' . md5($wpdb->blogid . time() . '0420i203zm'); 979 | $tmp_admin_uid = $user_ID; 980 | $tmp_stamp = time(); 981 | $tmp_errors = ''; 982 | $tmp_error_fields = ''; 983 | $tmp_error_messages = ''; 984 | $tmp_global_errors = 0; 985 | $tmp_creator_items = ''; 986 | 987 | for ( $counter = 1; $counter <= $blog_user_creator_fields; $counter += 1) { 988 | $tmp_user_name = $_POST['blog_user_name_' . $counter]; 989 | $tmp_user_email = $_POST['user_email_' . $counter]; 990 | $tmp_blog_name = $_POST['blog_user_name_' . $counter]; 991 | //=============================================// 992 | $tmp_blog_name = str_replace($current_site->domain,'',$tmp_blog_name); 993 | $tmp_blog_name = str_replace($current_site->path,'',$tmp_blog_name); 994 | $tmp_blog_name = str_replace("http://",'',$tmp_blog_name); 995 | //============================================// 996 | $tmp_blog_title = sprintf( __( '%s \'s Blog', 'blog_user_creator' ), $tmp_blog_name ); 997 | $tmp_blog_title = stripslashes( $tmp_blog_title); 998 | //============================================// 999 | $tmp_blog_types = ''; 1000 | if (count($blog_types) > 1){ 1001 | if ($blog_types_selection == 'single' || $blog_types_selection == ''){ 1002 | $tmp_blog_types = '|' . $_POST['blog_type'] . '|'; 1003 | } else if ($blog_types_selection == 'multiple') { 1004 | $tmp_blog_types = '|' . join("|", $_POST['blog_types']) . '|'; 1005 | } 1006 | } else { 1007 | $tmp_blog_types = isset( $_POST['blog_type'] ) ? '|' . $_POST['blog_type'] . '|' : ''; 1008 | } 1009 | //============================================// 1010 | $tmp_add_admin = $_POST['add_admin']; 1011 | $tmp_error = 0; 1012 | $tmp_error_field = ''; 1013 | $tmp_error_msg = ''; 1014 | 1015 | if ( !( $tmp_user_name == '' && $tmp_user_email == '' ) ) { 1016 | preg_match( "/[a-z0-9]+/", $tmp_blog_name, $maybe ); 1017 | if( isset( $maybe[0] ) && $tmp_blog_name != $maybe[0] ) { 1018 | if ($tmp_error == ''){ 1019 | $tmp_error = 1; 1020 | $tmp_error_field = 'blog_user_name'; 1021 | $tmp_error_msg = __( 'Only lowercase letters and numbers allowed', 'blog_user_creator' ); 1022 | } 1023 | } 1024 | 1025 | $illegal_names = get_site_option( 'illegal_names' ); 1026 | if( $illegal_names == false ) { 1027 | $illegal_names = array( 'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator' ); 1028 | add_site_option( 'illegal_names', $illegal_names ); 1029 | } 1030 | if( in_array( $tmp_blog_name, $illegal_names ) == true ) { 1031 | if ($tmp_error == ''){ 1032 | $tmp_error = 1; 1033 | $tmp_error_field = 'blog_user_name'; 1034 | $tmp_error_msg = __( 'Sorry, that name is not allowed', 'blog_user_creator' ); 1035 | } 1036 | } 1037 | if( strlen( $tmp_blog_name ) < 4 && !is_super_admin() ) { 1038 | if ($tmp_error == ''){ 1039 | $tmp_error = 1; 1040 | $tmp_error_field = 'blog_user_name'; 1041 | $tmp_error_msg = __( 'Sorry, blog/user names must be at least 4 characters', 'blog_user_creator' ); 1042 | } 1043 | } 1044 | 1045 | if ( strpos( ' ' . $tmp_blog_name, '_' ) != false ){ 1046 | if ($tmp_error == ''){ 1047 | $tmp_error = 1; 1048 | $tmp_error_field = 'blog_user_name'; 1049 | $tmp_error_msg = __( 'Sorry, blog/user names may not contain the character \'_\'', 'blog_user_creator' ); 1050 | } 1051 | } 1052 | 1053 | // all numeric? 1054 | preg_match( '/[0-9]*/', $tmp_blog_name, $match ); 1055 | if ( $match[0] == $tmp_blog_name ){ 1056 | if ($tmp_error == ''){ 1057 | $tmp_error = 1; 1058 | $tmp_error_field = 'blog_user_name'; 1059 | $tmp_error_msg = __( 'Sorry, blog/user names must have letters too', 'blog_user_creator' ); 1060 | } 1061 | } 1062 | 1063 | // taken? 1064 | if ($base == ''){ 1065 | $base = '/'; 1066 | } 1067 | $tmp_domain = strtolower( esc_html( $tmp_blog_name ) ); 1068 | if( constant( 'VHOST' ) == 'yes' ) { 1069 | $tmp_blog_domain = $tmp_domain.'.'.$current_site->domain; 1070 | $tmp_blog_path = $base; 1071 | } else { 1072 | $tmp_blog_domain = $current_site->domain; 1073 | $tmp_blog_path = $base.$tmp_domain.'/'; 1074 | } 1075 | $tmp_blog_count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->blogs WHERE domain = '" . $tmp_blog_domain . "' AND path = '" . $tmp_blog_path . "'" ); 1076 | if ( $tmp_blog_count > 0 ){ 1077 | if ($tmp_error == ''){ 1078 | $tmp_error = 1; 1079 | $tmp_error_field = 'blog_user_name'; 1080 | $tmp_error_msg = __( 'Sorry, that blog/user name already exists', 'blog_user_creator' ); 1081 | } 1082 | } 1083 | 1084 | //no username and no email 1085 | if ($tmp_user_name == '' && $tmp_user_email == ''){ 1086 | if ($tmp_error == ''){ 1087 | $tmp_error = 1; 1088 | $tmp_error_field = 'user_email'; 1089 | $tmp_error_msg = __( 'You must provide a valid email address', 'blog_user_creator' ); 1090 | } 1091 | } 1092 | //username but no email 1093 | if ($tmp_user_name != '' && $tmp_user_email == ''){ 1094 | if ($tmp_error == ''){ 1095 | $tmp_error = 1; 1096 | $tmp_error_field = 'user_email'; 1097 | $tmp_error_msg = __( 'You must provide a valid email address', 'blog_user_creator' ); 1098 | } 1099 | } 1100 | //check user name exists 1101 | $tmp_user_count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->users WHERE user_login = '" . $tmp_user_name . "'" ); 1102 | if ($tmp_user_count > 0){ 1103 | $tmp_user_email_count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->users WHERE user_login = '" . $tmp_user_name . "' AND user_email = '" . $tmp_user_email . "'" ); 1104 | if ($tmp_user_email_count > 0){ 1105 | //they just entered the username as well 1106 | } else { 1107 | //user exists and emails don't match 1108 | if ($tmp_error == ''){ 1109 | $tmp_error = 1; 1110 | $tmp_error_field = 'blog_user_name'; 1111 | $tmp_error_msg = __( 'Sorry, that blog/user name already exists', 'blog_user_creator' ); 1112 | } 1113 | } 1114 | } 1115 | 1116 | // Has someone already signed up for this username? 1117 | $signup = $wpdb->get_row("SELECT * FROM $wpdb->signups WHERE user_login = '" . $tmp_user_name . "'"); 1118 | if ( $signup != null ) { 1119 | $registered_at = mysql2date('U', $signup->registered); 1120 | $now = current_time( 'timestamp', true ); 1121 | $diff = $now - $registered_at; 1122 | // If registered more than two days ago, cancel registration and let this signup go through. 1123 | if ( $diff > 172800 ) { 1124 | $wpdb->query("DELETE FROM $wpdb->signups WHERE user_login = '" . $tmp_user_name . "'"); 1125 | } else { 1126 | if ($tmp_error == ''){ 1127 | $tmp_error = 1; 1128 | $tmp_error_field = 'blog_user_name'; 1129 | $tmp_error_msg = __( 'That blog/user name is currently reserved but may be available in a couple of days', 'blog_user_creator' ); 1130 | } 1131 | } 1132 | } 1133 | 1134 | preg_match( '/[a-z0-9]+/', $tmp_user_name, $maybe ); 1135 | if( isset( $maybe[0] ) && $tmp_user_name != $maybe[0] ) { 1136 | if ($tmp_error == ''){ 1137 | $tmp_error = 1; 1138 | $tmp_error_field = 'blog_user_name'; 1139 | $tmp_error_msg = __( 'Only lowercase letters and numbers allowed in usernames', 'blog_user_creator' ); 1140 | } 1141 | } 1142 | $tmp_email_count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->users WHERE user_email = '" . $tmp_user_email . "'" ); 1143 | if ($tmp_email_count > 0){ 1144 | //bypass 1145 | } else { 1146 | //no username? 1147 | if ( $tmp_user_name == '' ){ 1148 | if ($tmp_error == ''){ 1149 | $tmp_error = 1; 1150 | $tmp_error_field = 'blog_user_name'; 1151 | $tmp_error_msg = __( 'You must provide a blog/user name', 'blog_user_creator' ); 1152 | } 1153 | } 1154 | // all numeric? 1155 | preg_match( '/[0-9]*/', $tmp_user_name, $match ); 1156 | if ( $match[0] == $tmp_user_name ){ 1157 | if ($tmp_error == ''){ 1158 | $tmp_error = 1; 1159 | $tmp_error_field = 'blog_user_name'; 1160 | $tmp_error_msg = __( 'Sorry, blog/user names must have letters too', 'blog_user_creator' ); 1161 | } 1162 | } 1163 | if( strlen( $tmp_user_name ) < 4 ) { 1164 | if ($tmp_error == ''){ 1165 | $tmp_error = 1; 1166 | $tmp_error_field = 'blog_user_name'; 1167 | $tmp_error_msg = __( 'Sorry, blog/user names must be at least 4 characters', 'blog_user_creator' ); 1168 | } 1169 | } 1170 | if ( strpos( ' ' . $tmp_user_name, '_' ) != false ){ 1171 | if ($tmp_error == ''){ 1172 | $tmp_error = 1; 1173 | $tmp_error_field = 'blog_user_name'; 1174 | $tmp_error_msg = __( 'Sorry, blog/user names may not contain the character \'_\'', 'blog_user_creator' ); 1175 | } 1176 | } 1177 | 1178 | $illegal_names = get_site_option( 'illegal_names' ); 1179 | if( is_array( $illegal_names ) == false ) { 1180 | $illegal_names = array( 'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator' ); 1181 | add_site_option( 'illegal_names', $illegal_names ); 1182 | } 1183 | if( in_array( $tmp_user_name, $illegal_names ) == true ) { 1184 | if ($tmp_error == ''){ 1185 | $tmp_error = 1; 1186 | $tmp_error_field = 'blog_user_name'; 1187 | $tmp_error_msg = __( 'Sorry, that blog/user name is not allowed', 'blog_user_creator' ); 1188 | } 1189 | } 1190 | } 1191 | $tmp_email_count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->users WHERE user_email = '" . $tmp_user_email . "'" ); 1192 | if ($tmp_email_count > 0){ 1193 | //email already in system, let it through 1194 | } else { 1195 | if (is_email_address_unsafe($tmp_user_email)){ 1196 | if ($tmp_error == ''){ 1197 | $tmp_error = 1; 1198 | $tmp_error_field = 'user_email'; 1199 | $tmp_error_msg = __( 'You cannot use that email address. We are having problems with them blocking some of our email. Please use another email provider.', 'blog_user_creator' ); 1200 | } 1201 | } 1202 | if ( !is_email( $tmp_user_email ) ) { 1203 | if ($tmp_error == ''){ 1204 | $tmp_error = 1; 1205 | $tmp_error_field = 'user_email'; 1206 | $tmp_error_msg = __( 'Please enter a correct email address', 'blog_user_creator' ); 1207 | } 1208 | } 1209 | $limited_email_domains = get_site_option( 'limited_email_domains' ); 1210 | if ( is_array( $limited_email_domains ) && empty( $limited_email_domains ) == false ) { 1211 | $emaildomain = substr( $tmp_user_email, 1 + strpos( $tmp_user_email, '@' ) ); 1212 | if( in_array( $emaildomain, $limited_email_domains ) == false ) { 1213 | if ($tmp_error == ''){ 1214 | $tmp_error = 1; 1215 | $tmp_error_field = 'user_email'; 1216 | $tmp_error_msg = __( 'Sorry, that email address is not allowed', 'blog_user_creator' ); 1217 | } 1218 | } 1219 | } 1220 | } 1221 | //========================================// 1222 | $tmp_creator_items[$counter]['user_name'] = $tmp_user_name; 1223 | $tmp_creator_items[$counter]['user_email'] = $tmp_user_email; 1224 | $tmp_creator_items[$counter]['user_pass'] = isset( $tmp_user_pass ) ? $tmp_user_pass : ''; 1225 | $tmp_creator_items[$counter]['blog_name'] = $tmp_blog_name; 1226 | $tmp_creator_items[$counter]['blog_title'] = $tmp_blog_title; 1227 | $tmp_creator_items[$counter]['blog_types'] = $tmp_blog_types; 1228 | $tmp_creator_items[$counter]['add_admin'] = $tmp_add_admin; 1229 | 1230 | $tmp_errors[$counter] = $tmp_error; 1231 | $tmp_error_fields[$counter] = $tmp_error_field; 1232 | $tmp_error_messages[$counter] = $tmp_error_msg; 1233 | if ($tmp_error == 1){ 1234 | $tmp_global_errors = $tmp_global_errors + 1; 1235 | } 1236 | } 1237 | } 1238 | if ( $tmp_global_errors > 0 ) { 1239 | ?> 1240 |

1241 | 1242 |

1243 | 1244 | 1247 |
1248 | 1251 | 1252 | 1255 |

1256 | 1257 | 1){ 1260 | if ($blog_types_selection == 'single' || $blog_types_selection == ''){ 1261 | ?> 1262 | 1263 | 1264 | 1271 | 1272 | 1275 | 1276 | 1277 | 1284 | 1285 | 1290 | 1291 | 1296 | 1297 | 1298 | 1304 | 1305 |
1302 |
1303 |
1306 | 1310 |

1311 | 1312 | 1313 |

1314 |

1315 | 1321 |

1322 | 1325 |

1326 | 1329 | 1330 | 1331 | 1332 | 1336 | 1337 | 1338 | 1339 | 1342 | 1343 |
1333 |
1334 | domain, $current_site->path ) ?>
1335 |
1340 |
1341 |
1344 | 1349 |

1350 | 1351 | 1352 |

1353 |

1354 |
1355 | ' . __( 'Creatings blogs...', 'blog_user_creator' ) . '

'; 1361 | 1362 | if( $tmp_creator_items ) { 1363 | foreach ( $tmp_creator_items as $tmp_creator_item ) { 1364 | $this->queue_insert( $tmp_batch_ID, $tmp_stamp, $tmp_creator_item['blog_name'], addslashes( $tmp_creator_item['blog_title'] ),$tmp_creator_item['blog_types'], $tmp_creator_item['add_admin'], $tmp_admin_uid, $tmp_creator_item['user_name'],$tmp_creator_item['user_pass'], addslashes( $tmp_creator_item['user_email'] ) ); 1365 | } 1366 | } 1367 | $tmp_queue_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->base_prefix . "blog_user_creator_queue WHERE blog_user_creator_site_ID = '" . $wpdb->siteid . "' AND blog_user_creator_blog_ID = '" . $wpdb->blogid . "'" ); 1368 | if ($tmp_queue_count > 0){ 1369 | echo " 1370 | 1373 | "; 1374 | } else { 1375 | echo " 1376 | 1379 | "; 1380 | } 1381 | 1382 | //========================================// 1383 | } 1384 | break; 1385 | //---------------------------------------------------// 1386 | case "process_queue": 1387 | echo '

' . __( 'Creatings blogs...', 'blog_user_creator' ) . '

'; 1388 | $tmp_queue_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->base_prefix . "blog_user_creator_queue WHERE blog_user_creator_site_ID = '" . $wpdb->siteid . "' AND blog_user_creator_blog_ID = '" . $wpdb->blogid . "'" ); 1389 | $this->queue_process( $wpdb->blogid, $wpdb->siteid ); 1390 | 1391 | if ($tmp_queue_count > 0){ 1392 | echo " 1393 | 1396 | "; 1397 | } else { 1398 | echo " 1399 | 1402 | "; 1403 | } 1404 | break; 1405 | } 1406 | echo ''; 1407 | } 1408 | 1409 | } 1410 | $blog_user_creator =& new Blog_User_Creator(); 1411 | 1412 | 1413 | /** 1414 | * Show notification if WPMUDEV Update Notifications plugin is not installed 1415 | **/ 1416 | if ( !function_exists( 'wdp_un_check' ) ) { 1417 | add_action( 'admin_notices', 'wdp_un_check', 5 ); 1418 | add_action( 'network_admin_notices', 'wdp_un_check', 5 ); 1419 | 1420 | function wdp_un_check() { 1421 | if ( !class_exists( 'WPMUDEV_Update_Notifications' ) && current_user_can( 'edit_users' ) ) 1422 | echo '

' . __('Please install the latest version of our free Update Notifications plugin which helps you stay up-to-date with the most stable, secure versions of WPMU DEV themes and plugins. More information »', 'wpmudev') . '

'; 1423 | } 1424 | } 1425 | --------------------------------------------------------------------------------