fn_set_notification('N', __('notice'), __('done')); } break; case 'files': $params = array('pack_name' => empty($_REQUEST['dbdump_filename']) ? date('dMY_His', TIME) : fn_basename($_REQUEST['dbdump_filename']), 'fs_compress' => !empty($_REQUEST['compress_type']) ? $_REQUEST['compress_type'] : 'zip', 'extra_folders' => !empty($_REQUEST['extra_folders']) ? $_REQUEST['extra_folders'] : array()); $dump_file_path = DataKeeper::backupFiles($params); if (!empty($dump_file_path)) { fn_set_notification('N', __('notice'), __('done')); } break; } } // Restore if ($mode == 'restore') { if (!empty($_REQUEST['backup_file'])) { $restore_result = DataKeeper::restore($_REQUEST['backup_file']); if ($restore_result === true) { fn_set_notification('N', __('notice'), __('done')); } else { fn_set_notification('E', __('error'), $restore_result); } } } if ($mode == 'm_delete') { if (!empty($_REQUEST['backup_files'])) { foreach ($_REQUEST['backup_files'] as $file) { @unlink(Registry::get('config.dir.backups') . fn_basename($file)); } } } if ($mode == 'upload') {
$uc_settings['ftp_directory'] = $_REQUEST['ftp_directory']; } include_once $config['dir']['root'] . '/app/Tygh/DataKeeper.php'; include_once $config['dir']['root'] . '/app/Tygh/Validators.php'; db_connect($config['db_host'], $config['db_user'], $config['db_password'], $config['db_name']); // Set auto-scroller $scroller = <<<SCR <script type="text/javascript"> interval_id = window.setInterval(function(){ window.scrollTo(0,document.body.scrollHeight); }, 300); </script> SCR; echo $scroller; db_query('SET NAMES UTF8, sql_mode = ""'); if (\Tygh\DataKeeper::restore($backup_filename)) { fn_rm($config['dir']['cache_templates']); $url = $config['http_location'] . '/' . $config['admin_index']; fn_echo('<br><strong>Restore completed</strong><br><br>'); fn_echo('<a href="' . $url . '">Return to the administrator area</a>'); } else { fn_echo('<br><strong>Unable to restore</strong>'); } // Collect statictics $revert_stats_url = $config['resources']['updates_server'] . "/index.php?dispatch=product_updates.reverted&" . http_build_query($stats_data); $ch = curl_init(); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($ch, CURLOPT_HTTPGET, 1); curl_setopt($ch, CURLOPT_URL, $revert_stats_url); curl_exec($ch); curl_close($ch);