public static function render() { $current_wpid = MainWPUtility::get_current_wpid(); if (!MainWPUtility::ctype_digit($current_wpid)) { return; } $website = MainWPDB::Instance()->getWebsiteById($current_wpid, true); ?> <div id="mainwp-notes-area"> <div id="mainwp-notes-note" style="padding-bottom: 1em;"> <?php if ($website->note == '') { echo "No Saved Notes"; } else { echo $website->note; } ?> </div> <div style="text-align: center; border-top: 1px Solid #f4f4f4; padding-top: 1em;"> <a href="#" class="mainwp_notes_show_all button button-primary" id="mainwp_notes_<?php echo $website->id; ?> "><?php _e('Edit Notes', 'mainwp'); ?> </a> </div> </div> <?php }
function on_admin_menu() { if (MainWPUtility::isAdmin()) { global $current_user; delete_user_option($current_user->ID, 'screen_layout_toplevel_page_mainwp_tab'); $this->dashBoard = add_menu_page('MainWP', 'MainWP', 'read', 'mainwp_tab', array($this, 'on_show_page'), plugins_url('images/mainwpicon.png', dirname(__FILE__)), '2.00001'); if (mainwp_current_user_can("dashboard", "access_global_dashboard")) { add_submenu_page('mainwp_tab', 'MainWP', __('Dashboard', 'mainwp'), 'read', 'mainwp_tab', array($this, 'on_show_page')); } $val = get_user_option('screen_layout_' . $this->dashBoard); if (!MainWPUtility::ctype_digit($val)) { update_user_option($current_user->ID, 'screen_layout_' . $this->dashBoard, 2, true); } add_action('load-' . $this->dashBoard, array(&$this, 'on_load_page')); } // else // { // $this->dashBoard = add_menu_page('MainWP', 'MainWP', 'read', 'mainwp_tab', array($this, 'require_registration'), plugins_url('images/mainwpicon.png', dirname(__FILE__)), '2.0001'); // } }
public static function prepareUpload() { include_once ABSPATH . '/wp-admin/includes/plugin-install.php'; $output = array(); $output['sites'] = array(); if ($_POST['selected_by'] == 'site') { //Get sites foreach ($_POST['selected_sites'] as $enc_id) { $websiteid = $enc_id; if (MainWPUtility::ctype_digit($websiteid)) { $website = MainWPDB::Instance()->getWebsiteById($websiteid); $output['sites'][$website->id] = MainWPUtility::mapSite($website, array('id', 'url', 'name')); } } } else { //Get sites from group foreach ($_POST['selected_groups'] as $enc_id) { $groupid = $enc_id; if (MainWPUtility::ctype_digit($groupid)) { $websites = MainWPDB::Instance()->query(MainWPDB::Instance()->getSQLWebsitesByGroupId($groupid)); while ($websites && ($website = @MainWPDB::fetch_object($websites))) { if ($website->sync_errors != '') { continue; } $output['sites'][$website->id] = MainWPUtility::mapSite($website, array('id', 'url', 'name')); } @MainWPDB::free_result($websites); } } } $output['urls'] = array(); foreach ($_POST['files'] as $file) { $output['urls'][] = MainWPUtility::getDownloadUrl('bulk', $file); } $output['urls'] = implode('||', $output['urls']); $output['urls'] = apply_filters('mainwp_installbulk_prepareupload', $output['urls']); die(json_encode($output)); }
public static function action($pAction) { $plugin = $_POST['plugin']; $websiteIdEnc = $_POST['websiteId']; if (empty($plugin)) { die(json_encode(array('error' => 'Invalid Request.'))); } $websiteId = $websiteIdEnc; if (!MainWPUtility::ctype_digit($websiteId)) { die(json_encode(array('error' => 'Invalid Request.'))); } $website = MainWPDB::Instance()->getWebsiteById($websiteId); if (!MainWPUtility::can_edit_website($website)) { die(json_encode(array('error' => 'You can not edit this website.'))); } try { $information = MainWPUtility::fetchUrlAuthed($website, 'plugin_action', array('action' => $pAction, 'plugin' => $plugin)); } catch (MainWPException $e) { die(json_encode(array('error' => $e->getMessage()))); } if (!isset($information['status']) || $information['status'] != 'SUCCESS') { die(json_encode(array('error' => 'Unexpected error.'))); } }
public static function pauseBackup() { if (isset($_POST['id']) && MainWPUtility::ctype_digit($_POST['id'])) { $task = MainWPDB::Instance()->getBackupTaskById($_POST['id']); if (MainWPUtility::can_edit_backuptask($task)) { MainWPDB::Instance()->updateBackupTaskWithValues($task->id, array('paused' => 1)); die(json_encode(array('result' => 'SUCCESS'))); } } die(json_encode(array('notask' => true))); }
public static function getPostMeta($postId, $keys, $value, $websiteId) { if (!MainWPUtility::ctype_digit($postId)) { return; } if (!MainWPUtility::ctype_digit($websiteId)) { return; } $website = MainWPDB::Instance()->getWebsiteById($websiteId); if (!MainWPUtility::can_edit_website($website)) { return; } try { $results = MainWPUtility::fetchUrlAuthed($website, 'get_post_meta', array('id' => base64_encode($postId), 'keys' => base64_encode($keys), 'value' => base64_encode($value))); } catch (MainWPException $e) { return; } return $results; }
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 (MainWPUtility::ctype_digit($k)) { $website = MainWPDB::Instance()->getWebsiteById($k); $dbwebsites[$website->id] = MainWPUtility::mapSite($website, array('id', 'url', 'name', 'adminname', 'nossl', 'privkey', 'nosslkey')); } } } else { //Get all websites from the selected groups foreach ($selected_groups as $k) { if (MainWPUtility::ctype_digit($k)) { $websites = MainWPDB::Instance()->query(MainWPDB::Instance()->getSQLWebsitesByGroupId($k)); while ($websites && ($website = @MainWPDB::fetch_object($websites))) { $dbwebsites[$website->id] = MainWPUtility::mapSite($website, array('id', 'url', 'name', 'adminname', 'nossl', 'privkey', 'nosslkey')); } @MainWPDB::free_result($websites); } } } 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(); MainWPUtility::fetchUrlsAuthed($dbwebsites, 'newuser', $post_data, array(MainWPBulkAdd::getClassName(), 'PostingBulk_handler'), $output); } ?> <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 updateGroup() { if (isset($_POST['groupId']) && MainWPUtility::ctype_digit($_POST['groupId'])) { $group = MainWPDB::Instance()->getGroupById($_POST['groupId']); if (MainWPUtility::can_edit_group($group)) { MainWPDB::Instance()->clearGroup($group->id); if (isset($_POST['websiteIds'])) { foreach ($_POST['websiteIds'] as $websiteId) { $website = MainWPDB::Instance()->getWebsiteById($websiteId); if (MainWPUtility::can_edit_website($website)) { MainWPDB::Instance()->updateGroupSite($group->id, $website->id); } } } die(json_encode(array('result' => true))); } } die(json_encode(array('result' => false))); }
public static function action_update($pAction) { $postId = $_POST['postId']; $websiteIdEnc = $_POST['websiteId']; $post_data = $_POST['post_data']; if (!MainWPUtility::ctype_digit($postId)) { die('FAIL'); } $websiteId = $websiteIdEnc; if (!MainWPUtility::ctype_digit($websiteId)) { die('FAIL'); } $website = MainWPDB::Instance()->getWebsiteById($websiteId); if (!MainWPUtility::can_edit_website($website)) { die('FAIL'); } try { $information = MainWPUtility::fetchUrlAuthed($website, 'post_action', array('action' => $pAction, 'id' => $postId, 'post_data' => $post_data)); } catch (MainWPException $e) { die('FAIL'); } if (!isset($information['status']) || $information['status'] != 'SUCCESS') { die('FAIL'); } }
function upgradePluginTheme() { try { $websiteId = $type = null; $slugs = array(); if (isset($_POST['websiteId'])) { $websiteId = $_POST['websiteId']; } if (isset($_POST['slugs'])) { $slugs = $_POST['slugs']; } if (isset($_POST['type'])) { $type = $_POST['type']; } $error = ""; if ($type == "plugin" && !mainwp_current_user_can("dashboard", "update_plugins")) { $error = mainwp_do_not_have_permissions("Update Plugins", false); } else { if ($type == "theme" && !mainwp_current_user_can("dashboard", "update_themes")) { $error = mainwp_do_not_have_permissions("Update Themes", false); } } if (!empty($error)) { die(json_encode(array('error' => $error))); } if (MainWPUtility::ctype_digit($websiteId)) { $website = MainWPDB::Instance()->getWebsiteById($websiteId); if (MainWPUtility::can_edit_website($website)) { $information = MainWPUtility::fetchUrlAuthed($website, 'upgradeplugintheme', array('type' => $type, 'list' => urldecode(implode(',', $slugs)))); die(json_encode($information)); } } } catch (MainWPException $e) { die(json_encode(array('error' => $e->getMessage()))); } die; }
public static function hookGetDBSites($pluginFile, $key, $sites, $groups, $options = false) { if (!self::hookVerify($pluginFile, $key)) { return false; } $dbwebsites = array(); $data = array('id', 'url', 'name', 'adminname', 'nossl', 'privkey', 'nosslkey', 'verify_certificate'); if (is_array($options)) { foreach ($options as $option_name => $value) { if ($value === true && isset(self::$possible_options[$option_name])) { $data[] = self::$possible_options[$option_name]; } } } if ($sites != '') { foreach ($sites as $k => $v) { if (MainWPUtility::ctype_digit($v)) { $website = MainWPDB::Instance()->getWebsiteById($v); $dbwebsites[$website->id] = MainWPUtility::mapSite($website, $data); } } } if ($groups != '') { foreach ($groups as $k => $v) { if (MainWPUtility::ctype_digit($v)) { $websites = MainWPDB::Instance()->query(MainWPDB::Instance()->getSQLWebsitesByGroupId($v)); while ($websites && ($website = @MainWPDB::fetch_object($websites))) { $dbwebsites[$website->id] = MainWPUtility::mapSite($website, $data); } @MainWPDB::free_result($websites); } } } return $dbwebsites; }
public static function renderSites() { $current_wpid = MainWPUtility::get_current_wpid(); if ($current_wpid) { $sql = MainWPDB::Instance()->getSQLWebsiteById($current_wpid); } else { $sql = MainWPDB::Instance()->getSQLWebsitesForCurrentUser(); } $websites = MainWPDB::Instance()->query($sql); if (!$websites) { return; } $total_securityIssues = 0; @MainWPDB::data_seek($websites, 0); while ($websites && ($website = @MainWPDB::fetch_object($websites))) { if (MainWPUtility::ctype_digit($website->securityIssues)) { $total_securityIssues += $website->securityIssues; } } //We found some with security issues! if ($total_securityIssues > 0) { ?> <div class="clear"> <div class="mainwp-row-top darkred"> <span class="mainwp-left-col"><span class="mainwp-rightnow-number"><?php echo $total_securityIssues; ?> </span> <?php _e('Security issue', 'mainwp'); echo $total_securityIssues > 1 ? 's' : ''; ?> </span> <span class="mainwp-mid-col"> </span> <span class="mainwp-right-col"><a href="#" id="mainwp_securityissues_show" onClick="return rightnow_show('securityissues');"><?php _e('Show All', 'mainwp'); ?> </a> <input type="button" class="securityIssues_dashboard_allFixAll button-primary" value="<?php _e('Fix All', 'mainwp'); ?> "/></span> </div> <div id="wp_securityissues" style="display: none"> <?php @MainWPDB::data_seek($websites, 0); while ($websites && ($website = @MainWPDB::fetch_object($websites))) { if (!MainWPUtility::ctype_digit($website->securityIssues) || $website->securityIssues == 0) { continue; } ?> <div class="mainwp-row" siteid="<?php echo $website->id; ?> "> <span class="mainwp-left-col"><a href="admin.php?page=managesites&scanid=<?php echo $website->id; ?> "><?php echo stripslashes($website->name); ?> </a></span> <span class="mainwp-mid-col"><span class="<?php echo $website->securityIssues > 0 ? 'darkred' : 'mainwp_ga_plus'; ?> "><span class="mainwp-rightnow-number"><?php echo $website->securityIssues; ?> </span> Issue<?php echo $website->securityIssues > 1 ? 's' : ''; ?> </span></span> <span class="mainwp-right-col"><?php if ($website->securityIssues == 0) { ?> <input type="button" class="securityIssues_dashboard_unfixAll button" value="<?php _e('Unfix All', 'mainwp'); ?> "/> <?php } else { ?> <input type="button" class="securityIssues_dashboard_fixAll button-primary" value="<?php _e('Fix All', 'mainwp'); ?> "/> <?php } ?> <i class="fa fa-spinner fa-pulse img-loader" style="display: none;"></i> </span> </div> <?php } ?> </div> </div> <?php } }
public static function ignoreUpdates() { $websiteIdEnc = $_POST['websiteId']; $websiteId = $websiteIdEnc; if (!MainWPUtility::ctype_digit($websiteId)) { die('FAIL'); } $website = MainWPDB::Instance()->getWebsiteById($websiteId); if (!MainWPUtility::can_edit_website($website)) { die('FAIL'); } $themes = $_POST['themes']; $names = $_POST['names']; $decodedIgnoredThemes = json_decode($website->ignored_themes, true); if (!is_array($decodedIgnoredThemes)) { $decodedIgnoredThemes = array(); } if (is_array($themes)) { for ($i = 0; $i < count($themes); $i++) { $slug = $themes[$i]; $name = $names[$i]; if (!isset($decodedIgnoredThemes[$slug])) { $decodedIgnoredThemes[$slug] = urldecode($name); } } MainWPDB::Instance()->updateWebsiteValues($website->id, array('ignored_themes' => json_encode($decodedIgnoredThemes))); } die(json_encode(array('result' => true))); }
public static function ignorePluginThemeConflict($type, $name, $siteid) { if (MainWPUtility::ctype_digit($siteid)) { $website = MainWPDB::Instance()->getWebsiteById($siteid); if (MainWPUtility::can_edit_website($website)) { $name = urldecode($name); if ($type == 'plugin') { $decodedIgnoredPlugins = json_decode($website->ignored_pluginConflicts, true); if (!is_array($decodedIgnoredPlugins)) { $decodedIgnoredPlugins = array(); } if (!in_array($name, $decodedIgnoredPlugins)) { $decodedIgnoredPlugins[] = $name; MainWPDB::Instance()->updateWebsiteValues($website->id, array('ignored_pluginConflicts' => json_encode($decodedIgnoredPlugins))); } } else { if ($type == 'theme') { $decodedIgnoredThemes = json_decode($website->ignored_themeConflicts, true); if (!is_array($decodedIgnoredThemes)) { $decodedIgnoredThemes = array(); } if (!in_array($name, $decodedIgnoredThemes)) { $decodedIgnoredThemes[] = $name; MainWPDB::Instance()->updateWebsiteValues($website->id, array('ignored_themeConflicts' => json_encode($decodedIgnoredThemes))); } } } } } else { //Ignore globally $userExtension = MainWPDB::Instance()->getUserExtension(); $name = urldecode($name); if ($type == 'plugin') { $globalIgnoredPluginConflicts = json_decode($userExtension->ignored_pluginConflicts, true); if (!is_array($globalIgnoredPluginConflicts)) { $globalIgnoredPluginConflicts = array(); } if (!in_array($name, $globalIgnoredPluginConflicts)) { $globalIgnoredPluginConflicts[] = $name; $userExtension->ignored_pluginConflicts = json_encode($globalIgnoredPluginConflicts); MainWPDB::Instance()->updateUserExtension($userExtension); } } else { if ($type == 'theme') { $globalIgnoredThemeConflicts = json_decode($userExtension->ignored_themeConflicts, true); if (!is_array($globalIgnoredThemeConflicts)) { $globalIgnoredThemeConflicts = array(); } if (!in_array($name, $globalIgnoredThemeConflicts)) { $globalIgnoredThemeConflicts[] = $name; $userExtension->ignored_themeConflicts = json_encode($globalIgnoredThemeConflicts); MainWPDB::Instance()->updateUserExtension($userExtension); } } } } return 'success'; }
public static function syncInformationArray(&$pWebsite, &$information, $sync_errors = '', $offline_check_result = 1, $error = false, $pAllowDisconnect = true) { $emptyArray = json_encode(array()); $websiteValues = array('directories' => $emptyArray, 'plugin_upgrades' => $emptyArray, 'theme_upgrades' => $emptyArray, 'securityIssues' => $emptyArray, 'themes' => $emptyArray, 'plugins' => $emptyArray, 'users' => $emptyArray, 'categories' => $emptyArray, 'pluginConflicts' => $emptyArray, 'themeConflicts' => $emptyArray, 'offline_check_result' => $offline_check_result); $websiteSyncValues = array('uptodate' => 0, 'sync_errors' => $sync_errors, 'version' => 0); $done = false; if (isset($information['siteurl'])) { $websiteValues['siteurl'] = $information['siteurl']; $done = true; } if (isset($information['version'])) { $websiteSyncValues['version'] = $information['version']; $done = true; } if (isset($information['directories']) && is_array($information['directories'])) { $websiteValues['directories'] = @json_encode($information['directories']); $done = true; } else { if (isset($information['directories'])) { $websiteValues['directories'] = $information['directories']; $done = true; } } if (isset($information['wp_updates']) && $information['wp_updates'] != null) { MainWPDB::Instance()->updateWebsiteOption($pWebsite, 'wp_upgrades', @json_encode(array('current' => $information['wpversion'], 'new' => $information['wp_updates']))); $done = true; } else { MainWPDB::Instance()->updateWebsiteOption($pWebsite, 'wp_upgrades', $emptyArray); } if (isset($information['plugin_updates'])) { $websiteValues['plugin_upgrades'] = @json_encode($information['plugin_updates']); $done = true; } if (isset($information['theme_updates'])) { $websiteValues['theme_upgrades'] = @json_encode($information['theme_updates']); $done = true; } if (isset($information['premium_updates'])) { MainWPDB::Instance()->updateWebsiteOption($pWebsite, 'premium_upgrades', @json_encode($information['premium_updates'])); $done = true; } else { MainWPDB::Instance()->updateWebsiteOption($pWebsite, 'premium_upgrades', $emptyArray); } if (isset($information['securityIssues']) && MainWPUtility::ctype_digit($information['securityIssues']) && $information['securityIssues'] >= 0) { $websiteValues['securityIssues'] = $information['securityIssues']; $done = true; } if (isset($information['recent_comments'])) { MainWPDB::Instance()->updateWebsiteOption($pWebsite, 'recent_comments', @json_encode($information['recent_comments'])); $done = true; } else { MainWPDB::Instance()->updateWebsiteOption($pWebsite, 'recent_comments', $emptyArray); } if (isset($information['recent_posts'])) { MainWPDB::Instance()->updateWebsiteOption($pWebsite, 'recent_posts', @json_encode($information['recent_posts'])); $done = true; } else { MainWPDB::Instance()->updateWebsiteOption($pWebsite, 'recent_posts', $emptyArray); } if (isset($information['recent_pages'])) { MainWPDB::Instance()->updateWebsiteOption($pWebsite, 'recent_pages', @json_encode($information['recent_pages'])); $done = true; } else { MainWPDB::Instance()->updateWebsiteOption($pWebsite, 'recent_pages', $emptyArray); } if (isset($information['themes'])) { $websiteValues['themes'] = @json_encode($information['themes']); $done = true; } if (isset($information['plugins'])) { $websiteValues['plugins'] = @json_encode($information['plugins']); $done = true; } if (isset($information['users'])) { $websiteValues['users'] = @json_encode($information['users']); $done = true; } if (isset($information['categories'])) { $websiteValues['categories'] = @json_encode($information['categories']); $done = true; } if (isset($information['totalsize'])) { $websiteSyncValues['totalsize'] = $information['totalsize']; $done = true; } if (isset($information['dbsize'])) { $websiteSyncValues['dbsize'] = $information['dbsize']; $done = true; } if (isset($information['extauth'])) { $websiteSyncValues['extauth'] = $information['extauth']; $done = true; } if (isset($information['pluginConflicts'])) { $websiteValues['pluginConflicts'] = @json_encode($information['pluginConflicts']); $done = true; } if (isset($information['themeConflicts'])) { $websiteValues['themeConflicts'] = @json_encode($information['themeConflicts']); $done = true; } if (isset($information['last_post_gmt'])) { $websiteSyncValues['last_post_gmt'] = $information['last_post_gmt']; $done = true; } if (isset($information['mainwpdir'])) { $websiteValues['mainwpdir'] = $information['mainwpdir']; $done = true; } if (isset($information['uniqueId'])) { $websiteValues['uniqueId'] = $information['uniqueId']; $done = true; } if (isset($information['faviIcon'])) { MainWPDB::Instance()->updateWebsiteOption($pWebsite, 'favi_icon', trim($information['faviIcon'])); $done = true; } else { MainWPDB::Instance()->updateWebsiteOption($pWebsite, 'favi_icon', ""); } if (!$done) { if (isset($information['wpversion'])) { $websiteSyncValues['uptodate'] = 1; $done = true; } else { if (isset($information['error'])) { MainWPLogger::Instance()->warningForWebsite($pWebsite, 'SYNC ERROR', '[' . $information['error'] . ']'); $error = true; $done = true; $websiteSyncValues['sync_errors'] = __('Error - ', 'mainwp') . $information['error']; } else { if (!empty($sync_errors)) { MainWPLogger::Instance()->warningForWebsite($pWebsite, 'SYNC ERROR', '[' . $sync_errors . ']'); $error = true; if (!$pAllowDisconnect) { $sync_errors = ''; } $websiteSyncValues['sync_errors'] = $sync_errors; } else { MainWPLogger::Instance()->warningForWebsite($pWebsite, 'SYNC ERROR', '[Undefined error]'); $error = true; if ($pAllowDisconnect) { $websiteSyncValues['sync_errors'] = __('Undefined error - please reinstall the MainWP Child Plugin on the client site', 'mainwp'); } } } } } if ($done) { $websiteSyncValues['dtsSync'] = time(); } MainWPDB::Instance()->updateWebsiteSyncValues($pWebsite->id, $websiteSyncValues); MainWPDB::Instance()->updateWebsiteValues($pWebsite->id, $websiteValues); //Sync action if (!$error) { do_action('mainwp-site-synced', $pWebsite, $information); } return !$error; }
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 (MainWPUtility::ctype_digit($k)) { $website = MainWPDB::Instance()->getWebsiteById($k); $dbwebsites[$website->id] = MainWPUtility::mapSite($website, array('id', 'url', 'name', 'adminname', 'nossl', 'privkey', 'nosslkey')); } } } else { //Get all websites from the selected groups foreach ($selected_groups as $k) { if (MainWPUtility::ctype_digit($k)) { $websites = MainWPDB::Instance()->query(MainWPDB::Instance()->getSQLWebsitesByGroupId($k)); while ($websites && ($website = @MainWPDB::fetch_object($websites))) { if ($website->sync_errors != '') { continue; } $dbwebsites[$website->id] = MainWPUtility::mapSite($website, array('id', 'url', 'name', 'adminname', 'nossl', 'privkey', 'nosslkey')); } @MainWPDB::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(); MainWPUtility::fetchUrlsAuthed($dbwebsites, 'newadminpassword', $post_data, array(MainWPBulkAdd::getClassName(), 'PostingBulk_handler'), $output); } } } if (!$show_form) { //Added to.. ?> <div class="wrap"> <img src="<?php echo plugins_url('images/icons/mainwp-passwords.png', dirname(__FILE__)); ?> " style="float: left; margin-right: 8px; margin-top: 7px ;" alt="MainWP Passwords" height="32"/><h2 id="add-new-user"> 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 { // header in User page MainWPUser::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 MainWPUI::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"> <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="mainwp-field mainwp-password" name="pass1" type="password" id="pass1" autocomplete="off" /> <br /> <input class="mainwp-field mainwp-password" 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> <tr><td></td><td colspan="2"><input type="submit" name="updateadminpassword" id="bulk_updateadminpassword" class="button-primary" value="<?php _e('Update Now', 'mainwp'); ?> " /></td></tr> </table> </div> </div> </form> <?php MainWPUser::renderFooter('UpdateAdminPasswords'); } }
public function updateCompletedSites($id, $completedSites) { if (MainWPUtility::ctype_digit($id)) { return $this->wpdb->update($this->tableName('wp_backup'), array('completed_sites' => json_encode($completedSites)), array('id' => $id)); } return false; }
public static function upgradePluginTheme($id, $type, $list) { if (isset($id) && MainWPUtility::ctype_digit($id)) { $website = MainWPDB::Instance()->getWebsiteById($id); if (MainWPUtility::can_edit_website($website)) { $information = MainWPUtility::fetchUrlAuthed($website, 'upgradeplugintheme', array('type' => $type, 'list' => urldecode($list))); if (isset($information['upgrades'])) { $tmp = array(); //todo: 20130718: the syncing in else branch may be removed in the future, it now works with the sync below (just here for older childs..) if (isset($information['sync'])) { foreach ($information['upgrades'] as $k => $v) { $tmp[urlencode($k)] = $v; } } else { $decodedPluginUpgrades = json_decode($website->plugin_upgrades, true); $decodedThemeUpgrades = json_decode($website->theme_upgrades, true); $decodedPremiumUpgrades = json_decode(MainWPDB::Instance()->getWebsiteOption($website, 'premium_upgrades'), true); if (is_array($decodedPremiumUpgrades)) { foreach ($decodedPremiumUpgrades as $crrSlug => $premiumUpgrade) { if ($premiumUpgrade['type'] == 'plugin') { if (!is_array($decodedPluginUpgrades)) { $decodedPluginUpgrades = array(); } $decodedPluginUpgrades[$crrSlug] = $premiumUpgrade; } else { if ($premiumUpgrade['type'] == 'theme') { if (!is_array($decodedThemeUpgrades)) { $decodedThemeUpgrades = array(); } $decodedThemeUpgrades[$crrSlug] = $premiumUpgrade; } } } } foreach ($information['upgrades'] as $k => $v) { $tmp[urlencode($k)] = $v; if ($v == 1) { if ($type == 'plugin') { if (isset($decodedPluginUpgrades[$k])) { unset($decodedPluginUpgrades[$k]); } } if ($type == 'theme') { if (isset($decodedThemeUpgrades[$k])) { unset($decodedThemeUpgrades[$k]); } } } } if ($type == 'plugin') { MainWPDB::Instance()->updateWebsiteValues($website->id, array('plugin_upgrades' => json_encode($decodedPluginUpgrades))); } if ($type == 'theme') { MainWPDB::Instance()->updateWebsiteValues($website->id, array('theme_upgrades' => json_encode($decodedThemeUpgrades))); } } return $tmp; } else { if (isset($information['error'])) { throw new MainWPException('WPERROR', $information['error']); } else { throw new MainWPException('ERROR', 'Invalid response from site'); } } } } throw new MainWPException('ERROR', __('Invalid request', 'mainwp')); }
public static function render() { $current_wpid = MainWPUtility::get_current_wpid(); if (!MainWPUtility::ctype_digit($current_wpid)) { return; } $website = MainWPDB::Instance()->getWebsiteById($current_wpid, true); ?> <div class="mainwp-row-top"> <div style="display: inline-block; width: 100px;"><?php _e('Groups:', 'mainwp'); ?> </div> <?php echo $website->groups == '' ? 'None' : $website->groups; ?> </div> <div class="mainwp-row"> <div style="display: inline-block; width: 100px;"><?php _e('Notes:', 'mainwp'); ?> </div> <a href="#" class="mainwp_notes_show_all" id="mainwp_notes_<?php echo $website->id; ?> "><i class="fa fa-pencil"></i> <?php _e('Open Notes', 'mainwp'); ?> </a><img src="<?php echo plugins_url('images/notes.png', dirname(__FILE__)); ?> " class="mainwp_notes_img" id="mainwp_notes_img_<?php echo $website->id; ?> " <?php if ($website->note == '') { echo 'style="display: none;"'; } ?> /> </div> <span style="display: none" id="mainwp_notes_<?php echo $website->id; ?> _note"><?php echo $website->note; ?> </span> <div class="mainwp-row"> <div style="display: inline-block; width: 100px;"><?php _e('Go to:', 'mainwp'); ?> </div> <a href="admin.php?page=SiteOpen&newWindow=yes&websiteid=<?php echo $website->id; ?> " target="_blank"><i class="fa fa-external-link"></i> <?php _e('WP Admin', 'mainwp'); ?> </a> | <a target="_blank" href="<?php echo $website->url; ?> "><i class="fa fa-external-link"></i> <?php _e('Front Page', 'mainwp'); ?> </a> </div> <div class="mainwp-row"> <div style="display: inline-block; width: 100px;"><?php _e('Child Site:', 'mainwp'); ?> </div> <a href="admin.php?page=managesites&id=<?php echo $website->id; ?> "><i class="fa fa-pencil-square-o"></i> <?php _e('Edit', 'mainwp'); ?> </a> | <a target="_blank" href="admin.php?page=managesites&scanid=<?php echo $website->id; ?> "><i class="fa fa-shield"></i> <?php _e('Security Scan', 'mainwp'); ?> </a> </div> <?php do_action("mainwp_shortcuts_widget", $website); ?> <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"><a href="<?php echo admin_url('admin.php?page=managesites&dashboard=' . $website->id); ?> "><?php echo stripslashes($website->name); ?> </a></div> <div id="mainwp_notes_content"> <textarea style="width: 580px !important; height: 300px;" id="mainwp_notes_note"></textarea> </div> <div><em>Allowed HTML Tags: <p>, <strong>, <em>, <br/>, <hr/>, <a> </em></div><br/> <form> <div style="float: right" id="mainwp_notes_status"></div> <input type="button" class="button cont button-primary" id="mainwp_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_websiteid" value=""/> </form> </div> <?php }
function mainwp_backuptask_run_site() { try { $this->secure_request('mainwp_backuptask_run_site'); if (!isset($_POST['site_id']) || !MainWPUtility::ctype_digit($_POST['site_id']) || !isset($_POST['task_id']) || !MainWPUtility::ctype_digit($_POST['task_id'])) { throw new MainWPException('Invalid request'); } die(json_encode(array('result' => MainWPManageBackups::backup($_POST['task_id'], $_POST['site_id'], $_POST['fileNameUID'])))); } catch (MainWPException $e) { die(json_encode(array('error' => array('message' => $e->getMessage(), 'extra' => $e->getMessageExtra())))); } }
public static function updateChildsiteValue() { if (isset($_POST['site_id']) && MainWPUtility::ctype_digit($_POST['site_id'])) { $website = MainWPDB::Instance()->getWebsiteById($_POST['site_id']); if (MainWPUtility::can_edit_website($website)) { $error = ''; $uniqueId = isset($_POST['unique_id']) ? $_POST['unique_id'] : ""; try { $information = MainWPUtility::fetchUrlAuthed($website, 'update_values', array('uniqueId' => $uniqueId)); } catch (MainWPException $e) { $error = $e->getMessage(); } if ($error != '') { die(json_encode(array('error' => $error))); } else { if (isset($information['result']) && $information['result'] == 'ok') { die(json_encode(array('result' => 'SUCCESS'))); } else { die(json_encode(array('undefined_error' => true))); } } } } die(json_encode(array('error' => 'NO_SIDE_ID'))); }
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 (MainWPUtility::ctype_digit($k)) { $website = MainWPDB::Instance()->getWebsiteById($k); $dbwebsites[$website->id] = MainWPUtility::mapSite($website, array('id', 'url', 'name', 'adminname', 'nossl', 'privkey', 'nosslkey')); } } } else { //Get all websites from the selected groups foreach ($selected_groups as $k) { if (MainWPUtility::ctype_digit($k)) { $websites = MainWPDB::Instance()->query(MainWPDB::Instance()->getSQLWebsitesByGroupId($k)); while ($websites && ($website = @MainWPDB::fetch_object($websites))) { if ($website->sync_errors != '') { continue; } $dbwebsites[$website->id] = MainWPUtility::mapSite($website, array('id', 'url', 'name', 'adminname', 'nossl', 'privkey', 'nosslkey')); } @MainWPDB::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); MainWPUtility::fetchUrlsAuthed($dbwebsites, 'newpost', $post_data, array(MainWPBulkAdd::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; foreach ($dbwebsites as $website) { if (isset($output->ok[$website->id]) && $output->ok[$website->id] == 1) { $countSites++; } } if (!empty($countSites)) { $seconds = time() - $startTime; MainWPTwitter::updateTwitterInfo('new_page', $countSites, $seconds, 1, $startTime, 1); } if (MainWPTwitter::enabledTwitterMessages()) { $twitters = MainWPTwitter::getTwitterNotice('new_page'); if (is_array($twitters)) { foreach ($twitters as $timeid => $twit_mess) { if (!empty($twit_mess)) { $sendText = MainWPTwitter::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 MainWPTwitter::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 updateTipSettings() { if (MainWPUtility::ctype_digit($_POST['status'])) { $userExtension = MainWPDB::Instance()->getUserExtension(); $userExtension->tips = $_POST['status']; MainWPDB::Instance()->updateUserExtension($userExtension); } }