public static function Instance()
 {
     if (null === MainWP_Child_Plugins_Check::$instance) {
         MainWP_Child_Plugins_Check::$instance = new MainWP_Child_Plugins_Check();
     }
     return MainWP_Child_Plugins_Check::$instance;
 }
Esempio n. 2
0
 function getSiteStats($information = array(), $exit = true)
 {
     global $wp_version;
     if ($exit) {
         $this->updateExternalSettings();
     }
     MainWP_Helper::update_option('mainwp_child_branding_disconnected', '', 'yes');
     if (isset($_POST['server'])) {
         MainWP_Helper::update_option('mainwp_child_server', $_POST['server']);
     }
     if (isset($_POST['numberdaysOutdatePluginTheme']) && !empty($_POST['numberdaysOutdatePluginTheme'])) {
         $days_outdate = get_option('mainwp_child_plugintheme_days_outdate', 365);
         if ($days_outdate !== $_POST['numberdaysOutdatePluginTheme']) {
             $days_outdate = $_POST['numberdaysOutdatePluginTheme'];
             MainWP_Helper::update_option('mainwp_child_plugintheme_days_outdate', $days_outdate);
             MainWP_Child_Plugins_Check::Instance()->cleanup_deactivation(false);
             MainWP_Child_Themes_Check::Instance()->cleanup_deactivation(false);
         }
     }
     $information['version'] = self::$version;
     $information['wpversion'] = $wp_version;
     $information['siteurl'] = get_option('siteurl');
     $information['nossl'] = '1' === get_option('mainwp_child_nossl') ? 1 : 0;
     include_once ABSPATH . '/wp-admin/includes/update.php';
     $timeout = 3 * 60 * 60;
     // 3minutes
     @set_time_limit($timeout);
     @ini_set('max_execution_time', $timeout);
     //Check for new versions
     if (null !== $this->filterFunction) {
         add_filter('pre_site_transient_update_core', $this->filterFunction, 99);
     }
     if (null !== $this->filterFunction) {
         add_filter('pre_transient_update_core', $this->filterFunction, 99);
     }
     @wp_version_check();
     $core_updates = get_core_updates();
     if (count($core_updates) > 0) {
         foreach ($core_updates as $core_update) {
             if ('latest' === $core_update->response) {
                 break;
             }
             if ('upgrade' === $core_update->response && version_compare($wp_version, $core_update->current, '<=')) {
                 $information['wp_updates'] = $core_update->current;
             }
         }
     }
     if (!isset($information['wp_updates'])) {
         $information['wp_updates'] = null;
     }
     if (null !== $this->filterFunction) {
         remove_filter('pre_site_transient_update_core', $this->filterFunction, 99);
     }
     if (null !== $this->filterFunction) {
         remove_filter('pre_transient_update_core', $this->filterFunction, 99);
     }
     add_filter('default_option_active_plugins', array(&$this, 'default_option_active_plugins'));
     add_filter('option_active_plugins', array(&$this, 'default_option_active_plugins'));
     //First check for new premium updates
     $update_check = apply_filters('mwp_premium_update_check', array());
     if (!empty($update_check)) {
         foreach ($update_check as $updateFeedback) {
             if (is_array($updateFeedback['callback']) && isset($updateFeedback['callback'][0]) && isset($updateFeedback['callback'][1])) {
                 @call_user_func(array($updateFeedback['callback'][0], $updateFeedback['callback'][1]));
             } else {
                 if (is_string($updateFeedback['callback'])) {
                     @call_user_func($updateFeedback['callback']);
                 }
             }
         }
     }
     $informationPremiumUpdates = apply_filters('mwp_premium_update_notification', array());
     $premiumPlugins = array();
     $premiumThemes = array();
     if (is_array($informationPremiumUpdates)) {
         $premiumUpdates = array();
         $information['premium_updates'] = array();
         $informationPremiumUpdatesLength = count($informationPremiumUpdates);
         for ($i = 0; $i < $informationPremiumUpdatesLength; $i++) {
             if (!isset($informationPremiumUpdates[$i]['new_version'])) {
                 continue;
             }
             $slug = isset($informationPremiumUpdates[$i]['slug']) ? $informationPremiumUpdates[$i]['slug'] : $informationPremiumUpdates[$i]['Name'];
             if ('plugin' === $informationPremiumUpdates[$i]['type']) {
                 $premiumPlugins[] = $slug;
             } else {
                 if ('theme' === $informationPremiumUpdates[$i]['type']) {
                     $premiumThemes[] = $slug;
                 }
             }
             $new_version = $informationPremiumUpdates[$i]['new_version'];
             unset($informationPremiumUpdates[$i]['old_version']);
             unset($informationPremiumUpdates[$i]['new_version']);
             $information['premium_updates'][$slug] = $informationPremiumUpdates[$i];
             $information['premium_updates'][$slug]['update'] = (object) array('new_version' => $new_version, 'premium' => true, 'slug' => $slug);
             if (!in_array($slug, $premiumUpdates)) {
                 $premiumUpdates[] = $slug;
             }
         }
         MainWP_Helper::update_option('mainwp_premium_updates', $premiumUpdates);
     }
     remove_filter('default_option_active_plugins', array(&$this, 'default_option_active_plugins'));
     remove_filter('option_active_plugins', array(&$this, 'default_option_active_plugins'));
     if (null !== $this->filterFunction) {
         add_filter('pre_site_transient_update_plugins', $this->filterFunction, 99);
     }
     global $wp_current_filter;
     $wp_current_filter[] = 'load-plugins.php';
     @wp_update_plugins();
     include_once ABSPATH . '/wp-admin/includes/plugin.php';
     $plugin_updates = get_plugin_updates();
     if (is_array($plugin_updates)) {
         $information['plugin_updates'] = array();
         foreach ($plugin_updates as $slug => $plugin_update) {
             if (in_array($plugin_update->Name, $premiumPlugins)) {
                 continue;
             }
             $information['plugin_updates'][$slug] = $plugin_update;
         }
     }
     if (null !== $this->filterFunction) {
         remove_filter('pre_site_transient_update_plugins', $this->filterFunction, 99);
     }
     if (null !== $this->filterFunction) {
         add_filter('pre_site_transient_update_themes', $this->filterFunction, 99);
     }
     @wp_update_themes();
     include_once ABSPATH . '/wp-admin/includes/theme.php';
     $theme_updates = $this->upgrade_get_theme_updates();
     if (is_array($theme_updates)) {
         $information['theme_updates'] = array();
         foreach ($theme_updates as $slug => $theme_update) {
             $name = is_array($theme_update) ? $theme_update['Name'] : $theme_update->Name;
             if (in_array($name, $premiumThemes)) {
                 continue;
             }
             $information['theme_updates'][$slug] = $theme_update;
         }
     }
     if (null !== $this->filterFunction) {
         remove_filter('pre_site_transient_update_themes', $this->filterFunction, 99);
     }
     $information['recent_comments'] = $this->get_recent_comments(array('approve', 'hold'), 5);
     $information['recent_posts'] = $this->get_recent_posts(array('publish', 'draft', 'pending', 'trash'), 5);
     $information['recent_pages'] = $this->get_recent_posts(array('publish', 'draft', 'pending', 'trash'), 5, 'page');
     $securityIssuess = 0;
     if (!MainWP_Security::prevent_listing_ok()) {
         $securityIssuess++;
     }
     if (!MainWP_Security::remove_wp_version_ok()) {
         $securityIssuess++;
     }
     if (!MainWP_Security::remove_rsd_ok()) {
         $securityIssuess++;
     }
     if (!MainWP_Security::remove_wlw_ok()) {
         $securityIssuess++;
     }
     //        if (!MainWP_Security::remove_core_update_ok()) $securityIssuess++;
     //        if (!MainWP_Security::remove_plugin_update_ok()) $securityIssuess++;
     //        if (!MainWP_Security::remove_theme_update_ok()) $securityIssuess++;
     //        if (!MainWP_Security::fix_file_permissions_ok()) $securityIssuess++;
     if (!MainWP_Security::remove_database_reporting_ok()) {
         $securityIssuess++;
     }
     if (!MainWP_Security::remove_php_reporting_ok()) {
         $securityIssuess++;
     }
     if (!MainWP_Security::remove_scripts_version_ok() || !MainWP_Security::remove_styles_version_ok()) {
         $securityIssuess++;
     }
     if (!MainWP_Security::admin_user_ok()) {
         $securityIssuess++;
     }
     if (!MainWP_Security::remove_readme_ok()) {
         $securityIssuess++;
     }
     $information['securityIssues'] = $securityIssuess;
     //Directory listings!
     $information['directories'] = $this->scanDir(ABSPATH, 3);
     $cats = get_categories(array('hide_empty' => 0, 'hierarchical' => true));
     $categories = array();
     foreach ($cats as $cat) {
         $categories[] = $cat->name;
     }
     $information['categories'] = $categories;
     $information['totalsize'] = $this->getTotalFileSize();
     $information['dbsize'] = MainWP_Child_DB::get_size();
     $auths = get_option('mainwp_child_auth');
     $information['extauth'] = $auths && isset($auths[$this->maxHistory]) ? $auths[$this->maxHistory] : null;
     $plugins = $this->get_all_plugins_int(false);
     $themes = $this->get_all_themes_int(false);
     $information['plugins'] = $plugins;
     $information['themes'] = $themes;
     if (isset($_POST['optimize']) && '1' === $_POST['optimize']) {
         $information['users'] = $this->get_all_users_int();
     }
     if (isset($_POST['pluginConflicts']) && '' !== $_POST['pluginConflicts']) {
         $pluginConflicts = json_decode(stripslashes($_POST['pluginConflicts']), true);
         $conflicts = array();
         if (count($pluginConflicts) > 0) {
             if (!$plugins) {
                 $plugins = $this->get_all_plugins_int(false);
             }
             if (is_array($plugins) && is_array($pluginConflicts)) {
                 foreach ($plugins as $plugin) {
                     foreach ($pluginConflicts as $pluginConflict) {
                         if ('1' === $plugin['active'] && ($plugin['name'] === $pluginConflict || $plugin['slug'] === $pluginConflict)) {
                             $conflicts[] = $plugin['name'];
                         }
                     }
                 }
             }
         }
         if (count($conflicts) > 0) {
             $information['pluginConflicts'] = $conflicts;
         }
     }
     if (isset($_POST['themeConflicts']) && '' !== $_POST['themeConflicts']) {
         $themeConflicts = json_decode(stripslashes($_POST['themeConflicts']), true);
         $conflicts = array();
         if (is_array($themeConflicts) && count($themeConflicts) > 0) {
             $theme = wp_get_theme()->get('Name');
             foreach ($themeConflicts as $themeConflict) {
                 if ($theme === $themeConflict) {
                     $conflicts[] = $theme;
                 }
             }
         }
         if (count($conflicts) > 0) {
             $information['themeConflicts'] = $conflicts;
         }
     }
     if (isset($_POST['othersData'])) {
         $othersData = json_decode(stripslashes($_POST['othersData']), true);
         if (!is_array($othersData)) {
             $othersData = array();
         }
         $information = apply_filters('mainwp-site-sync-others-data', $information, $othersData);
         if (version_compare(phpversion(), '5.3', '>=')) {
             if (isset($othersData['syncBackUpWordPress']) && $othersData['syncBackUpWordPress']) {
                 if (MainWP_Child_Back_Up_Wordpress::isActivated()) {
                     $information['syncBackUpWordPress'] = MainWP_Child_Back_Up_Wordpress::Instance()->syncData();
                 }
             }
         }
         if (isset($othersData['syncWPRocketData']) && 'yes' === $othersData['syncWPRocketData']) {
             $data = array();
             if (MainWP_Child_WP_Rocket::isActivated()) {
                 $boxes = get_user_meta($GLOBALS['current_user']->ID, 'rocket_boxes', true);
                 $data['rocket_boxes'] = $boxes;
             }
             $information['syncWPRocketData'] = $data;
         }
     }
     $information['faviIcon'] = $this->get_favicon();
     $last_post = wp_get_recent_posts(array('numberposts' => absint('1')));
     if (isset($last_post[0])) {
         $last_post = $last_post[0];
     }
     if (isset($last_post) && isset($last_post['post_modified_gmt'])) {
         $information['last_post_gmt'] = strtotime($last_post['post_modified_gmt']);
     }
     $information['mainwpdir'] = MainWP_Helper::validateMainWPDir() ? 1 : -1;
     $information['uniqueId'] = get_option('mainwp_child_uniqueId', '');
     $information['plugins_outdate_info'] = MainWP_Child_Plugins_Check::Instance()->get_plugins_outdate_info();
     $information['themes_outdate_info'] = MainWP_Child_Themes_Check::Instance()->get_themes_outdate_info();
     if ($exit) {
         MainWP_Helper::write($information);
     }
     return $information;
 }