Пример #1
0
 public function __construct()
 {
     $this->host = @$_SERVER['HTTP_HOST'];
     $this->uri = @$_SERVER['REQUEST_URI'];
     $this->scheme = @$_SERVER['REQUEST_SCHEME'];
     $this->port = @$_SERVER['SERVER_PORT'];
     if (!$this->scheme) {
         if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != '') {
             $this->scheme = 'https';
         } else {
             $this->scheme = 'http';
         }
     }
     if (!$this->port) {
         $this->port = 80;
     }
     $this->reloadMethod = SGConfig::get('SG_RELOAD_METHOD');
     if ($this->reloadMethod === null) {
         $this->setBestReloadMethod();
     }
 }
Пример #2
0
 private function resetRestoreProgress($restorePath)
 {
     $this->currentBackupFileCount = 0;
     $this->progressUpdateInterval = SGConfig::get('SG_ACTION_PROGRESS_UPDATE_INTERVAL');
     $this->nextProgressUpdate = $this->progressUpdateInterval;
 }
Пример #3
0
<?php

require_once dirname(__FILE__) . '/../boot.php';
$backupDirectory = SGConfig::get('SG_BACKUP_DIRECTORY');
$maxUploadSize = ini_get('upload_max_filesize');
?>
<div class="modal-dialog">
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
            <h4 class="modal-title"><?php 
_t('Import');
?>
</h4>
        </div>
        <div class="modal-body sg-modal-body">
            <div class="col-md-12">
                <div class="form-group">
                    <label class="col-md-2 control-label sg-upload-label" for="textinput"><?php 
_t('SGBP file');
?>
</label>
                    <div class="col-md-10">
                        <div class="input-group">
                            <span class="input-group-btn">
                                <span class="btn btn-primary btn-file">
                                    <?php 
_t('Browse');
?>
&hellip; <input type="file" class="sg-backup-upload-input" name="sgbpFile" accept=".sgbp" data-max-file-size="<?php 
echo convertToBytes($maxUploadSize . 'B');
Пример #4
0
 private function getTables()
 {
     $tableNames = array();
     $tables = $this->sgdb->query('SHOW TABLES FROM ' . SG_DB_NAME);
     if (!$tables) {
         throw new SGExceptionDatabaseError('Could not get tables of database: ' . SG_DB_NAME);
     }
     foreach ($tables as $table) {
         $tableName = $table['Tables_in_' . SG_DB_NAME];
         $tablesToExclude = explode(',', SGConfig::get('SG_BACKUP_DATABASE_EXCLUDE'));
         if (in_array($tableName, $tablesToExclude)) {
             continue;
         }
         $tableNames[] = $tableName;
     }
     return $tableNames;
 }
Пример #5
0
 private function didFinishBackup()
 {
     if (SGConfig::get('SG_REVIEW_POPUP_STATE') != SG_NEVER_SHOW_REVIEW_POPUP) {
         SGConfig::set('SG_REVIEW_POPUP_STATE', SG_SHOW_REVIEW_POPUP);
     }
     $action = $this->didFindWarnings() ? SG_ACTION_STATUS_FINISHED_WARNINGS : SG_ACTION_STATUS_FINISHED;
     self::changeActionStatus($this->actionId, $action);
     SGBackupLog::writeAction('backup', SG_BACKUP_LOG_POS_END);
     if (SGBoot::isFeatureAvailable('NOTIFICATIONS')) {
         SGBackupMailNotification::sendBackupNotification(true);
     }
     SGBackupLog::write('Total duration: ' . formattedDuration($this->actionStartTs, time()));
     $this->cleanUp();
 }
Пример #6
0
<?php

require_once dirname(__FILE__) . '/../boot.php';
$directories = SGConfig::get('SG_BACKUP_FILE_PATHS');
$directories = explode(',', $directories);
$dropbox = SGConfig::get('SG_DROPBOX_ACCESS_TOKEN');
$gdrive = SGConfig::get('SG_GOOGLE_DRIVE_REFRESH_TOKEN');
$ftp = SGConfig::get('SG_STORAGE_FTP_CONNECTED');
?>
<div class="modal-dialog">
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
            <h4 class="modal-title"><?php 
_t('Manual Backup');
?>
</h4>
        </div>
        <form class="form-horizontal" method="post" id="manualBackup">
            <div class="modal-body sg-modal-body">
                <!-- Multiple Radios -->
                <div class="form-group">
                    <div class="col-md-12">
                        <div class="radio">
                            <label for="fullbackup-radio">
                                <input type="radio" name="backupType" id="fullbackup-radio" value="1" checked="checked">
                                <?php 
_t('Full backup');
?>
                            </label>
                        </div>
Пример #7
0
function getReport()
{
    $jsonArray = array();
    $headerArray = array();
    $jsonArray['ptype'] = '1';
    $jsonArray['token'] = '28016ffb35b451291bfed7c5905474d6';
    $lastReportTime = SGConfig::get('SG_LAST_REPORT_DATE');
    if (!$lastReportTime) {
        SGConfig::set('SG_LAST_REPORT_DATE', time());
    }
    SGBackup::getLogFileHeader($headerArray);
    $jsonArray['header'] = $headerArray;
    $jsonArray['header']['uid'] = sha1("http://" . @$_SERVER[HTTP_HOST] . @$_SERVER[REQUEST_URI]);
    $sgdb = SGDatabase::getInstance();
    $res = $sgdb->query('SELECT type, subtype, status, count(*) AS scount FROM ' . SG_ACTION_TABLE_NAME . ' WHERE update_date > FROM_UNIXTIME(%d) GROUP BY type, subtype, status', array($lastReportTime));
    if (count($res)) {
        foreach ($res as $item) {
            $jsonArray['log'][] = $item;
        }
    }
    return json_encode($jsonArray);
}
Пример #8
0
 private static function prepare()
 {
     $backupPath = SGConfig::get('SG_BACKUP_DIRECTORY');
     //create directory for backups
     if (!is_dir($backupPath)) {
         if (!@mkdir($backupPath)) {
             throw new SGExceptionMethodNotAllowed('Cannot create folder: ' . $backupPath);
         }
         if (!@file_put_contents($backupPath . '.htaccess', 'deny from all')) {
             throw new SGExceptionMethodNotAllowed('Cannot create htaccess file');
         }
     }
     //check permissions of backups directory
     if (!is_writable($backupPath)) {
         throw new SGExceptionForbidden('Permission denied. Directory is not writable: ' . $backupPath);
     }
 }
Пример #9
0
<?php

require_once dirname(__FILE__) . '/boot.php';
require_once SG_PUBLIC_INCLUDE_PATH . '/header.php';
$isNotificationEnabled = SGConfig::get('SG_NOTIFICATIONS_ENABLED');
$userEmail = SGConfig::get('SG_NOTIFICATIONS_EMAIL_ADDRESS');
$isAnonymousStatisticsEnabled = SGConfig::get('SG_SEND_ANONYMOUS_STATISTICS');
$intervalSelectElement = array('1000' => '1 second', '2000' => '2 seconds', '3000' => '3 seconds', '5000' => '5 seconds', '7000' => '7 seconds', '10000' => '10 seconds');
$selectedInterval = SGConfig::get('SG_AJAX_REQUEST_FREQUENCY') ? SGConfig::get('SG_AJAX_REQUEST_FREQUENCY') : SG_AJAX_DEFAULT_REQUEST_FREQUENCY;
require_once SG_PUBLIC_INCLUDE_PATH . 'sidebar.php';
?>
    <div id="sg-content-wrapper">
        <div class="container-fluid">
            <div class="row sg-settings-container">
                <div class="col-md-12">
                    <form class="form-horizontal" method="post" data-sgform="ajax" data-type="sgsettings">
                        <fieldset>
                            <legend><?php 
echo _t('General settings');
?>
</legend>
                            <?php 
if (SGBoot::isFeatureAvailable('NOTIFICATIONS')) {
    ?>
                                <div class="form-group">
                                    <label class="col-md-8 sg-control-label sg-user-info">
                                        <?php 
    echo _t('Email notifications');
    if (!empty($userEmail)) {
        ?>
                                            <br/><span class="text-muted sg-user-email sg-helper-block"><?php 
Пример #10
0
require_once SG_BACKUP_PATH . 'SGBackup.php';
require_once SG_LIB_PATH . 'SGReloadHandler.php';
require_once SG_LIB_PATH . 'SGPauseHandler.php';
try {
    $success = array('success' => 1);
    if (isAjax() && count($_POST)) {
        $options = $_POST;
        $error = array();
        if (@in_array('wp-content', $options['directory'])) {
            $options['directory'] = array('wp-content');
        }
        if (@$options['backupType'] == SG_BACKUP_TYPE_FULL) {
        }
        setManualBackupOptions($options);
    } else {
        $options = json_decode(SGConfig::get('SG_ACTIVE_BACKUP_OPTIONS'), true);
        setManualBackupOptions($options);
    }
    $wpContent = basename(WP_CONTENT_DIR);
    $upload_dir = wp_upload_dir();
    $wpUploads = basename($upload_dir['basedir']);
    $reloadHandler = new SGReloadHandler();
    if ($reloadHandler->canReload()) {
        $pauseHandler = new SGPauseHandler();
        $notificationCenter = SGNotificationCenter::getInstance();
        $notificationCenter->addObserver(SG_NOTIFICATION_SHOULD_CONTINUE_ACTION, $pauseHandler, 'shouldPause', true);
        $notificationCenter->addObserver(SG_NOTIFICATION_DID_FINISH_BACKUP, $pauseHandler, 'didFinishBackup');
    }
    $b = new SGBackup();
    $b->backup();
    if ($reloadHandler->canReload()) {
Пример #11
0
<?php

require_once dirname(__FILE__) . '/../boot.php';
require_once SG_BACKUP_PATH . 'SGBackup.php';
if (isAjax()) {
    while (true) {
        $created = SGConfig::get('SG_RUNNING_ACTION', true);
        if ($created) {
            die('1');
        }
    }
    die('2');
}
Пример #12
0
function enqueue_backup_guard_scripts($hook)
{
    if (!strpos($hook, 'backup_guard')) {
        return;
    }
    wp_enqueue_style('backup-guard-spinner', plugin_dir_url(__FILE__) . 'public/css/spinner.css');
    wp_enqueue_style('backup-guard-wordpress', plugin_dir_url(__FILE__) . 'public/css/bgstyle.wordpress.css');
    wp_enqueue_style('backup-guard-less', plugin_dir_url(__FILE__) . 'public/css/sgstyles.less');
    add_filter('style_loader_tag', 'backup_guard_less_loader');
    echo '<script type="text/javascript">sgBackup={}; SG_AJAX_URL = "' . SG_PUBLIC_AJAX_URL . '";';
    $sgAjaxRequestFrequency = SGConfig::get('SG_AJAX_REQUEST_FREQUENCY') ? SGConfig::get('SG_AJAX_REQUEST_FREQUENCY') : SG_AJAX_DEFAULT_REQUEST_FREQUENCY;
    echo 'SG_AJAX_REQUEST_FREQUENCY = "' . $sgAjaxRequestFrequency . '";';
    echo 'function getAjaxUrl(url) {' . 'if (url==="cloudDropbox" || url==="cloudGdrive") return "' . admin_url('admin-post.php?action=backup_guard_') . '"+url;' . 'return "' . admin_url('admin-ajax.php') . '";}</script>';
    wp_enqueue_script('backup-guard-less-framework', plugin_dir_url(__FILE__) . 'public/js/less.min.js', array('jquery'), '1.0.0', true);
    wp_enqueue_script('backup-guard-bootstrap-framework', plugin_dir_url(__FILE__) . 'public/js/bootstrap.min.js', array('jquery'), '1.0.0', true);
    wp_enqueue_script('backup-guard-sgrequest-js', plugin_dir_url(__FILE__) . 'public/js/sgrequesthandler.js', array('jquery'), '1.0.0', true);
    wp_enqueue_script('backup-guard-sgwprequest-js', plugin_dir_url(__FILE__) . 'public/js/sgrequesthandler.wordpress.js', array('jquery'), '1.0.0', true);
    wp_enqueue_script('backup-guard-main-js', plugin_dir_url(__FILE__) . 'public/js/main.js', array('jquery'), '1.0.0', true);
}
Пример #13
0
 private function prepareForBackup()
 {
     //start logging
     SGBackupLog::writeAction('backup', SG_BACKUP_LOG_POS_START);
     //save timestamp for future use
     $this->actionStartTs = time();
     //create action inside db
     $status = $this->databaseBackupAvailable ? SG_ACTION_STATUS_IN_PROGRESS_DB : SG_ACTION_STATUS_IN_PROGRESS_FILES;
     $this->actionId = self::createAction($this->fileName, SG_ACTION_TYPE_BACKUP, $status);
     //set paths
     $this->filesBackupPath = SG_BACKUP_DIRECTORY . $this->fileName . '/' . $this->fileName . '.sgbp';
     $this->databaseBackupPath = SG_BACKUP_DIRECTORY . $this->fileName . '/' . $this->fileName . '.sql';
     //prepare sgbp file
     @file_put_contents($this->filesBackupPath, '');
     if (!is_writable($this->filesBackupPath)) {
         throw new SGExceptionForbidden('Could not create backup file: ' . $filePath);
     }
     $this->backupFiles->setFilePath($this->filesBackupPath);
     SGConfig::set('SG_RUNNING_ACTION', 1, true);
     //check if upload to storages is needed
     $uploadToStorages = SGConfig::get('SG_BACKUP_UPLOAD_TO_STORAGES');
     if (SGBoot::isFeatureAvailable('STORAGE') && $uploadToStorages) {
         $storages = explode(',', $uploadToStorages);
         $arr = array();
         foreach ($storages as $storageId) {
             $actionId = SGBackupStorage::queueBackupForUpload($this->fileName, $storageId);
             $arr[] = $actionId;
         }
         $this->queuedStorageUploads = $arr;
     }
     //register shutdown function (used for handling execution time limits)
     register_shutdown_function('shutdownAction', $this->actionId, SG_ACTION_TYPE_BACKUP, $this->filesBackupPath, $this->databaseBackupPath);
 }
Пример #14
0
 public function __construct()
 {
     $this->startTs = time();
     $this->timeout = SGConfig::get('SG_RELOAD_INTERVAL');
 }
Пример #15
0
    ?>
                        </td>
                    </tr>
                <?php 
}
?>
                </tbody>
            </table>
            <div class="text-right">
                <ul class="pagination"></ul>
            </div>
        </fieldset>
    </div>
    <?php 
require_once SG_PUBLIC_INCLUDE_PATH . '/footer.php';
?>
    <?php 
if (time() - SGConfig::get('SG_LAST_REPORT_DATE') > SG_REPORT_INTERVAL && SGConfig::get('SG_SEND_ANONYMOUS_STATISTICS') !== '0') {
    $report = base64_encode(getReport());
    SGConfig::set('SG_LAST_REPORT_DATE', time());
    ?>
        <script type="text/javascript">jQuery.post('https://backup-guard.com/tms/api', {report: "<?php 
    echo $report;
    ?>
"});</script>
    <?php 
}
?>
</div>
<div class="clearfix"></div>