<table border="0" width="100%" cellspacing="0" cellpadding="0">
  <tr>
    <td width="100%" bgcolor="#F0F0F0"><p><b>&gt;&gt; Форум <? If ($com == "msgadd") { echo " &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="img/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>Все сообщения, не относящиеся к нашему сервису, а также содержащие нецензурные выражения будут удалены, пользователю же написавшему подобные сообщения будет закрыт доступ к форму.</p></td>
  </tr>
</table>
<p>&nbsp;</p>

<?
$ip = getenv("REMOTE_ADDR");

If ($ip == "63.76.234.54" or $ip == "194.158.208.151" or $ip == "212.5.100.140" or $ip == "194.67.159.230") {
 echo "<p><b>Форум временно закрыт</b></p>";
 exit;
}
?>


<table border="1" width="98%" cellpadding="0" align="center" style="border-collapse: collapse" bordercolor="#9ace8b" cellspacing="1">
  <tr>
    <td width="100%" valign="top">
      <table border="1" width="100%" cellspacing="0" cellpadding="0" bgcolor="#F1FFED" style="border-collapse: collapse" bordercolor="#FFFFFF">
        <tr>
           <td width="100%" bgcolor="#9ace8b"><p><b><? If ($com == "msgadd") { echo "Добавление нового сообщения"; } Else { echo "Форум проекта"; }?></b></p></td>
        </tr>
        <tr>
           <td width="100%" valign="top">

<?
If ($com == "msgadd") {
 If ($send == "ok") {
  $mmsg = $msg;
  $msg = str_replace("\n","<br>",htmlspecialchars(stripslashes($msg)));
  $msg = str_replace("^","_",$msg);
  $name = str_replace("^","_",htmlspecialchars(stripslashes($name)));
  $email = str_replace("^","_",htmlspecialchars(stripslashes($email)));

  $ff2 = fopen("tx/forum.txt", "a");
  fwrite($ff2, "$name^$email^" . getenv("REMOTE_ADDR") . "^" . date("d.m.Y H:i:s") . "^$msg\n");
  fclose($ff2);

  mail("info@fishka.biz", "fishka.biz/forum", "от: $name\ne-mail: $email\n$mmsg", "From: forum_notify@$serv_const_servname\n Content-Type: text/plain;\n charset=\"koi8-r\"");

  echo "<script> alert('Сообщение успешно размещено в форуме!'); </script>";
  echo "<script> document.location.href='/forum.php'; </script>";
  exit;
 }

 ?>
 <SCRIPT language=javascript>
 function frmpost(){
	if(document.all){
		if(frm.name.value.length == 0) {
			alert("Вы не заполнили поле 'Ваше имя'!");
			return;
		}
		if(frm.email.value.length == 0) {
			alert("Вы не заполнили поле 'E-mail'!");
			return;
		}
		if(frm.msg.value.length == 0) {
			alert("Вы не заполнили поле 'Текст сообщения'!");
			return;
		}
		frm.submit();
	}
 }
 </SCRIPT>

<form method="POST" NAME = "frm" ACTION = "forum.php?com=msgadd">
<input type="hidden" name="send" value="ok">
          <table border="1" width="100%" cellspacing="0" cellpadding="0" bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF">
            <tr>
              <td width="30%" bgcolor="#9ACE8B" height="19" bordercolorlight="#F1FFED" bordercolordark="#FFFFFF"><p>Ваше имя:</p></td>
              <td width="70%" height="19" bordercolor="#F1FFED"><p>
              <input type="text" name="name" size="70" style="font-family: Verdana, Arial; font-size: 8pt; border: 1px solid #9ACE8B; "></p></td>
            </tr>
            <tr>
              <td width="30%" bgcolor="#9ACE8B" height="19" bordercolorlight="#F1FFED" bordercolordark="#FFFFFF"><p>E-mail:</p></td>
              <td width="70%" height="19" bordercolor="#F1FFED"><p>
              <input type="text" name="email" size="70" style="font-family: Verdana, Arial; font-size: 8pt; border: 1px solid #9ACE8B; "></p></td>
            </tr>
            <tr>
              <td width="30%" bgcolor="#9ACE8B" height="19" bordercolorlight="#F1FFED" bordercolordark="#FFFFFF" valign="top"><p>Текст сообщения:</p></td>
              <td width="70%" height="19" bordercolor="#F1FFED"><p>
              <textarea rows="5" name="msg" cols="70" style="font-family: Verdana, Arial; font-size: 8pt; border: 1px solid #9ACE8B; "></textarea></p></td>
            </tr>
            <tr>
              <td width="30%" height="19" bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF" valign="top"></td>
              <td width="70%" height="19" bordercolor="#F1FFED"><p>
              <input type="button" onClick="frmpost();" value="Добавить" name="B1" style="border:1px solid #9ACE8B; font-family: Verdana, Arial; font-size: 8pt; background-color:#F1FFED">&nbsp;<input type="reset" value="Очистить" name="B1" style="border:1px solid #9ACE8B; font-family: Verdana, Arial; font-size: 8pt; background-color:#F1FFED">&nbsp;<input type="button" value="Отмена" name="B2" onClick="history.back();" style="border:1px solid #9ACE8B; font-family: Verdana, Arial; font-size: 8pt; background-color:#F1FFED"></p></td>
            </tr>
          </table>
</form>
           </td>
        </tr>
      </table>
    </td>
  </tr>
</table>
 <?
}
ElseIf ($d_id <> "") {
 If ($send == "ok" and $name == "ice-breaker:43encj") {
  $ff = @file("tx/forum.txt");
  $wf = fopen("tx/forum.txt", "w");
  for ($i = 0; $i < count($ff); $i++) {
   if ($i <> $d_id) {
    fwrite($wf, trim($ff[$i]) . "\n");
   }
  }
  fclose($wf);

  echo "<script> alert('Удалено!'); document.location.href='/forum.php'; </script>";
  exit;
 }

 echo "<form method='POST'>
<input type='hidden' name='send' value='ok'>
<p>Код:
<input type='text' name='name' size='14' style='font-family: Verdana, Arial; font-size: 8pt; border: 1px solid #9ACE8B; '>
<input type='submit' value='Подтверждаю' name='B1' style='border:1px solid #9ACE8B; font-family: Verdana, Arial; font-size: 8pt; background-color:#F1FFED'></p>
</form>";

}
Else {
?>
    <table border="0" width="100%" cellspacing="0" cellpadding="0">
<?
 If ($lst == "") {
  $lst = "1";
 }

 $ff = @file("tx/forum.txt");
 $rd = $ff;

 for ($i = 0; $i < count($rd); $i++) {
  $ff[count($rd)-$i-1] = $rd[$i];
 }

 $lfrom = (integer) $lst * $serv_const_lstcount - $serv_const_lstcount;
 $lto = (integer) $lst * $serv_const_lstcount;
 If ($lto > count($ff)) {
  $lto = count($ff);
 }

 for ($i = $lfrom; $i < $lto; $i++) {
  $ar = explode("^", trim($ff[$i]));
  $tid = count($ff)-$i-1;
  echo "
      <tr>
        <td width='30%' valign='top' style='border-bottom: 1px solid #9ACE8B; ; border-left-color:#9ACE8B; border-right-color:#9ACE8B; border-top-color:#9ACE8B'>
          <p><img src='img/pic_mail_old.gif' border='0'> от: <b><a class='cap2' href='mailto:$ar[1]'>$ar[0]</a></b></p>
          <p>отправлено: $ar[3]</p>
          <p>IP: $ar[2], <a href='forum.php?d_id=$tid' class='cap0'>d</a></p>
        </td>
        <td width='70%' valign='top' style='border-bottom: 1px solid #9ACE8B; ; border-left-color:#9ACE8B; border-right-color:#9ACE8B; border-top-color:#9ACE8B'><p>$ar[4]</p></td>
      </tr>";
 }
 ?>
    </table>

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

 <p>&nbsp;&nbsp;Страница:
 <?
 for ($c = 1; $c <= ceil(count($ff) / $serv_const_lstcount); $c++) {
  If ($lst == $c) {
   echo "<b><a href='/forum.php?lst=$c' class='cap3'>$c</a></b>";
  }
  Else {
   echo "<a href='/forum.php?lst=$c' class='cap4'>$c</a>";
  }
  If ($c <> ceil(count($ff) / $serv_const_lstcount)) {
   echo " | ";
  }
 }
 ?>
 </p>
 <p align="center">
 <input type="button" value="Добавить сообщение" name="B1" onClick="document.location.href='/forum.php?com=msgadd'" style="border:1px solid #9ACE8B; font-family: Verdana, Arial; font-size: 8pt; background-color:#F1FFED"></p>
<?
}
?>