Пример #1
0
    public static function render()
    {
        $current_wpid = MainWP_Utility::get_current_wpid();
        if (!MainWP_Utility::ctype_digit($current_wpid)) {
            return;
        }
        $website = MainWP_DB::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 
    }
Пример #2
0
 function on_admin_menu()
 {
     if (MainWP_Utility::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 (!MainWP_Utility::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');
     //        }
 }
Пример #3
0
 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 (MainWP_Utility::ctype_digit($websiteid)) {
                 $website = MainWP_DB::Instance()->getWebsiteById($websiteid);
                 $output['sites'][$website->id] = MainWP_Utility::mapSite($website, array('id', 'url', 'name'));
             }
         }
     } else {
         //Get sites from group
         foreach ($_POST['selected_groups'] as $enc_id) {
             $groupid = $enc_id;
             if (MainWP_Utility::ctype_digit($groupid)) {
                 $websites = MainWP_DB::Instance()->query(MainWP_DB::Instance()->getSQLWebsitesByGroupId($groupid));
                 while ($websites && ($website = @MainWP_DB::fetch_object($websites))) {
                     if ($website->sync_errors != '') {
                         continue;
                     }
                     $output['sites'][$website->id] = MainWP_Utility::mapSite($website, array('id', 'url', 'name'));
                 }
                 @MainWP_DB::free_result($websites);
             }
         }
     }
     $output['urls'] = array();
     foreach ($_POST['files'] as $file) {
         $output['urls'][] = MainWP_Utility::getDownloadUrl('bulk', $file);
     }
     $output['urls'] = implode('||', $output['urls']);
     $output['urls'] = apply_filters('mainwp_installbulk_prepareupload', $output['urls']);
     die(json_encode($output));
 }
Пример #4
0
 public static function updateTipSettings()
 {
     if (MainWP_Utility::ctype_digit($_POST['status'])) {
         $userExtension = MainWP_DB::Instance()->getUserExtension();
         $userExtension->tips = $_POST['status'];
         MainWP_DB::Instance()->updateUserExtension($userExtension);
     }
 }
    public static function render()
    {
        $current_wpid = MainWP_Utility::get_current_wpid();
        if (!MainWP_Utility::ctype_digit($current_wpid)) {
            return;
        }
        $website = MainWP_DB::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: &lt;p&gt;, &lt;strong&gt;, &lt;em&gt;, &lt;br/&gt;, &lt;hr/&gt;, &lt;a&gt; </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 
    }
Пример #6
0
 function mainwp_backuptask_run_site()
 {
     try {
         $this->secure_request('mainwp_backuptask_run_site');
         if (!isset($_POST['site_id']) || !MainWP_Utility::ctype_digit($_POST['site_id']) || !isset($_POST['task_id']) || !MainWP_Utility::ctype_digit($_POST['task_id'])) {
             throw new MainWP_Exception('Invalid request');
         }
         die(json_encode(array('result' => MainWP_Manage_Backups::backup($_POST['task_id'], $_POST['site_id'], $_POST['fileNameUID']))));
     } catch (MainWP_Exception $e) {
         die(json_encode(array('error' => array('message' => $e->getMessage(), 'extra' => $e->getMessageExtra()))));
     }
 }
Пример #7
0
 public static function upgradePluginTheme($id, $type, $list)
 {
     if (isset($id) && MainWP_Utility::ctype_digit($id)) {
         $website = MainWP_DB::Instance()->getWebsiteById($id);
         if (MainWP_Utility::can_edit_website($website)) {
             $information = MainWP_Utility::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(MainWP_DB::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') {
                         MainWP_DB::Instance()->updateWebsiteValues($website->id, array('plugin_upgrades' => json_encode($decodedPluginUpgrades)));
                     }
                     if ($type == 'theme') {
                         MainWP_DB::Instance()->updateWebsiteValues($website->id, array('theme_upgrades' => json_encode($decodedThemeUpgrades)));
                     }
                 }
                 return $tmp;
             } else {
                 if (isset($information['error'])) {
                     throw new MainWP_Exception('WPERROR', $information['error']);
                 } else {
                     throw new MainWP_Exception('ERROR', 'Invalid response from site');
                 }
             }
         }
     }
     throw new MainWP_Exception('ERROR', __('Invalid request', 'mainwp'));
 }
 public static function action($pAction)
 {
     $plugin = $_POST['plugin'];
     $websiteIdEnc = $_POST['websiteId'];
     if (empty($plugin)) {
         die(json_encode(array('error' => 'Invalid Request.')));
     }
     $websiteId = $websiteIdEnc;
     if (!MainWP_Utility::ctype_digit($websiteId)) {
         die(json_encode(array('error' => 'Invalid Request.')));
     }
     $website = MainWP_DB::Instance()->getWebsiteById($websiteId);
     if (!MainWP_Utility::can_edit_website($website)) {
         die(json_encode(array('error' => 'You can not edit this website.')));
     }
     try {
         $information = MainWP_Utility::fetchUrlAuthed($website, 'plugin_action', array('action' => $pAction, 'plugin' => $plugin));
     } catch (MainWP_Exception $e) {
         die(json_encode(array('error' => $e->getMessage())));
     }
     if (!isset($information['status']) || $information['status'] != 'SUCCESS') {
         die(json_encode(array('error' => 'Unexpected error.')));
     }
 }
Пример #9
0
 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, 'translation_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) {
         MainWP_DB::Instance()->updateWebsiteOption($pWebsite, 'wp_upgrades', @json_encode(array('current' => $information['wpversion'], 'new' => $information['wp_updates'])));
         $done = true;
     } else {
         MainWP_DB::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['translation_updates'])) {
         $websiteValues['translation_upgrades'] = @json_encode($information['translation_updates']);
         $done = true;
     }
     if (isset($information['premium_updates'])) {
         MainWP_DB::Instance()->updateWebsiteOption($pWebsite, 'premium_upgrades', @json_encode($information['premium_updates']));
         $done = true;
     } else {
         MainWP_DB::Instance()->updateWebsiteOption($pWebsite, 'premium_upgrades', $emptyArray);
     }
     if (isset($information['securityIssues']) && MainWP_Utility::ctype_digit($information['securityIssues']) && $information['securityIssues'] >= 0) {
         $websiteValues['securityIssues'] = $information['securityIssues'];
         $done = true;
     }
     if (isset($information['recent_comments'])) {
         MainWP_DB::Instance()->updateWebsiteOption($pWebsite, 'recent_comments', @json_encode($information['recent_comments']));
         $done = true;
     } else {
         MainWP_DB::Instance()->updateWebsiteOption($pWebsite, 'recent_comments', $emptyArray);
     }
     if (isset($information['recent_posts'])) {
         MainWP_DB::Instance()->updateWebsiteOption($pWebsite, 'recent_posts', @json_encode($information['recent_posts']));
         $done = true;
     } else {
         MainWP_DB::Instance()->updateWebsiteOption($pWebsite, 'recent_posts', $emptyArray);
     }
     if (isset($information['recent_pages'])) {
         MainWP_DB::Instance()->updateWebsiteOption($pWebsite, 'recent_pages', @json_encode($information['recent_pages']));
         $done = true;
     } else {
         MainWP_DB::Instance()->updateWebsiteOption($pWebsite, 'recent_pages', $emptyArray);
     }
     if (isset($information['themes'])) {
         $websiteValues['themes'] = @json_encode($information['themes']);
         $done = true;
     }
     $to_fix = false;
     if (isset($information['plugins'])) {
         foreach ($information['plugins'] as $info) {
             if (isset($info['slug']) && in_array($info['slug'], array('ithemes-security-pro/ithemes-security-pro.php', 'monarch/monarch.php'))) {
                 $to_fix = true;
             }
         }
         $websiteValues['plugins'] = @json_encode($information['plugins']);
         $done = true;
     }
     if ($to_fix) {
         $request = get_option('mainwp_request_plugins_page_site_' . $pWebsite->id);
         if (empty($request)) {
             update_option('mainwp_request_plugins_page_site_' . $pWebsite->id, 'yes');
         }
     } else {
         if ('yes' == get_option('mainwp_request_plugins_page_site_' . $pWebsite->id)) {
             delete_option('mainwp_request_plugins_page_site_' . $pWebsite->id);
         }
     }
     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(array_filter($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'])) {
         MainWP_DB::Instance()->updateWebsiteOption($pWebsite, 'favi_icon', trim($information['faviIcon']));
         $done = true;
     } else {
         MainWP_DB::Instance()->updateWebsiteOption($pWebsite, 'favi_icon', '');
     }
     if (isset($information['plugins_outdate_info'])) {
         MainWP_DB::Instance()->updateWebsiteOption($pWebsite, 'plugins_outdate_info', @json_encode($information['plugins_outdate_info']));
         $done = true;
     } else {
         MainWP_DB::Instance()->updateWebsiteOption($pWebsite, 'plugins_outdate_info', $emptyArray);
     }
     if (isset($information['themes_outdate_info'])) {
         MainWP_DB::Instance()->updateWebsiteOption($pWebsite, 'themes_outdate_info', @json_encode($information['themes_outdate_info']));
         $done = true;
     } else {
         MainWP_DB::Instance()->updateWebsiteOption($pWebsite, 'themes_outdate_info', $emptyArray);
     }
     if (!$done) {
         if (isset($information['wpversion'])) {
             $websiteSyncValues['uptodate'] = 1;
             $done = true;
         } else {
             if (isset($information['error'])) {
                 MainWP_Logger::Instance()->warningForWebsite($pWebsite, 'SYNC ERROR', '[' . $information['error'] . ']');
                 $error = true;
                 $done = true;
                 $websiteSyncValues['sync_errors'] = __('Error - ', 'mainwp') . $information['error'];
             } else {
                 if (!empty($sync_errors)) {
                     MainWP_Logger::Instance()->warningForWebsite($pWebsite, 'SYNC ERROR', '[' . $sync_errors . ']');
                     $error = true;
                     if (!$pAllowDisconnect) {
                         $sync_errors = '';
                     }
                     $websiteSyncValues['sync_errors'] = $sync_errors;
                 } else {
                     MainWP_Logger::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();
     }
     MainWP_DB::Instance()->updateWebsiteSyncValues($pWebsite->id, $websiteSyncValues);
     MainWP_DB::Instance()->updateWebsiteValues($pWebsite->id, $websiteValues);
     //Sync action
     if (!$error) {
         do_action('mainwp-site-synced', $pWebsite, $information);
     }
     return !$error;
 }
Пример #10
0
 public static function getPostMeta($postId, $keys, $value, $websiteId)
 {
     if (!MainWP_Utility::ctype_digit($postId)) {
         return;
     }
     if (!MainWP_Utility::ctype_digit($websiteId)) {
         return;
     }
     $website = MainWP_DB::Instance()->getWebsiteById($websiteId);
     if (!MainWP_Utility::can_edit_website($website)) {
         return;
     }
     try {
         $results = MainWP_Utility::fetchUrlAuthed($website, 'get_post_meta', array('id' => base64_encode($postId), 'keys' => base64_encode($keys), 'value' => base64_encode($value)));
     } catch (MainWP_Exception $e) {
         return;
     }
     return $results;
 }
Пример #11
0
 public static function ignoreUpdates()
 {
     $websiteIdEnc = $_POST['websiteId'];
     $websiteId = $websiteIdEnc;
     if (!MainWP_Utility::ctype_digit($websiteId)) {
         die('FAIL');
     }
     $website = MainWP_DB::Instance()->getWebsiteById($websiteId);
     if (!MainWP_Utility::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);
             }
         }
         MainWP_DB::Instance()->updateWebsiteValues($website->id, array('ignored_themes' => json_encode($decodedIgnoredThemes)));
     }
     die(json_encode(array('result' => true)));
 }
 public static function action_update($pAction)
 {
     $postId = $_POST['postId'];
     $websiteIdEnc = $_POST['websiteId'];
     $post_data = $_POST['post_data'];
     if (!MainWP_Utility::ctype_digit($postId)) {
         die('FAIL');
     }
     $websiteId = $websiteIdEnc;
     if (!MainWP_Utility::ctype_digit($websiteId)) {
         die('FAIL');
     }
     $website = MainWP_DB::Instance()->getWebsiteById($websiteId);
     if (!MainWP_Utility::can_edit_website($website)) {
         die('FAIL');
     }
     try {
         $information = MainWP_Utility::fetchUrlAuthed($website, 'post_action', array('action' => $pAction, 'id' => $postId, 'post_data' => $post_data));
     } catch (MainWP_Exception $e) {
         die('FAIL');
     }
     if (!isset($information['status']) || $information['status'] != 'SUCCESS') {
         die('FAIL');
     }
 }
 public static function pauseBackup()
 {
     if (isset($_POST['id']) && MainWP_Utility::ctype_digit($_POST['id'])) {
         $task = MainWP_DB::Instance()->getBackupTaskById($_POST['id']);
         if (MainWP_Utility::can_edit_backuptask($task)) {
             MainWP_DB::Instance()->updateBackupTaskWithValues($task->id, array('paused' => 1));
             die(json_encode(array('result' => 'SUCCESS')));
         }
     }
     die(json_encode(array('notask' => true)));
 }
Пример #14
0
 public static function updateGroup()
 {
     if (isset($_POST['groupId']) && MainWP_Utility::ctype_digit($_POST['groupId'])) {
         $group = MainWP_DB::Instance()->getGroupById($_POST['groupId']);
         if (MainWP_Utility::can_edit_group($group)) {
             MainWP_DB::Instance()->clearGroup($group->id);
             if (isset($_POST['websiteIds'])) {
                 foreach ($_POST['websiteIds'] as $websiteId) {
                     $website = MainWP_DB::Instance()->getWebsiteById($websiteId);
                     if (MainWP_Utility::can_edit_website($website)) {
                         MainWP_DB::Instance()->updateGroupSite($group->id, $website->id);
                     }
                 }
             }
             die(json_encode(array('result' => true)));
         }
     }
     die(json_encode(array('result' => false)));
 }
Пример #15
0
    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>&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 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 renderSites()
    {
        $current_wpid = MainWP_Utility::get_current_wpid();
        if ($current_wpid) {
            $sql = MainWP_DB::Instance()->getSQLWebsiteById($current_wpid);
        } else {
            $sql = MainWP_DB::Instance()->getSQLWebsitesForCurrentUser();
        }
        $websites = MainWP_DB::Instance()->query($sql);
        if (!$websites) {
            return;
        }
        $total_securityIssues = 0;
        @MainWP_DB::data_seek($websites, 0);
        while ($websites && ($website = @MainWP_DB::fetch_object($websites))) {
            if (MainWP_Utility::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">&nbsp;</span>
					<span class="mainwp-right-col"><a href="#" id="mainwp_securityissues_show" onClick="return rightnow_show('securityissues');"><?php 
            _e('Show All', 'mainwp');
            ?>
</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<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 
            @MainWP_DB::data_seek($websites, 0);
            while ($websites && ($website = @MainWP_DB::fetch_object($websites))) {
                if (!MainWP_Utility::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 
        } else {
            esc_html_e('No security issues detected.', 'mainwp');
        }
    }
    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 ! " ? $ % ^ &amp; ).', '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 ! " ? $ % ^ &amp; ).', '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');
        }
    }
Пример #18
0
 public static function updateChildsiteValue()
 {
     if (isset($_POST['site_id']) && MainWP_Utility::ctype_digit($_POST['site_id'])) {
         $website = MainWP_DB::Instance()->getWebsiteById($_POST['site_id']);
         if (MainWP_Utility::can_edit_website($website)) {
             $error = '';
             $uniqueId = isset($_POST['unique_id']) ? $_POST['unique_id'] : '';
             try {
                 $information = MainWP_Utility::fetchUrlAuthed($website, 'update_values', array('uniqueId' => $uniqueId));
             } catch (MainWP_Exception $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')));
 }
Пример #19
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));
        }
    }
Пример #20
0
 public function updateCompletedSites($id, $completedSites)
 {
     if (MainWP_Utility::ctype_digit($id)) {
         return $this->wpdb->update($this->tableName('wp_backup'), array('completed_sites' => json_encode($completedSites)), array('id' => $id));
     }
     return false;
 }
Пример #21
0
 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', 'ssl_version');
     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 (MainWP_Utility::ctype_digit($v)) {
                 $website = MainWP_DB::Instance()->getWebsiteById($v);
                 $dbwebsites[$website->id] = MainWP_Utility::mapSite($website, $data);
             }
         }
     }
     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))) {
                     $dbwebsites[$website->id] = MainWP_Utility::mapSite($website, $data);
                 }
                 @MainWP_DB::free_result($websites);
             }
         }
     }
     return $dbwebsites;
 }
Пример #22
0
 public static function ignorePluginThemeConflict($type, $name, $siteid)
 {
     if (MainWP_Utility::ctype_digit($siteid)) {
         $website = MainWP_DB::Instance()->getWebsiteById($siteid);
         if (MainWP_Utility::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;
                     MainWP_DB::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;
                         MainWP_DB::Instance()->updateWebsiteValues($website->id, array('ignored_themeConflicts' => json_encode($decodedIgnoredThemes)));
                     }
                 }
             }
         }
     } else {
         //Ignore globally
         $userExtension = MainWP_DB::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);
                 MainWP_DB::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);
                     MainWP_DB::Instance()->updateUserExtension($userExtension);
                 }
             }
         }
     }
     return 'success';
 }
Пример #23
0
 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', 'mainwp'), false);
         } else {
             if ($type == 'theme' && !mainwp_current_user_can('dashboard', 'update_themes')) {
                 $error = mainwp_do_not_have_permissions(__('update themes', 'mainwp'), false);
             }
         }
         if (!empty($error)) {
             die(json_encode(array('error' => $error)));
         }
         if (MainWP_Utility::ctype_digit($websiteId)) {
             $website = MainWP_DB::Instance()->getWebsiteById($websiteId);
             if (MainWP_Utility::can_edit_website($website)) {
                 $information = MainWP_Utility::fetchUrlAuthed($website, 'upgradeplugintheme', array('type' => $type, 'list' => urldecode(implode(',', $slugs))));
                 die(json_encode($information));
             }
         }
     } catch (MainWP_Exception $e) {
         die(json_encode(array('error' => $e->getMessage())));
     }
     die;
 }
Пример #24
0
 public static function upgradePluginThemeTranslation($id, $type, $list)
 {
     if (isset($id) && MainWP_Utility::ctype_digit($id)) {
         $website = MainWP_DB::Instance()->getWebsiteById($id);
         if (MainWP_Utility::can_edit_website($website)) {
             $information = MainWP_Utility::fetchUrlAuthed($website, 'translation' === $type ? 'upgradetranslation' : 'upgradeplugintheme', array('type' => $type, 'list' => urldecode($list)));
             if (isset($information['upgrades'])) {
                 $tmp = array();
                 if (isset($information['upgrades'])) {
                     foreach ($information['upgrades'] as $k => $v) {
                         $tmp[urlencode($k)] = $v;
                     }
                 }
                 return $tmp;
             } else {
                 if (isset($information['error'])) {
                     throw new MainWP_Exception('WPERROR', $information['error']);
                 } else {
                     throw new MainWP_Exception('ERROR', 'Invalid response from site');
                 }
             }
         }
     }
     throw new MainWP_Exception('ERROR', __('Invalid request', 'mainwp'));
 }