<?
//If (getenv("REMOTE_ADDR") == "127.0.0.6") {
// echo "<script> alert('Отказано в доступе!'); history.back(); </script>";
//}

If ($send == "ok") {

  If ($to == "" or $msg == "" or $name == "" or $email == "") {
   echo "<script> alert('Заполните все поля!'); history.back(); </script>";
   exit;
  }

  If (file_exists("users/$to") == true) {
   $ftm = fopen("mail/$to", "a");
   $name = str_replace("^","_",htmlspecialchars(stripslashes($name)));
   $email = str_replace("^","_",htmlspecialchars(stripslashes($email)));
   $msg = str_replace("\n","<br>",htmlspecialchars(stripslashes($msg)));
   $msg = str_replace("^","_",$msg);
   $msg = "Сообщение из раздела 'Обратная связь'<br>Отправитель: $name (<a href='mailto:$email'>$email</a>)<br>Его IP адрес: " . getenv("REMOTE_ADDR") . "<br>Текст сообщения:<br>$msg";

   fwrite($ftm, "0^$cl^" . date("d.m.Y H:i:s") . "^" . $msg . "\n");
   fclose($ftm);
  }

  echo "<script> alert('Сообщение успешно отправленно!'); </script>";
  echo "<script> document.location.href='/my.phtml" . $idstr . "&com=mail'; </script>";
  exit;

}
?>

<table border="0" width="100%" cellspacing="0" cellpadding="0">
  <tr>
    <td width="100%" bgcolor="#F0F0F0"><p><b>&gt;&gt; Обратная связь с продавцом</b></p></td>
  </tr>
</table>
<p>&nbsp;</p>

<table border="0" width="98%" cellspacing="0" cellpadding="4" bgcolor="#C0C0C0" align="center">
  <tr>
    <td width="2%" valign="middle" bgcolor="#F0F0F0" height="1" style="border-left: 1 solid #C0C0C0; border-top: 1 solid #C0C0C0; border-bottom: 1 solid #C0C0C0"><p align="center"><img border="0" src="/pic_info.gif" width="16" height="16"></p></td>
    <td width="98%" bgcolor="#F0F0F0" height="1" style="border-right: 1 solid #C0C0C0; border-top: 1 solid #C0C0C0; border-bottom: 1 solid #C0C0C0"><p>В этом разделе Вы можете связаться с любым продавцом нашего сервиса по внутренней почте. Ответ продавца придет Вам на e-mail.</p></td>
  </tr>
</table>
<p>&nbsp;</p>


<table border="0" width="98%" cellpadding="0" align="center" style="border: 1 solid #0000FF" cellspacing="1">
  <tr>
    <td width="100%" valign="top">
      <table border="0" width="100%" cellspacing="0" cellpadding="0">
        <tr>
           <td width="100%" bgcolor="#FBC900"><p><b>Связь с продавцом...</b></p></td>
        </tr>
        <tr>
           <td width="100%" valign="top">
<p>&nbsp;</p>
<form method="POST" name="mailfrm">
<input type="hidden" name="send" value="ok">
 <table border="1" width="600" cellspacing="0" cellpadding="0" bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF" height="34" align="center" style="border: 1 solid #C0C0C0">
    <tr>
     <td width="175" bgcolor="#C4CAFF" height="19" bordercolorlight="#000000" bordercolordark="#FFFFFF"><p>Ваше имя:</p></td>
     <td width="395" height="19"><p><input type="text" name="name" size="24" style="font-family: Verdana, Arial; font-size: 8pt; border: 1 solid #7F9DB9"></p></td>
    </tr>
    <tr>
     <td width="175" bgcolor="#C4CAFF" height="19" bordercolorlight="#000000" bordercolordark="#FFFFFF"><p>Ваш e-mail:</p></td>
     <td width="395" height="19"><p><input type="text" name="email" size="24" style="font-family: Verdana, Arial; font-size: 8pt; border: 1 solid #7F9DB9"></p></td>
    </tr>
    <tr>
     <td width="175" bgcolor="#C4CAFF" height="19" bordercolorlight="#000000" bordercolordark="#FFFFFF"><p>Кому:</p></td>
     <td width="395" height="19"><p><input type="text" name="to" size="24" style="font-family: Verdana, Arial; font-size: 8pt; border: 1 solid #7F9DB9"></p></td>
    </tr>
    <tr>
     <td width="175" bgcolor="#C4CAFF" height="19" bordercolorlight="#000000" bordercolordark="#FFFFFF" valign="top"><p>Текст сообщения:</p></td>
     <td width="395" height="19"><p><textarea rows="6" name="msg" cols="65" style="font-family: Verdana, Arial; font-size: 8pt; border: 1 solid #7F9DB9"></textarea></p></td>
    </tr>
    <tr>
     <td width="175" height="19" bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF" valign="top"></td>
     <td width="395" height="19"><p><input type="submit" name="B1" value="Отправить" style="font-family: Verdana, Arial; font-size: 8pt"></p></td>
    </tr>
 </table>
</form>

           </td>
        </tr>
      </table>
    </td>
  </tr>
</table>