<?php
//header("Expires: Mon, 26 Jul 1997 05:00:00 GMT" );
//header("Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . "GMT" );
//header("Cache-Control: no-cache, must-revalidate" );
//header("Pragma: no-cache" );
//header("Content-type: text/x-json");
include($_SERVER['DOCUMENT_ROOT'] .'/script/HeaderInc.php');
//if('XMLHttpRequest' == $_SERVER['HTTP_X_REQUESTED_WITH']) {
//  $VarUrlStr = $_POST['UrlStr'];
  if(true === isset($_POST['UrlType']) && true === isset($_POST['UrlMethod'])){
//    $ObjUpdateMod = new UpdateMod($_POST['UrlType'], new SystemMod($MS_SP));
    $ArrArgs = $_POST;
    if(true === isset($_FILES)){
      $ArrArgs = array_merge($ArrArgs, $_FILES);
    }
    $ObjUpdateMod = UpdateMod::getUpdater($ArrArgs, new SystemMod($MS_SP));
    if (true === $ObjUpdateMod->UpdateFileIsset()){
      if(true === $ObjUpdateMod->UpdateFileGet()){
        $ArrReturn = array('message' => $MS_SP->Sp_LangMessage['message']['RestorePo'] .': '. $ObjUpdateMod->VarUpdateFileName .' '. SiteLibs::ConvertSizeToStr(filesize($ObjUpdateMod->VarUpdateFile), $MS_SP->Sp_LangMessage['filesize']));
      }
      else{
        $ArrReturn = array('error' => $MS_SP->Sp_LangMessage['error']['ErrCannotDownloadFile']);
      }
    }
    else{
      $ArrReturn = array('error' => $MS_SP->Sp_LangMessage['warning']['WarnNoUpdate']);
    }
  }
  else{
    $ArrReturn = array('error' => $MS_SP->Sp_LangMessage['error']['ErrSettingWrong']);
  }
//}
//else{
//  $ArrReturn = array('error' => $MS_SP->Sp_LangMessage['error']['ErrFuncAccessDenied']);
//}
echo json_encode($ArrReturn);
//$smarty->assign('ArrReturn', $ArrReturn);
//$smarty->display('PageSave.tpl');
include($_SERVER['DOCUMENT_ROOT'] .'/script/FooterInc.php');
?>