<?php
include($_SERVER['DOCUMENT_ROOT'] .'/script/HeaderInc.php');
if('XMLHttpRequest' == $_SERVER['HTTP_X_REQUESTED_WITH'] && true === isset($_SESSION['SessionAuth']['id']) && 0 < $_SESSION['SessionAuth']['id']) {
  if(true === isset($_POST['dns_name']) && '' != $_POST['dns_name']){
    require_once ('Net/DNS.php');
    $resolver = new Net_DNS_Resolver();
    if(true === isset($_POST['dns_servername']) && '' != $_POST['dns_servername']){
      $ArrDns = array($_POST['dns_servername']);
    }
    else{
      $ArrDns = array($MS_SP->Sp_Config['DnsServerForUtils']);
    }
    $resolver->nameservers = $ArrDns;
    $response = $resolver->rawQuery($_POST['dns_name']);
    if ($response && 1 <= count($response->answer)) {
//      SiteLibs::GetVarDump($response->answer);
      $smarty->assign('Arr', $response->answer);
      $VarReturn = $smarty->fetch('Utils/Dns/Result.tpl');
    }
    else{
      $VarReturn = $MS_SP->Sp_LangMessage['warning']['WarnSearchResultEmpty'];
    }
  }
  else{
    $VarReturn = $MS_SP->Sp_LangMessage['error']['ErrSettingWrong'];
  }
}
else{
  $VarReturn = $MS_SP->Sp_LangMessage['error']['ErrFuncAccessDenied'];
}
echo $VarReturn;
include($_SERVER['DOCUMENT_ROOT'] .'/script/FooterInc.php');
?>