public static function renderBackupSite(&$website)
    {
        if (!mainwp_current_user_can("dashboard", "execute_backups")) {
            mainwp_do_not_have_permissions("execute backups");
            return;
        }
        $primaryBackupMethods = apply_filters("mainwp-getprimarybackup-methods", array());
        if (!is_array($primaryBackupMethods)) {
            $primaryBackupMethods = array();
        }
        $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 (count($primaryBackupMethods) == 0) {
            ?>
            <tr>
                <div class="mainwp_info-box"><?php 
            _e('Did you know that MainWP has Extensions for working with popular backup plugins? Visit the <a href="https://extensions.mainwp.com/product-category/mainwp-extensions/backups/" target="_blank" ?>Extensions Site</a> for options.', 'mainwp');
            ?>
</div>
            </tr>
        <?php 
        }
        ?>

        	<div class="postbox" id="mainwp-backup-details">
                <h3 class="mainwp_box_title"><span><i class="fa fa-hdd-o"></i> <?php 
        _e('Backup Details', 'mainwp');
        ?>
</span></h3>
                <div class="inside">
                <?php 
        if (!MainWPUtility::can_edit_website($website)) {
            die('This is not your website.');
        }
        MainWPManageSites::showBackups($website);
        ?>
                </div>
            </div>
            <div class="postbox" id="mainwp-backup-optins-site">
            <h3 class="mainwp_box_title"><span><i class="fa fa-hdd-o"></i> <?php 
        _e('Backup Options', 'mainwp');
        ?>
</span></h3>
            <div class="inside">
            <form method="POST" action="" id="mainwp_backup_sites_page">
            <table class="form-table">
                <tbody>
                <tr>
                    <th scope="row"><?php 
        _e('Backup File Name:', 'mainwp');
        ?>
</th>
                    <td><input type="text" name="backup_filename" id="backup_filename" value="" class="mainwp-field mainwp-file-name" /><span class="mainwp-form_hint" style="display: inline; max-width: 500px;"><?php 
        _e('Allowed Structure Tags:', 'mainwp');
        ?>
 <strong>%sitename%</strong>, <strong>%url%</strong>, <strong>%date%</strong>, <strong>%time%</strong>, <strong>%type%</strong></span>
                    </td>
                </tr>
                <tr><td colspan="2"><hr /></td></tr>
                <tr>
                    <th scope="row"><?php 
        _e('Backup Type:', 'mainwp');
        ?>
</th>
                    <td>
                        <a class="mainwp_action left mainwp_action_down" href="#" id="backup_type_full"><?php 
        _e('FULL BACKUP', 'mainwp');
        ?>
</a><a class="mainwp_action right" href="#" id="backup_type_db"><?php 
        _e('DATABASE BACKUP', 'mainwp');
        ?>
</a>
                    </td>
                </tr>
                <tr class="mainwp_backup_exclude_files_content"><td colspan="2"><hr /></td></tr>
                <tr class="mainwp-exclude-suggested">
                    <th scope="row" style="vertical-align: top"><?php 
        _e('Suggested Exclude', 'mainwp');
        ?>
:</th>
                    <td><p style="background: #7fb100; color: #ffffff; padding: .5em;"><?php 
        _e('Every WordPress website is different but the sections below generally do not need to be backed up and since many of them are large in size they can even cause issues with your backup including server timeouts.', 'mainwp');
        ?>
</p></td>
                </tr>
                <tr class="mainwp-exclude-backup-locations">
                    <td colspan="2"><h4><i class="fa fa-cloud-upload"></i> <?php 
        _e('Known Backup Locations', 'mainwp');
        ?>
</h4></td>
                </tr>
                <tr class="mainwp-exclude-backup-locations">
                    <td><label for="mainwp-known-backup-locations"><?php 
        _e('Exclude', 'mainwp');
        ?>
</label><input type="checkbox" id="mainwp-known-backup-locations" checked></td>
                    <td class="mainwp-td-des"><a href="#" id="mainwp-show-kbl-folders"><?php 
        _e('+ Show Excluded Folders', 'mainwp');
        ?>
</a><a href="#" id="mainwp-hide-kbl-folders"><?php 
        _e('- Hide Excluded Folders', 'mainwp');
        ?>
</a><br/>
                        <textarea id="mainwp-kbl-content" disabled></textarea>
                        <br/><?php 
        _e('This adds known backup locations of popular WordPress backup plugins to the exclude list.  Old backups can take up a lot of space and can cause your current MainWP backup to timeout.', 'mainwp');
        ?>
</td>
                </tr>
                <tr class="mainwp-exclude-separator"><td colspan="2" style="padding: 0 !important;"><hr /></td></tr>
                <tr class="mainwp-exclude-cache-locations">
                    <td colspan="2"><h4><i class="fa fa-cubes"></i> <?php 
        _e('Known Cache Locations', 'mainwp');
        ?>
</h4></td>
                </tr>
                <tr class="mainwp-exclude-cache-locations">
                    <td><label for="mainwp-known-cache-locations"><?php 
        _e('Exclude', 'mainwp');
        ?>
</label><input type="checkbox" id="mainwp-known-cache-locations" checked></td>
                    <td class="mainwp-td-des"><a href="#" id="mainwp-show-kcl-folders"><?php 
        _e('+ Show Excluded Folders', 'mainwp');
        ?>
</a><a href="#" id="mainwp-hide-kcl-folders"><?php 
        _e('- Hide Excluded Folders', 'mainwp');
        ?>
</a><br/>
                        <textarea id="mainwp-kcl-content" disabled></textarea>
                        <br/><?php 
        _e('This adds known cache locations of popular WordPress cache plugins to the exclude list.  A cache can be massive with thousands of files and can cause your current MainWP backup to timeout.  Your cache will be rebuilt by your caching plugin when the backup is restored.', 'mainwp');
        ?>
</td>
                </tr>
                <tr class="mainwp-exclude-separator"><td colspan="2" style="padding: 0 !important;"><hr /></td></tr>
                <tr class="mainwp-exclude-nonwp-folders">
                    <td colspan="2"><h4><i class="fa fa-folder"></i> <?php 
        _e('Non-WordPress Folders', 'mainwp');
        ?>
</h4></td>
                </tr>
                <tr class="mainwp-exclude-nonwp-folders">
                    <td><label for="mainwp-non-wordpress-folders"><?php 
        _e('Exclude', 'mainwp');
        ?>
</label><input type="checkbox" id="mainwp-non-wordpress-folders" checked></td>
                    <td class="mainwp-td-des"><a href="#" id="mainwp-show-nwl-folders"><?php 
        _e('+ Show Excluded Folders', 'mainwp');
        ?>
</a><a href="#" id="mainwp-hide-nwl-folders"><?php 
        _e('- Hide Excluded Folders', 'mainwp');
        ?>
</a><br/>
                        <textarea id="mainwp-nwl-content" disabled></textarea>
                        <br/><?php 
        _e('This adds folders that are not part of the WordPress core (wp-admin, wp-content and wp-include) to the exclude list. Non-WordPress folders can contain a large amount of data or may be a sub-domain or add-on domain that should be backed up individually and not with this backup.', 'mainwp');
        ?>
</td>
                </tr>
                <tr class="mainwp-exclude-separator"><td colspan="2" style="padding: 0 !important;"><hr /></td></tr>
                <tr class="mainwp-exclude-zips">
                    <td colspan="2"><h4><i class="fa fa-file-archive-o"></i> <?php 
        _e('ZIP Archives', 'mainwp');
        ?>
</h4></td>
                </tr>
                <tr class="mainwp-exclude-zips">
                    <td><label for="mainwp-zip-archives"><?php 
        _e('Exclude', 'mainwp');
        ?>
</label><input type="checkbox" id="mainwp-zip-archives" checked></td>
                    <td class="mainwp-td-des"><?php 
        _e('Zip files can be large and are often not needed for a WordPress backup. Be sure to deselect this option if you do have zip files you need backed up.', 'mainwp');
        ?>
</td>
                </tr>
                <tr class="mainwp-exclude-separator"><td colspan="2" style="padding: 0 !important;"><hr /></td></tr>
                <tr class="mainwp_backup_exclude_files_content">
                    <th scope="row" style="vertical-align: top"><h4 class="mainwp-custom-excludes"><i class="fa fa-minus-circle"></i> <?php 
        _e('Custom Excludes', 'mainwp');
        ?>
</h4></th>
                    <td>
                        <p style="background: #7fb100; color: #ffffff; padding: .5em;"><?php 
        _e('Exclude any additional files that you do not need backed up for this site. Click a folder name to drill down into the directory.', 'mainwp');
        ?>
</p>
                        <br />
                        <?php 
        printf(__('Click directories to navigate. Click the red sign ( <img style="margin-bottom: -3px;" src="%s"> ) to exclude a folder.', 'mainwp'), plugins_url('images/exclude.png', dirname(__FILE__)));
        ?>
<br /><br />
                        <table class="mainwp_excluded_folders_cont">
                            <tr>
                                <td style="width: 280px;">
                                    <div id="backup_exclude_folders"
                                         siteid="<?php 
        echo $website->id;
        ?>
"
                                         class="mainwp_excluded_folders"></div>
                                </td>
                                <td>
                                    <?php 
        _e('Excluded files & directories:', 'mainwp');
        ?>
<br/>
                                    <textarea id="excluded_folders_list"></textarea>
                                </td>
                            </tr>
                        </table>
                        <span class="description"><strong><?php 
        _e('ATTENTION:', 'mainwp');
        ?>
</strong> <?php 
        _e('Do not exclude any folders if you are using this backup to clone or migrate the wordpress installation.', 'mainwp');
        ?>
</span>
                    </td>
                </tr>
                <?php 
        if ($hasRemoteDestinations !== null) {
            ?>
                <tr><td colspan="2"><hr /></td></tr>
                <tr>
                    <th scope="row"><?php 
            _e('Store Backup In:', 'mainwp');
            ?>
</th>
                    <td>
                        <a class="mainwp_action left <?php 
            echo !$hasRemoteDestinations ? 'mainwp_action_down' : '';
            ?>
" href="#" id="backup_location_local"><?php 
            _e('LOCAL SERVER ONLY', 'mainwp');
            ?>
</a><a class="mainwp_action right <?php 
            echo $hasRemoteDestinations ? 'mainwp_action_down' : '';
            ?>
" href="#" id="backup_location_remote"><?php 
            _e('REMOTE DESTINATION', 'mainwp');
            ?>
</a>
                    </td>
                </tr>
                <tr class="mainwp_backup_destinations" <?php 
            echo !$hasRemoteDestinations ? 'style="display: none;"' : '';
            ?>
>
                    <th scope="row"><?php 
            _e('Backup Subfolder:', 'mainwp');
            ?>
</th>
                    <td><input type="text" id="backup_subfolder" name="backup_subfolder"
                                                           value="MainWP Backups/%url%/%type%/%date%"/><span class="mainwp-form_hint" style="display: inline; max-width: 500px;">Allowed Structure Tags: <strong>%sitename%</strong>, <strong>%url%</strong>, <strong>%date%</strong>, <strong>%task%</strong>, <strong>%type%</strong></span></td>
                </tr>
                <?php 
        }
        ?>
                    <?php 
        do_action('mainwp_backups_remote_settings', array('website' => $website->id));
        ?>

                <?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 = MainWPDB::Instance()->getWebsiteBackupSettings($website->id);
        $archiveFormat = $backupSettings->archiveFormat;
        $useGlobal = $archiveFormat == 'global';
        ?>
                <tr><td colspan="2"><hr /></td></tr>
                <tr>
                    <th scope="row"><?php 
        _e('Archive Format', '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 
        MainWPUtility::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><?php 
        _e('Override', 'mainwp');
        ?>
<br/><br />

                        <div style="float: left"><?php 
        _e('Auto detect:', 'mainwp');
        ?>
&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 
        MainWPUtility::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>
            </table>

                <input type="hidden" name="site_id" id="backup_site_id" value="<?php 
        echo $website->id;
        ?>
"/>
                <input type="hidden" name="backup_site_full_size" id="backup_site_full_size" value="<?php 
        echo $website->totalsize;
        ?>
"/>
                <input type="hidden" name="backup_site_db_size" id="backup_site_db_size" value="<?php 
        echo $website->dbsize;
        ?>
"/>

                <p class="submit"><input type="button" name="backup_btnSubmit" id="backup_btnSubmit"
                                         class="button-primary"
                                         value="Backup Now"/></p>

            </form>
            </div>
        </div>

    <div id="managesite-backup-status-box" title="Backup <?php 
        echo stripslashes($website->name);
        ?>
" style="display: none; text-align: center">
        <div style="height: 190px; overflow: auto; margin-top: 20px; margin-bottom: 10px; text-align: left" id="managesite-backup-status-text">
        </div>
        <input id="managesite-backup-status-close" type="button" name="Close" value="Cancel" class="button" />
    </div>
    <?php 
    }
    public static function renderMetabox()
    {
        $website = MainWPUtility::get_current_wpid();
        if (!$website) {
            return;
        }
        $website = MainWPDB::Instance()->getWebsiteById($website);
        MainWPManageSites::showBackups($website);
        ?>
        <?php 
        if (mainwp_current_user_can("dashboard", "execute_backups")) {
            ?>
        <hr />
        <div style="text-align: center;"><a href="<?php 
            echo admin_url('admin.php?page=managesites&backupid=' . $website->id);
            ?>
" class="button-primary"><?php 
            _e('Backup Now', 'mainwp');
            ?>
</a></div>
        <?php 
        }
        ?>
        <?php 
    }