Ejemplo n.º 1
0
 public static function renderAllSites()
 {
     global $current_user;
     if (isset($_REQUEST['do'])) {
         if ($_REQUEST['do'] == 'new') {
             self::renderNewSite();
         } else {
             if ($_REQUEST['do'] == 'test') {
                 self::renderTest();
             }
         }
         return;
     }
     $website = null;
     if (isset($_GET['backupid']) && MainWP_Utility::ctype_digit($_GET['backupid'])) {
         $websiteid = $_GET['backupid'];
         $backupwebsite = MainWP_DB::Instance()->getWebsiteById($websiteid);
         if (MainWP_Utility::can_edit_website($backupwebsite)) {
             MainWP_Manage_Sites::renderBackupSite($backupwebsite);
             return;
         }
     }
     if (isset($_GET['scanid']) && MainWP_Utility::ctype_digit($_GET['scanid'])) {
         $websiteid = $_GET['scanid'];
         $scanwebsite = MainWP_DB::Instance()->getWebsiteById($websiteid);
         if (MainWP_Utility::can_edit_website($scanwebsite)) {
             MainWP_Manage_Sites::renderScanSite($scanwebsite);
             return;
         }
     }
     if (isset($_GET['seowebsiteid']) && MainWP_Utility::ctype_digit($_GET['seowebsiteid'])) {
         $websiteid = $_GET['seowebsiteid'];
         $seoWebsite = MainWP_DB::Instance()->getWebsiteById($websiteid);
         if (MainWP_Utility::can_edit_website($seoWebsite)) {
             MainWP_Manage_Sites::renderSeoPage($seoWebsite);
             return;
         }
     }
     if (isset($_GET['dashboard']) && MainWP_Utility::ctype_digit($_GET['dashboard'])) {
         $websiteid = $_GET['dashboard'];
         $dashboardWebsite = MainWP_DB::Instance()->getWebsiteById($websiteid);
         if (MainWP_Utility::can_edit_website($dashboardWebsite)) {
             MainWP_Manage_Sites::renderDashboard($dashboardWebsite);
             return;
         }
     }
     if (isset($_GET['id']) && MainWP_Utility::ctype_digit($_GET['id'])) {
         $websiteid = $_GET['id'];
         $website = MainWP_DB::Instance()->getWebsiteById($websiteid);
         if (!MainWP_Utility::can_edit_website($website)) {
             $website = null;
         }
     }
     if ($website == null) {
         self::_renderAllSites();
     } else {
         $updated = false;
         //Edit website!
         if (isset($_POST['submit']) && isset($_POST['mainwp_managesites_edit_siteadmin']) && $_POST['mainwp_managesites_edit_siteadmin'] != '') {
             //update site
             $groupids = array();
             $groupnames = array();
             if (isset($_POST['selected_groups'])) {
                 foreach ($_POST['selected_groups'] as $group) {
                     $groupids[] = $group;
                 }
             }
             if (isset($_POST['mainwp_managesites_edit_addgroups']) && $_POST['mainwp_managesites_edit_addgroups'] != '') {
                 $tmpArr = explode(',', $_POST['mainwp_managesites_edit_addgroups']);
                 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);
                     }
                 }
             }
             $newPluginDir = isset($_POST['mainwp_options_footprint_plugin_folder']) ? $_POST['mainwp_options_footprint_plugin_folder'] : '';
             $maximumFileDescriptorsOverride = isset($_POST['mainwp_options_maximumFileDescriptorsOverride']);
             $maximumFileDescriptorsAuto = isset($_POST['mainwp_maximumFileDescriptorsAuto']);
             $maximumFileDescriptors = isset($_POST['mainwp_options_maximumFileDescriptors']) && MainWP_Utility::ctype_digit($_POST['mainwp_options_maximumFileDescriptors']) ? $_POST['mainwp_options_maximumFileDescriptors'] : 150;
             $archiveFormat = isset($_POST['mainwp_archiveFormat']) ? $_POST['mainwp_archiveFormat'] : 'global';
             $http_user = $_POST['mainwp_managesites_edit_http_user'];
             $http_pass = $_POST['mainwp_managesites_edit_http_pass'];
             $url = $_POST['mainwp_managesites_edit_siteurl_protocol'] . '://' . MainWP_Utility::removeHttpPrefix($website->url, true);
             MainWP_DB::Instance()->updateWebsite($website->id, $url, $current_user->ID, $_POST['mainwp_managesites_edit_sitename'], $_POST['mainwp_managesites_edit_siteadmin'], $groupids, $groupnames, $_POST['offline_checks'], $newPluginDir, $maximumFileDescriptorsOverride, $maximumFileDescriptorsAuto, $maximumFileDescriptors, $_POST['mainwp_managesites_edit_verifycertificate'], $archiveFormat, isset($_POST['mainwp_managesites_edit_uniqueId']) ? $_POST['mainwp_managesites_edit_uniqueId'] : '', $http_user, $http_pass);
             do_action('mainwp_update_site', $website->id);
             $backup_before_upgrade = isset($_POST['mainwp_backup_before_upgrade']) ? intval($_POST['mainwp_backup_before_upgrade']) : 2;
             if ($backup_before_upgrade > 2) {
                 $backup_before_upgrade = 2;
             }
             $newValues = array('automatic_update' => !isset($_POST['mainwp_automaticDailyUpdate']) ? 0 : 1, 'backup_before_upgrade' => $backup_before_upgrade, 'loadFilesBeforeZip' => $_POST['mainwp_options_loadFilesBeforeZip']);
             if (mainwp_current_user_can('dashboard', 'ignore_unignore_updates')) {
                 $newValues['is_ignoreCoreUpdates'] = isset($_POST['mainwp_is_ignoreCoreUpdates']) && $_POST['mainwp_is_ignoreCoreUpdates'] ? 1 : 0;
                 $newValues['is_ignorePluginUpdates'] = isset($_POST['mainwp_is_ignorePluginUpdates']) && $_POST['mainwp_is_ignorePluginUpdates'] ? 1 : 0;
                 $newValues['is_ignoreThemeUpdates'] = isset($_POST['mainwp_is_ignoreThemeUpdates']) && $_POST['mainwp_is_ignoreThemeUpdates'] ? 1 : 0;
             }
             MainWP_DB::Instance()->updateWebsiteValues($website->id, $newValues);
             $updated = true;
             //Reload the site
             $website = MainWP_DB::Instance()->getWebsiteById($website->id);
         }
         $groups = MainWP_DB::Instance()->getGroupsForCurrentUser();
         $statusses = array('hourly', '2xday', 'daily', 'weekly');
         $pluginDir = $website->pluginDir;
         self::renderHeader('ManageSitesEdit');
         MainWP_Manage_Sites_View::renderAllSites($website, $updated, $groups, $statusses, $pluginDir);
         self::renderFooter('ManageSitesEdit');
     }
 }