public static function hookFetchUrlsAuthed($pluginFile, $key, $dbwebsites, $what, $params, $handle, $output) { if (!self::hookVerify($pluginFile, $key)) { return false; } return MainWP_Utility::fetchUrlsAuthed($dbwebsites, $what, $params, $handle, $output); }
public static function getTerms($websiteid, $prefix = '', $what = 'site', $gen_type = 'post') { $output = new stdClass(); $output->errors = array(); $output->cats = array(); $dbwebsites = array(); if ($what == 'group') { $input_name = 'groups_selected_cats_' . $prefix . '[]'; } else { $input_name = 'sites_selected_cats_' . $prefix . '[]'; } if (!empty($websiteid)) { if (MainWP_Utility::ctype_digit($websiteid)) { $website = MainWP_DB::Instance()->getWebsiteById($websiteid); $dbwebsites[$website->id] = MainWP_Utility::mapSite($website, array('id', 'url', 'name', 'adminname', 'nossl', 'privkey', 'nosslkey')); } } if ($gen_type == 'post') { $bkc_option_path = 'default_keywords_post'; $keyword_option = 'keywords_page'; } else { if ($gen_type == 'page') { $bkc_option_path = 'default_keywords_page'; $keyword_option = 'keywords_page'; } } if ($prefix == 'bulk') { $opt = apply_filters('mainwp-get-options', $value = '', 'mainwp_content_extension', 'bulk_keyword_cats', $bkc_option_path); $selected_cats = unserialize(base64_decode($opt)); } else { $opt = apply_filters('mainwp-get-options', $value = '', 'mainwp_content_extension', $keyword_option); if (is_array($opt) && is_array($opt[$prefix])) { $selected_cats = unserialize(base64_decode($opt[$prefix]['selected_cats'])); } } $selected_cats = is_array($selected_cats) ? $selected_cats : array(); $ret = ''; if (count($dbwebsites) > 0) { $opt = apply_filters('mainwp-get-options', $value = '', 'mainwp_content_extension', 'taxonomy'); $post_data = array('taxonomy' => base64_encode($opt)); MainWP_Utility::fetchUrlsAuthed($dbwebsites, 'get_terms', $post_data, array(MainWP_Post::getClassName(), 'PostsGetTerms_handler'), $output); foreach ($dbwebsites as $siteid => $website) { $cats = array(); if (is_array($selected_cats[$siteid])) { foreach ($selected_cats[$siteid] as $val) { $cats[] = $val['term_id']; } } if (!empty($output->errors[$siteid])) { $ret .= '<p> ' . __('Error - ', 'mainwp') . $output->errors[$siteid] . '</p>'; } else { if (count($output->cats[$siteid]) > 0) { foreach ($output->cats[$siteid] as $cat) { if ($cat->term_id) { if (in_array($cat->term_id, $cats)) { $checked = ' checked="checked" '; } else { $checked = ''; } $ret .= '<div class="mainwp_selected_sites_item ' . (!empty($checked) ? 'selected_sites_item_checked' : '') . '"><input type="checkbox" name="' . $input_name . '" value="' . $siteid . ',' . $cat->term_id . ',' . stripslashes($cat->name) . '" ' . $checked . '/><label>' . $cat->name . '</label></div>'; } } } else { $ret .= '<p>No categories have been found</p>'; } } } } else { $ret .= '<p>' . __('Error - ', 'mainwp') . ' no site</p>'; } echo $ret; }
public static function renderAllThemesTable($output = null) { $keyword = null; $search_status = 'all'; if ($output == null) { $keyword = isset($_POST['keyword']) && !empty($_POST['keyword']) ? trim($_POST['keyword']) : null; $search_status = isset($_POST['status']) ? $_POST['status'] : 'all'; $search_theme_status = isset($_POST['theme_status']) ? $_POST['theme_status'] : 'all'; $output = new stdClass(); $output->errors = array(); $output->themes = array(); if (get_option('mainwp_optimize') == 1) { //Fetch all! //Build websites array //Search in local cache $websites = MainWP_DB::Instance()->query(MainWP_DB::Instance()->getSQLWebsitesForCurrentUser()); while ($websites && ($website = @MainWP_DB::fetch_object($websites))) { $allThemes = json_decode($website->themes, true); for ($i = 0; $i < count($allThemes); $i++) { $theme = $allThemes[$i]; if ($search_theme_status != 'all') { if ($theme['active'] == 1 && $search_theme_status !== 'active') { continue; } else { if ($theme['active'] != 1 && $search_theme_status !== 'inactive') { continue; } } } if ($keyword != '' && stristr($theme['name'], $keyword) === false) { continue; } $theme['websiteid'] = $website->id; $theme['websiteurl'] = $website->url; $output->themes[] = $theme; } } @MainWP_DB::free_result($websites); } else { //Fetch all! //Build websites array $dbwebsites = array(); $websites = MainWP_DB::Instance()->query(MainWP_DB::Instance()->getSQLWebsitesForCurrentUser()); 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); $post_data = array('keyword' => $keyword); if ($search_theme_status == 'active' || $search_theme_status == 'inactive') { $post_data['status'] = $search_theme_status; $post_data['filter'] = true; } else { $post_data['status'] = ''; $post_data['filter'] = false; } MainWP_Utility::fetchUrlsAuthed($dbwebsites, 'get_all_themes', $post_data, array(MainWP_Themes::getClassName(), 'ThemesSearch_handler'), $output); if (count($output->errors) > 0) { foreach ($output->errors as $siteid => $error) { echo '<strong>Error on ' . MainWP_Utility::getNiceURL($dbwebsites[$siteid]->url) . ': ' . $error . ' <br /></strong>'; } echo '<br />'; } if (count($output->errors) == count($dbwebsites)) { session_start(); $_SESSION['SNThemesAll'] = $output; return; } } if (session_id() == '') { session_start(); } $_SESSION['SNThemesAll'] = $output; $_SESSION['SNThemesAllStatus'] = array('keyword' => $keyword, 'status' => $search_status, 'theme_status' => $search_theme_status); } else { if (isset($_SESSION['SNThemesAllStatus'])) { $keyword = $_SESSION['SNThemesAllStatus']['keyword']; $search_status = $_SESSION['SNThemesAllStatus']['status']; $search_theme_status = $_SESSION['SNThemesAllStatus']['theme_status']; } } if (count($output->themes) == 0) { ?> No themes found <?php return; } ?> <div class="alignleft"> <select name="bulk_action" id="mainwp_bulk_action"> <option value="none"><?php _e('Choose Action', 'mainwp'); ?> </option> <option value="trust"><?php _e('Trust', 'mainwp'); ?> </option> <option value="untrust"><?php _e('Untrust', 'mainwp'); ?> </option> </select> <input type="button" name="" id="mainwp_bulk_trust_themes_action_apply" class="button" value="<?php _e('Confirm', 'mainwp'); ?> "/> <span id="mainwp_bulk_action_loading"><i class="fa fa-spinner fa-pulse"></i></span> </div> <div class="clear"></div> <?php //Map per siteId $themes = array(); //name_version -> slug foreach ($output->themes as $theme) { $themes[$theme['slug']] = $theme; } asort($themes); $userExtension = MainWP_DB::Instance()->getUserExtension(); $decodedIgnoredThemes = json_decode($userExtension->ignored_themes, true); $trustedThemes = json_decode($userExtension->trusted_themes, true); if (!is_array($trustedThemes)) { $trustedThemes = array(); } $trustedThemesNotes = json_decode($userExtension->trusted_themes_notes, true); if (!is_array($trustedThemesNotes)) { $trustedThemesNotes = array(); } ?> <table id="mainwp_themes_all_table" class="wp-list-table widefat fixed posts tablesorter" cellspacing="0"> <thead> <tr> <th scope="col" id="cb" class="manage-column column-cb check-column" style=""> <input name="themes" type="checkbox"></th> <th scope="col" id="info" class="manage-column column-cb check-column" style=""></th> <th scope="col" id="theme" class="manage-column column-title sortable desc" style=""> <a href="#"><span><?php _e('Theme', 'mainwp'); ?> </span><span class="sorting-indicator"></span></a> </th> <th scope="col" id="thmstatus" class="manage-column column-title sortable desc" style=""> <a href="#"><span><?php _e('Status', 'mainwp'); ?> </span><span class="sorting-indicator"></span></a> </th> <th scope="col" id="trustlvl" class="manage-column column-title sortable desc" style=""> <a href="#"><span><?php _e('Trust Level', 'mainwp'); ?> </span><span class="sorting-indicator"></span></a> </th> <th scope="col" id="ignoredstatus" class="manage-column column-title sortable desc" style=""> <a href="#"><span><?php _e('Ignored Status', 'mainwp'); ?> </span><span class="sorting-indicator"></span></a> </th> <th scope="col" id="notes" class="manage-column column-posts" style=""><?php _e('Notes', 'mainwp'); ?> </th> </tr> </thead> <tfoot> <tr> <th scope="col" class="manage-column column-cb check-column" style=""> <input name="themes" type="checkbox"></th> <th scope="col" id="info_footer" class="manage-column column-cb check-column" style=""></th> <th scope="col" id="theme_footer" class="manage-column column-title sortable desc" style=""> <span><?php _e('Theme', 'mainwp'); ?> </span></th> <th scope="col" id="thmstatus_footer" class="manage-column column-posts" style=""><?php _e('Status', 'mainwp'); ?> </th> <th scope="col" id="trustlvl_footer" class="manage-column column-posts" style=""><?php _e('Trust Level', 'mainwp'); ?> </th> <th scope="col" id="ignoredstatus_footer" class="manage-column column-posts" style=""><?php _e('Ignored Status', 'mainwp'); ?> </th> <th scope="col" id="notes_footer" class="manage-column column-posts" style=""><?php _e('Notes', 'mainwp'); ?> </th> </tr> </tfoot> <tbody id="the-posts-list" class="list:posts"> <?php foreach ($themes as $slug => $theme) { $name = $theme['name']; if (!empty($search_status) && $search_status != 'all') { if ($search_status == 'trust' && !in_array($slug, $trustedThemes)) { continue; } else { if ($search_status == 'untrust' && in_array($slug, $trustedThemes)) { continue; } else { if ($search_status == 'ignored' && !isset($decodedIgnoredThemes[$slug])) { continue; } } } } ?> <tr id="post-1" class="post-1 post type-post status-publish format-standard hentry category-uncategorized alternate iedit author-self" valign="top" theme_slug="<?php echo urlencode($slug); ?> " theme_name="<?php echo rawurlencode($name); ?> "> <th scope="row" class="check-column"> <input type="checkbox" name="theme[]" value="<?php echo urlencode($slug); ?> "></th> <td scope="col" id="info_content" class="manage-column" style=""> <?php if (isset($decodedIgnoredThemes[$slug])) { MainWP_Utility::renderToolTip('Ignored themes will NOT be auto-updated.', null, 'images/icons/mainwp-red-info-16.png'); } ?> </td> <td scope="col" id="theme_content" class="manage-column sorted" style=""> <?php echo $name; ?> </td> <td scope="col" id="plgstatus_content" class="manage-column" style=""> <?php echo $theme['active'] == 1 ? __('Active', 'mainwp') : __('Inactive', 'mainwp'); ?> </td> <td scope="col" id="trustlvl_content" class="manage-column" style=""> <?php if (in_array($slug, $trustedThemes)) { echo '<font color="#7fb100">Trusted</font>'; } else { echo '<font color="#c00">Not Trusted</font>'; } ?> </td> <td scope="col" id="ignoredstatus_content" class="manage-column" style=""> <?php if (isset($decodedIgnoredThemes[$slug])) { echo '<font color="#c00">Ignored</font>'; } ?> </td> <td scope="col" id="notes_content" class="manage-column" style=""> <img src="<?php echo plugins_url('images/notes.png', dirname(__FILE__)); ?> " class="mainwp_notes_img" <?php if (!isset($trustedThemesNotes[$slug]) || $trustedThemesNotes[$slug] == '') { echo 'style="display: none;"'; } ?> /> <a href="#" class="mainwp_trusted_theme_notes_show"><i class="fa fa-pencil"></i> <?php _e('Open', 'mainwp'); ?> </a> <div style="display: none" class="note"><?php if (isset($trustedThemesNotes[$slug])) { echo $trustedThemesNotes[$slug]; } ?> </div> </td> </tr> <?php } ?> </tbody> </table> <div id="mainwp_notes_overlay" class="mainwp_overlay"></div> <div id="mainwp_notes" class="mainwp_popup"> <a id="mainwp_notes_closeX" class="mainwp_closeX" style="display: inline; "></a> <div id="mainwp_notes_title" class="mainwp_popup_title"></span> </div> <div id="mainwp_notes_content"> <textarea style="width: 580px !important; height: 300px;" id="mainwp_notes_note"></textarea> </div> <form> <div style="float: right" id="mainwp_notes_status"></div> <input type="button" class="button cont button-primary" id="mainwp_trusted_theme_notes_save" value="<?php _e('Save Note', 'mainwp'); ?> "/> <input type="button" class="button cont" id="mainwp_notes_cancel" value="<?php _e('Close', 'mainwp'); ?> "/> <input type="hidden" id="mainwp_notes_slug" value=""/> </form> </div> <div class="pager" id="pager"> <form> <img src="<?php echo plugins_url('images/first.png', dirname(__FILE__)); ?> " class="first"> <img src="<?php echo plugins_url('images/prev.png', dirname(__FILE__)); ?> " class="prev"> <input type="text" class="pagedisplay"> <img src="<?php echo plugins_url('images/next.png', dirname(__FILE__)); ?> " class="next"> <img src="<?php echo plugins_url('images/last.png', dirname(__FILE__)); ?> " class="last"> <span> <?php _e('Show:', 'mainwp'); ?> </span><select class="pagesize"> <option selected="selected" value="10">10</option> <option value="20">20</option> <option value="30">30</option> <option value="40">40</option> </select><span> <?php _e('Plugins per page', 'mainwp'); ?> </span> </form> </div> <?php }
public static function renderTable($keyword, $status, $groups, $sites) { MainWP_Cache::initCache('Plugins'); $output = new stdClass(); $output->errors = array(); $output->plugins = array(); if (get_option('mainwp_optimize') == 1) { if ($sites != '') { foreach ($sites as $k => $v) { if (MainWP_Utility::ctype_digit($v)) { $website = MainWP_DB::Instance()->getWebsiteById($v); $allPlugins = json_decode($website->plugins, true); for ($i = 0; $i < count($allPlugins); $i++) { $plugin = $allPlugins[$i]; if ($status == 'active' || $status == 'inactive') { if ($plugin['active'] != ($status == 'active' ? 1 : 0)) { continue; } } if ($keyword != '' && !stristr($plugin['name'], $keyword)) { continue; } $plugin['websiteid'] = $website->id; $plugin['websiteurl'] = $website->url; $output->plugins[] = $plugin; } } } } if ($groups != '') { //Search in local cache foreach ($groups as $k => $v) { if (MainWP_Utility::ctype_digit($v)) { $websites = MainWP_DB::Instance()->query(MainWP_DB::Instance()->getSQLWebsitesByGroupId($v)); while ($websites && ($website = @MainWP_DB::fetch_object($websites))) { if ($website->sync_errors != '') { continue; } $allPlugins = json_decode($website->plugins, true); for ($i = 0; $i < count($allPlugins); $i++) { $plugin = $allPlugins[$i]; if ($status == 'active' || $status == 'inactive') { if ($plugin['active'] != ($status == 'active' ? 1 : 0)) { continue; } } if ($keyword != '' && !stristr($plugin['name'], $keyword)) { continue; } $plugin['websiteid'] = $website->id; $plugin['websiteurl'] = $website->url; $output->plugins[] = $plugin; } } @MainWP_DB::free_result($websites); } } } } else { //Fetch all! //Build websites array $dbwebsites = array(); if ($sites != '') { foreach ($sites as $k => $v) { if (MainWP_Utility::ctype_digit($v)) { $website = MainWP_DB::Instance()->getWebsiteById($v); $dbwebsites[$website->id] = MainWP_Utility::mapSite($website, array('id', 'url', 'name', 'adminname', 'nossl', 'privkey', 'nosslkey')); } } } if ($groups != '') { foreach ($groups as $k => $v) { if (MainWP_Utility::ctype_digit($v)) { $websites = MainWP_DB::Instance()->query(MainWP_DB::Instance()->getSQLWebsitesByGroupId($v)); 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); } } } $post_data = array('keyword' => $keyword); if ($status == 'active' || $status == 'inactive') { $post_data['status'] = $status; $post_data['filter'] = true; } else { $post_data['status'] = ''; $post_data['filter'] = false; } MainWP_Utility::fetchUrlsAuthed($dbwebsites, 'get_all_plugins', $post_data, array(MainWP_Plugins::getClassName(), 'PluginsSearch_handler'), $output); if (count($output->errors) > 0) { foreach ($output->errors as $siteid => $error) { echo '<strong>Error on ' . MainWP_Utility::getNiceURL($dbwebsites[$siteid]->url) . ': ' . $error . ' <br /></strong>'; } echo '<br />'; } if (count($output->errors) == count($dbwebsites)) { return; } } MainWP_Cache::addContext('Plugins', array('keyword' => $keyword, 'the_status' => $status)); ob_start(); ?> <div class="alignleft"> <select name="bulk_action" id="mainwp_bulk_action"> <option value="none"><?php _e('Choose Action', 'mainwp'); ?> </option> <?php if (mainwp_current_user_can('dashboard', 'activate_deactivate_plugins')) { ?> <?php if ($status == 'active') { ?> <option value="deactivate"><?php _e('Deactivate', 'mainwp'); ?> </option> <?php } ?> <?php } ?> <?php if ($status == 'inactive') { ?> <?php if (mainwp_current_user_can('dashboard', 'activate_deactivate_plugins')) { ?> <option value="activate"><?php _e('Activate', 'mainwp'); ?> </option> <?php } ?> <?php if (mainwp_current_user_can('dashboard', 'delete_plugins')) { ?> <option value="delete"><?php _e('Delete', 'mainwp'); ?> </option> <?php } ?> <?php } ?> <?php if (mainwp_current_user_can('dashboard', 'ignore_unignore_updates')) { ?> <option value="ignore_updates"><?php _e('Ignore Updates', 'mainwp'); ?> </option> <?php } ?> </select> <input type="button" name="" id="mainwp_bulk_plugins_action_apply" class="button" value="<?php esc_attr_e('Confirm', 'mainwp'); ?> "/> <span id="mainwp_bulk_action_loading"><i class="fa fa-spinner fa-pulse"></i></span> </div> <div class="clear"></div> <?php if (count($output->plugins) == 0) { ?> No plugins found <?php $newOutput = ob_get_clean(); echo $newOutput; MainWP_Cache::addBody('Plugins', $newOutput); return; } //Map per siteId $sites = array(); //id -> url $sitePlugins = array(); //site_id -> plugin_version_name -> plugin obj $plugins = array(); //name_version -> slug $pluginsVersion = $pluginsName = $pluginsMainWP = array(); //name_version -> title_version $pluginsRealVersion = array(); //name_version -> title_version foreach ($output->plugins as $plugin) { $sites[$plugin['websiteid']] = $plugin['websiteurl']; $plugins[$plugin['name'] . '_' . $plugin['version']] = $plugin['slug']; $pluginsName[$plugin['name'] . '_' . $plugin['version']] = $plugin['name']; $pluginsVersion[$plugin['name'] . '_' . $plugin['version']] = $plugin['name'] . ' ' . $plugin['version']; $pluginsMainWP[$plugin['name'] . '_' . $plugin['version']] = isset($plugin['mainwp']) ? $plugin['mainwp'] : 'F'; $pluginsRealVersion[$plugin['name'] . '_' . $plugin['version']] = $plugin['version']; if (!isset($sitePlugins[$plugin['websiteid']]) || !is_array($sitePlugins[$plugin['websiteid']])) { $sitePlugins[$plugin['websiteid']] = array(); } $sitePlugins[$plugin['websiteid']][$plugin['name'] . '_' . $plugin['version']] = $plugin; } ?> <div id="mainwp-table-overflow" style="overflow: auto !important ;"> <table class="ui-tinytable wp-list-table widefat fixed pages" id="plugins_fixedtable" style="width: auto; word-wrap: normal"> <thead> <tr> <th class="headcol" style="text-align: center; border-bottom: 1px Solid #e1e1e1; font-size: 18px; z-index:999; padding: auto; width: 15em !important;"><?php _e('Child Site / Plugin', 'mainwp'); ?> <p style="font-size: 10px; line-height: 12px;"><?php _e('Click on the Plugin Name to select the plugin on all sites or click the Site URL to select all plugins on the site.', 'mainwp'); ?> </p> </th> <?php foreach ($pluginsVersion as $plugin_name => $plugin_title) { ?> <th height="100" width="120" style="padding: 5px;"> <div style="max-width: 120px; text-align: center;" title="<?php echo $plugin_title; ?> "> <input type="checkbox" value="<?php echo $plugins[$plugin_name]; ?> " id="<?php echo $plugin_name; ?> " version="<?php echo $pluginsRealVersion[$plugin_name]; ?> " class="mainwp_plugin_check_all" style="display: none ;" /> <label for="<?php echo $plugin_name; ?> "><?php echo $plugin_title; ?> </label> </div> </th> <?php } ?> </tr> </thead> <tbody> <?php foreach ($sites as $site_id => $site_url) { ?> <tr> <td class="headcol"> <input class="websiteId" type="hidden" name="id" value="<?php echo $site_id; ?> "/> <label for="<?php echo $site_url; ?> "><strong><?php echo $site_url; ?> </strong></label> <input type="checkbox" value="" id="<?php echo $site_url; ?> " class="mainwp_site_check_all" style="display: none ;"/> </td> <?php foreach ($pluginsVersion as $plugin_name => $plugin_title) { echo '<td class="long" style="text-align: center">'; if (isset($sitePlugins[$site_id]) && isset($sitePlugins[$site_id][$plugin_name]) && (!isset($pluginsMainWP[$plugin_name]) || $pluginsMainWP[$plugin_name] === 'F')) { echo '<input type="checkbox" value="' . $plugins[$plugin_name] . '" name="' . $pluginsName[$plugin_name] . '" class="selected_plugin" />'; } echo '</td>'; } ?> </tr> <?php } ?> </tbody> </table> </div> <script type="text/javascript"> jQuery(document).ready(function() { jQuery("#plugins_fixedtable").tableHeadFixer({"left" : 1}); }); </script> <?php $newOutput = ob_get_clean(); echo $newOutput; MainWP_Cache::addBody('Plugins', $newOutput); }
public static function doImport() { 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; } } } $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']); $ret = array(); $dbwebsites = array(); $not_valid = array(); $error_sites = ''; if ($_POST['select_by'] == 'site') { //Get all selected websites foreach ($selected_sites as $url) { if (!empty($url)) { $website = MainWP_DB::Instance()->getWebsitesByUrl($url); if ($website) { $dbwebsites[$website[0]->id] = MainWP_Utility::mapSite($website[0], array('id', 'url', 'name', 'adminname', 'nossl', 'privkey', 'nosslkey')); } else { $not_valid[] = __("Error - The website doesn't exist in the Network.", 'mainwp') . " " . $url; $error_sites .= $url . ';'; } } } } else { //Get all websites from the selected groups foreach ($selected_groups as $group) { if (MainWP_DB::Instance()->getGroupsByName($group)) { $websites = MainWP_DB::Instance()->query(MainWP_DB::Instance()->getSQLWebsitesByGroupName($group)); if ($websites) { 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); } else { $not_valid[] = __('Error - These are not websites in the group. ', 'mainwp') . $group; $error_sites .= $group . ';'; } } else { $not_valid[] = __("Error - The group doesn't exist in the Network. ", 'mainwp') . $group; $error_sites .= $group . ';'; } } } 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); } $ret['ok_list'] = $ret['error_list'] = array(); foreach ($dbwebsites as $website) { if (isset($output->ok[$website->id]) && $output->ok[$website->id] == 1) { $ret['ok_list'][] = 'New user(s) created: ' . stripslashes($website->name); } else { $ret['error_list'][] = $output->errors[$website->id] . ' ' . stripslashes($website->name); $error_sites .= $website->url . ';'; } } foreach ($not_valid as $val) { $ret['error_list'][] = $val; } $ret['failed_logging'] = ''; if (!empty($error_sites)) { $error_sites = rtrim($error_sites, ';'); $ret['failed_logging'] = $_POST['user_login'] . ',' . $_POST['email'] . ',' . $_POST['first_name'] . ',' . $_POST['last_name'] . ',' . $_POST['url'] . ',' . $_POST['pass1'] . ',' . intval($_POST['send_password']) . ',' . $_POST['role'] . ',' . $error_sites . ','; } $ret['line_number'] = $_POST['line_number']; die(json_encode($ret)); }
public static function performUpload() { MainWP_Utility::endSession(); //Fetch info.. $post_data = array('url' => json_encode(explode('||', $_POST['urls'])), 'type' => $_POST['type']); if ($_POST['activatePlugin'] == 'true') { $post_data['activatePlugin'] = 'yes'; } if ($_POST['overwrite'] == 'true') { $post_data['overwrite'] = true; } $output = new stdClass(); $output->ok = array(); $output->errors = array(); $websites = array(MainWP_DB::Instance()->getWebsiteById($_POST['siteId'])); MainWP_Utility::fetchUrlsAuthed($websites, 'installplugintheme', $post_data, array(MainWP_Install_Bulk::getClassName(), 'InstallPluginTheme_handler'), $output); die(json_encode($output)); }
public static function posting() { ?> <div class="wrap"> <?php // Use this to add a new page. To bulk change pages click on the "Manage" tab. do_action('mainwp_bulkpage_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) { //Posts the saved sites if (isset($_GET['id'])) { $id = $_GET['id']; $post = get_post($id); if ($post) { $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))); $post_slug = base64_decode(get_post_meta($id, '_slug', true)); $post_custom = get_post_custom($id); 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_type' => 'page', '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_featured_image' => base64_encode($post_featured_image), 'mainwp_upload_dir' => base64_encode(serialize($mainwp_upload_dir))); $post_data = apply_filters('mainwp_bulkpage_posting', $post_data, $id); 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-page', $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_page', $countSites, $seconds, $countRealItems, $startTime, 1); } if (MainWP_Twitter::enabledTwitterMessages()) { $twitters = MainWP_Twitter::getTwitterNotice('new_page'); if (is_array($twitters)) { foreach ($twitters as $timeid => $twit_mess) { if (!empty($twit_mess)) { $sendText = MainWP_Twitter::getTwitToSend('new_page', $timeid); ?> <div class="mainwp-tips mainwp_info-box-blue twitter"><span class="mainwp-tip" twit-what="new_page" twit-id="<?php echo $timeid; ?> "><?php echo $twit_mess; ?> </span> <?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 page created. ' . '<a href="' . $output->link[$website->id] . '" target="_blank">View Page</a>' : 'ERROR: ' . $output->errors[$website->id]; ?> </p> <?php } ?> </div> <?php } else { ?> <div class="error below-h2"> <p><strong>ERROR</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=PageBulkAdd" 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 }
public static function render() { $show_form = true; if (isset($_POST['updateadminpassword'])) { check_admin_referer('mainwp_updateadminpassword', 'security'); $errors = 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 where you want to change the admin password.', 'mainwp'); } } else { $errors[] = __('Please select whether you want to change the admin password for specific sites or groups.', 'mainwp'); } if (!isset($_POST['pass1']) || $_POST['pass1'] == '' || !isset($_POST['pass2']) || $_POST['pass2'] == '') { $errors[] = __('Please enter the password twice.', 'mainwp'); } else { if ($_POST['pass1'] != $_POST['pass2']) { $errors[] = __('Please enter the same password in the two password fields.', 'mainwp'); } } if (count($errors) == 0) { $show_form = false; $new_password = array('user_pass' => $_POST['pass1']); $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))) { 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); } } } if (count($dbwebsites) > 0) { $post_data = array('new_password' => base64_encode(serialize($new_password))); $output = new stdClass(); $output->ok = array(); $output->errors = array(); MainWP_Utility::fetchUrlsAuthed($dbwebsites, 'newadminpassword', $post_data, array(MainWP_Bulk_Add::getClassName(), 'PostingBulk_handler'), $output); } } } if (!$show_form) { //Added to.. ?> <div class="wrap"> <h2 id="add-new-user"><i class="fa fa-key"></i> Update Admin Passwords</h2> <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 ? __('Admin password updated.', 'mainwp') : __('ERROR: ', 'mainwp') . $output->errors[$website->id]; ?> </p> <?php } ?> </div> <br/> <a href="<?php echo get_admin_url(); ?> admin.php?page=UpdateAdminPasswords" class="add-new-h2" target="_top"><?php _e('Update admin passwords', '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 } else { wp_enqueue_script('user-profile'); // header in User page MainWP_User::renderHeader('UpdateAdminPasswords'); ?> <form action="" method="post" name="createuser" id="createuser" class="add:users: validate"> <input type="hidden" name="security" value="<?php echo wp_create_nonce('mainwp_updateadminpassword'); ?> "/> <div class="mainwp_config_box_right"> <?php MainWP_UI::select_sites_box(__('Select Sites to Update', 'mainwp')); ?> </div> <div class="mainwp_config_box_left postbox mainwp-postbox"> <h3 class="mainwp_box_title"> <i class="fa fa-key"></i> <?php _e('Bulk Update Administrator Passwords', 'mainwp'); ?> </h3> <div class="inside"> <table class="form-table"> <?php global $wp_version; if (version_compare('4.3-alpha', $wp_version, '>=')) { ?> <tr class="form-field form-required"> <th scope="row"><label for="pass1"><?php _e('Enter New Password ', 'mainwp'); ?> <br/><span class="description"><?php _e('(twice, required)', 'mainwp'); ?> </span></label> </th> <td> <input name="user_login" type="hidden" id="user_login" value="admin"> <input class="" name="pass1" type="password" id="pass1" autocomplete="off"/> <br/> <input class="" name="pass2" type="password" id="pass2" autocomplete="off"/> <br/> <div id="pass-strength-result" style="display: block;"><?php _e('Strength indicator', 'mainwp'); ?> </div> <p class="description indicator-hint" style="clear:both;"><?php _e('Hint: The password should be at least seven characters long. To make it stronger, use upper and lower case letters, numbers and symbols like ! " ? $ % ^ & ).', 'mainwp'); ?> </p> </td> </tr> <?php } else { ?> <tr class="form-field form-required user-pass1-wrap"> <th scope="row"> <label for="pass1"> <?php _e('New Password', 'mainwp'); ?> <span class="description hide-if-js"><?php _e('(required)'); ?> </span> </label> </th> <td> <input class="hidden" value=" "/><!-- #24364 workaround --> <!-- <button type="button" class="button button-secondary wp-generate-pw hide-if-no-js">--><?php //_e( 'Show password' ); ?> <!--</button>--> <div class="wp-pwd123"> <?php $initial_password = wp_generate_password(24); ?> <span class="password-input-wrapper"> <input type="password" name="pass1" id="pass1" class="regular-text" autocomplete="off" data-reveal="1" data-pw="<?php echo esc_attr($initial_password); ?> " aria-describedby="pass-strength-result"/> </span> <button type="button" class="button button-secondary wp-hide-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e('Hide password'); ?> "> <span class="dashicons dashicons-hidden"></span> <span class="text"><?php _e('Hide'); ?> </span> </button> <!-- <button type="button" class="button button-secondary wp-cancel-pw hide-if-no-js" data-toggle="0" aria-label="--><?php //esc_attr_e( 'Cancel password change' ); ?> <!--">--> <!-- <span class="text">--><?php //_e( 'Cancel' ); ?> <!--</span>--> <!-- </button>--> <div style="display:none" id="pass-strength-result" aria-live="polite"></div> </div> </td> </tr> <tr class="form-field form-required user-pass2-wrap hide-if-js"> <td scope="row"><label for="pass2"><?php _e('Repeat Password'); ?> <span class="description"><?php _e('(required)'); ?> </span></label></td> <td> <input name="pass2" type="password" id="pass2" value="<?php echo esc_attr($initial_password); ?> " autocomplete="off"/> </td> </tr> <?php } ?> <tr> <td colspan="2"> <p class="description indicator-hint"><?php _e('Hint: The password should be at least seven characters long. To make it stronger, use upper and lower case letters, numbers and symbols like ! " ? $ % ^ & ).', 'mainwp'); ?> </p> </td> </tr> <tr> <td></td> <td colspan="2"> <input type="submit" name="updateadminpassword" id="bulk_updateadminpassword" class="button-primary button button-hero" value="<?php _e('Update Now', 'mainwp'); ?> "/> </td> </tr> </table> </div> </div> </form> <?php MainWP_User::renderFooter('UpdateAdminPasswords'); } }