Esempio n. 1
0
 public static function wpadm_show_backup()
 {
     require_once DRBBACKUP_BASE_DIR . "/modules/dropbox.class.php";
     parent::$type = 'full';
     $dropbox_options = get_option(PREFIX_BACKUP_ . 'dropbox-setting');
     if ($dropbox_options) {
         $dropbox_options = unserialize(base64_decode($dropbox_options));
         if (isset($dropbox_options['app_key']) && isset($dropbox_options['app_secret']) && isset($dropbox_options['auth_token_secret'])) {
             $dropbox = new dropbox($dropbox_options['app_key'], $dropbox_options['app_secret'], $dropbox_options['auth_token_secret']);
             $folder_project = self::getNameProject();
             $backups = $dropbox->listing($folder_project);
             $n = count($backups['items']);
             $data['data'] = array();
             for ($i = 0; $i < $n; $i++) {
                 $backup = $dropbox->listing($folder_project . "/" . $backups['items'][$i]['name']);
                 $data['data'][$i]['name'] = $backups['items'][$i]['name'];
                 $data['data'][$i]['size'] = (double) $backup['size'] * 1024 * 1024;
                 $data['data'][$i]['dt'] = parent::getDateInName($backups['items'][$i]['name']);
                 $data['data'][$i]['count'] = count($backup['items']);
                 $data['data'][$i]['type'] = 'dropbox';
                 $k = $data['data'][$i]['count'];
                 $data['data'][$i]['files'] = '[';
                 for ($j = 0; $j < $k; $j++) {
                     $data['data'][$i]['files'] .= $backup['items'][$j]['name'] . ',';
                 }
             }
         }
     }
     if (isset($_GET['pay']) && $_GET['pay'] == 'success') {
         if (!file_exists(WPAdm_Core::getTmpDir() . "/pay_success")) {
             file_put_contents(WPAdm_Core::getTmpDir() . "/pay_success", 1);
             parent::setMessage(langWPADM::get('', false));
         }
     }
     if (isset($_GET['pay']) && $_GET['pay'] == 'cancel') {
         parent::setError(langWPADM::get('Checkout was canceled', false));
     }
     $data_local = parent::read_backups();
     if (isset($data['data'])) {
         $data['data'] = array_merge($data_local['data'], $data['data']);
         $data['md5'] = md5(print_r($data['data'], 1));
     } else {
         $data = $data_local;
     }
     if (file_exists(WPAdm_Core::getTmpDir() . "/pay_success")) {
         $plugin_info = get_plugins("/" . parent::$plugin_name);
         $plugin_version = isset($plugin_info[parent::$plugin_name . '.php']['Version']) ? $plugin_info[parent::$plugin_name . '.php']['Version'] : '';
         $data_server = parent::sendToServer(array('actApi' => "proBackupCheck", 'site' => home_url(), 'email' => get_option('admin_email'), 'plugin' => parent::$plugin_name, 'key' => '', 'plugin_version' => $plugin_version));
         if (isset($data_server['status']) && $data_server['status'] == 'success' && isset($data_server['key'])) {
             update_option(PREFIX_BACKUP_ . 'pro-key', $data_server['key']);
             if (isset($data_server['url']) && !empty($data_server['url'])) {
                 parent::setMessage(str_replace('&s', $data_server['url'], langWPADM::get('The "Dropbox backup & restore PRO" version can be downloaded here <a href="&s">download</a>', false)));
             }
         }
     }
     if (!function_exists('get_plugins')) {
         require_once ABSPATH . 'wp-admin/includes/plugin.php';
     }
     $stars5 = file_exists(WPAdm_Core::getTmpDir() . "/notice-star");
     $plugin_data = array_values(get_plugins('/dropbox-backup'));
     $is_runnig = WPAdm_Running::is_running();
     $show = !get_option('wpadm_pub_key') && is_super_admin();
     $error = parent::getError(true);
     $msg = parent::getMessage(true);
     $base_path = DRBBACKUP_BASE_DIR;
     ob_start();
     require_once $base_path . DIRECTORY_SEPARATOR . "template" . DIRECTORY_SEPARATOR . "wpadm_show_backup.php";
     echo ob_get_clean();
 }
Esempio n. 2
0
 public static function delete_backup()
 {
     if (isset($_POST['backup-type'])) {
         if ($_POST['backup-type'] == 'local') {
             require_once DRBBACKUP_BASE_DIR . "/modules/class-wpadm-core.php";
             $dir = WPADM_DIR_BACKUP . '/' . $_POST['backup-name'];
             $delete = false;
             if (is_dir($dir)) {
                 WPAdm_Core::rmdir($dir);
                 $delete = true;
             }
             $dir = ABSPATH . WPADM_DIR_NAME . '/' . $_POST['backup-name'];
             if (is_dir($dir)) {
                 WPAdm_Core::rmdir($dir);
                 $delete = true;
             }
             if ($delete) {
                 parent::setMessage(str_replace('%s', $_POST['backup-name'], langWPADM::get('Backup(%s) was deleted', false)));
             }
         } elseif ($_POST['backup-type'] == 'dropbox') {
             require_once DRBBACKUP_BASE_DIR . "/modules/dropbox.class.php";
             $dropbox_options = get_option(PREFIX_BACKUP_ . 'dropbox-setting');
             if ($dropbox_options) {
                 $dropbox_options = unserialize(base64_decode($dropbox_options));
                 $dropbox = new dropbox($dropbox_options['app_key'], $dropbox_options['app_secret'], $dropbox_options['auth_token_secret']);
                 $folder_project = self::getNameProject();
                 $res = $dropbox->deleteFile("{$folder_project}/{$_POST['backup-name']}");
                 if ($res['is_deleted'] === true) {
                     parent::setMessage(str_replace('%s', $_POST['backup-name'], langWPADM::get('Backup(%s) was deleted', false)));
                 }
             }
         }
     }
     header("Location: " . admin_url("admin.php?page=wpadm_wp_full_backup_dropbox"));
 }