示例#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']) && MainWPUtility::ctype_digit($_GET['backupid'])) {
         $websiteid = $_GET['backupid'];
         $backupwebsite = MainWPDB::Instance()->getWebsiteById($websiteid);
         if (MainWPUtility::can_edit_website($backupwebsite)) {
             MainWPManageSites::renderBackupSite($backupwebsite);
             return;
         }
     }
     if (isset($_GET['scanid']) && MainWPUtility::ctype_digit($_GET['scanid'])) {
         $websiteid = $_GET['scanid'];
         $scanwebsite = MainWPDB::Instance()->getWebsiteById($websiteid);
         if (MainWPUtility::can_edit_website($scanwebsite)) {
             MainWPManageSites::renderScanSite($scanwebsite);
             return;
         }
     }
     if (isset($_GET['seowebsiteid']) && MainWPUtility::ctype_digit($_GET['seowebsiteid'])) {
         $websiteid = $_GET['seowebsiteid'];
         $seoWebsite = MainWPDB::Instance()->getWebsiteById($websiteid);
         if (MainWPUtility::can_edit_website($seoWebsite)) {
             MainWPManageSites::renderSeoPage($seoWebsite);
             return;
         }
     }
     if (isset($_GET['dashboard']) && MainWPUtility::ctype_digit($_GET['dashboard'])) {
         $websiteid = $_GET['dashboard'];
         $dashboardWebsite = MainWPDB::Instance()->getWebsiteById($websiteid);
         if (MainWPUtility::can_edit_website($dashboardWebsite)) {
             MainWPManageSites::renderDashboard($dashboardWebsite);
             return;
         }
     }
     if (isset($_GET['id']) && MainWPUtility::ctype_digit($_GET['id'])) {
         $websiteid = $_GET['id'];
         $website = MainWPDB::Instance()->getWebsiteById($websiteid);
         if (!MainWPUtility::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 = MainWPDB::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']) && MainWPUtility::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'];
             MainWPDB::Instance()->updateWebsite($website->id, $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;
             }
             MainWPDB::Instance()->updateWebsiteValues($website->id, $newValues);
             $updated = true;
             //Reload the site
             $website = MainWPDB::Instance()->getWebsiteById($website->id);
         }
         $groups = MainWPDB::Instance()->getGroupsForCurrentUser();
         $statusses = array('hourly', '2xday', 'daily', 'weekly');
         $pluginDir = $website->pluginDir;
         self::renderHeader('ManageSitesEdit');
         MainWPManageSitesView::renderAllSites($website, $updated, $groups, $statusses, $pluginDir);
         self::renderFooter('ManageSitesEdit');
     }
 }