Exemplo n.º 1
0
 function admin_init()
 {
     if (!MainWP_Utility::isAdmin()) {
         return;
     }
     if (get_option('mainwp_activated') == 'yes') {
         delete_option('mainwp_activated');
         wp_redirect(admin_url('admin.php?page=managesites&do=new'));
         return;
     }
     global $mainwpUseExternalPrimaryBackupsMethod;
     if ($mainwpUseExternalPrimaryBackupsMethod === null) {
         $mainwpUseExternalPrimaryBackupsMethod = apply_filters('mainwp-getprimarybackup-activated', '');
     }
     add_action('admin_notices', array($this, 'mainwp_warning_notice'));
     $this->posthandler->init();
     wp_enqueue_script('jquery-ui-tooltip');
     wp_enqueue_script('jquery-ui-autocomplete');
     wp_enqueue_script('jquery-ui-progressbar');
     wp_enqueue_script('jquery-ui-datepicker');
     wp_enqueue_script('jquery-ui-dialog');
     global $wp_scripts;
     $ui = $wp_scripts->query('jquery-ui-core');
     $version = $ui->ver;
     if (MainWP_Utility::startsWith($version, '1.10')) {
         wp_enqueue_style('jquery-ui-style', MAINWP_PLUGIN_URL . 'css/1.10.4/jquery-ui.min.css', array(), '1.10.4');
     } else {
         wp_enqueue_style('jquery-ui-style', MAINWP_PLUGIN_URL . 'css/1.11.1/jquery-ui.min.css', array(), '1.11.1');
     }
     wp_enqueue_script('mainwp', MAINWP_PLUGIN_URL . 'js/mainwp.js', array('jquery-ui-tooltip', 'jquery-ui-autocomplete', 'jquery-ui-progressbar', 'jquery-ui-dialog', 'jquery-ui-datepicker'), $this->current_version);
     $mainwpParams = array('image_url' => MAINWP_PLUGIN_URL . 'images/', 'backup_before_upgrade' => get_option('mainwp_backup_before_upgrade') == 1, 'admin_url' => admin_url(), 'date_format' => get_option('date_format'), 'time_format' => get_option('time_format'), 'enabledTwit' => MainWP_Twitter::enabledTwitterMessages(), 'maxSecondsTwit' => MAINWP_TWITTER_MAX_SECONDS);
     wp_localize_script('mainwp', 'mainwpParams', $mainwpParams);
     wp_enqueue_script('mainwp-tristate', MAINWP_PLUGIN_URL . 'js/tristate.min.js', array('mainwp'), $this->current_version);
     $mainwpTranslations = MainWP_System_View::getMainWPTranslations();
     wp_localize_script('mainwp', 'mainwpTranslations', $mainwpTranslations);
     $security_nonces = $this->posthandler->getSecurityNonces();
     wp_localize_script('mainwp', 'security_nonces', $security_nonces);
     MainWP_Meta_Boxes::initMetaBoxes();
     wp_enqueue_script('thickbox');
     wp_enqueue_script('user-profile');
     wp_enqueue_style('thickbox');
     if (isset($_GET['page']) && ($_GET['page'] == 'PluginsManage' || $_GET['page'] == 'ThemesManage')) {
         wp_enqueue_script('mainwp-fixedtable', MAINWP_PLUGIN_URL . 'js/tableHeadFixer.js', array('jquery', 'jquery-ui-core'), $this->current_version);
     }
     if (!current_user_can('update_core')) {
         remove_action('admin_notices', 'update_nag', 3);
     }
 }
 private static function addExcludedBackups(&$files, &$arr)
 {
     $newExcludes = array();
     //Backup buddy
     $newExcludes[] = 'wp-content/uploads/backupbuddy_backups';
     $newExcludes[] = 'wp-content/uploads/backupbuddy_temp';
     $newExcludes[] = 'wp-content/uploads/pb_backupbuddy';
     //ManageWP
     $newExcludes[] = 'wp-content/managewp';
     //InfiniteWP
     $newExcludes[] = 'wp-content/infinitewp';
     //WordPress Backup to Dropbox
     $newExcludes[] = 'wp-content/backups';
     //BackWPUp
     $newExcludes[] = 'wp-content/uploads/backwpup*';
     //WP Complete Backup
     $newExcludes[] = 'wp-content/plugins/wp-complete-backup/storage';
     //Online Backup for WordPress
     $newExcludes[] = 'wp-content/backups';
     //XCloner
     $newExcludes[] = 'administrator/backups';
     foreach ($newExcludes as $newExclude) {
         $path = explode('/', $newExclude);
         $found = true;
         $newExcludeSuffix = null;
         $currentArr = null;
         foreach ($path as $pathPart) {
             if ($currentArr == null) {
                 if (isset($files[$pathPart])) {
                     $currentArr = $files[$pathPart];
                 }
             } else {
                 if (isset($currentArr[$pathPart])) {
                     $currentArr = $currentArr[$pathPart];
                 } else {
                     if (MainWP_Utility::endsWith($pathPart, '*')) {
                         foreach ($currentArr as $key => $val) {
                             if (MainWP_Utility::startsWith($key, substr($pathPart, 0, strlen($pathPart) - 1))) {
                                 if ($newExcludeSuffix == null) {
                                     $newExcludeSuffix = array();
                                 }
                                 $newExcludeSuffix[] = $key;
                             }
                         }
                         if ($newExcludeSuffix != null && count($newExcludeSuffix) > 0) {
                             break;
                         }
                     }
                     $currentArr = null;
                 }
             }
             if (!is_array($currentArr)) {
                 $found = false;
                 break;
             }
         }
         if ($found) {
             if ($newExcludeSuffix != null) {
                 $newExclude = substr($newExclude, 0, strrpos($newExclude, '/') + 1);
                 foreach ($newExcludeSuffix as $newExcludeSuff) {
                     $arr[] = $newExclude . $newExcludeSuff;
                 }
             } else {
                 $arr[] = $newExclude;
             }
         }
     }
 }
    public static function renderAllSites(&$website, $updated, $groups, $statusses, $pluginDir)
    {
        if (!mainwp_current_user_can('dashboard', 'edit_sites')) {
            mainwp_do_not_have_permissions(__('edit sites', 'mainwp'));
            return;
        }
        $remote_destinations = apply_filters('mainwp_backups_remote_get_destinations', null, array('website' => $website->id));
        $hasRemoteDestinations = $remote_destinations == null ? $remote_destinations : count($remote_destinations);
        ?>
        <div class="error below-h2" style="display: none;" id="ajax-error-zone"></div>
        <div id="ajax-information-zone" class="updated" style="display: none;"></div>
        <?php 
        if ($updated) {
            ?>
            <div id="mainwp_managesites_edit_message" class="updated"><p><?php 
            _e('Website updated.', 'mainwp');
            ?>
</p></div>
            <?php 
        }
        ?>
        <form method="POST" action="" id="mainwp-edit-single-site-form" enctype="multipart/form-data">
            <div class="postbox">
            <h3 class="mainwp_box_title"><i class="fa fa-cog"></i> <?php 
        _e('General Options', 'mainwp');
        ?>
</h3>
            <div class="inside">
            <table class="form-table">
                <tbody>
                <tr>
                    <th scope="row"><?php 
        _e('Site Name', 'mainwp');
        ?>
</th>
                    <td><input type="text" name="mainwp_managesites_edit_sitename"
                               value="<?php 
        echo stripslashes($website->name);
        ?>
" class="regular-text"/></td>
                </tr>
                <tr>
                    <th scope="row"><?php 
        _e('Site URL', 'mainwp');
        ?>
</th>
                    <td><select id="mainwp_managesites_edit_siteurl_protocol" name="mainwp_managesites_edit_siteurl_protocol"><option <?php 
        echo MainWP_Utility::startsWith($website->url, 'http:') ? 'selected' : '';
        ?>
 value="http">http://</option><option <?php 
        echo MainWP_Utility::startsWith($website->url, 'https:') ? 'selected' : '';
        ?>
 value="https">https://</option></select> <input type="text" id="mainwp_managesites_edit_siteurl" disabled="disabled"
                               value="<?php 
        echo MainWP_Utility::removeHttpPrefix($website->url, true);
        ?>
" class="regular-text" /> <span
                            class="mainwp-form_hint-display"><?php 
        _e('Site URL cannot be changed.', 'mainwp');
        ?>
</span></td>
                </tr>
                <tr>
                    <th scope="row"><?php 
        _e('Administrator Username', 'mainwp');
        ?>
</th>
                    <td><input type="text" name="mainwp_managesites_edit_siteadmin"
                               id="mainwp_managesites_edit_siteadmin"
                               value="<?php 
        echo $website->adminname;
        ?>
"
                               class="regular-text"/></td>
                </tr>
                <tr>
                    <th scope="row"><?php 
        _e('Groups', 'mainwp');
        ?>
</th>
                    <td>
                        <input type="text" name="mainwp_managesites_edit_addgroups"
                               id="mainwp_managesites_edit_addgroups" value=""
                               class="regular-text"/> <span
                            class="mainwp-form_hint"><?php 
        _e('Separate groups by commas (e.g. Group 1, Group 2).', 'mainwp');
        ?>
</span>

                        <div id="selected_groups" style="display: block; width: 25em">
                            <?php 
        if (count($groups) == 0) {
            echo 'No groups added yet.';
        }
        $groupsSite = MainWP_DB::Instance()->getGroupsByWebsiteId($website->id);
        foreach ($groups as $group) {
            echo '<div class="mainwp_selected_groups_item"><input type="checkbox" name="selected_groups[]" value="' . $group->id . '" ' . (isset($groupsSite[$group->id]) && $groupsSite[$group->id] ? 'checked' : '') . ' />&nbsp' . stripslashes($group->name) . '</div>';
        }
        ?>
                        </div>
                        <span class="description"><?php 
        _e('Or assign existing groups.', 'mainwp');
        ?>
</span>
                    </td>
                </tr>
                <tr>
                    <th scope="row"><?php 
        _e('Offline Checks', 'mainwp');
        ?>
</th>
                    <td>
                        <input type="radio" name="offline_checks" id="check_disabled" value="disabled"
                            <?php 
        echo !in_array($website->offline_checks, $statusses) ? 'checked="true"' : '';
        ?>
 /> <?php 
        _e('Disabled', 'mainwp');
        ?>
 &nbsp;&nbsp;&nbsp;
                        <input type="radio" name="offline_checks" id="check_hourly"
                               value="hourly" <?php 
        echo $website->offline_checks == 'hourly' ? 'checked="true"' : '';
        ?>
/> <?php 
        _e('Hourly', 'mainwp');
        ?>
 &nbsp;&nbsp;&nbsp;
                        <input type="radio" name="offline_checks" id="check_2xday"
                               value="2xday" <?php 
        echo $website->offline_checks == '2xday' ? 'checked="true"' : '';
        ?>
/> <?php 
        _e('2x Day', 'mainwp');
        ?>
 &nbsp;&nbsp;&nbsp;
                        <input type="radio" name="offline_checks" id="check_daily"
                               value="daily" <?php 
        echo $website->offline_checks == 'daily' ? 'checked="true"' : '';
        ?>
/> <?php 
        _e('Daily', 'mainwp');
        ?>
 &nbsp;&nbsp;&nbsp;
                        <input type="radio" name="offline_checks" id="check_weekly" value="weekly"
                            <?php 
        echo $website->offline_checks == 'weekly' ? 'checked="true"' : '';
        ?>
/>
                        Weekly  &nbsp;
                    <span class="mainwp-form_hint-display"><?php 
        _e('Notifications are sent to:', 'mainwp');
        ?>
 <?php 
        echo MainWP_Utility::getNotificationEmail();
        ?>
                        (<?php 
        _e('this address can be changed', 'mainwp');
        ?>
 <a
                                href="<?php 
        echo get_admin_url();
        ?>
admin.php?page=Settings"><?php 
        _e('here', 'mainwp');
        ?>
</a>)</span>
                    </td>
                </tr>
                <tr>
                    <th scope="row"><?php 
        _e('Client Plugin Folder Option', 'mainwp');
        ?>
 <?php 
        MainWP_Utility::renderToolTip('Default, files/folders on the child site are viewable.<br />Hidden, when attempting to view files a 404 file will be returned, however a footprint does still exist.<br /><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.</strong>');
        ?>
</th>
                    <td>
                        <div class="mainwp-radio" style="float: left;">
                          <input type="radio" value="" name="mainwp_options_footprint_plugin_folder" id="mainwp_options_footprint_plugin_folder_global" <?php 
        echo $pluginDir == '' ? 'checked="true"' : '';
        ?>
"/>
                          <label for="mainwp_options_footprint_plugin_folder_global"></label>
                        </div>Global Setting (<a href="<?php 
        echo admin_url('admin.php?page=Settings#network-footprint');
        ?>
">Change Here</a>)<br/>
                        <div class="mainwp-radio" style="float: left;">
                          <input type="radio" value="default" name="mainwp_options_footprint_plugin_folder" id="mainwp_options_footprint_plugin_folder_default" <?php 
        echo $pluginDir == 'default' ? 'checked="true"' : '';
        ?>
"/>
                          <label for="mainwp_options_footprint_plugin_folder_default"></label>
                        </div>Default<br/>
                        <div class="mainwp-radio" style="float: left;">
                          <input type="radio" value="hidden" name="mainwp_options_footprint_plugin_folder" id="mainwp_options_footprint_plugin_folder_hidden" <?php 
        echo $pluginDir == 'hidden' ? 'checked="true"' : '';
        ?>
/>
                          <label for="mainwp_options_footprint_plugin_folder_hidden"></label>
                        </div>Hidden (<strong>Note: </strong><i>If the heatmap is turned on, the heatmap javascript will still be visible.</i>) <br/>
                    </td>
                </tr>               
                <tr>
                    <th scope="row"><?php 
        _e('Require Backup Before Upgrade', 'mainwp');
        ?>
 <?php 
        MainWP_Utility::renderToolTip(__('Backup only works when enabled in the global settings as well.', 'mainwp'), admin_url('admin.php?page=Settings'));
        ?>
</th>
                    <td>
                         <select id="mainwp_backup_before_upgrade" name="mainwp_backup_before_upgrade">
                             <option <?php 
        echo $website->backup_before_upgrade == 1 ? 'selected' : '';
        ?>
 value="1"><?php 
        _e('Yes', 'mainwp');
        ?>
</option>
                             <option <?php 
        echo $website->backup_before_upgrade == 0 ? 'selected' : '';
        ?>
 value="0"><?php 
        _e('No', 'mainwp');
        ?>
</option>
                             <option <?php 
        echo $website->backup_before_upgrade == 2 ? 'selected' : '';
        ?>
 value="2"><?php 
        _e('Use Global Setting', 'mainwp');
        ?>
</option>
                         </select> <i>(<?php 
        _e('Default', 'mainwp');
        ?>
: <?php 
        _e('Use Global Setting', 'mainwp');
        ?>
)</i>
                         
                    </td>
                </tr>
                 <tr>
                    <th scope="row"><?php 
        _e('Auto Update Core', 'mainwp');
        ?>
 <?php 
        MainWP_Utility::renderToolTip('Auto update only works when enabled in the global settings as well.', admin_url('admin.php?page=Settings'));
        ?>
</th>
                    <td>
                        <div class="mainwp-checkbox">
                        <input type="checkbox" name="mainwp_automaticDailyUpdate"
                               id="mainwp_automaticDailyUpdate" <?php 
        echo $website->automatic_update == 1 ? 'checked="true"' : '';
        ?>
 />
                        <label for="mainwp_automaticDailyUpdate"></label>
                        </div>
                    </td>
                </tr>
                <?php 
        if (mainwp_current_user_can('dashboard', 'ignore_unignore_updates')) {
            ?>
                <tr>
                    <th scope="row"><?php 
            _e('Ignore Core Updates', 'mainwp');
            ?>
 <?php 
            MainWP_Utility::renderToolTip('Set to YES if you want to Ignore Core Updates.');
            ?>
</th>
                    <td>
                        <div class="mainwp-checkbox">
                        <input type="checkbox" name="mainwp_is_ignoreCoreUpdates"
                               id="mainwp_is_ignoreCoreUpdates" <?php 
            echo $website->is_ignoreCoreUpdates == 1 ? 'checked="true"' : '';
            ?>
 />
                        <label for="mainwp_is_ignoreCoreUpdates"></label>
                        </div>
                    </td>
                </tr>  
                <tr>
                    <th scope="row"><?php 
            _e('Ignore All Plugin Updates', 'mainwp');
            ?>
 <?php 
            MainWP_Utility::renderToolTip('Set to YES if you want to Ignore All Plugin Updates.');
            ?>
</th>
                    <td>
                        <div class="mainwp-checkbox">
                        <input type="checkbox" name="mainwp_is_ignorePluginUpdates"
                               id="mainwp_is_ignorePluginUpdates" <?php 
            echo $website->is_ignorePluginUpdates == 1 ? 'checked="true"' : '';
            ?>
 />
                        <label for="mainwp_is_ignorePluginUpdates"></label>
                        </div>
                    </td>
                </tr>  
                <tr>
                    <th scope="row"><?php 
            _e('Ignore All Theme Updates', 'mainwp');
            ?>
 <?php 
            MainWP_Utility::renderToolTip('Set to YES if you want to Ignore All Theme Updates.');
            ?>
</th>
                    <td>
                        <div class="mainwp-checkbox">
                        <input type="checkbox" name="mainwp_is_ignoreThemeUpdates"
                               id="mainwp_is_ignoreThemeUpdates" <?php 
            echo $website->is_ignoreThemeUpdates == 1 ? 'checked="true"' : '';
            ?>
 />
                        <label for="mainwp_is_ignoreThemeUpdates"></label>
                        </div>
                    </td>
                </tr>
                <?php 
        }
        ?>
                <?php 
        do_action('mainwp_extension_sites_edit_tablerow', $website);
        ?>
                </tbody>
            </table>
            </div>
            </div>
            <div class="clear"></div>
            <div class="postbox">
            <h3 class="mainwp_box_title"><span><i class="fa fa-cog"></i> <?php 
        _e('Advanced Options', 'mainwp');
        ?>
</span></h3>
            <div class="inside">
            <table class="form-table" style="width: 100%">
                <?php 
        $disabled_unique = empty($website->uniqueId) ? true : false;
        ?>
                <tr class="form-field form-required">
                    <th scope="row"><?php 
        _e('Child Unique Security ID ', 'mainwp');
        MainWP_Utility::renderToolTip('The Unique Security ID adds additional protection between the Child plugin and your Main Dashboard. The Unique Security ID will need to match when being added to the Main Dashboard. This is additional security and should not be needed in most situations.');
        ?>
</th>
                    <td><input type="text" id="mainwp_managesites_edit_uniqueId" style="width: 350px;" <?php 
        echo $disabled_unique ? 'disabled="disabled"' : '';
        ?>
                             name="mainwp_managesites_edit_uniqueId" value="<?php 
        echo $website->uniqueId;
        ?>
" class=""/><span class="mainwp-form_hint">The Unique Security ID adds additional protection between the Child plugin and your Main Dashboard. The Unique Security ID will need to match when being added to the Main Dashboard. This is additional security and should not be needed in most situations.</span></td>
                </tr>                
                 <tr class="form-field form-required">
                    <th scope="row"><?php 
        _e('Verify Certificate', 'mainwp');
        ?>
 <?php 
        MainWP_Utility::renderToolTip(__('Verify the childs SSL certificate. This should be disabled if you are using out of date or self signed certificates.', 'mainwp'));
        ?>
</th>
                    <td>
                        <select id="mainwp_managesites_edit_verifycertificate" name="mainwp_managesites_edit_verifycertificate">
                             <option <?php 
        echo $website->verify_certificate == 1 ? 'selected' : '';
        ?>
 value="1"><?php 
        _e('Yes', 'mainwp');
        ?>
</option>
                             <option <?php 
        echo $website->verify_certificate == 0 ? 'selected' : '';
        ?>
 value="0"><?php 
        _e('No', 'mainwp');
        ?>
</option>
                             <option <?php 
        echo $website->verify_certificate == 2 ? 'selected' : '';
        ?>
 value="2"><?php 
        _e('Use Global Setting', 'mainwp');
        ?>
</option>
                         </select> <i>(Default: Yes)</i>
                    </td>
                </tr>
                <tr class="form-field form-required">
                   <th scope="row"><?php 
        _e('SSL Version', 'mainwp');
        ?>
 <?php 
        MainWP_Utility::renderToolTip(__('Prefered SSL Version to connect to your site.', 'mainwp'));
        ?>
</th>
                    <td>
                        <select id="mainwp_managesites_edit_ssl_version" name="mainwp_managesites_edit_ssl_version">
                             <option <?php 
        echo $website->ssl_version == 'auto' ? 'selected' : '';
        ?>
 value="auto"><?php 
        _e('Auto detect', 'mainwp');
        ?>
</option>
                             <option <?php 
        echo $website->ssl_version == '1.x' ? 'selected' : '';
        ?>
 value="1.x"><?php 
        _e('TLS v1.x', 'mainwp');
        ?>
</option>
                             <option <?php 
        echo $website->ssl_version == '2' ? 'selected' : '';
        ?>
 value="2"><?php 
        _e('SSL v2', 'mainwp');
        ?>
</option>
                             <option <?php 
        echo $website->ssl_version == '3' ? 'selected' : '';
        ?>
 value="3"><?php 
        _e('SSL v3', 'mainwp');
        ?>
</option>
                             <option <?php 
        echo $website->ssl_version == '1.0' ? 'selected' : '';
        ?>
 value="1.0"><?php 
        _e('TLS v1.0', 'mainwp');
        ?>
</option>
                             <option <?php 
        echo $website->ssl_version == '1.1' ? 'selected' : '';
        ?>
 value="1.1"><?php 
        _e('TLS v1.1', 'mainwp');
        ?>
</option>
                             <option <?php 
        echo $website->ssl_version == '1.2' ? 'selected' : '';
        ?>
 value="1.2"><?php 
        _e('TLS v1.2', 'mainwp');
        ?>
</option>
                         </select> <em>(<?php 
        _e('Default: Auto detect', 'mainwp');
        ?>
)</em>
                    </td>
                </tr>

                <!-- fake fields are a workaround for chrome autofill getting the wrong fields -->
                <input style="display:none" type="text" name="fakeusernameremembered"/>
                <input style="display:none" type="password" name="fakepasswordremembered"/>

                <tr>
                    <td colspan="2"><div class="mainwp_info-box"><?php 
        _e('If your Child Site is protected with HTTP basic authentication, please set the username and password for authentication here.', 'mainwp');
        ?>
</div></td>
                </tr>

                <tr class="form-field form-required">
                     <th scope="row"><?php 
        _e('HTTP username ', 'mainwp');
        ?>
</th>
                     <td><input type="text" id="mainwp_managesites_edit_http_user" style="width: 350px;" name="mainwp_managesites_edit_http_user" value="<?php 
        echo empty($website->http_user) ? '' : $website->http_user;
        ?>
" class=""/></td>
                </tr>
                <tr class="form-field form-required">
                     <th scope="row"><?php 
        _e('HTTP password ', 'mainwp');
        ?>
</th>
                     <td><input type="password" id="mainwp_managesites_edit_http_pass" style="width: 350px;" name="mainwp_managesites_edit_http_pass" value="<?php 
        echo empty($website->http_pass) ? '' : $website->http_pass;
        ?>
" class=""/></td>
                </tr>
            </table>
            </div>
            </div>
            
            <div class="clear"></div>
            <div class="postbox">
            <h3 class="mainwp_box_title"><span><i class="fa fa-cog"></i> <?php 
        _e('Backup Settings', 'mainwp');
        ?>
</span></h3>
            <div class="inside">
            <table class="form-table" style="width: 100%">
                <?php 
        $globalArchiveFormat = get_option('mainwp_archiveFormat');
        if ($globalArchiveFormat == false) {
            $globalArchiveFormat = 'tar.gz';
        }
        if ($globalArchiveFormat == 'zip') {
            $globalArchiveFormatText = 'Zip';
        } else {
            if ($globalArchiveFormat == 'tar') {
                $globalArchiveFormatText = 'Tar';
            } else {
                if ($globalArchiveFormat == 'tar.gz') {
                    $globalArchiveFormatText = 'Tar GZip';
                } else {
                    if ($globalArchiveFormat == 'tar.bz2') {
                        $globalArchiveFormatText = 'Tar BZip2';
                    }
                }
            }
        }
        $backupSettings = MainWP_DB::Instance()->getWebsiteBackupSettings($website->id);
        $archiveFormat = $backupSettings->archiveFormat;
        $useGlobal = $archiveFormat == 'global';
        ?>
                <tr>
                    <th scope="row"><?php 
        _e('Archive Format', 'mainwp');
        ?>
 <?php 
        MainWP_Utility::renderToolTip(__('', 'mainwp'));
        ?>
</th>
                    <td>
                        <table class="mainwp-nomarkup">
                            <tr>
                                <td valign="top">
                                    <span class="mainwp-select-bg"><select name="mainwp_archiveFormat" id="mainwp_archiveFormat">
                                        <option value="global" <?php 
        if ($useGlobal) {
            ?>
selected<?php 
        }
        ?>
>Global setting (<?php 
        echo $globalArchiveFormatText;
        ?>
)</option>
                                        <option value="zip" <?php 
        if ($archiveFormat == 'zip') {
            ?>
selected<?php 
        }
        ?>
>Zip</option>
                                        <option value="tar" <?php 
        if ($archiveFormat == 'tar') {
            ?>
selected<?php 
        }
        ?>
>Tar</option>
                                        <option value="tar.gz" <?php 
        if ($archiveFormat == 'tar.gz') {
            ?>
selected<?php 
        }
        ?>
>Tar GZip</option>
                                        <option value="tar.bz2" <?php 
        if ($archiveFormat == 'tar.bz2') {
            ?>
selected<?php 
        }
        ?>
>Tar BZip2</option>
                                    </select><label></label></span>
                                </td>
                                <td>
                                    <i>
                                    <span id="info_global" class="archive_info" <?php 
        if (!$useGlobal) {
            ?>
style="display: none;"<?php 
        }
        ?>
><?php 
        if ($globalArchiveFormat == 'zip') {
            ?>
Uses PHP native Zip-library, when missing, the PCLZip library included in Wordpress will be used. (Good compression, fast with native zip-library)<?php 
        } elseif ($globalArchiveFormat == 'tar') {
            ?>
Uses PHP native Zip-library, when missing, the PCLZip library included in Wordpress will be used. (Good compression, fast with native zip-library)<?php 
        } elseif ($globalArchiveFormat == 'tar.gz') {
            ?>
Creates a GZipped tar-archive. (Good compression, fast, low memory usage)<?php 
        } elseif ($globalArchiveFormat == 'tar.bz2') {
            ?>
Creates a BZipped tar-archive. (Best compression, fast, low memory usage)<?php 
        }
        ?>
</span>
                                    <span id="info_zip" class="archive_info" <?php 
        if ($archiveFormat != 'zip') {
            ?>
style="display: none;"<?php 
        }
        ?>
>Uses PHP native Zip-library, when missing, the PCLZip library included in Wordpress will be used. (Good compression, fast with native zip-library)</span>
                                    <span id="info_tar" class="archive_info" <?php 
        if ($archiveFormat != 'tar') {
            ?>
style="display: none;"<?php 
        }
        ?>
>Creates an uncompressed tar-archive. (No compression, fast, low memory usage)</span>
                                    <span id="info_tar.gz" class="archive_info" <?php 
        if ($archiveFormat != 'tar.gz') {
            ?>
style="display: none;"<?php 
        }
        ?>
>Creates a GZipped tar-archive. (Good compression, fast, low memory usage)</span>
                                    <span id="info_tar.bz2" class="archive_info" <?php 
        if ($archiveFormat != 'tar.bz2') {
            ?>
style="display: none;"<?php 
        }
        ?>
>Creates a BZipped tar-archive. (Best compression, fast, low memory usage)</span>
                                    </i>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>

                <?php 
        $maximumFileDescriptorsOverride = $website->maximumFileDescriptorsOverride == 1;
        $maximumFileDescriptorsAuto = $website->maximumFileDescriptorsAuto == 1;
        $maximumFileDescriptors = $website->maximumFileDescriptors;
        ?>
                <tr class="archive_method archive_zip" <?php 
        if ($archiveFormat != 'zip') {
            ?>
style="display: none;"<?php 
        }
        ?>
>
                    <th scope="row"><?php 
        _e('Maximum File Descriptors on Child', 'mainwp');
        ?>
 <?php 
        MainWP_Utility::renderToolTip('The maximum number of open file descriptors on the child hosting.', 'http://docs.mainwp.com/maximum-number-of-file-descriptors/');
        ?>
</th>
                    <td>
                        <div class="mainwp-radio" style="float: left;">
                          <input type="radio" value="" name="mainwp_options_maximumFileDescriptorsOverride" id="mainwp_options_maximumFileDescriptorsOverride_global" <?php 
        echo !$maximumFileDescriptorsOverride ? 'checked="true"' : '';
        ?>
"/>
                          <label for="mainwp_options_maximumFileDescriptorsOverride_global"></label>
                        </div>Global Setting (<a href="<?php 
        echo admin_url('admin.php?page=Settings');
        ?>
">Change Here</a>)<br/>
                        <div class="mainwp-radio" style="float: left;">
                          <input type="radio" value="override" name="mainwp_options_maximumFileDescriptorsOverride" id="mainwp_options_maximumFileDescriptorsOverride_override" <?php 
        echo $maximumFileDescriptorsOverride ? 'checked="true"' : '';
        ?>
"/>
                          <label for="mainwp_options_maximumFileDescriptorsOverride_override"></label>
                        </div>Override<br/><br />

                        <div style="float: left">Auto Detect:&nbsp;</div><div class="mainwp-checkbox"><input type="checkbox" id="mainwp_maximumFileDescriptorsAuto" name="mainwp_maximumFileDescriptorsAuto" <?php 
        echo $maximumFileDescriptorsAuto ? 'checked="checked"' : '';
        ?>
 /> <label for="mainwp_maximumFileDescriptorsAuto"></label></div><div style="float: left"><i>(<?php 
        _e('Enter a fallback value because not all hosts support this function.', 'mainwp');
        ?>
)</i></div><div style="clear:both"></div>
                        <input type="text" name="mainwp_options_maximumFileDescriptors" id="mainwp_options_maximumFileDescriptors"
                               value="<?php 
        echo $maximumFileDescriptors;
        ?>
"/><span class="mainwp-form_hint"><?php 
        _e('The maximum number of open file descriptors on the child hosting.  0 sets unlimited.', 'mainwp');
        ?>
</span>
                    </td>
                </tr>
                <tr class="archive_method archive_zip" <?php 
        if ($archiveFormat != 'zip') {
            ?>
style="display: none;"<?php 
        }
        ?>
>
                    <th scope="row"><?php 
        _e('Load Files in Memory Before Zipping', 'mainwp');
        ?>
 <?php 
        MainWP_Utility::renderToolTip('This causes the files to be opened and closed immediately, using less simultaneous I/O operations on the disk. For huge sites with a lot of files we advise to disable this, memory usage will drop but we will use more file handlers when backing up.', 'http://docs.mainwp.com/load-files-memory/');
        ?>
</th>
                    <td>
                        <input type="radio" name="mainwp_options_loadFilesBeforeZip" id="mainwp_options_loadFilesBeforeZip_global" value="1" <?php 
        if ($website->loadFilesBeforeZip == false || $website->loadFilesBeforeZip == 1) {
            ?>
checked="true"<?php 
        }
        ?>
/> Global setting (<a href="<?php 
        echo admin_url('admin.php?page=Settings');
        ?>
">Change Here</a>)<br />
                        <input type="radio" name="mainwp_options_loadFilesBeforeZip" id="mainwp_options_loadFilesBeforeZip_yes" value="2" <?php 
        if ($website->loadFilesBeforeZip == 2) {
            ?>
checked="true"<?php 
        }
        ?>
/> Yes<br />
                        <input type="radio" name="mainwp_options_loadFilesBeforeZip" id="mainwp_options_loadFilesBeforeZip_no" value="0" <?php 
        if ($website->loadFilesBeforeZip == 0) {
            ?>
checked="true"<?php 
        }
        ?>
/> No<br />
                    </td>
                </tr>
                <?php 
        if ($hasRemoteDestinations !== null) {
            do_action('mainwp_backups_remote_settings', array('website' => $website->id, 'hide' => 'no'));
        }
        ?>
            </table>
            </div>
            </div>
            
            <?php 
        $plugin_upgrades = json_decode($website->plugin_upgrades, true);
        if (!is_array($plugin_upgrades)) {
            $plugin_upgrades = array();
        }
        $userExtension = MainWP_DB::Instance()->getUserExtension();
        $globalIgnoredPluginConflicts = json_decode($userExtension->ignored_pluginConflicts, true);
        ?>
            <?php 
        do_action('mainwp-extension-sites-edit', $website);
        ?>
<p class="submit"><input type="submit" name="submit" id="submit" class="button-primary button button-hero"
                                     value="<?php 
        _e('Update Site', 'mainwp');
        ?>
"/></p>
        </form>       
        <?php 
    }
    public static function renderBulkUpload()
    {
        ?>
            <div id="MainWPBulkUploadSitesLoading" class="updated" style="display: none;">
                <div><i class="fa fa-spinner fa-pulse"></i> <?php 
        _e('Importing sites', 'mainwp');
        ?>
</div>
            </div>
            <?php 
        $errors = array();
        if ($_FILES['mainwp_managesites_file_bulkupload']['error'] == UPLOAD_ERR_OK) {
            if (is_uploaded_file($_FILES['mainwp_managesites_file_bulkupload']['tmp_name'])) {
                $content = file_get_contents($_FILES['mainwp_managesites_file_bulkupload']['tmp_name']);
                $lines = explode("\r", $content);
                $allowedHeaders = array('site name', 'url', 'admin name', 'group', 'security id', 'http username', 'http password', 'verify certificate', 'ssl version');
                $default = array('', '', '', '', '', '', '', '1', 'auto');
                if (is_array($lines) && count($lines) > 0) {
                    $i = 0;
                    $header_line = null;
                    $header_line_split = null;
                    foreach ($lines as $originalLine) {
                        $line = trim($originalLine);
                        if (MainWP_Utility::startsWith($line, '#')) {
                            continue;
                        }
                        if ($header_line == null && $_POST['mainwp_managesites_chk_header_first']) {
                            $header_line = $line . "\n";
                            $header_line_split_tmp = explode(',', $header_line);
                            $header_line_split = array();
                            for ($x = 0; $x < count($header_line_split_tmp); $x++) {
                                $header_line_split[$x] = strtolower(trim(trim($header_line_split_tmp[$x]), '"'));
                            }
                            continue;
                        }
                        $items = explode(',', $line);
                        $line = '';
                        for ($x = 0; $x < count($allowedHeaders); $x++) {
                            if ($line != '') {
                                $line .= ',';
                            }
                            $idx = $x;
                            if (!empty($header_line_split)) {
                                $idx = array_search($allowedHeaders[$x], $header_line_split);
                            }
                            $val = null;
                            if ($idx > -1) {
                                $val = trim(trim($items[$idx]), '"');
                                if ($allowedHeaders[$x] == 'verify certificate') {
                                    if ($val == 'T') {
                                        $val = '1';
                                    } else {
                                        $val = '0';
                                    }
                                }
                            }
                            if (empty($val)) {
                                $val = $default[$x];
                            }
                            $line .= $val;
                        }
                        ?>
                            <input type="hidden"
                                   id="mainwp_managesites_import_csv_line_<?php 
                        echo $i + 1;
                        ?>
"
                                   value="<?php 
                        echo esc_attr($line);
                        ?>
"
                                   original="<?php 
                        echo esc_attr($originalLine);
                        ?>
" />
                            <?php 
                        $i++;
                    }
                    ?>
                        <div class="postbox">
                        <h3 class="mainwp_box_title"><i class="fa fa-globe"></i> <?php 
                    _e('Importing New Child Sites', 'mainwp');
                    ?>
</h3>
                        <div class="inside">
                        <input type="hidden" id="mainwp_managesites_do_import" value="1"/>
                        <input type="hidden" id="mainwp_managesites_total_import" value="<?php 
                    echo $i;
                    ?>
"/>

                        <p>
                        <div class="mainwp_managesites_import_listing" id="mainwp_managesites_import_logging">
                            <pre class="log"><?php 
                    echo esc_attr($header_line);
                    ?>
</pre>
                        </div></p>

                        <p class="submit"><input type="button" name="mainwp_managesites_btn_import"
                                                 id="mainwp_managesites_btn_import"
                                                 class="button-primary button button-hero" value="<?php 
                    _e('Pause', 'mainwp');
                    ?>
"/>
                            <input type="button" name="mainwp_managesites_btn_save_csv"
                                   id="mainwp_managesites_btn_save_csv" disabled="disabled"
                                   class="button-hero button" value="<?php 
                    _e('Save Failed', 'mainwp');
                    ?>
"/>
                        </p>

                        <p>
                        <div class="mainwp_managesites_import_listing"
                             id="mainwp_managesites_import_fail_logging" style="display: none;">
                            <pre class="log"><?php 
                    echo esc_attr($header_line);
                    ?>
</pre>
                        </div></p>
                        </div>
                        </div>
                        <?php 
                } else {
                    $errors[] = 'Error: Data is not valid. <br />';
                }
            } else {
                $errors[] = 'Error: Upload error. <br />';
            }
        } else {
            $errors[] = 'Error: Upload error. <br />';
        }
        if (count($errors) > 0) {
            ?>
                <div class="error below-h2">
                    <?php 
            foreach ($errors as $error) {
                ?>
                    <p><strong>ERROR</strong>: <?php 
                echo $error;
                ?>
</p>
                    <?php 
            }
            ?>
                </div>
                <br/>
                <a href="<?php 
            echo get_admin_url();
            ?>
admin.php?page=managesites" class="add-new-h2" target="_top"><?php 
            _e('Add
                    New', 'mainwp');
            ?>
</a>
                <a href="<?php 
            echo get_admin_url();
            ?>
admin.php?page=mainwp_tab" class="add-new-h2" target="_top"><?php 
            _e('Return
                    to Dashboard', 'mainwp');
            ?>
</a>
                <?php 
        }
    }