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 }
public function warningForWebsite($pWebsite, $pAction, $pMessage, $addStackTrace = true) { $stackTrace = ''; if ($addStackTrace) { @ob_start(); @debug_print_backtrace(); $stackTrace = "\n" . @ob_get_clean(); } if (empty($pWebsite)) { return $this->log('[-] [-] ::' . $pAction . ':: ' . $pMessage . $stackTrace, self::WARNING); } return $this->log('[' . $pWebsite->name . '] [' . MainWP_Utility::getNiceURL($pWebsite->url) . '] ::' . $pAction . ':: ' . $pMessage . $stackTrace, self::WARNING); }
public function testloginapi($args) { $defaults = array('request' => 'testloginapi'); $args = wp_parse_args($defaults, $args); $target_url = self::create_software_api_url($args); $request = wp_remote_get($target_url, array('timeout' => 50, 'sslverify' => self::$apisslverify)); // $request = wp_remote_post( MainWP_Api_Manager::instance()->getUpgradeUrl() . 'wc-api/am-software-api/', array('body' => $args) ); if (is_wp_error($request)) { if (self::$apisslverify == 1) { MainWP_Utility::update_option('mainwp_api_sslVerifyCertificate', 0); return array('retry_action' => 1); } throw new Exception($request->get_error_message()); return false; } $code = wp_remote_retrieve_response_code($request); if ($code != 200) { throw new Exception('Error: code ' . $code); return false; } $response = wp_remote_retrieve_body($request); return $response; }
public static function renderSettings() { $userExtension = MainWP_DB::Instance()->getUserExtension(); $pluginDir = $userExtension == null || ($userExtension->pluginDir == null || $userExtension->pluginDir == '') ? 'default' : $userExtension->pluginDir; $user_email = MainWP_Utility::getNotificationEmail(); $siteview = $userExtension->site_view; $snAutomaticDailyUpdate = get_option('mainwp_automaticDailyUpdate'); $backup_before_upgrade = get_option('mainwp_backup_before_upgrade'); $lastAutomaticUpdate = MainWP_DB::Instance()->getWebsitesLastAutomaticSync(); if ($lastAutomaticUpdate == 0) { $nextAutomaticUpdate = 'Any minute'; } else { if (MainWP_DB::Instance()->getWebsitesCountWhereDtsAutomaticSyncSmallerThenStart() > 0 || MainWP_DB::Instance()->getWebsitesCheckUpdatesCount() > 0) { $nextAutomaticUpdate = 'Processing your websites.'; } else { $nextAutomaticUpdate = MainWP_Utility::formatTimestamp(MainWP_Utility::getTimestamp(mktime(0, 0, 0, date('n'), date('j') + 1))); } } if ($lastAutomaticUpdate == 0) { $lastAutomaticUpdate = 'Never'; } else { $lastAutomaticUpdate = MainWP_Utility::formatTimestamp(MainWP_Utility::getTimestamp($lastAutomaticUpdate)); } ?> <div class="postbox" id="mainwp-hide-child-plugin-settings"> <h3 class="mainwp_box_title"> <span><i class="fa fa-cog"></i> <?php _e('Network Optimization', 'mainwp'); ?> </span></h3> <div class="inside"> <div class="mainwp_info-box-red" style="margin-top: 5px;"><?php _e('<strong>STOP BEFORE TURNING ON!</strong> Hiding the Child Plugin does require the plugin to make changes to your .htaccess file that in rare instances or server configurations could cause problems.', 'mainwp'); ?> </div> <table class="form-table"> <tbody> <tr> <th scope="row"><?php _e('Hide MainWP Child Plugin from Search Engines', 'mainwp'); ?> <br/> <em style="font-size: 12px;">(<?php _e('does not hide from users', 'mainwp'); ?> )</em> </th> <td> <table> <tr> <td valign="top" style="padding-left: 0; padding-right: 5px; padding-top: 0px; padding-bottom: 0px; vertical-align: top;"> <div class="mainwp-checkbox"> <input type="checkbox" value="hidden" name="mainwp_options_footprint_plugin_folder" id="mainwp_options_footprint_plugin_folder_default" <?php echo $pluginDir == 'hidden' ? 'checked="true"' : ''; ?> /><label for="mainwp_options_footprint_plugin_folder_default"></label> </div> </td> <td valign="top" style="padding: 0"> <label for="mainwp_options_footprint_plugin_folder_default"> <em><?php _e('This will make anyone including Search Engines trying find your Child Plugin encounter a 404 page. Hiding the Child Plugin does require the plugin to make changes to your .htaccess file that in rare instances or server configurations could cause problems.', 'mainwp'); ?> </em> </label> </td> </tr> </table> </td> </tr> <tr> <th scope="row"><?php _e('Optimize for Shared Hosting or Big Networks', 'mainwp'); ?> <?php MainWP_Utility::renderToolTip(__('Updates will be cached for quick loading. A manual refresh from the Dashboard is required to view new plugins, themes, pages or users. Recommended for Networks over 50 sites.', 'mainwp')); ?> </th> <td> <div class="mainwp-checkbox"> <input type="checkbox" name="mainwp_optimize" id="mainwp_optimize" <?php echo get_option('mainwp_optimize') == 1 ? 'checked="true"' : ''; ?> /> <label for="mainwp_optimize"></label> </div> </td> </tr> </tbody> </table> </div> </div> <div class="postbox" id="mainwp-global-options-settings"> <h3 class="mainwp_box_title"> <span><i class="fa fa-cog"></i> <?php _e('Global Options', 'mainwp'); ?> </span></h3> <div class="inside"> <table class="form-table"> <tbody> <tr> <th scope="row"><?php _e('Notification Email', 'mainwp'); MainWP_Utility::renderToolTip(__('This address is used to send monitoring alerts.', 'mainwp')); ?> </th> <td> <input type="text" class="" name="mainwp_options_email" size="35" value="<?php echo $user_email; ?> "/><span class="mainwp-form_hint"><?php _e('This address is used to send monitoring alerts.', 'mainwp'); ?> </span> </td> </tr> <tr> <th scope="row"><?php _e('Use WP-Cron', 'mainwp'); MainWP_Utility::renderToolTip(__('When not using WP-Cron you will need to set up a cron job via your hosting.', 'mainwp'), 'http://docs.mainwp.com/disable-wp-cron/'); ?> </th> <td> <div class="mainwp-checkbox"> <input type="checkbox" name="mainwp_options_wp_cron" id="mainwp_options_wp_cron" <?php echo get_option('mainwp_wp_cron') == 1 || get_option('mainwp_wp_cron') === false ? 'checked="true"' : ''; ?> /> <label for="mainwp_options_wp_cron"></label> </div> </td> </tr> <?php if (MainWP_Utility::isAdmin()) { ?> <tr> <th scope="row"><?php _e('Show Basic SEO Stats', 'mainwp'); MainWP_Utility::renderToolTip(__('This requires your Dashboard to query the Google servers for this information.', 'mainwp')); ?> </th> <td> <div class="mainwp-checkbox"> <input type="checkbox" name="mainwp_seo" id="mainwp_seo" <?php echo get_option('mainwp_seo') == 1 ? 'checked="true"' : ''; ?> /> <label for="mainwp_seo"></label> </div> </td> </tr> <?php } ?> </tbody> </table> </div> </div> <div class="postbox" id="mainwp-upgrade-options-settings"> <h3 class="mainwp_box_title"> <span><i class="fa fa-cog"></i> <?php _e('Upgrade Options', 'mainwp'); ?> </span></h3> <div class="inside"> <table class="form-table"> <tbody> <tr> <th scope="row"><?php _e('Require Backup Before Upgrade', 'mainwp'); MainWP_Utility::renderToolTip(__('With this option enabled, when you try to upgrade a plugin, theme or WordPress core, MainWP will check if there is a full backup created for the site(s) you are trying to upgrade in last 7 days. If you have a fresh backup of the site(s) MainWP will proceed to the upgrade process, if not it will ask you to create a full backup.', 'mainwp')); ?> </th> <td> <div class="mainwp-checkbox"> <input type="checkbox" name="mainwp_backup_before_upgrade" id="mainwp_backup_before_upgrade" size="35" <?php echo $backup_before_upgrade == 1 ? 'checked="true"' : ''; ?> /> <label for="mainwp_backup_before_upgrade"></label> </div> </td> </tr> <tr> <th scope="row"><?php _e('Automatic Daily Update', 'mainwp'); MainWP_Utility::renderToolTip(__('Choose to have MainWP install updates, or notify you by email of available updates. Updates apply to WordPress Core files, Plugins and Themes.', 'mainwp')); ?> </th> <td> <table class="mainwp-nomarkup"> <tr> <td valign="top"> <span class="mainwp-select-bg"> <select name="mainwp_automaticDailyUpdate" id="mainwp_automaticDailyUpdate"> <option value="2" <?php if ($snAutomaticDailyUpdate === false || $snAutomaticDailyUpdate == 2) { ?> selected<?php } ?> >E-mail Notifications of New Updates</option> <option value="1" <?php if ($snAutomaticDailyUpdate == 1) { ?> selected<?php } ?> >Install Trusted Updates</option> <option value="0" <?php if ($snAutomaticDailyUpdate !== false && $snAutomaticDailyUpdate == 0) { ?> selected<?php } ?> >Off</option> </select> <label></label> </span> <br/><em><?php _e('Last run: ', 'mainwp'); echo $lastAutomaticUpdate; ?> </em> <br /><em><?php _e('Next run: ', 'mainwp'); echo $nextAutomaticUpdate; ?> </em> </td> </tr> </table> </td> </tr> <tr> <th scope="row"><?php _e('Abandoned Plugins/Thems Tolerance', 'mainwp'); MainWP_Utility::renderToolTip(__("In case the plugin or theme author didn't release an update for the set number of days, the plugin/theme will be marked and Possibly Abandoned.", 'mainwp')); ?> </th> <td> <input type="text" name="mainwp_numberdays_Outdate_Plugin_Theme" class="" id="mainwp_numberdays_Outdate_Plugin_Theme" value="<?php echo get_option('mainwp_numberdays_Outdate_Plugin_Theme') === false ? 365 : get_option('mainwp_numberdays_Outdate_Plugin_Theme'); ?> "/> </td> </tr> </tbody> </table> </div> </div> <div class="postbox" id="mainwp-date-return-options-settings"> <h3 class="mainwp_box_title"><span><i class="fa fa-cog"></i> <?php _e('Data Return Options', 'mainwp'); ?> </span> </h3> <div class="inside"> <table class="form-table"> <tbody> <tr> <th scope="row"><?php _e('Maximum Number of Posts/Pages', 'mainwp'); MainWP_Utility::renderToolTip(__('0 for unlimited, CAUTION: a large amount will decrease the speed and might crash the communication.', 'mainwp')); ?> </th> <td> <input type="text" name="mainwp_maximumPosts" class="" id="mainwp_maximumPosts" value="<?php echo get_option('mainwp_maximumPosts') === false ? 50 : get_option('mainwp_maximumPosts'); ?> "/> </td> </tr> <tr> <th scope="row"><?php _e('Maximum Number of Comments', 'mainwp'); MainWP_Utility::renderToolTip(__('0 for unlimited, CAUTION: a large amount will decrease the speed and might crash the communication.', 'mainwp')); ?> </th> <td> <input type="text" name="mainwp_maximumComments" class="" id="mainwp_maximumComments" value="<?php echo get_option('mainwp_maximumComments') === false ? 50 : get_option('mainwp_maximumComments'); ?> "/> </td> </tr> </tbody> </table> </div> </div> <?php }
public static function renderDashboardBody($websites, $pDashboard, $pScreenLayout) { $opts = get_option('mainwp_opts_showhide_sections', false); $hide_shortcuts = is_array($opts) && isset($opts['welcome_shortcuts']) && $opts['welcome_shortcuts'] == 'hide' ? true : false; ?> <form action="admin-post.php" method="post"> <?php wp_nonce_field('mainwp_tab-general'); ?> <?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); ?> <?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); ?> <input type="hidden" name="action" value="save_howto_testPages_general"/> <div id="mainwp-welocme-bar" class="welcome-panel" style="padding-left: 2em;"> <table id="mainwp-refresh-bar" width="100%"> <tbody> <tr> <td> <div id="mainwp-welocme-bar-top"> <span style="float:right;"> <a style="font-size: 18px;" class="button-hero button mainwp-upgrade-button" id="dashboard_refresh" title="<?php echo MainWP_Right_Now::renderLastUpdate(); ?> "><i class="fa fa-refresh"></i> <?php _e('Sync Data with Child Sites', 'mainwp'); ?> </a> <a style="font-size: 18px;" class="button-hero button-primary button" target="_blank" href="https://extensions.mainwp.com"><i class="fa fa-cart-plus"></i> <?php _e('Get New Extensions', 'mainwp'); ?> </a> </span> <?php $current_wp_id = MainWP_Utility::get_current_wpid(); $website = null; if (!empty($current_wp_id)) { $website = $websites[0]; } $imgfavi = ''; if ($website !== null) { if (get_option('mainwp_use_favicon', 1) == 1) { $favi = MainWP_DB::Instance()->getWebsiteOption($website, 'favi_icon', ''); $favi_url = MainWP_Utility::get_favico_url($favi, $website); $imgfavi = '<img src="' . $favi_url . '" width="16" height="16" style="vertical-align:middle;"/> '; } } if ($website !== null) { if (time() - $website->dtsSync > 60 * 60 * 24) { ?> <h3> <i class="fa fa-flag"></i> <?php _e('Your MainWP Dashboard has not been synced for 24 hours!', 'mainwp'); ?> </h3> <p class="about-description"><?php _e('Click the Sync Data button to get the latest data from child sites.', 'mainwp'); ?> </p> <?php } else { ?> <h3><?php echo sprintf(__('Welcome to %s Dashboard!', 'mainwp'), stripslashes($website->name)); ?> </h3> <p class="about-description"><?php echo sprintf(__('This information is only for %s%s', 'mainwp'), $imgfavi, MainWP_Utility::getNiceURL($website->url, true)); ?> </p> <?php } } else { $sync_status = MainWP_DB::Instance()->getLastSyncStatus(); if ($sync_status === 'not_synced') { ?> <h3> <i class="fa fa-flag"></i> <?php _e('Your MainWP Dashboard has not been synced for 24 hours!', 'mainwp'); ?> </h3> <p class="about-description"><?php _e('Click the Sync Data button to get the latest data from child sites.', 'mainwp'); ?> </p> <?php } else { if ($sync_status === 'all_synced') { ?> <h3><?php echo __('All sites have been synced within the last 24 hours!', 'mainwp'); ?> </h3> <p class="about-description"><?php echo __('Manage your WordPress sites with ease.', 'mainwp'); ?> </p> <?php } else { ?> <h3><i class="fa fa-flag"></i> <?php echo __("Some child sites didn't sync correctly!", 'mainwp'); ?> </h3> <p class="about-description"><?php echo __('Check the Sync Status widget to review sites that have not been synced.', 'mainwp'); ?> </p> <?php } } } ?> </div> <br/> <span style="float: right; margin-right: 1em;"><a id="mainwp-link-showhide-welcome-shortcuts" status="<?php echo $hide_shortcuts ? 'hide' : 'show'; ?> " href="#"><?php echo $hide_shortcuts ? __('Show Shortcuts', 'mainwp') : __('Hide Shortcuts', 'mainwp'); ?> </a></span> <div id="mainwp-welcome-bar-shotcuts" style="clear: both;<?php echo $hide_shortcuts ? 'display: none;' : ''; ?> "> <div class="welcome-panel-column"> <h4><?php _e('Get Started', 'mainwp'); ?> </h4> <ul> <li> <a href="<?php echo get_admin_url(); ?> admin.php?page=managesites&do=new"><i class="fa fa-globe"></i> <?php _e('Add New Site', 'mainwp'); ?> </a></li> <li> <a href="<?php echo get_admin_url(); ?> admin.php?page=ManageGroups"><i class="fa fa-globe"></i> <?php _e('Create Child Site Groups', 'mainwp'); ?> </a></li> <li> <a href="<?php echo get_admin_url(); ?> admin.php?page=ManageBackupsAddNew"><i class="fa fa-hdd-o"></i> <?php _e('Schedule Backups', 'mainwp'); ?> </a></li> <li> <a href="<?php echo get_admin_url(); ?> admin.php?page=Settings"><i class="fa fa-cogs"></i> <?php _e('Check MainWP Settings', 'mainwp'); ?> </a></li> </ul> </div> <div class="welcome-panel-column"> <h4><?php _e('Next Steps', 'mainwp'); ?> </h4> <ul> <li> <a href="<?php echo get_admin_url(); ?> admin.php?page=PostBulkAdd"><i class="fa fa-file-text"></i> <?php _e('Add Post to Child Site(s)', 'mainwp'); ?> </a></li> <li> <a href="<?php echo get_admin_url(); ?> admin.php?page=PageBulkAdd"><i class="fa fa-file"></i> <?php _e('Add Page to Child Site(s)', 'mainwp'); ?> </a></li> <li> <a href="<?php echo get_admin_url(); ?> admin.php?page=PluginsInstall"><i class="fa fa-plug"></i> <?php _e('Add Plugin to Child Site(s)', 'mainwp'); ?> </a></li> <li> <a href="<?php echo get_admin_url(); ?> admin.php?page=ThemesInstall"><i class="fa fa-paint-brush"></i> <?php _e('Add Theme to Child Site(s)', 'mainwp'); ?> </a></li> </ul> </div> <div class="welcome-panel-column welcome-panel-last"> <h4><?php _e('More Actions', 'mainwp'); ?> </h4> <ul> <li> <a href="<?php echo get_admin_url(); ?> admin.php?page=managesites&do=test"><i class="fa fa-globe"></i> <?php _e('Test Connection', 'mainwp'); ?> </a></li> <li> <a href="<?php echo get_admin_url(); ?> admin.php?page=Extensions"><i class="fa fa-plug"></i> <?php _e('Manage Extensions', 'mainwp'); ?> </a></li> <li> <a href="<?php echo get_admin_url(); ?> admin.php?page=ServerInformation"><i class="fa fa-server"></i> <?php _e('Check MainWP Requirements', 'mainwp'); ?> </a></li> <li> <a href="<?php echo get_admin_url(); ?> admin.php?page=DashboardOptions"><i class="fa fa-cogs"></i> <?php _e('Set Your Preferences', 'mainwp'); ?> </a></li> </ul> </div> </div> <div id="dashboard_refresh_statusextra" style="display: none"> <i class="fa fa-spinner fa-pulse"></i></div> </div> <div id="mainwp_dashboard_refresh_status"></div> </td></tr></tbody> </table> </div> <div id="mainwp_main_errors" class="mainwp_error"></div> </form> <div id="mainwp-dashboard-info-box"> <?php if (empty($current_wp_id) && MainWP_Twitter::enabledTwitterMessages()) { $filter = array('upgrade_everything', 'upgrade_all_wp_core', 'upgrade_all_plugins', 'upgrade_all_themes'); foreach ($filter as $what) { $twitters = MainWP_Twitter::getTwitterNotice($what); if (is_array($twitters)) { foreach ($twitters as $timeid => $twit_mess) { $sendText = ""; if (!empty($twit_mess)) { if (!empty($sendText)) { $sendText = MainWP_Twitter::getTwitToSend($what, $timeid); ?> <div class="mainwp-tips mainwp_info-box-blue twitter"> <span class="mainwp-tip" twit-what="<?php echo $what; ?> " twit-id="<?php echo $timeid; ?> "><?php echo $twit_mess; ?> </span> <?php MainWP_Twitter::genTwitterButton($sendText); ?> <span><a href="#" class="mainwp-dismiss-twit"><i class="fa fa-times-circle"></i> <?php _e('Dismiss', 'mainwp'); ?> </a></span></div> <?php } } } } } ?> <?php } ?> </div> <div id="dashboard-widgets-wrap"> <?php require_once ABSPATH . 'wp-admin/includes/dashboard.php'; wp_dashboard(); ?> <div class="clear"></div> </div><!-- dashboard-widgets-wrap --> <?php }
/** * Save the file to the specified path * @return boolean TRUE on success */ function save($path) { $wpFileSystem = MainWP_Utility::getWPFilesystem(); if ($wpFileSystem != null) { $path = str_replace(MainWP_Utility::getBaseDir(), '', $path); $moved = $wpFileSystem->put_contents($path, file_get_contents($_FILES['qqfile']['tmp_name'])); } else { $moved = move_uploaded_file($_FILES['qqfile']['tmp_name'], $path); } if (!$moved) { return false; } return true; }
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.'))); } }
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; }
public static function renderSettings() { $userExtension = MainWP_DB::Instance()->getUserExtension(); $onlineNotifications = $userExtension == null || ($userExtension->offlineChecksOnlineNotification == null || $userExtension->offlineChecksOnlineNotification == '') ? '0' : $userExtension->offlineChecksOnlineNotification; ?> <div class="postbox" id="mainwp-offline-check-options-settings"> <h3 class="mainwp_box_title"> <span><i class="fa fa-cog"></i> <?php _e('Offline Check Options', 'mainwp'); ?> </span></h3> <div class="inside"> <div class="mainwp_info-box-red"> <strong>IMPORTANT:</strong> This feature is being retired and replaced by the Free MainWP Advanced Uptime Monitor Extension which provides more advanced monitoring system.<br/> <a href="https://mainwp.com/extension/advanced-uptime-monitor/">Get the Free MainWP Advanced Uptime Monitor Extension here!</a> </div> <table class="form-table"> <tbody> <tr> <th scope="row"><?php _e('Online Notifications', 'mainwp'); ?> <?php MainWP_Utility::renderToolTip(__('Network will monitor your sites for downtime and uptime. By default emails are only sent when your site is down.', 'mainwp')); ?> </th> <td> <div class="mainwp-checkbox"> <input type="checkbox" name="mainwp_options_offlinecheck_onlinenotification" id="mainwp_options_offlinecheck_onlinenotification" <?php echo $onlineNotifications == 1 ? 'checked="true"' : ''; ?> /> <label for="mainwp_options_offlinecheck_onlinenotification"></label> </div><?php _e('Enable notifications even when the website is online', 'mainwp'); ?> </td> </tr> </tbody> </table> </div> </div> <?php }
public static function checkBackups() { //if (get_option('mainwp_backup_before_upgrade') != 1) return true; if (!is_array($_POST['sites'])) { return true; } $global_backup_before_upgrade = get_option('mainwp_backup_before_upgrade'); $output = array(); foreach ($_POST['sites'] as $siteId) { $website = MainWP_DB::Instance()->getWebsiteById($siteId); if ($website->backup_before_upgrade == 0 || $website->backup_before_upgrade == 2 && $global_backup_before_upgrade == 0) { continue; } $dir = MainWP_Utility::getMainWPSpecificDir($siteId); //Check if backup ok $lastBackup = -1; if (file_exists($dir) && ($dh = opendir($dir))) { while (($file = readdir($dh)) !== false) { if ($file != '.' && $file != '..') { $theFile = $dir . $file; if (MainWP_Utility::isArchive($file) && !MainWP_Utility::isSQLArchive($file) && filemtime($theFile) > $lastBackup) { $lastBackup = filemtime($theFile); } } } closedir($dh); } $output['sites'][$siteId] = $lastBackup < time() - 7 * 24 * 60 * 60 ? false : true; } return $output; }
public static function renderActionLogs() { self::renderHeader('Action logs'); if (isset($_REQUEST['actionlogs_status'])) { if ($_REQUEST['actionlogs_status'] != MainWP_Logger::DISABLED) { MainWP_Logger::Instance()->setLogPriority($_REQUEST['actionlogs_status']); } MainWP_Logger::Instance()->log('Action logs set to: ' . MainWP_Logger::Instance()->getLogText($_REQUEST['actionlogs_status']), MainWP_Logger::LOG); if ($_REQUEST['actionlogs_status'] == MainWP_Logger::DISABLED) { MainWP_Logger::Instance()->setLogPriority($_REQUEST['actionlogs_status']); } MainWP_Utility::update_option('mainwp_actionlogs', $_REQUEST['actionlogs_status']); } $enabled = get_option('mainwp_actionlogs'); if ($enabled === false) { $enabled = MainWP_Logger::DISABLED; } ?> <div class="postbox" id="mainwp-code-display"> <h3 class="hndle" style="padding: 8px 12px; font-size: 14px;"><span>Action logs</span></h3> <div style="padding: 1em;"> <form method="POST" action=""> Status: <select name="actionlogs_status"> <option value="<?php echo MainWP_Logger::DISABLED; ?> " <?php if (MainWP_Logger::DISABLED == $enabled) { echo 'selected'; } ?> >Disabled </option> <option value="<?php echo MainWP_Logger::WARNING; ?> " <?php if (MainWP_Logger::WARNING == $enabled) { echo 'selected'; } ?> >Warning </option> <option value="<?php echo MainWP_Logger::INFO; ?> " <?php if (MainWP_Logger::INFO == $enabled) { echo 'selected'; } ?> >Info </option> <option value="<?php echo MainWP_Logger::DEBUG; ?> " <?php if (MainWP_Logger::DEBUG == $enabled) { echo 'selected'; } ?> >Debug </option> </select> <input type="submit" class="button button-primary" value="Save"/> </form> </div> <div style="padding: 1em;"><?php MainWP_Logger::showLog(); ?> </div> </div> <?php self::renderFooter('Action logs'); }
public static function renderSites($renew, $pExit = true) { $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); $allPages = array(); if ($websites) { while ($websites && ($website = @MainWP_DB::fetch_object($websites))) { if ($website->recent_pages == '') { continue; } $pages = json_decode($website->recent_pages, 1); if (count($pages) == 0) { continue; } foreach ($pages as $page) { $page['website'] = (object) array('id' => $website->id, 'url' => $website->url); $allPages[] = $page; } } @MainWP_DB::free_result($websites); } $recent_pages_published = MainWP_Utility::getSubArrayHaving($allPages, 'status', 'publish'); $recent_pages_published = MainWP_Utility::sortmulti($recent_pages_published, 'dts', 'desc'); $recent_pages_draft = MainWP_Utility::getSubArrayHaving($allPages, 'status', 'draft'); $recent_pages_draft = MainWP_Utility::sortmulti($recent_pages_draft, 'dts', 'desc'); $recent_pages_pending = MainWP_Utility::getSubArrayHaving($allPages, 'status', 'pending'); $recent_pages_pending = MainWP_Utility::sortmulti($recent_pages_pending, 'dts', 'desc'); $recent_pages_trash = MainWP_Utility::getSubArrayHaving($allPages, 'status', 'trash'); $recent_pages_trash = MainWP_Utility::sortmulti($recent_pages_trash, 'dts', 'desc'); ?> <div class="clear"> <a href="<?php echo admin_url('admin.php?page=PageBulkAdd&select=' . ($current_wpid ? $current_wpid : 'all')); ?> " class="button-primary" style="float: right"><?php _e('Add New', 'mainwp'); ?> </a> <a class="mainwp_action left mainwp_action_down recent_posts_published_lnk" href="#"><?php _e('Published', 'mainwp'); ?> (<?php echo count($recent_pages_published); ?> )</a><a class="mainwp_action mid recent_posts_draft_lnk" href="#"><?php _e('Draft', 'mainwp'); ?> (<?php echo count($recent_pages_draft); ?> )</a><a class="mainwp_action mid recent_posts_pending_lnk" href="#"><?php _e('Pending', 'mainwp'); ?> (<?php echo count($recent_pages_pending); ?> )</a><a class="mainwp_action right recent_posts_trash_lnk" href="#"><?php _e('Trash', 'mainwp'); ?> (<?php echo count($recent_pages_trash); ?> )</a><br/><br/> <div class="recent_posts_published"> <?php for ($i = 0; $i < count($recent_pages_published) && $i < 5; $i++) { if (!isset($recent_pages_published[$i]['title']) || $recent_pages_published[$i]['title'] == '') { $recent_pages_published[$i]['title'] = '(No Title)'; } if (isset($recent_pages_published[$i]['dts'])) { if (!stristr($recent_pages_published[$i]['dts'], '-')) { $recent_pages_published[$i]['dts'] = MainWP_Utility::formatTimestamp(MainWP_Utility::getTimestamp($recent_pages_published[$i]['dts'])); } } ?> <div class="mainwp-row mainwp-recent"> <input class="postId" type="hidden" name="id" value="<?php echo $recent_pages_published[$i]['id']; ?> "/> <input class="websiteId" type="hidden" name="id" value="<?php echo $recent_pages_published[$i]['website']->id; ?> "/> <span class="mainwp-left-col" style="width: 60% !important; margin-right: 1em;"><a href="<?php echo $recent_pages_published[$i]['website']->url; ?> ?p=<?php echo $recent_pages_published[$i]['id']; ?> " target="_blank"><?php echo htmlentities($recent_pages_published[$i]['title'], ENT_COMPAT | ENT_HTML401, 'UTF-8'); ?> </a></span> <span class="mainwp-mid-col"> <a href="<?php echo admin_url('admin.php?page=CommentBulkManage&siteid=' . $recent_pages_published[$i]['website']->id . '&postid=' . $recent_pages_published[$i]['id']); ?> " title="<?php echo $recent_pages_published[$i]['comment_count']; ?> " class="post-com-count" style="display: inline-block !important;"> <span class="comment-count"><?php echo $recent_pages_published[$i]['comment_count']; ?> </span> </a> </span> <span class="mainwp-right-col"> <a href="<?php echo $recent_pages_published[$i]['website']->url; ?> " target="_blank"> <i class="fa fa-external-link"></i> <?php echo MainWP_Utility::getNiceURL($recent_pages_published[$i]['website']->url); ?> </a> <br/> <?php echo $recent_pages_published[$i]['dts']; ?> </span> <div style="clear: left;"></div> <div class="mainwp-row-actions"> <a href="#" class="mainwp-post-unpublish"><?php _e('Unpublish', 'mainwp'); ?> </a> | <a href="admin.php?page=SiteOpen&websiteid=<?php echo $recent_pages_published[$i]['website']->id; ?> &location=<?php echo base64_encode('post.php?action=editpost&post=' . $recent_pages_published[$i]['id'] . '&action=edit'); ?> " title="Edit this post"><?php _e('Edit', 'mainwp'); ?> </a> | <a href="#" class="mainwp-post-trash"><?php _e('Trash', 'mainwp'); ?> </a>| <a href="<?php echo $recent_pages_published[$i]['website']->url . (substr($recent_pages_published[$i]['website']->url, -1) != '/' ? '/' : '') . '?p=' . $recent_pages_published[$i]['id']; ?> " target="_blank" title="View '<?php echo $recent_pages_published[$i]['title']; ?> '" rel="permalink"><?php _e('View', 'mainwp'); ?> </a> | <a href="admin.php?page=PageBulkManage" class="mainwp-post-viewall"><?php _e('View All', 'mainwp'); ?> </a> </div> <div class="mainwp-row-actions-working"> <i class="fa fa-spinner fa-pulse"></i> <?php _e('Please wait', 'mainwp'); ?> <div> </div> </div> </div> <?php } ?> </div> <div class="recent_posts_draft" style="display: none"> <?php for ($i = 0; $i < count($recent_pages_draft) && $i < 5; $i++) { if (!isset($recent_pages_draft[$i]['title']) || $recent_pages_draft[$i]['title'] == '') { $recent_pages_draft[$i]['title'] = '(No Title)'; } if (isset($recent_pages_draft[$i]['dts'])) { if (!stristr($recent_pages_draft[$i]['dts'], '-')) { $recent_pages_draft[$i]['dts'] = MainWP_Utility::formatTimestamp(MainWP_Utility::getTimestamp($recent_pages_draft[$i]['dts'])); } } ?> <div class="mainwp-row mainwp-recent"> <input class="postId" type="hidden" name="id" value="<?php echo $recent_pages_draft[$i]['id']; ?> "/> <input class="websiteId" type="hidden" name="id" value="<?php echo $recent_pages_draft[$i]['website']->id; ?> "/> <span class="mainwp-left-col" style="width: 60% !important; margin-right: 1em;"><a href="<?php echo $recent_pages_draft[$i]['website']->url; ?> ?p=<?php echo $recent_pages_draft[$i]['id']; ?> " target="_blank"><?php echo htmlentities($recent_pages_draft[$i]['title'], ENT_COMPAT | ENT_HTML401, 'UTF-8'); ?> </a></span> <span class="mainwp-mid-col"> <a href="<?php echo admin_url('admin.php?page=CommentBulkManage&siteid=' . $recent_pages_draft[$i]['website']->id . '&postid=' . $recent_pages_draft[$i]['id']); ?> " title="<?php echo $recent_pages_draft[$i]['comment_count']; ?> " class="post-com-count" style="display: inline-block !important;"> <span class="comment-count"><?php echo $recent_pages_draft[$i]['comment_count']; ?> </span> </a> </span> <span class="mainwp-right-col"><?php echo MainWP_Utility::getNiceURL($recent_pages_draft[$i]['website']->url); ?> <br/><?php echo $recent_pages_draft[$i]['dts']; ?> </span> <div style="clear: left;"></div> <div class="mainwp-row-actions"> <a href="#" class="mainwp-post-publish"><?php _e('Publish', 'mainwp'); ?> </a> | <a href="admin.php?page=SiteOpen&websiteid=<?php echo $recent_pages_draft[$i]['website']->id; ?> &location=<?php echo base64_encode('post.php?action=editpost&post=' . $recent_pages_draft[$i]['id'] . '&action=edit'); ?> " title="Edit this post"><?php _e('Edit', 'mainwp'); ?> </a> | <a href="#" class="mainwp-post-trash"><?php _e('Trash', 'mainwp'); ?> </a> | <a href="admin.php?page=PostBulkManage" class="mainwp-post-viewall"><?php _e('View All', 'mainwp'); ?> </a> </div> <div class="mainwp-row-actions-working"> <i class="fa fa-spinner fa-pulse"></i> <?php _e('Please wait', 'mainwp'); ?> </div> <div> </div> </div> <?php } ?> </div> <div class="recent_posts_pending" style="display: none"> <?php for ($i = 0; $i < count($recent_pages_pending) && $i < 5; $i++) { if (!isset($recent_pages_pending[$i]['title']) || $recent_pages_pending[$i]['title'] == '') { $recent_pages_pending[$i]['title'] = '(No Title)'; } if (isset($recent_pages_pending[$i]['dts'])) { if (!stristr($recent_pages_pending[$i]['dts'], '-')) { $recent_pages_pending[$i]['dts'] = MainWP_Utility::formatTimestamp(MainWP_Utility::getTimestamp($recent_pages_pending[$i]['dts'])); } } ?> <div class="mainwp-row mainwp-recent"> <input class="postId" type="hidden" name="id" value="<?php echo $recent_pages_pending[$i]['id']; ?> "/> <input class="websiteId" type="hidden" name="id" value="<?php echo $recent_pages_pending[$i]['website']->id; ?> "/> <span class="mainwp-left-col" style="width: 60% !important; margin-right: 1em;"><a href="<?php echo $recent_pages_pending[$i]['website']->url; ?> ?p=<?php echo $recent_pages_pending[$i]['id']; ?> " target="_blank"><?php echo htmlentities($recent_pages_pending[$i]['title'], ENT_COMPAT | ENT_HTML401, 'UTF-8'); ?> </a></span> <span class="mainwp-mid-col"> <a href="<?php echo admin_url('admin.php?page=CommentBulkManage&siteid=' . $recent_pages_pending[$i]['website']->id . '&postid=' . $recent_pages_pending[$i]['id']); ?> " title="<?php echo $recent_pages_pending[$i]['comment_count']; ?> " class="post-com-count" style="display: inline-block !important;"> <span class="comment-count"><?php echo $recent_pages_pending[$i]['comment_count']; ?> </span> </a> </span> <span class="mainwp-right-col"><?php echo MainWP_Utility::getNiceURL($recent_pages_pending[$i]['website']->url); ?> <br/><?php echo $recent_pages_pending[$i]['dts']; ?> </span> <div style="clear: left;"></div> <div class="mainwp-row-actions"> <a href="#" class="mainwp-post-publish"><?php _e('Publish', 'mainwp'); ?> </a> | <a href="admin.php?page=SiteOpen&websiteid=<?php echo $recent_pages_pending[$i]['website']->id; ?> &location=<?php echo base64_encode('post.php?action=editpost&post=' . $recent_pages_pending[$i]['id'] . '&action=edit'); ?> " title="Edit this post"><?php _e('Edit', 'mainwp'); ?> </a> | <a href="#" class="mainwp-post-trash"><?php _e('Trash', 'mainwp'); ?> </a> | <a href="admin.php?page=PostBulkManage" class="mainwp-post-viewall"><?php _e('View All', 'mainwp'); ?> </a> </div> <div class="mainwp-row-actions-working"> <i class="fa fa-spinner fa-pulse"></i> <?php _e('Please wait', 'mainwp'); ?> </div> <div> </div> </div> <?php } ?> </div> <div class="recent_posts_trash" style="display: none"> <?php for ($i = 0; $i < count($recent_pages_trash) && $i < 5; $i++) { if (!isset($recent_pages_trash[$i]['title']) || $recent_pages_trash[$i]['title'] == '') { $recent_pages_trash[$i]['title'] = '(No Title)'; } if (isset($recent_pages_trash[$i]['dts'])) { if (!stristr($recent_pages_trash[$i]['dts'], '-')) { $recent_pages_trash[$i]['dts'] = MainWP_Utility::formatTimestamp(MainWP_Utility::getTimestamp($recent_pages_trash[$i]['dts'])); } } ?> <div class="mainwp-row mainwp-recent"> <input class="postId" type="hidden" name="id" value="<?php echo $recent_pages_trash[$i]['id']; ?> "/> <input class="websiteId" type="hidden" name="id" value="<?php echo $recent_pages_trash[$i]['website']->id; ?> "/> <span class="mainwp-left-col" style="width: 60% !important; margin-right: 1em;"><?php echo $recent_pages_trash[$i]['title']; ?> </span> <span class="mainwp-mid-col"> <a href="<?php echo admin_url('admin.php?page=CommentBulkManage&siteid=' . $recent_pages_trash[$i]['website']->id . '&postid=' . $recent_pages_trash[$i]['id']); ?> " title="<?php echo $recent_pages_trash[$i]['comment_count']; ?> " class="post-com-count" style="display: inline-block !important;"> <span class="comment-count"><?php echo $recent_pages_trash[$i]['comment_count']; ?> </span> </a> </span> <span class="mainwp-right-col"><?php echo MainWP_Utility::getNiceURL($recent_pages_trash[$i]['website']->url); ?> <br/><?php echo $recent_pages_trash[$i]['dts']; ?> </span> <div style="clear: left;"></div> <div class="mainwp-row-actions"> <a href="#" class="mainwp-post-restore"><?php _e('Restore', 'mainwp'); ?> </a> | <a href="#" class="mainwp-post-delete delete" style="color: red;"><?php _e('Delete Permanently', 'mainwp'); ?> </a> </div> <div class="mainwp-row-actions-working"> <i class="fa fa-spinner fa-pulse"></i> <?php _e('Please wait', 'mainwp'); ?> </div> <div> </div> </div> <?php } ?> </div> </div> <div class="clear"></div> <?php if ($pExit == true) { exit; } }
function mainwp_force_destroy_sessions() { $this->secure_request('mainwp_force_destroy_sessions'); $website_id = isset($_POST['website_id']) ? (int) $_POST['website_id'] : 0; if (!MainWP_DB::Instance()->getWebsiteById($website_id)) { die(json_encode(array('error' => array('message' => __('This website does not exist', 'mainwp'))))); } $website = MainWP_DB::Instance()->getWebsiteById($website_id); if (!MainWP_Utility::can_edit_website($website)) { die(json_encode(array('error' => array('message' => __('You cannot edit this website', 'mainwp'))))); } try { $information = MainWP_Utility::fetchUrlAuthed($website, 'settings_tools', array('action' => 'force_destroy_sessions')); global $mainWP; if ($mainWP->getVersion() == '2.0.22' || $mainWP->getVersion() == '2.0.23') { if (get_option('mainwp_fixed_security_2022') != 1) { update_option('mainwp_fixed_security_2022', 1); } } } catch (Exception $e) { $information = array('error' => __('fetchUrlAuthed exception', 'mainwp')); } die(json_encode($information)); }
public static function unIgnorePluginThemeConflict($type, $name, $siteid) { if ($siteid != '') { //For the sites.. if ($siteid == '_ALL_') { $websites = MainWP_DB::Instance()->query(MainWP_DB::Instance()->getSQLWebsitesForCurrentUser()); } else { $websites = MainWP_DB::Instance()->query(MainWP_DB::Instance()->getSQLWebsiteById($siteid)); } while ($websites && ($website = @MainWP_DB::fetch_object($websites))) { 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 ($name == '') { MainWP_DB::Instance()->updateWebsiteValues($website->id, array('ignored_pluginConflicts' => json_encode(array()))); } else { if (in_array($name, $decodedIgnoredPlugins)) { $idx = array_search($name, $decodedIgnoredPlugins); array_splice($decodedIgnoredPlugins, $idx, 1); 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 ($name == '') { MainWP_DB::Instance()->updateWebsiteValues($website->id, array('ignored_themeConflicts' => json_encode(array()))); } else { if (in_array($name, $decodedIgnoredThemes)) { $idx = array_search($name, $decodedIgnoredThemes); array_splice($decodedIgnoredThemes, $idx, 1); MainWP_DB::Instance()->updateWebsiteValues($website->id, array('ignored_themeConflicts' => json_encode($decodedIgnoredThemes))); } } } } } } @MainWP_DB::free_result($websites); } else { //unignore 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 ($name == '') { //Unignore all $globalIgnoredPluginConflicts = array(); $userExtension->ignored_pluginConflicts = json_encode($globalIgnoredPluginConflicts); MainWP_DB::Instance()->updateUserExtension($userExtension); } else { if (in_array($name, $globalIgnoredPluginConflicts)) { $idx = array_search($name, $globalIgnoredPluginConflicts); array_splice($globalIgnoredPluginConflicts, $idx, 1); $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 ($name == '') { $globalIgnoredThemeConflicts = array(); $userExtension->ignored_themeConflicts = json_encode($globalIgnoredThemeConflicts); MainWP_DB::Instance()->updateUserExtension($userExtension); } else { if (in_array($name, $globalIgnoredThemeConflicts)) { $idx = array_search($name, $globalIgnoredThemeConflicts); array_splice($globalIgnoredThemeConflicts, $idx, 1); $userExtension->ignored_themeConflicts = json_encode($globalIgnoredThemeConflicts); MainWP_DB::Instance()->updateUserExtension($userExtension); } } } } } return 'success'; }
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; }
public static function doImport() { if (isset($_POST['select_by'])) { $selected_sites = array(); if (isset($_POST['selected_sites']) && is_array($_POST['selected_sites'])) { foreach ($_POST['selected_sites'] as $selected) { $selected_sites[] = $selected; } } $selected_groups = array(); if (isset($_POST['selected_groups']) && is_array($_POST['selected_groups'])) { foreach ($_POST['selected_groups'] as $selected) { $selected_groups[] = $selected; } } } $user_to_add = array('user_pass' => $_POST['pass1'], 'user_login' => $_POST['user_login'], 'user_url' => $_POST['url'], 'user_email' => $_POST['email'], 'first_name' => $_POST['first_name'], 'last_name' => $_POST['last_name'], 'role' => $_POST['role']); $ret = array(); $dbwebsites = array(); $not_valid = array(); $error_sites = ''; if ($_POST['select_by'] == 'site') { //Get all selected websites foreach ($selected_sites as $url) { if (!empty($url)) { $website = MainWP_DB::Instance()->getWebsitesByUrl($url); if ($website) { $dbwebsites[$website[0]->id] = MainWP_Utility::mapSite($website[0], array('id', 'url', 'name', 'adminname', 'nossl', 'privkey', 'nosslkey')); } else { $not_valid[] = __("Error - The website doesn't exist in the Network.", 'mainwp') . " " . $url; $error_sites .= $url . ';'; } } } } else { //Get all websites from the selected groups foreach ($selected_groups as $group) { if (MainWP_DB::Instance()->getGroupsByName($group)) { $websites = MainWP_DB::Instance()->query(MainWP_DB::Instance()->getSQLWebsitesByGroupName($group)); if ($websites) { while ($websites && ($website = @MainWP_DB::fetch_object($websites))) { $dbwebsites[$website->id] = MainWP_Utility::mapSite($website, array('id', 'url', 'name', 'adminname', 'nossl', 'privkey', 'nosslkey')); } @MainWP_DB::free_result($websites); } else { $not_valid[] = __('Error - These are not websites in the group. ', 'mainwp') . $group; $error_sites .= $group . ';'; } } else { $not_valid[] = __("Error - The group doesn't exist in the Network. ", 'mainwp') . $group; $error_sites .= $group . ';'; } } } if (count($dbwebsites) > 0) { $post_data = array('new_user' => base64_encode(serialize($user_to_add)), 'send_password' => isset($_POST['send_password']) ? $_POST['send_password'] : ''); $output = new stdClass(); $output->ok = array(); $output->errors = array(); MainWP_Utility::fetchUrlsAuthed($dbwebsites, 'newuser', $post_data, array(MainWP_Bulk_Add::getClassName(), 'PostingBulk_handler'), $output); } $ret['ok_list'] = $ret['error_list'] = array(); foreach ($dbwebsites as $website) { if (isset($output->ok[$website->id]) && $output->ok[$website->id] == 1) { $ret['ok_list'][] = 'New user(s) created: ' . stripslashes($website->name); } else { $ret['error_list'][] = $output->errors[$website->id] . ' ' . stripslashes($website->name); $error_sites .= $website->url . ';'; } } foreach ($not_valid as $val) { $ret['error_list'][] = $val; } $ret['failed_logging'] = ''; if (!empty($error_sites)) { $error_sites = rtrim($error_sites, ';'); $ret['failed_logging'] = $_POST['user_login'] . ',' . $_POST['email'] . ',' . $_POST['first_name'] . ',' . $_POST['last_name'] . ',' . $_POST['url'] . ',' . $_POST['pass1'] . ',' . intval($_POST['send_password']) . ',' . $_POST['role'] . ',' . $error_sites . ','; } $ret['line_number'] = $_POST['line_number']; die(json_encode($ret)); }
public static function render(&$extensions) { $loader_url = '<i class="fa fa-spinner fa-pulse"></i>'; if (mainwp_current_user_can('dashboard', 'manage_extensions')) { ?> <?php } ?> <div class="postbox"> <div class="handlediv"><br></div> <h3 class="mainwp_box_title"> <span><?php printf(_n('%d Installed MainWP Extension', '%d Installed MainWP Extensions', count($extensions) == 1 ? 1 : 2, 'mainwp'), count($extensions)); ?> </span> </h3> <div id="mainwp-extensions-wrap"> <?php if (count($extensions) == 0) { ?> <div class="inside"> <div class="mainwp_info-box-blue"> <h3><?php _e('What are Extensions?', 'mainwp'); ?> </h3> <?php _e('Extensions are specific features or tools created for the purpose of expanding the basic functionality of MainWP.', 'mainwp'); ?> <h3><?php _e('Why have Extensions?', 'mainwp'); ?> </h3> <?php _e('The core of MainWP has been designed to provide the functions most needed by our users and minimize code bloat. Extensions offer custom functions and features so that each user can tailor their MainWP to their specific needs.', 'mainwp'); ?> <p> <a href="https://extensions.mainwp.com/"><?php _e('Download your first extension now.', 'mainwp'); ?> </a> </p> </div> </div> <?php } else { ?> <div style="background: #eee; padding: 1em .6em;"> <a class="mainwp_action left mainwp_action_down" href="#" id="mainwp-extensions-expand"><?php _e('Expand', 'mainwp'); ?> </a><a class="mainwp_action right" href="#" id="mainwp-extensions-collapse"><?php _e('Collapse', 'mainwp'); ?> </a> <?php if (mainwp_current_user_can('dashboard', 'manage_extensions')) { ?> <div style="float: right; margin-top: -3px;"> <a href="#" class="button mainwp-extensions-disable-all"><?php _e('Disable All', 'mainwp'); ?> </a> <a href="#" class="button-primary mainwp-extensions-enable-all"><?php _e('Enable All', 'mainwp'); ?> </a> <a href="<?php echo admin_url('plugin-install.php?tab=upload'); ?> " class="mainwp-upgrade-button button-primary button"><?php _e('Install New Extension', 'mainwp'); ?> </a> </div> <div style="clear: both;"></div> <?php } ?> </div> <div id="mainwp-extensions-list"> <?php $user_can_manage_extensions = mainwp_current_user_can('dashboard', 'manage_extensions'); if (isset($extensions) && is_array($extensions)) { foreach ($extensions as $extension) { if (!mainwp_current_user_can('extension', dirname($extension['slug']))) { continue; } $active = MainWP_Extensions::isExtensionActivated($extension['plugin']); $enabled = MainWP_Extensions::isExtensionEnabled($extension['plugin']); $queue_status = ''; if (isset($extension['apiManager']) && $extension['apiManager']) { $queue_status = 'status="queue"'; } ?> <div class="mainwp-extensions-childHolder" extension_slug="<?php echo $extension['slug']; ?> " <?php echo $queue_status; ?> license-status="<?php echo $active ? 'activated' : 'deactivated'; ?> "> <table style="width: 100%"> <td class="mainwp-extensions-childIcon"> <?php if (isset($extension['iconURI']) && $extension['iconURI'] != '') { ?> <img title="<?php echo $extension['name']; ?> " src="<?php echo MainWP_Utility::removeHttpPrefix($extension['iconURI']); ?> " class="mainwp-extensions-img large <?php echo $enabled ? '' : 'mainwp-extension-icon-desaturated'; ?> " /><?php } else { ?> <img title="MainWP Placeholder" src="<?php echo plugins_url('images/extensions/placeholder.png', dirname(__FILE__)); ?> " class="mainwp-extensions-img large <?php echo $enabled ? '' : 'mainwp-extension-icon-desaturated'; ?> " /><?php } ?> </td> <td valign="top"> <table style="width: 100%"> <tr> <td class="mainwp-extensions-childName"> <?php if (isset($extension['direct_page']) && !empty($extension['direct_page'])) { ?> <a href="<?php echo admin_url('admin.php?page=' . $extension['direct_page']); ?> " style="text-decoration: none;"> <?php echo $extension['name']; ?> </a> <?php } else { if (isset($extension['callback'])) { ?> <a href="<?php echo admin_url('admin.php?page=' . $extension['page']); ?> " style="text-decoration: none;"> <?php echo $extension['name']; ?> </a> <?php } else { echo $extension['name']; } } ?> </td> <td class="mainwp-extensions-childVersion">V. <?php echo $extension['version']; ?> </td> <td class="mainwp-extensions-childActions"> <?php if (isset($extension['apiManager']) && $extension['apiManager']) { ?> <?php if ($active) { ?> <a href="javascript:void(0)" class="api-status activated" ><?php _e('Activated', 'mainwp'); ?> </a> <?php } else { ?> <a href="javascript:void(0)" class="api-status deactivated" title="Not Activated"><?php _e('Deactivated', 'mainwp'); ?> </a> <?php } ?> <?php } ?> <?php if ($enabled) { ?> <button href="#" <?php echo $user_can_manage_extensions ? 'class="button mainwp-extensions-disable"' : 'disabled="disabled"'; ?> ><?php _e('Disable', 'mainwp'); ?> </button> <?php } else { ?> <button <?php echo $user_can_manage_extensions ? 'class="button-primary mainwp-extensions-enable"' : 'disabled="disabled"'; ?> ><?php _e('Enable', 'mainwp'); ?> </button> <?php } ?> <?php if (isset($extension['apiManager']) && $extension['apiManager']) { ?> <?php if ($user_can_manage_extensions) { ?> <?php if ($active) { ?> <a href="#" class="mainwp-extensions-api-activation" style="font-size: 28px;"><i class="fa fa-lock"></i></a> <?php } else { ?> <a href="#" class="mainwp-extensions-api-activation" style="font-size: 28px;"><i class="fa fa-unlock"></i></a> <?php } ?> <?php } else { ?> <?php if ($active) { ?> <span style="font-size: 28px; color: #e5e5e5;"><i class="fa fa-lock"></i></span> <?php } else { ?> <span style="font-size: 28px; color: #e5e5e5;"><i class="fa fa-unlock"></i></span> <?php } ?> <?php } ?> <?php } else { ?> <span style="font-size: 28px; color: #e5e5e5;"><i class="fa fa-lock"></i></span> <?php } ?> <?php if (isset($extension['direct_page']) && !empty($extension['direct_page'])) { ?> <a href="<?php echo admin_url('admin.php?page=' . $extension['direct_page']); ?> " style="font-size: 28px;"><i class="fa fa-wrench"></i></a> <?php } else { if (isset($extension['callback'])) { ?> <a href="<?php echo admin_url('admin.php?page=' . $extension['page']); ?> " style="font-size: 28px;"><i class="fa fa-wrench"></i></a> <?php } else { ?> <span style="font-size: 28px; color: #e5e5e5;"><i class="fa fa-wrench"></i></span> <?php } } ?> <?php if (false && $user_can_manage_extensions) { ?> <a href="#" class="mainwp-extensions-trash" style="font-size: 28px"><i class="fa fa-trash"></i></a> <?php } else { ?> <span style="font-size: 28px; color: #e5e5e5;"><i class="fa fa-trash"></i></span> <?php } ?> </td> </tr> <tr class="mainwp-extensions-extra mainwp-extension-description"> <td colspan="3"> <br/><br/><?php echo preg_replace('/\\<cite\\>.*\\<\\/cite\\>/', '', $extension['description']); ?> <br/><br/></td> </tr> <tr class="mainwp-extensions-links"> <td colspan="3"> <?php printf(__('By %s', 'mainwp'), str_replace(array('http:', 'https:'), '', $extension['author'])); ?> <?php echo isset($extension['DocumentationURI']) && !empty($extension['DocumentationURI']) ? ' | <a href="' . str_replace(array('http:', 'https:'), '', $extension['DocumentationURI']) . '" target="_blank" title="' . __('Documentation', 'mainwp') . '">' . __('Documentation', 'mainwp') . '</a>' : ''; ?> <?php echo isset($extension['SupportForumURI']) && !empty($extension['SupportForumURI']) ? ' | <a href="' . str_replace(array('http:', 'https:'), '', $extension['SupportForumURI']) . '" target="_blank" title="' . __('Support Forum', 'mainwp') . '">' . __('Support Forum', 'mainwp') . '</a>' : ''; ?> <?php if (isset($extension['apiManager']) && $extension['apiManager']) { ?> <?php echo ' | <a href="#" class="mainwp-extensions-api-activation" >' . __('Enter Activation API', 'mainwp') . '</a>'; ?> <?php } ?> </td> </tr> <?php if (isset($extension['apiManager']) && $extension['apiManager']) { ?> <tr class="mainwp-extensions-api-row"> <td colspan="3"> <div class="api-row-div"> <span> <input type="text" class="input api_key" placeholder="<?php esc_attr_e('API License Key', 'mainwp'); ?> " value="<?php echo $extension['api_key']; ?> "/> <input type="text" class="input api_email" placeholder="<?php esc_attr_e('API License Email', 'mainwp'); ?> " value="<?php echo $extension['activation_email']; ?> "/> <input type="button" class="button-primary mainwp-extensions-activate" value="<?php esc_attr_e('Activate', 'mainwp'); ?> "> <span class="mainwp_loading"><i class="fa fa-spinner fa-pulse"></i></span> </span> <span style="float:right"> <?php _e('Deactivate License Key', 'mainwp'); ?> <input type="checkbox" class="mainwp-extensions-deactivate-chkbox" <?php echo $extension['deactivate_checkbox'] == 'on' ? 'checked' : ''; ?> > <input type="button" class="button-primary mainwp-extensions-deactivate" value="<?php _e('Deactivate', 'mainwp'); ?> "> </span> </div> <span class="activate-api-status hidden"></span> </td> </tr> <?php } ?> </table> </td> </table> </div> <?php } } ?> </div> <?php } ?> </div></div><?php self::mainwpAvailableExtensions($extensions); }
public static function renderSites() { $sql = MainWP_DB::Instance()->getSQLWebsitesForCurrentUser(); $websites = MainWP_DB::Instance()->query($sql); if (!$websites) { return; } $all_sites_synced = true; $top_row = true; ?> <div class="clear"> <div id="wp_syncs"> <?php ob_start(); @MainWP_DB::data_seek($websites, 0); while ($websites && ($website = @MainWP_DB::fetch_object($websites))) { if (empty($website) || $website->sync_errors != '') { continue; } if (time() - $website->dtsSync < 60 * 60 * 24) { continue; } $all_sites_synced = false; $lastSyncTime = !empty($website->dtsSync) ? MainWP_Utility::formatTimestamp(MainWP_Utility::getTimestamp($website->dtsSync)) : ''; ?> <div class="<?php echo $top_row ? 'mainwp-row-top' : 'mainwp-row'; ?> mainwp_wp_sync" site_id="<?php echo $website->id; ?> " site_name="<?php echo rawurlencode($website->name); ?> "> <span class="mainwp-left-col"><a href="<?php echo admin_url('admin.php?page=managesites&dashboard=' . $website->id); ?> "><?php echo stripslashes($website->name); ?> </a><input type="hidden" id="wp_sync<?php echo $website->id; ?> " /></span> <span class="mainwp-mid-col wordpressInfo" id="wp_sync_<?php echo $website->id; ?> "> <?php echo $lastSyncTime; ?> </span> <span class="mainwp-right-col wordpressAction"> <div id="wp_syncs_<?php echo $website->id; ?> "> <a class="mainwp-upgrade-button button" onClick="rightnow_wp_sync('<?php echo $website->id; ?> ')"><?php _e('Sync Now', 'mainwp'); ?> </a> </div> </span> </div> <?php $top_row = false; } $output = ob_get_clean(); if ($all_sites_synced) { echo esc_html__('All sites have been synced within the last 24 hours', 'mainwp') . "."; } else { echo '<div class="mainwp_info-box-red">' . esc_html__('Sites not synced in the last 24 hours.', 'mainwp') . '</div>'; echo $output; } ?> </div> </div> <?php @MainWP_DB::free_result($websites); }
function column_details($item) { $output = '<strong>' . __('LAST RUN MANUALLY: ', 'mainwp') . '</strong>' . ($item->last_run_manually == 0 ? '-' : MainWP_Utility::formatTimestamp(MainWP_Utility::getTimestamp($item->last_run_manually))) . '<br />'; $output .= '<strong>' . __('LAST RUN: ', 'mainwp') . '</strong>' . ($item->last_run == 0 ? '-' : MainWP_Utility::formatTimestamp(MainWP_Utility::getTimestamp($item->last_run))) . '<br />'; $output .= '<strong>' . __('LAST COMPLETED: ', 'mainwp') . '</strong>' . ($item->completed == 0 ? '-' : MainWP_Utility::formatTimestamp(MainWP_Utility::getTimestamp($item->completed))) . '<br />'; $output .= '<strong>' . __('NEXT RUN: ', 'mainwp') . '</strong>' . ($item->last_run == 0 ? __('Any minute', 'mainwp') : MainWP_Utility::formatTimestamp(($item->schedule == 'daily' ? 60 * 60 * 24 : ($item->schedule == 'weekly' ? 60 * 60 * 24 * 7 : 60 * 60 * 24 * 30)) + MainWP_Utility::getTimestamp($item->last_run))); $output .= '<strong>'; if ($item->last_run != 0 && $item->completed < $item->last_run) { $output .= __('<br />CURRENTLY RUNNING: ', 'mainwp') . '</strong>'; $completed_sites = $item->completed_sites; if ($completed_sites != '') { $completed_sites = json_decode($completed_sites, 1); } if (!is_array($completed_sites)) { $completed_sites = array(); } $output .= count($completed_sites) . ' / ' . count($item->the_sites); } return $output; }
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))); }
function activation() { delete_option('mainwp_requests'); MainWP_DB::Instance()->update(); MainWP_DB::Instance()->install(); //Redirect to settings page MainWP_Utility::update_option('mainwp_activated', 'yes'); }
/** * @param string $pluginFile Extension plugin file to verify * @param string $key The child-key * @param int $groupid The id of the group you wish to retrieve * @param bool $for_manager * * @return array|bool An array of arrays, the inner-array contains the id/name/array of site ids for the supplied groupid/all groups. False when something goes wrong. */ public static function hookGetGroups($pluginFile, $key, $groupid, $for_manager = false) { if (!self::hookVerify($pluginFile, $key)) { return false; } if ($for_manager && (!defined('MWP_TEAMCONTROL_PLUGIN_SLUG') || !mainwp_current_user_can('extension', dirname(MWP_TEAMCONTROL_PLUGIN_SLUG)))) { return false; } if (isset($groupid)) { $group = MainWP_DB::Instance()->getGroupById($groupid); if (!MainWP_Utility::can_edit_group($group)) { return false; } $websites = MainWP_DB::Instance()->getWebsitesByGroupId($group->id); $websitesOut = array(); foreach ($websites as $website) { $websitesOut[] = $website->id; } return array(array('id' => $groupid, 'name' => $group->name, 'websites' => $websitesOut)); } $groups = MainWP_DB::Instance()->getGroupsAndCount(null, $for_manager); $output = array(); foreach ($groups as $group) { $websites = MainWP_DB::Instance()->getWebsitesByGroupId($group->id); $websitesOut = array(); foreach ($websites as $website) { if (in_array($website->id, $websitesOut)) { continue; } $websitesOut[] = $website->id; } $output[] = array('id' => $group->id, 'name' => $group->name, 'websites' => $websitesOut); } return $output; }
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 resetUserCookie($what, $value = '') { global $current_user; if ($user_id = $current_user->ID) { $reset_cookies = get_option('mainwp_reset_user_cookies'); if (!is_array($reset_cookies)) { $reset_cookies = array(); } if (!isset($reset_cookies[$user_id]) || !isset($reset_cookies[$user_id][$what])) { $reset_cookies[$user_id][$what] = 1; MainWP_Utility::update_option('mainwp_reset_user_cookies', $reset_cookies); update_user_option($user_id, 'mainwp_saved_user_cookies', array()); return false; } $user_cookies = get_user_option('mainwp_saved_user_cookies'); if (!is_array($user_cookies)) { $user_cookies = array(); } if (!isset($user_cookies[$what])) { return false; } } return true; }
public static function renderMainWPTools() { if (!mainwp_current_user_can('dashboard', 'manage_dashboard_settings')) { mainwp_do_not_have_permissions(__('manage dashboard settings', 'mainwp')); return; } $wp_menu_items = array('dashboard' => __('Dashboard', 'mainwp'), 'posts' => __('Posts', 'mainwp'), 'media' => __('Media', 'mainwp'), 'pages' => __('Pages', 'mainwp'), 'appearance' => __('Appearance', 'mainwp'), 'comments' => __('Comments', 'mainwp'), 'users' => __('Users', 'mainwp'), 'tools' => __('Tools', 'mainwp')); $hide_menus = get_option('mwp_setup_hide_wp_menus'); if (!is_array($hide_menus)) { $hide_menus = array(); } self::renderHeader('MainWPTools'); ?> <form method="POST" action=""> <div class="postbox" id="mainwp-tools"> <h3 class="mainwp_box_title"> <span><i class="fa fa-wrench"></i> <?php _e('MainWP Tools', 'mainwp'); ?> </span></h3> <div class="inside"> <table class="form-table"> <tbody> <tr> <th scope="row"><?php _e('Force Dashboard to Establish New Connection', 'mainwp'); ?> <?php MainWP_Utility::renderToolTip(__('Use this option to establish new connection with child sites.', 'mainwp')); ?> </th> <td> <input type="submit" name="" id="force-destroy-sessions-button" class="button-primary button" value="<?php esc_attr_e('Establish New Connection', 'mainwp'); ?> "/><br/> <em> <?php _e('Forces your Dashboard to reconnect with your Child sites. This feature will log out any currently logged in users on the Child sites and require them to re-log in. Only needed if suggested by MainWP Support.', 'mainwp'); ?> </em> </td> </tr> <tr> <th scope="row"><?php _e('Scan child sites for known issues', 'mainwp'); ?> <?php MainWP_Utility::renderToolTip(__('Use this option to scan child sites for known issues.', 'mainwp')); ?> </th> <td> <a href="<?php echo admin_url('admin.php?page=MainWP_Child_Scan'); ?> " class="button-primary button"><?php _e('Scan', 'mainwp'); ?> </a><br/> <em> <?php _e('Scans each site individually for known issues.', 'mainwp'); ?> </em> </td> </tr> <tr> <th scope="row"><?php _e('MainWP Quick Setup', 'mainwp'); ?> </th> <td> <a href="admin.php?page=mainwp-setup" class="button-primary button"/><?php _e('Start Quick Setup', 'mainwp'); ?> </a><br/> <em> <?php _e('MainWP Quick Setup allows you to quickly set your MainWP Dashboard preferences.', 'mainwp'); ?> </em> </td> </tr> </tbody> </table> <div class="mainwp_info-box"><?php _e('Changing this settings will overwrite Clean & Lock Extension settings. Do not forget to migrate the settings you wish to keep.', 'mainwp'); ?> </div> <table class="form-table"> <tbody> <tr> <th scope="row"><?php _e('Hide WP Menus', 'mainwp'); ?> </th> <td> <ul class="mainwp_checkboxes mainwp_hide_wpmenu_checkboxes"> <?php foreach ($wp_menu_items as $name => $item) { $_selected = ''; if (in_array($name, $hide_menus)) { $_selected = 'checked'; } ?> <li> <input type="checkbox" id="mainwp_hide_wpmenu_<?php echo $name; ?> " name="mainwp_hide_wpmenu[]" <?php echo $_selected; ?> value="<?php echo $name; ?> " class="mainwp-checkbox2"> <label for="mainwp_hide_wpmenu_<?php echo $name; ?> " class="mainwp-label2"><?php echo $item; ?> </label> </li> <?php } ?> </ul> </td> </tr> </tbody> </table> </div> </div> <p class="submit"><input type="submit" name="submit" id="submit" class="button-primary button button-hero" value="<?php esc_attr_e('Save Settings', 'mainwp'); ?> "/></p> </form> <?php self::renderFooter('MainWPTools'); }
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: <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 }
public static function openSiteRestore($website, $file, $size) { ?> <div class="wrap"> <a href="https://mainwp.com" id="mainwplogo" title="MainWP" target="_blank"><img src="<?php echo plugins_url('images/logo.png', dirname(__FILE__)); ?> " height="50" alt="MainWP"/></a> <h2><i class="fa fa-globe"></i> <?php echo stripslashes($website->name); ?> </h2> <div style="clear: both;"></div> <br/> <div id="mainwp_background-box"> <?php _e('Will redirect to your website immediately.', 'mainwp'); $url = isset($website->siteurl) && $website->siteurl != '' ? $website->siteurl : $website->url; $url .= substr($url, -1) != '/' ? '/' : ''; $postdata = MainWP_Utility::getGetDataAuthed($website, $file, MainWP_Utility::getFileParameter($website), true); $postdata['size'] = $size; ?> <form method="POST" action="<?php echo $url; ?> " id="redirectForm"> <?php foreach ($postdata as $name => $value) { echo '<input type="hidden" name="' . $name . '" value="' . $value . '" />'; } ?> </form> </div> </div> <?php }
public static function addSite($website) { $error = ''; $message = ''; if ($website) { $error = __('Your site is already added to MainWP', 'mainwp'); } else { try { //Add if (function_exists('openssl_pkey_new')) { $conf = array('private_key_bits' => 384); $conf_loc = MainWP_System::get_openssl_conf(); if (!empty($conf_loc)) { $conf['config'] = $conf_loc; } $res = openssl_pkey_new($conf); @openssl_pkey_export($res, $privkey, null, $conf); $pubkey = openssl_pkey_get_details($res); $pubkey = $pubkey['key']; } else { $privkey = '-1'; $pubkey = '-1'; } $url = $_POST['managesites_add_wpurl']; $pluginConflicts = get_option('mainwp_pluginConflicts'); if ($pluginConflicts !== false) { $pluginConflicts = array_keys($pluginConflicts); } $themeConflicts = get_option('mainwp_themeConflicts'); if ($themeConflicts !== false) { $themeConflicts = array_keys($themeConflicts); } // to fix bug if (is_array($pluginConflicts)) { $pluginConflicts = array_filter($pluginConflicts); } if (is_array($themeConflicts)) { $themeConflicts = array_filter($themeConflicts); } $verifyCertificate = !isset($_POST['verify_certificate']) || empty($_POST['verify_certificate']) ? null : $_POST['verify_certificate']; $sslVersion = MainWP_Utility::getCURLSSLVersion(!isset($_POST['ssl_version']) || empty($_POST['ssl_version']) ? null : $_POST['ssl_version']); $addUniqueId = isset($_POST['managesites_add_uniqueId']) ? $_POST['managesites_add_uniqueId'] : ''; $http_user = isset($_POST['managesites_add_http_user']) ? $_POST['managesites_add_http_user'] : ''; $http_pass = isset($_POST['managesites_add_http_pass']) ? $_POST['managesites_add_http_pass'] : ''; $information = MainWP_Utility::fetchUrlNotAuthed($url, $_POST['managesites_add_wpadmin'], 'register', array('pubkey' => $pubkey, 'server' => get_admin_url(), 'uniqueId' => $addUniqueId, 'pluginConflicts' => json_encode($pluginConflicts), 'themeConflicts' => json_encode($themeConflicts)), false, $verifyCertificate, $http_user, $http_pass, $sslVersion); if (isset($information['error']) && $information['error'] != '') { $error = $information['error']; } else { if (isset($information['register']) && $information['register'] == 'OK') { //Add website to database $groupids = array(); $groupnames = array(); if (isset($_POST['groupids'])) { foreach ($_POST['groupids'] as $group) { $groupids[] = $group; } } if (isset($_POST['groupnames']) && $_POST['groupnames'] != '' || isset($_POST['groupnames_import']) && $_POST['groupnames_import'] != '') { if ($_POST['groupnames']) { $tmpArr = explode(',', $_POST['groupnames']); } else { if ($_POST['groupnames_import']) { $tmpArr = explode(';', $_POST['groupnames_import']); } } foreach ($tmpArr as $tmp) { $group = MainWP_DB::Instance()->getGroupByNameForUser(trim($tmp)); if ($group) { if (!in_array($group->id, $groupids)) { $groupids[] = $group->id; } } else { $groupnames[] = trim($tmp); } } } if (!isset($information['uniqueId']) || empty($information['uniqueId'])) { $addUniqueId = ''; } $http_user = isset($_POST['managesites_add_http_user']) ? $_POST['managesites_add_http_user'] : ''; $http_pass = isset($_POST['managesites_add_http_pass']) ? $_POST['managesites_add_http_pass'] : ''; global $current_user; $id = MainWP_DB::Instance()->addWebsite($current_user->ID, $_POST['managesites_add_wpname'], $_POST['managesites_add_wpurl'], $_POST['managesites_add_wpadmin'], base64_encode($pubkey), base64_encode($privkey), $information['nossl'], isset($information['nosslkey']) ? $information['nosslkey'] : null, $groupids, $groupnames, $verifyCertificate, $addUniqueId, $http_user, $http_pass, $sslVersion); $message = sprintf(__('Site successfully added - Visit the Site\'s %sDashboard%s now.', 'mainwp'), '<a href="admin.php?page=managesites&dashboard=' . $id . '" style="text-decoration: none;" title="' . __('Dashboard', 'mainwp') . '">', '</a>'); $website = MainWP_DB::Instance()->getWebsiteById($id); MainWP_Sync::syncInformationArray($website, $information); } else { $error = __('Undefined error.', 'mainwp'); } } } catch (MainWP_Exception $e) { if ($e->getMessage() == 'HTTPERROR') { $error = 'HTTP error' . ($e->getMessageExtra() != null ? ' - ' . $e->getMessageExtra() : ''); } else { if ($e->getMessage() == 'NOMAINWP') { $error = __('No MainWP Child plugin detected, first install and activate the plugin and add your site to MainWP afterwards. If you continue experiencing this issue please ', 'mainwp'); if ($e->getMessageExtra() != null) { $error .= sprintf(__('test your connection %shere%s or ', 'mainwp'), '<a href="' . admin_url('admin.php?page=managesites&do=test&site=' . urlencode($e->getMessageExtra())) . '">', '</a>'); } $error .= sprintf(__('post as much information as possible on the error in the %ssupport forum%s.', 'mainwp'), '<a href="https://mainwp.com/forum/">', '</a>'); } else { $error = $e->getMessage(); } } } } return array($message, $error); }
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; }
function prepare_items($globalIgnoredPluginConflicts = array(), $globalIgnoredThemeConflicts = array()) { $this->globalIgnoredPluginConflicts = $globalIgnoredPluginConflicts; $this->globalIgnoredThemeConflicts = $globalIgnoredThemeConflicts; $orderby = 'wp.url'; if (!isset($_GET['orderby'])) { $_order_by = get_option('mainwp_managesites_orderby'); $_order = get_option('mainwp_managesites_order'); if (!empty($_order_by)) { $_GET['orderby'] = $_order_by; $_GET['order'] = $_order; } } else { MainWP_Utility::update_option('mainwp_managesites_orderby', $_GET['orderby']); MainWP_Utility::update_option('mainwp_managesites_order', $_GET['order']); } if (isset($_GET['orderby'])) { if ($_GET['orderby'] == 'site') { $orderby = 'wp.name ' . ($_GET['order'] == 'asc' ? 'asc' : 'desc'); } else { if ($_GET['orderby'] == 'url') { $orderby = 'wp.url ' . ($_GET['order'] == 'asc' ? 'asc' : 'desc'); } else { if ($_GET['orderby'] == 'group') { $orderby = 'GROUP_CONCAT(gr.name ORDER BY gr.name SEPARATOR ", ") ' . ($_GET['order'] == 'asc' ? 'asc' : 'desc'); } else { if ($_GET['orderby'] == 'status') { $orderby = 'CASE true WHEN ((pluginConflicts <> "[]") AND (pluginConflicts IS NOT NULL) AND (pluginConflicts <> "")) THEN 1 WHEN (offline_check_result = -1) THEN 2 WHEN (wp_sync.sync_errors IS NOT NULL) AND (wp_sync.sync_errors <> "") THEN 3 ELSE 4 + (CASE plugin_upgrades WHEN "[]" THEN 0 ELSE 1 + LENGTH(plugin_upgrades) - LENGTH(REPLACE(plugin_upgrades, "\\"Name\\":", "\\"Name\\"")) END) + (CASE theme_upgrades WHEN "[]" THEN 0 ELSE 1 + LENGTH(theme_upgrades) - LENGTH(REPLACE(theme_upgrades, "\\"Name\\":", "\\"Name\\"")) END) + (CASE wp_upgrades WHEN "[]" THEN 0 ELSE 1 END) END ' . ($_GET['order'] == 'asc' ? 'asc' : 'desc'); } else { if (isset($_REQUEST['orderby']) && $_REQUEST['orderby'] == 'last_post') { $orderby = 'wp_sync.last_post_gmt ' . ($_GET['order'] == 'asc' ? 'asc' : 'desc'); } } } } } } $perPage = $this->get_items_per_page('mainwp_managesites_per_page'); $currentPage = $this->get_pagenum(); $no_request = !isset($_REQUEST['s']) && !isset($_REQUEST['g']) && !isset($_REQUEST['status']); if (!isset($_REQUEST['status'])) { if ($no_request) { $_status = get_option('mainwp_managesites_filter_status'); if (!empty($_status)) { $_REQUEST['status'] = $_status; } } else { MainWP_Utility::update_option('mainwp_managesites_filter_status', ''); } } else { MainWP_Utility::update_option('mainwp_managesites_filter_status', $_REQUEST['status']); } if (!isset($_REQUEST['g'])) { if ($no_request) { $_g = get_option('mainwp_managesites_filter_group'); if (!empty($_g)) { $_REQUEST['g'] = $_g; } } else { MainWP_Utility::update_option('mainwp_managesites_filter_group', ''); } } else { MainWP_Utility::update_option('mainwp_managesites_filter_group', $_REQUEST['g']); } $where = null; if (isset($_REQUEST['status']) && $_REQUEST['status'] != '') { if ($_REQUEST['status'] == 'online') { $where = 'wp.offline_check_result = 1'; } else { if ($_REQUEST['status'] == 'offline') { $where = 'wp.offline_check_result = -1'; } else { if ($_REQUEST['status'] == 'disconnected') { $where = 'wp_sync.sync_errors != ""'; } else { if ($_REQUEST['status'] == 'update') { $available_update_ids = $this->get_available_update_siteids(); if (empty($available_update_ids)) { $where = 'wp.id = -1'; } else { $where = 'wp.id IN (' . implode(',', $available_update_ids) . ') '; } } } } } } if (isset($_REQUEST['g']) && $_REQUEST['g'] != '') { $websites = MainWP_DB::Instance()->query(MainWP_DB::Instance()->getSQLWebsitesByGroupId($_REQUEST['g'], true)); $totalRecords = $websites ? MainWP_DB::num_rows($websites) : 0; if ($websites) { @MainWP_DB::free_result($websites); } if (isset($_GET['orderby']) && $_GET['orderby'] == 'group') { $orderby = 'wp.url'; } $websites = MainWP_DB::Instance()->query(MainWP_DB::Instance()->getSQLWebsitesByGroupId($_REQUEST['g'], true, $orderby, ($currentPage - 1) * $perPage, $perPage, $where)); } else { if (isset($_REQUEST['status']) && $_REQUEST['status'] != '') { $websites = MainWP_DB::Instance()->query(MainWP_DB::Instance()->getSQLWebsitesForCurrentUser(true, null, $orderby, false, false, $where)); $totalRecords = $websites ? MainWP_DB::num_rows($websites) : 0; if ($websites) { @MainWP_DB::free_result($websites); } $websites = MainWP_DB::Instance()->query(MainWP_DB::Instance()->getSQLWebsitesForCurrentUser(true, null, $orderby, ($currentPage - 1) * $perPage, $perPage, $where)); } else { $websites = MainWP_DB::Instance()->query(MainWP_DB::Instance()->getSQLWebsitesForCurrentUser(true, isset($_REQUEST['s']) && $_REQUEST['s'] != '' ? $_REQUEST['s'] : null, $orderby)); $totalRecords = $websites ? MainWP_DB::num_rows($websites) : 0; if ($websites) { @MainWP_DB::free_result($websites); } $websites = MainWP_DB::Instance()->query(MainWP_DB::Instance()->getSQLWebsitesForCurrentUser(true, isset($_REQUEST['s']) && $_REQUEST['s'] != '' ? $_REQUEST['s'] : null, $orderby, ($currentPage - 1) * $perPage, $perPage)); } } $this->set_pagination_args(array('total_items' => $totalRecords, 'per_page' => $perPage)); $this->items = $websites; }