function handleSettingsPost()
 {
     if (isset($_GET['page'])) {
         if ($_GET['page'] == 'DashboardOptions') {
             if (isset($_POST['submit'])) {
                 MainWP_Utility::update_option('mainwp_use_favicon', !isset($_POST['mainwp_use_favicon']) ? 0 : 1);
                 MainWP_Utility::update_option('mainwp_hide_footer', !isset($_POST['mainwp_hide_footer']) ? 0 : 1);
                 MainWP_Utility::update_option('mainwp_hide_tips', !isset($_POST['mainwp_hide_tips']) ? 0 : 1);
                 $enabled_twit = !isset($_POST['mainwp_hide_twitters_message']) ? 0 : 1;
                 MainWP_Utility::update_option('mainwp_hide_twitters_message', $enabled_twit);
                 if (!$enabled_twit) {
                     MainWP_Twitter::clearAllTwitterMessages();
                 }
             }
         } else {
             if ($_GET['page'] == 'Settings') {
                 if (isset($_POST['submit'])) {
                     if (isset($_POST['mainwp_primaryBackup'])) {
                         MainWP_Utility::update_option('mainwp_primaryBackup', $_POST['mainwp_primaryBackup']);
                     }
                 }
             } else {
                 if ($_GET['page'] == 'MainWPTools') {
                     if (isset($_POST['submit'])) {
                         $hide_menus = array();
                         if (isset($_POST['mainwp_hide_wpmenu']) && is_array($_POST['mainwp_hide_wpmenu']) && count($_POST['mainwp_hide_wpmenu']) > 0) {
                             foreach ($_POST['mainwp_hide_wpmenu'] as $value) {
                                 $hide_menus[] = $value;
                             }
                         }
                         MainWP_Utility::update_option('mwp_setup_hide_wp_menus', $hide_menus);
                     }
                 }
             }
         }
     }
     if (isset($_POST['select_mainwp_options_siteview'])) {
         $userExtension = MainWP_DB::Instance()->getUserExtension();
         $userExtension->site_view = empty($_POST['select_mainwp_options_siteview']) ? 0 : 1;
         MainWP_DB::Instance()->updateUserExtension($userExtension);
     }
 }
Exemple #2
0
    public static function posting()
    {
        //Posts the saved sites
        ?>
		<div class="wrap">
			<h2>New Post</h2>
			<?php 
        do_action('mainwp_bulkpost_before_post', $_GET['id']);
        $skip_post = false;
        if (isset($_GET['id'])) {
            if ('yes' == get_post_meta($_GET['id'], '_mainwp_skip_posting', true)) {
                $skip_post = true;
                wp_delete_post($_GET['id'], true);
            }
        }
        if (!$skip_post) {
            if (isset($_GET['id'])) {
                $id = $_GET['id'];
                $post = get_post($id);
                if ($post) {
                    //                die('<pre>'.print_r($post, 1).'</pre>');
                    $selected_by = get_post_meta($id, '_selected_by', true);
                    $selected_sites = unserialize(base64_decode(get_post_meta($id, '_selected_sites', true)));
                    $selected_groups = unserialize(base64_decode(get_post_meta($id, '_selected_groups', true)));
                    /** @deprecated */
                    $post_category = base64_decode(get_post_meta($id, '_categories', true));
                    $post_tags = base64_decode(get_post_meta($id, '_tags', true));
                    $post_slug = base64_decode(get_post_meta($id, '_slug', true));
                    $post_custom = get_post_custom($id);
                    //                if (isset($post_custom['_tags'])) $post_custom['_tags'] = base64_decode(trim($post_custom['_tags']));
                    include_once ABSPATH . 'wp-includes' . DIRECTORY_SEPARATOR . 'post-thumbnail-template.php';
                    $post_featured_image = get_post_thumbnail_id($id);
                    $mainwp_upload_dir = wp_upload_dir();
                    $new_post = array('post_title' => $post->post_title, 'post_content' => $post->post_content, 'post_status' => $post->post_status, 'post_date' => $post->post_date, 'post_date_gmt' => $post->post_date_gmt, 'post_tags' => $post_tags, 'post_name' => $post_slug, 'post_excerpt' => $post->post_excerpt, 'comment_status' => $post->comment_status, 'ping_status' => $post->ping_status, 'id_spin' => $post->ID);
                    if ($post_featured_image != null) {
                        //Featured image is set, retrieve URL
                        $img = wp_get_attachment_image_src($post_featured_image, 'full');
                        $post_featured_image = $img[0];
                    }
                    $dbwebsites = array();
                    if ($selected_by == 'site') {
                        //Get all selected websites
                        foreach ($selected_sites as $k) {
                            if (MainWP_Utility::ctype_digit($k)) {
                                $website = MainWP_DB::Instance()->getWebsiteById($k);
                                $dbwebsites[$website->id] = MainWP_Utility::mapSite($website, array('id', 'url', 'name', 'adminname', 'nossl', 'privkey', 'nosslkey'));
                            }
                        }
                    } else {
                        //Get all websites from the selected groups
                        foreach ($selected_groups as $k) {
                            if (MainWP_Utility::ctype_digit($k)) {
                                $websites = MainWP_DB::Instance()->query(MainWP_DB::Instance()->getSQLWebsitesByGroupId($k));
                                while ($websites && ($website = @MainWP_DB::fetch_object($websites))) {
                                    if ($website->sync_errors != '') {
                                        continue;
                                    }
                                    $dbwebsites[$website->id] = MainWP_Utility::mapSite($website, array('id', 'url', 'name', 'adminname', 'nossl', 'privkey', 'nosslkey'));
                                }
                                @MainWP_DB::free_result($websites);
                            }
                        }
                    }
                    $output = new stdClass();
                    $output->ok = array();
                    $output->errors = array();
                    $startTime = time();
                    if (count($dbwebsites) > 0) {
                        $post_data = array('new_post' => base64_encode(serialize($new_post)), 'post_custom' => base64_encode(serialize($post_custom)), 'post_category' => base64_encode($post_category), 'post_featured_image' => base64_encode($post_featured_image), 'mainwp_upload_dir' => base64_encode(serialize($mainwp_upload_dir)));
                        MainWP_Utility::fetchUrlsAuthed($dbwebsites, 'newpost', $post_data, array(MainWP_Bulk_Add::getClassName(), 'PostingBulk_handler'), $output);
                    }
                    $failed_posts = array();
                    foreach ($dbwebsites as $website) {
                        if ($output->ok[$website->id] == 1 && isset($output->added_id[$website->id])) {
                            do_action('mainwp-post-posting-post', $website, $output->added_id[$website->id], isset($output->link[$website->id]) ? $output->link[$website->id] : null);
                            do_action('mainwp-bulkposting-done', $post, $website, $output);
                        } else {
                            $failed_posts[] = $website->id;
                        }
                    }
                    $del_post = true;
                    $saved_draft = get_post_meta($id, '_saved_as_draft', true);
                    if ($saved_draft == 'yes') {
                        if (count($failed_posts) > 0) {
                            $del_post = false;
                            update_post_meta($post->ID, '_selected_sites', base64_encode(serialize($failed_posts)));
                            update_post_meta($post->ID, '_selected_groups', '');
                            wp_update_post(array('ID' => $id, 'post_status' => 'draft'));
                        }
                    }
                    if ($del_post) {
                        wp_delete_post($id, true);
                    }
                    $countSites = 0;
                    $countRealItems = 0;
                    foreach ($dbwebsites as $website) {
                        if (isset($output->ok[$website->id]) && $output->ok[$website->id] == 1) {
                            $countSites++;
                            $countRealItems++;
                        }
                    }
                    if (!empty($countSites)) {
                        $seconds = time() - $startTime;
                        MainWP_Twitter::updateTwitterInfo('new_post', $countSites, $seconds, $countRealItems, $startTime, 1);
                    }
                    if (MainWP_Twitter::enabledTwitterMessages()) {
                        $twitters = MainWP_Twitter::getTwitterNotice('new_post');
                        if (is_array($twitters)) {
                            foreach ($twitters as $timeid => $twit_mess) {
                                if (!empty($twit_mess)) {
                                    $sendText = MainWP_Twitter::getTwitToSend('new_post', $timeid);
                                    ?>
										<div class="mainwp-tips mainwp_info-box-blue twitter">
											<span class="mainwp-tip" twit-what="new_post" twit-id="<?php 
                                    echo $timeid;
                                    ?>
"><?php 
                                    echo $twit_mess;
                                    ?>
</span>&nbsp;<?php 
                                    MainWP_Twitter::genTwitterButton($sendText);
                                    ?>
											<span><a href="#" class="mainwp-dismiss-twit"><i class="fa fa-times-circle"></i> <?php 
                                    _e('Dismiss', 'mainwp');
                                    ?>
												</a></span></div>
										<?php 
                                }
                            }
                        }
                    }
                    ?>

						<div id="message" class="updated">
							<?php 
                    foreach ($dbwebsites as $website) {
                        ?>
								<p>
									<a href="<?php 
                        echo admin_url('admin.php?page=managesites&dashboard=' . $website->id);
                        ?>
"><?php 
                        echo stripslashes($website->name);
                        ?>
</a>
									: <?php 
                        echo isset($output->ok[$website->id]) && $output->ok[$website->id] == 1 ? 'New post created. ' . '<a href="' . $output->link[$website->id] . '" target="_blank">View Post</a>' : 'ERROR: ' . $output->errors[$website->id];
                        ?>
								</p>
							<?php 
                    }
                    ?>
						</div>
						<?php 
                }
                // if ($post)
            } else {
                ?>
					<div class="error below-h2">
						<p>
							<strong><?php 
                _e('ERROR', 'mainwp');
                ?>
</strong>: <?php 
                _e('An undefined error occured.', 'mainwp');
                ?>
						</p>
					</div>
					<?php 
            }
        }
        // no skip posting
        ?>
			<br/>
			<a href="<?php 
        echo get_admin_url();
        ?>
admin.php?page=PostBulkAdd" class="add-new-h2" target="_top"><?php 
        _e('Add New', 'mainwp');
        ?>
</a>
			<a href="<?php 
        echo get_admin_url();
        ?>
admin.php?page=mainwp_tab" class="add-new-h2" target="_top"><?php 
        _e('Return
            to Dashboard', 'mainwp');
        ?>
</a>

		</div>
		<?php 
    }
Exemple #3
0
    public static function renderDashboardBody($websites, $pDashboard, $pScreenLayout)
    {
        $opts = get_option('mainwp_opts_showhide_sections', false);
        $hide_shortcuts = is_array($opts) && isset($opts['welcome_shortcuts']) && $opts['welcome_shortcuts'] == 'hide' ? true : false;
        ?>
		<form action="admin-post.php" method="post">
			<?php 
        wp_nonce_field('mainwp_tab-general');
        ?>
			<?php 
        wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
        ?>
			<?php 
        wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
        ?>
			<input type="hidden" name="action" value="save_howto_testPages_general"/>

			<div id="mainwp-welocme-bar" class="welcome-panel" style="padding-left: 2em;">
				<table id="mainwp-refresh-bar" width="100%">
					<tbody>
					<tr>
						<td>
							<div id="mainwp-welocme-bar-top">
                    <span style="float:right;">
                    <a style="font-size: 18px;" class="button-hero button mainwp-upgrade-button" id="dashboard_refresh" title="<?php 
        echo MainWP_Right_Now::renderLastUpdate();
        ?>
"><i class="fa fa-refresh"></i> <?php 
        _e('Sync Data with Child Sites', 'mainwp');
        ?>
</a>
                    <a style="font-size: 18px;" class="button-hero button-primary button" target="_blank" href="https://extensions.mainwp.com"><i class="fa fa-cart-plus"></i> <?php 
        _e('Get New Extensions', 'mainwp');
        ?>
</a>
                    </span>
								<?php 
        $current_wp_id = MainWP_Utility::get_current_wpid();
        $website = null;
        if (!empty($current_wp_id)) {
            $website = $websites[0];
        }
        $imgfavi = '';
        if ($website !== null) {
            if (get_option('mainwp_use_favicon', 1) == 1) {
                $favi = MainWP_DB::Instance()->getWebsiteOption($website, 'favi_icon', '');
                $favi_url = MainWP_Utility::get_favico_url($favi, $website);
                $imgfavi = '<img src="' . $favi_url . '" width="16" height="16" style="vertical-align:middle;"/>&nbsp;';
            }
        }
        if ($website !== null) {
            if (time() - $website->dtsSync > 60 * 60 * 24) {
                ?>
<h3>
										<i class="fa fa-flag"></i> <?php 
                _e('Your MainWP Dashboard has not been synced for 24 hours!', 'mainwp');
                ?>
										</h3>
										<p class="about-description"><?php 
                _e('Click the Sync Data button to get the latest data from child sites.', 'mainwp');
                ?>
</p>
										<?php 
            } else {
                ?>
										<h3><?php 
                echo sprintf(__('Welcome to %s Dashboard!', 'mainwp'), stripslashes($website->name));
                ?>
</h3>
										<p class="about-description"><?php 
                echo sprintf(__('This information is only for %s%s', 'mainwp'), $imgfavi, MainWP_Utility::getNiceURL($website->url, true));
                ?>
</p>
										<?php 
            }
        } else {
            $sync_status = MainWP_DB::Instance()->getLastSyncStatus();
            if ($sync_status === 'not_synced') {
                ?>
<h3>
										<i class="fa fa-flag"></i> <?php 
                _e('Your MainWP Dashboard has not been synced for 24 hours!', 'mainwp');
                ?>
										</h3>
										<p class="about-description"><?php 
                _e('Click the Sync Data button to get the latest data from child sites.', 'mainwp');
                ?>
</p>
										<?php 
            } else {
                if ($sync_status === 'all_synced') {
                    ?>
										<h3><?php 
                    echo __('All sites have been synced within the last 24 hours!', 'mainwp');
                    ?>
</h3>
										<p class="about-description"><?php 
                    echo __('Manage your WordPress sites with ease.', 'mainwp');
                    ?>
</p>
										<?php 
                } else {
                    ?>
										<h3><i class="fa fa-flag"></i> <?php 
                    echo __("Some child sites didn't sync correctly!", 'mainwp');
                    ?>
</h3>
										<p class="about-description"><?php 
                    echo __('Check the Sync Status widget to review sites that have not been synced.', 'mainwp');
                    ?>
</p>
										<?php 
                }
            }
        }
        ?>
							</div>
							<br/>
							<span style="float: right; margin-right: 1em;"><a id="mainwp-link-showhide-welcome-shortcuts" status="<?php 
        echo $hide_shortcuts ? 'hide' : 'show';
        ?>
" href="#"><?php 
        echo $hide_shortcuts ? __('Show Shortcuts', 'mainwp') : __('Hide Shortcuts', 'mainwp');
        ?>
</a></span>

							<div id="mainwp-welcome-bar-shotcuts" style="clear: both;<?php 
        echo $hide_shortcuts ? 'display: none;' : '';
        ?>
">
								<div class="welcome-panel-column">
									<h4><?php 
        _e('Get Started', 'mainwp');
        ?>
</h4>
									<ul>
										<li>
											<a href="<?php 
        echo get_admin_url();
        ?>
admin.php?page=managesites&do=new"><i class="fa fa-globe"></i> <?php 
        _e('Add New Site', 'mainwp');
        ?>
											</a></li>
										<li>
											<a href="<?php 
        echo get_admin_url();
        ?>
admin.php?page=ManageGroups"><i class="fa fa-globe"></i> <?php 
        _e('Create Child Site Groups', 'mainwp');
        ?>
											</a></li>
										<li>
											<a href="<?php 
        echo get_admin_url();
        ?>
admin.php?page=ManageBackupsAddNew"><i class="fa fa-hdd-o"></i> <?php 
        _e('Schedule Backups', 'mainwp');
        ?>
											</a></li>
										<li>
											<a href="<?php 
        echo get_admin_url();
        ?>
admin.php?page=Settings"><i class="fa fa-cogs"></i> <?php 
        _e('Check MainWP Settings', 'mainwp');
        ?>
											</a></li>

									</ul>
								</div>
								<div class="welcome-panel-column">
									<h4><?php 
        _e('Next Steps', 'mainwp');
        ?>
</h4>
									<ul>
										<li>
											<a href="<?php 
        echo get_admin_url();
        ?>
admin.php?page=PostBulkAdd"><i class="fa fa-file-text"></i> <?php 
        _e('Add Post to Child Site(s)', 'mainwp');
        ?>
											</a></li>
										<li>
											<a href="<?php 
        echo get_admin_url();
        ?>
admin.php?page=PageBulkAdd"><i class="fa fa-file"></i> <?php 
        _e('Add Page to Child Site(s)', 'mainwp');
        ?>
											</a></li>
										<li>
											<a href="<?php 
        echo get_admin_url();
        ?>
admin.php?page=PluginsInstall"><i class="fa fa-plug"></i> <?php 
        _e('Add Plugin to Child Site(s)', 'mainwp');
        ?>
											</a></li>
										<li>
											<a href="<?php 
        echo get_admin_url();
        ?>
admin.php?page=ThemesInstall"><i class="fa fa-paint-brush"></i> <?php 
        _e('Add Theme to Child Site(s)', 'mainwp');
        ?>
											</a></li>
									</ul>
								</div>
								<div class="welcome-panel-column welcome-panel-last">
									<h4><?php 
        _e('More Actions', 'mainwp');
        ?>
</h4>
									<ul>
										<li>
											<a href="<?php 
        echo get_admin_url();
        ?>
admin.php?page=managesites&do=test"><i class="fa fa-globe"></i> <?php 
        _e('Test Connection', 'mainwp');
        ?>
											</a></li>
										<li>
											<a href="<?php 
        echo get_admin_url();
        ?>
admin.php?page=Extensions"><i class="fa fa-plug"></i> <?php 
        _e('Manage Extensions', 'mainwp');
        ?>
											</a></li>
										<li>
											<a href="<?php 
        echo get_admin_url();
        ?>
admin.php?page=ServerInformation"><i class="fa fa-server"></i> <?php 
        _e('Check MainWP Requirements', 'mainwp');
        ?>
											</a></li>
										<li>
											<a href="<?php 
        echo get_admin_url();
        ?>
admin.php?page=DashboardOptions"><i class="fa fa-cogs"></i> <?php 
        _e('Set Your Preferences', 'mainwp');
        ?>
											</a></li>
									</ul>
								</div>
							</div>
							<div id="dashboard_refresh_statusextra" style="display: none">
								<i class="fa fa-spinner fa-pulse"></i></div>
			</div>
			<div id="mainwp_dashboard_refresh_status"></div>
			</td></tr></tbody>
			</table>
			</div>
			<div id="mainwp_main_errors" class="mainwp_error"></div>
		</form>

		<div id="mainwp-dashboard-info-box">
		<?php 
        if (empty($current_wp_id) && MainWP_Twitter::enabledTwitterMessages()) {
            $filter = array('upgrade_everything', 'upgrade_all_wp_core', 'upgrade_all_plugins', 'upgrade_all_themes');
            foreach ($filter as $what) {
                $twitters = MainWP_Twitter::getTwitterNotice($what);
                if (is_array($twitters)) {
                    foreach ($twitters as $timeid => $twit_mess) {
                        $sendText = "";
                        if (!empty($twit_mess)) {
                            if (!empty($sendText)) {
                                $sendText = MainWP_Twitter::getTwitToSend($what, $timeid);
                                ?>
								<div class="mainwp-tips mainwp_info-box-blue twitter">
									<span class="mainwp-tip" twit-what="<?php 
                                echo $what;
                                ?>
"
										  twit-id="<?php 
                                echo $timeid;
                                ?>
"><?php 
                                echo $twit_mess;
                                ?>
</span>&nbsp;<?php 
                                MainWP_Twitter::genTwitterButton($sendText);
                                ?>
									<span><a href="#" class="mainwp-dismiss-twit"><i
												class="fa fa-times-circle"></i> <?php 
                                _e('Dismiss', 'mainwp');
                                ?>
										</a></span></div>
								<?php 
                            }
                        }
                    }
                }
            }
            ?>
		<?php 
        }
        ?>
		</div>


		<div id="dashboard-widgets-wrap">

			<?php 
        require_once ABSPATH . 'wp-admin/includes/dashboard.php';
        wp_dashboard();
        ?>

			<div class="clear"></div>
		</div><!-- dashboard-widgets-wrap -->
		<?php 
    }
 function mainwp_twitter_dashboard_action()
 {
     $success = false;
     if (isset($_POST['actionName']) && isset($_POST['countSites']) && !empty($_POST['countSites'])) {
         $success = MainWP_Twitter::updateTwitterInfo($_POST['actionName'], $_POST['countSites'], (int) $_POST['countSeconds'], isset($_POST['countRealItems']) ? $_POST['countRealItems'] : 0, time(), isset($_POST['countItems']) ? $_POST['countItems'] : 0);
     }
     if (isset($_POST['showNotice']) && !empty($_POST['showNotice'])) {
         if (MainWP_Twitter::enabledTwitterMessages()) {
             $twitters = MainWP_Twitter::getTwitterNotice($_POST['actionName']);
             $html = '';
             if (is_array($twitters)) {
                 foreach ($twitters as $timeid => $twit_mess) {
                     if (!empty($twit_mess)) {
                         $sendText = MainWP_Twitter::getTwitToSend($_POST['actionName'], $timeid);
                         $html .= '<div class="mainwp-tips mainwp_info-box-blue twitter"><span class="mainwp-tip" twit-what="' . $_POST['actionName'] . '" twit-id="' . $timeid . '">' . $twit_mess . '</span>&nbsp;' . MainWP_Twitter::genTwitterButton($sendText, false) . '<span><a href="#" class="mainwp-dismiss-twit" ><i class="fa fa-times-circle"></i>' . __('Dismiss', 'mainwp') . '</a></span></div>';
                     }
                 }
             }
             die($html);
         }
     } else {
         if ($success) {
             die('ok');
         }
     }
     die('');
 }
Exemple #5
0
    public static function doPost()
    {
        $errors = array();
        $errorFields = array();
        if (isset($_POST['select_by'])) {
            $selected_sites = array();
            if (isset($_POST['selected_sites']) && is_array($_POST['selected_sites'])) {
                foreach ($_POST['selected_sites'] as $selected) {
                    $selected_sites[] = $selected;
                }
            }
            $selected_groups = array();
            if (isset($_POST['selected_groups']) && is_array($_POST['selected_groups'])) {
                foreach ($_POST['selected_groups'] as $selected) {
                    $selected_groups[] = $selected;
                }
            }
            if ($_POST['select_by'] == 'group' && count($selected_groups) == 0 || $_POST['select_by'] == 'site' && count($selected_sites) == 0) {
                $errors[] = 'Please select the sites or groups you want to add the new user to.';
            }
        } else {
            $errors[] = 'Please select whether you want to add the user to specific sites or groups.';
        }
        if (!isset($_POST['user_login']) || $_POST['user_login'] == '') {
            $errorFields[] = 'user_login';
        }
        if (!isset($_POST['email']) || $_POST['email'] == '') {
            $errorFields[] = 'email';
        }
        if (!isset($_POST['pass1']) || $_POST['pass1'] == '' || !isset($_POST['pass2']) || $_POST['pass2'] == '') {
            $errorFields[] = 'pass1';
        } else {
            if ($_POST['pass1'] != $_POST['pass2']) {
                $errorFields[] = 'pass2';
            }
        }
        $allowed_roles = array('subscriber', 'administrator', 'editor', 'author', 'contributor');
        if (!isset($_POST['role']) || !in_array($_POST['role'], $allowed_roles)) {
            $errorFields[] = 'role';
        }
        if (count($errors) == 0 && count($errorFields) == 0) {
            $user_to_add = array('user_pass' => $_POST['pass1'], 'user_login' => $_POST['user_login'], 'user_url' => $_POST['url'], 'user_email' => $_POST['email'], 'first_name' => $_POST['first_name'], 'last_name' => $_POST['last_name'], 'role' => $_POST['role']);
            $dbwebsites = array();
            if ($_POST['select_by'] == 'site') {
                //Get all selected websites
                foreach ($selected_sites as $k) {
                    if (MainWP_Utility::ctype_digit($k)) {
                        $website = MainWP_DB::Instance()->getWebsiteById($k);
                        $dbwebsites[$website->id] = MainWP_Utility::mapSite($website, array('id', 'url', 'name', 'adminname', 'nossl', 'privkey', 'nosslkey'));
                    }
                }
            } else {
                //Get all websites from the selected groups
                foreach ($selected_groups as $k) {
                    if (MainWP_Utility::ctype_digit($k)) {
                        $websites = MainWP_DB::Instance()->query(MainWP_DB::Instance()->getSQLWebsitesByGroupId($k));
                        while ($websites && ($website = @MainWP_DB::fetch_object($websites))) {
                            $dbwebsites[$website->id] = MainWP_Utility::mapSite($website, array('id', 'url', 'name', 'adminname', 'nossl', 'privkey', 'nosslkey'));
                        }
                        @MainWP_DB::free_result($websites);
                    }
                }
            }
            $startTime = time();
            if (count($dbwebsites) > 0) {
                $post_data = array('new_user' => base64_encode(serialize($user_to_add)), 'send_password' => isset($_POST['send_password']) ? $_POST['send_password'] : '');
                $output = new stdClass();
                $output->ok = array();
                $output->errors = array();
                MainWP_Utility::fetchUrlsAuthed($dbwebsites, 'newuser', $post_data, array(MainWP_Bulk_Add::getClassName(), 'PostingBulk_handler'), $output);
            }
            $countSites = $countRealItems = 0;
            foreach ($dbwebsites as $website) {
                if (isset($output->ok[$website->id]) && $output->ok[$website->id] == 1) {
                    $countSites++;
                    $countRealItems++;
                }
            }
            if (!empty($countSites)) {
                $seconds = time() - $startTime;
                MainWP_Twitter::updateTwitterInfo('create_new_user', $countSites, $seconds, $countRealItems, $startTime, 1);
            }
            if (MainWP_Twitter::enabledTwitterMessages()) {
                $twitters = MainWP_Twitter::getTwitterNotice('create_new_user');
                if (is_array($twitters)) {
                    foreach ($twitters as $timeid => $twit_mess) {
                        if (!empty($twit_mess)) {
                            $sendText = MainWP_Twitter::getTwitToSend('create_new_user', $timeid);
                            ?>
							<div class="mainwp-tips mainwp_info-box-blue twitter">
								<span class="mainwp-tip" twit-what="create_new_user" twit-id="<?php 
                            echo $timeid;
                            ?>
"><?php 
                            echo $twit_mess;
                            ?>
</span>&nbsp;<?php 
                            MainWP_Twitter::genTwitterButton($sendText);
                            ?>
								<span><a href="#" class="mainwp-dismiss-twit"><i class="fa fa-times-circle"></i> <?php 
                            _e('Dismiss', 'mainwp');
                            ?>
									</a></span></div>
							<?php 
                        }
                    }
                }
            }
            ?>
			<div id="message" class="updated">
				<?php 
            foreach ($dbwebsites as $website) {
                ?>
					<p>
						<a href="<?php 
                echo admin_url('admin.php?page=managesites&dashboard=' . $website->id);
                ?>
"><?php 
                echo stripslashes($website->name);
                ?>
</a>
						: <?php 
                echo isset($output->ok[$website->id]) && $output->ok[$website->id] == 1 ? 'New user created.' : 'ERROR: ' . $output->errors[$website->id];
                ?>
					</p>
				<?php 
            }
            ?>
			</div>
			<br/>
			<a href="<?php 
            echo get_admin_url();
            ?>
admin.php?page=UserBulkAdd" class="add-new-h2" target="_top"><?php 
            _e('Add New', 'mainwp');
            ?>
</a>
			<a href="<?php 
            echo get_admin_url();
            ?>
admin.php?page=mainwp_tab" class="add-new-h2" target="_top"><?php 
            _e('Return to
            Dashboard', 'mainwp');
            ?>
</a>
			<?php 
        } else {
            echo 'ERROR ' . json_encode(array($errorFields, $errors));
        }
    }
    public static function _renderAllSites($showDelete = true, $showAddNew = true)
    {
        self::renderHeader('');
        $userExtension = MainWP_DB::Instance()->getUserExtension();
        $globalIgnoredPluginConflicts = json_decode($userExtension->ignored_pluginConflicts, true);
        if (!is_array($globalIgnoredPluginConflicts)) {
            $globalIgnoredPluginConflicts = array();
        }
        $globalIgnoredThemeConflicts = json_decode($userExtension->ignored_themeConflicts, true);
        if (!is_array($globalIgnoredThemeConflicts)) {
            $globalIgnoredThemeConflicts = array();
        }
        self::$sitesTable->prepare_items($globalIgnoredPluginConflicts, $globalIgnoredThemeConflicts);
        if (MainWP_Twitter::enabledTwitterMessages()) {
            $filter = array('upgrade_all_plugins', 'upgrade_all_themes', 'upgrade_all_wp_core');
            foreach ($filter as $what) {
                $twitters = MainWP_Twitter::getTwitterNotice($what);
                if (is_array($twitters)) {
                    foreach ($twitters as $timeid => $twit_mess) {
                        if (!empty($twit_mess)) {
                            $sendText = MainWP_Twitter::getTwitToSend($what, $timeid);
                            if (!empty($sendText)) {
                                ?>
								<div class="mainwp-tips mainwp_info-box-blue twitter"><span class="mainwp-tip" twit-what="<?php 
                                echo $what;
                                ?>
" twit-id="<?php 
                                echo $timeid;
                                ?>
"><?php 
                                echo $twit_mess;
                                ?>
</span>&nbsp;<?php 
                                MainWP_Twitter::genTwitterButton($sendText);
                                ?>
<span><a href="#" class="mainwp-dismiss-twit" ><i class="fa fa-times-circle"></i> <?php 
                                _e('Dismiss', 'mainwp');
                                ?>
</a></span></div>
								<?php 
                            }
                        }
                    }
                }
            }
        }
        ?>
		<div id="mainwp_managesites_content">
			<div id="mainwp_managesites_add_errors" class="mainwp_error mainwp_info-box-red"></div>
			<div id="mainwp_managesites_add_message" class="mainwp_updated updated mainwp_info-box"></div>
			<div id="mainwp_managesites_add_other_message" class="mainwp_updated updated mainwp_info-box hidden"></div>
			<?php 
        MainWP_Manage_Sites_View::_renderInfo();
        //            self::$sitesTable->display_search();
        ?>
			<form method="post" class="mainwp-table-container">
				<input type="hidden" name="page" value="sites_list_table">
				<?php 
        MainWP_Manage_Sites_View::_renderNotes();
        self::$sitesTable->display();
        self::$sitesTable->clear_items();
        ?>
			</form>
		</div>

		<div id="managesites-backup-box" title="Full backup required" style="display: none; text-align: center">
			<div style="height: 190px; overflow: auto; margin-top: 20px; margin-bottom: 10px; text-align: left" id="managesites-backup-content">
			</div>
			<input id="managesites-backup-all" type="button" name="Backup All" value="<?php 
        esc_attr_e('Backup All', 'mainwp');
        ?>
" class="button-primary"/>
			<input id="managesites-backup-ignore" type="button" name="Ignore" value="<?php 
        esc_attr_e('Ignore', 'mainwp');
        ?>
" class="button"/>
		</div>

		<div id="managesites-backupnow-box" title="Full backup" style="display: none; text-align: center">
			<div style="height: 190px; overflow: auto; margin-top: 20px; margin-bottom: 10px; text-align: left" id="managesites-backupnow-content">
			</div>
			<input id="managesites-backupnow-close" type="button" name="Ignore" value="<?php 
        esc_attr_e('Cancel', 'mainwp');
        ?>
" class="button"/>
		</div>

		<?php 
        self::renderFooter('');
    }