/** * 복원 */ public function restore() { if (!current_user_can('activate_plugins')) { wp_die(__('관리 권한이 없습니다.', 'kboard')); } if (isset($_POST['kboard-restore-execute-nonce']) && wp_verify_nonce($_POST['kboard-restore-execute-nonce'], 'kboard-restore-execute')) { header('Content-Type: text/html; charset=UTF-8'); $xmlfile = $_FILES['kboard_backup_xml_file']['tmp_name']; $xmlfile_name = basename($_FILES['kboard_backup_xml_file']['name']); if (is_uploaded_file($xmlfile)) { $file_extension = explode('.', $xmlfile_name); if (end($file_extension) == 'xml') { include_once KBOARD_DIR_PATH . '/class/KBBackup.class.php'; $backup = new KBBackup(); $backup->importXml($xmlfile); echo '<script>alert("' . __('복원파일의 데이터로 복구 되었습니다.', 'kboard') . '");</script>'; } else { echo '<script>alert("' . __('올바른 복원파일이 아닙니다.', 'kboard') . '");</script>'; } unlink($xmlfile); } else { echo '<script>alert("' . __('파일 업로드에 실패 했습니다.', 'kboard') . '");</script>'; } } $redirect_url = admin_url('admin.php?page=kboard_backup'); echo "<script>location.href='{$redirect_url}';</script>"; exit; }
<?php list($path) = explode(DIRECTORY_SEPARATOR . 'wp-content', dirname(__FILE__) . DIRECTORY_SEPARATOR); include $path . DIRECTORY_SEPARATOR . 'wp-load.php'; header('Content-Type: text/html; charset=UTF-8'); $referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''; $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ''; if ($referer) { $url = parse_url($referer); $referer_host = $url['host']; } else { wp_die('KBoard : ' . __('This page is restricted from external access.', 'kboard')); } if (!in_array($referer_host, array($host))) { wp_die('KBoard : ' . __('This page is restricted from external access.', 'kboard')); } if (!current_user_can('activate_plugins')) { wp_die('KBoard : ' . __('No backup privilege.', 'kboard')); } include KBOARD_DIR_PATH . '/class/KBBackup.class.php'; $backup = new KBBackup(); $tables = $backup->getTables(); $data = ''; foreach ($tables as $key => $value) { $data .= $backup->getXml($value); } $backup->download($data, 'xml');
function kboard_backup() { include 'class/KBBackup.class.php'; $backup = new KBBackup(); if ($_GET['action'] == 'upload') { $xmlfile = WP_CONTENT_DIR . '/uploads/' . basename($_FILES['kboard_backup_xml_file']['name']); if (move_uploaded_file($_FILES['kboard_backup_xml_file']['tmp_name'], $xmlfile)) { $file_extension = explode('.', $xmlfile); if (end($file_extension) == 'xml') { $backup->importXml($xmlfile); echo '<script>alert("복원파일의 데이터로 복구 되었습니다.");</script>'; } else { echo '<script>alert("복원에 실패 했습니다. 올바른 복원파일이 아닙니다.");</script>'; } unlink($xmlfile); } else { echo '<script>alert("파일의 업로드를 실패 했습니다.");</script>'; } } include_once 'pages/kboard_backup.php'; }
/** * 백업파일 다운로드 */ public function backup() { header('Content-Type: text/html; charset=UTF-8'); $referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''; $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ''; if ($referer) { $url = parse_url($referer); $referer_host = $url['host']; } else { wp_die('KBoard : ' . __('This page is restricted from external access.', 'kboard')); } if (!in_array($referer_host, array($host))) { wp_die('KBoard : ' . __('This page is restricted from external access.', 'kboard')); } if (!current_user_can('activate_plugins')) { wp_die('KBoard : ' . __('No backup privilege.', 'kboard')); } include KBOARD_DIR_PATH . '/class/KBBackup.class.php'; $backup = new KBBackup(); $tables = $backup->getTables(); $data = ''; foreach ($tables as $key => $value) { $data .= $backup->getXml($value); } $backup->download($data, 'xml'); exit; }