<?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']['id']) && true === is_numeric($_SESSION['SessionAuth']['id'])) {
  if(true === isset($_POST['UrlId']) && true === is_numeric($_POST['UrlId']) && 0 < $_POST['UrlId']){
    $ObjMessageMod = new MessageMod($MS_SP);
    $VarIsset = $ObjMessageMod->GetFromDb('SqlOne', 'GetOne', "a.message_id = '". $_POST['UrlId'] ."' AND message_date_familiarize != ''");
    if(true === isset($VarIsset) && true === is_numeric($VarIsset) && 0 < $VarIsset){
      $ArrReturn = array('error' => $MS_SP->Sp_LangMessage['error']['ErrMessageWasWritten']);
    }
    else{
      $VarResult = $ObjMessageMod->Familiarize($_POST);
      if(true === $VarResult){
        $ArrReturn = array('message' => $MS_SP->Sp_LangMessage['message']['MessMessageMarkSuccess']);
      }
      else{
        $ArrReturn = array('error' => $VarResult['error']);
      }
    }
  }
  else{
    $ArrReturn = array('error' => $MS_SP->Sp_LangMessage['error']['ErrNoRecordsForOperation']);
  }
}
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');
?>