<?php
# Subroutine: adm_restore_confirm.php called by Admin.php
# Xinfeng Chen, 2002.12.20
# Input: $file

require_once('bin/config.php');
require_once('admin/adm.inc');

#--- Validate dministrator ---
include('admin/adm_validate.php');
if(!$adm_validated){jumpTo('admin.php?cmd=logon'); exit;}

#--- Start Processing ---
require_once('core/class_forum_base.php');
CForumBase::setFileBase("$filepath");

#--- Check specified backup files ---
$backupPath=CForumBase::getDirPath('BACKUP');

$fname="$backupPath/$file";
if(!file_exists($fname) && !is_file($fname)){
 msgBox("备份文件错误，无法执行还原操作!",mCRITICAL);
 exit;
}

$fsize=ceil(filesize($fname)/1024);
$fp=fopen($fname,'rb');
$head=fread($fp,64);
fclose($fp);

list($tag,$bscope,$bid,$bts,$buser)=explode('|',$head);
$btime=strftime("%Y-%m-%d %H:%M:%S",$bts);
if($bscope != 'BOARD'){$bid='';}

switch($bscope){
 case 'ALL': $dirpath=CForumBase::getDirPath('BASE');break; 
 case 'BOARD':
  if(!$bid){
   msgBox("指定论坛错误，中止还原操作！",mCRITICAL);
   exit;
  }
  $dirpath=CForumBase::getDirPath('BOARD',$bid);break; 
 case 'USER': $dirpath=CForumBase::getDirPath('USER');break;
 default:
  msgBox("备份策略错误，中止还原操作！",mCRITICAL);
  exit;
}

$msg='备份文件正常.<br>';
$msg.="文件大小: $fsize K<br>";
$msg.="备份时间: $btime<br>";
$msg.="执行用户: $buser<br>";
$msg.="备份策略: $bscope<br>";
$msg.="论坛ID: $bid<br><br>";

if(file_exists($dirpath)){
 $msg.="还原目标 已存在。<font color=red>还原操作将覆盖当前内容！</font><br>";
}else{
 $msg.="还原目标 不存在。还原操作将建立相应目录。<br>";
}

msgBox($msg,mINFORMATION,'确认还原操作',
 "?cmd=restore_submit&file=$file", '执行还原操作');

?>