<?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'] && 
  true === isset($_SESSION['SessionAuth']['IpsAdmin']['reg']) && 1 == $_SESSION['SessionAuth']['IpsAdmin']['reg']){
  $VarUrlStr = $_POST['UrlStr'];
  if(true === isset($VarUrlStr) && '' != $VarUrlStr){
    $VarUrlStr = substr($VarUrlStr, 0, -1);
    $ArrRow = explode("|", $VarUrlStr);
    function MyStrRepl(&$item1){
      $item1 = str_replace('row', '', $item1);
    }
    array_walk($ArrRow, 'MyStrRepl');
    if(true === is_array($ArrRow) && 0 < count($ArrRow)){
      require_once($_SERVER['DOCUMENT_ROOT'] .'/script/Country.mod.php');
      $ObjCountryMod = new CountryMod($MS_SP);
      $i = 0;
      foreach ($ArrRow as $key => $value) {
        //echo "VarId: ". $key .'=>'. $value ."<br />";
        $VarResult = $ObjCountryMod->Del($value);
        if(true === $VarResult){
          $i++;
        }
      }
      $ArrReturn = array('message' => $i . $MS_SP->Sp_LangMessage['message']['MessRecordDeleteSuccessPart1'] . count($ArrRow) . $MS_SP->Sp_LangMessage['message']['MessRecordDeleteSuccessPart2']);
    }
    else{
      $ArrReturn = array('error' => $MS_SP->Sp_LangMessage['error']['ErrNoRecordsForDelete']);
    }
  }
  else{
    $ArrReturn = array('error' => $MS_SP->Sp_LangMessage['error']['ErrSettingWrong']);
  }
}
else{
  $ArrReturn = array('error' => $MS_SP->Sp_LangMessage['error']['ErrFuncAccessDenied']);
}
array_walk($ArrReturn, 'SiteLibs::ConvertArrayIconvBack', $MS_SP->Sp_Config['charset']);
echo json_encode($ArrReturn);
include($_SERVER['DOCUMENT_ROOT'] .'/script/FooterInc.php');
?>