function shutdownAction($actionId, $actionType, $filePath, $dbFilePath, $backupObj) { if ($backupObj->getReloading()) { return; } $action = SGBackup::getAction($actionId); if ($action && ($action['status'] == SG_ACTION_STATUS_IN_PROGRESS_DB || $action['status'] == SG_ACTION_STATUS_IN_PROGRESS_FILES)) { SGBackupLog::writeExceptionObject(new SGExceptionServerError('Execution time abort')); SGBackup::changeActionStatus($actionId, SG_ACTION_STATUS_ERROR); if ($actionType == SG_ACTION_TYPE_BACKUP) { @unlink($filePath); @unlink($dbFilePath); } } }
<?php require_once dirname(__FILE__) . '/../boot.php'; require_once SG_BACKUP_PATH . 'SGBackup.php'; if (isAjax() && count($_POST)) { $actionId = (int) $_POST['actionId']; $currentAction = SGBackup::getAction($actionId); if ($currentAction) { if ($currentAction['status'] == SG_ACTION_STATUS_IN_PROGRESS_FILES || $currentAction['status'] == SG_ACTION_STATUS_IN_PROGRESS_DB) { die(json_encode($currentAction)); } die('0'); } die('0'); }
<?php require_once dirname(__FILE__) . '/../boot.php'; require_once SG_BACKUP_PATH . 'SGBackup.php'; if (isAjax() && count($_POST)) { //Unset Active Options $activeOptions = array('database' => 0, 'files' => 0, 'ftp' => 0, 'gdrive' => 0, 'dropbox' => 0, 'background' => 0); SGConfig::set('SG_ACTIVE_BACKUP_OPTIONS', json_encode($activeOptions)); //Getting Backup Name $backupName = $_POST['bname']; $backup = new SGBackup(); $backup->restore($backupName); }
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); }
<?php require_once dirname(__FILE__) . '/../boot.php'; require_once SG_BACKUP_PATH . 'SGBackup.php'; if (isAjax() && isset($_POST['actionId'])) { $actionId = (int) $_POST['actionId']; SGBackup::cancelAction($actionId); die('1'); }
<?php require_once dirname(__FILE__) . '/../boot.php'; require_once SG_BACKUP_PATH . 'SGBackup.php'; $error = array(); $success = array('success' => 1); try { SGBackup::upload(@$_FILES['sgbpFile']); } catch (SGException $exception) { array_push($error, $exception->getMessage()); die(json_encode($error)); } die(json_encode($success));
SGConfig::set('SG_ACTION_BACKUP_DATABASE_AVAILABLE', 1, false); SGConfig::set('SG_ACTION_BACKUP_FILES_AVAILABLE', 1, false); $activeOptions['database'] = 1; $activeOptions['files'] = 1; } else { if ($options['backupType'] == SG_BACKUP_TYPE_CUSTOM) { //If database backup $isDatabaseBackup = empty($options['backupDatabase']) ? 0 : 1; SGConfig::set('SG_ACTION_BACKUP_DATABASE_AVAILABLE', $isDatabaseBackup, false); $activeOptions['database'] = $isDatabaseBackup; //If files backup if (isset($options['backupFiles']) && count($options['directory'])) { $directories = $options['directory']; SGConfig::set('SG_ACTION_BACKUP_FILES_AVAILABLE', 1, false); SGConfig::set('SG_BACKUP_FILE_PATHS', implode(',', $directories), false); $activeOptions['files'] = 1; } else { SGConfig::set('SG_ACTION_BACKUP_FILES_AVAILABLE', 0, false); SGConfig::set('SG_BACKUP_FILE_PATHS', 0, false); } } } SGConfig::set('SG_ACTIVE_BACKUP_OPTIONS', json_encode($activeOptions)); $backup = new SGBackup(); $backup->backup(); die(json_encode($success)); } catch (SGException $exception) { array_push($error, $exception->getMessage()); die(json_encode($error)); } }
<?php require_once dirname(__FILE__) . '/../boot.php'; require_once SG_BACKUP_PATH . 'SGBackup.php'; if (count($_GET)) { $response = array(); $downloadType = (int) $_GET['downloadType']; if ($downloadType == SG_BACKUP_DOWNLOAD_TYPE_BACKUP_LOG || $downloadType == SG_BACKUP_DOWNLOAD_TYPE_RESTORE_LOG || $downloadType == SG_BACKUP_DOWNLOAD_TYPE_SGBP) { $backupName = $_GET['backupName']; try { SGBackup::download($backupName, $downloadType); } catch (SGException $exception) { die($exception->getMessage()); } } }
<?php require_once dirname(__FILE__) . '/../boot.php'; require_once SG_BACKUP_PATH . 'SGBackup.php'; if (isset($_POST['backupName'])) { $backupName = $_POST['backupName']; SGBackup::deleteBackup($backupName); } die('{"success":1}');
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()) { $b->setReloading(true); $reloadHandler->reload(); } die(json_encode($success)); } catch (SGException $exception) { array_push($error, $exception->getMessage()); die(json_encode($error)); } function setManualBackupOptions($options) { $activeOptions = array('backupDatabase' => 0, 'backupFiles' => 0, 'ftp' => 0, 'gdrive' => 0, 'dropbox' => 0, 'background' => 0); //If background mode $isBackgroundMode = !empty($options['backgroundMode']) ? 1 : 0;
<?php require_once dirname(__FILE__) . '/../boot.php'; require_once SG_BACKUP_PATH . 'SGBackup.php'; if (isAjax()) { $runningActions = SGBackup::getRunningActions(); $isAnyActiveActions = count($runningActions); if ($isAnyActiveActions) { $activeBackup = $runningActions[0]; die(json_encode($activeBackup)); } die('0'); }
<?php require_once dirname(__FILE__) . '/boot.php'; require_once SG_PUBLIC_INCLUDE_PATH . '/header.php'; require_once SG_BACKUP_PATH . 'SGBackup.php'; $backups = SGBackup::getAllBackups(); $downloadUrl = admin_url('admin-post.php?action=backup_guard_downloadBackup&'); require_once SG_PUBLIC_INCLUDE_PATH . 'sidebar.php'; ?> <div id="sg-content-wrapper"> <div class="container-fluid"> <fieldset> <legend><?php echo _t('Backups'); ?> </legend> <a href="javascript:void(0)" id="sg-manual-backup" class="pull-left btn btn-success" data-toggle="modal" data-modal-name="manual-backup" data-remote="modalManualBackup"><i class="glyphicon glyphicon-play"></i> <?php _t('Perform manual backup'); ?> </a> <a href="javascript:void(0)" id="sg-import" class="pull-right btn btn-primary" data-toggle="modal" data-modal-name="import" data-remote="modalImport"><i class="glyphicon glyphicon-open"></i> <?php _t('Import'); ?> </a> <div class="clearfix"></div><br/> <table class="table table-striped paginated sg-backup-table"> <thead> <tr> <th><?php _t('Filename'); ?>