Просмотр файла file/letters/letters.php

Размер файла: 5.54Kb
<?php

Error_Reporting(E_ALL & ~E_NOTICE);
Error_Reporting (ERROR | WARNING);

extract($HTTP_GET_VARS);
extract($HTTP_POST_VARS);
extract($HTTP_COOKIE_VARS);
extract($HTTP_SERVER_VARS);
extract($HTTP_SESSION_VARS);

session_name('SESID');
session_start();
require("../../mysql.php");
require ('../../config.php'); //Подключаем настройки сайта. (config.php)
require ('../../themes/'.$themes.'.php'); //Вставляем скин сайта.
	echo "<div>";
echo "<div style='text-align: center'>ПИСЬМА</div>";
function tr_to_win($str)
{
$str=strtr($str,array("__"=>" ","_"=>"","a"=>"а","b"=>"б","v"=>"в","g"=>"г","d"=>"д","e"=>"е","yo"=>"ё","zh"=>"ж","z"=>"з","i"=>"и","j"=>"й","k"=>"к","l"=>"л","m"=>"м","n"=>"н","o"=>"о","p"=>"п","r"=>"р","s"=>"с","t"=>"т","u"=>"у","f"=>"ф","h"=>"х","c"=>"ц","ch"=>"ч","sh"=>"ш","sch"=>"щ","q"=>"ъ","x"=>"ы","%"=>"ь","ye"=>"э","yu"=>"ю","ya"=>"я",
"A"=>"А","B"=>"Б","V"=>"В","G"=>"Г","D"=>"Д","E"=>"Е","YO"=>"Ё","ZH"=>"Ж","Z"=>"З","I"=>"И","J"=>"Й","K"=>"К","L"=>"Л","M"=>"М","N"=>"Н","O"=>"О","P"=>"П","R"=>"Р","S"=>"С","T"=>"Т","U"=>"У","F"=>"Ф","H"=>"Х","C"=>"Ц","CH"=>"Ч","SH"=>"Ш","SCH"=>"Щ","Q"=>"Ъ","X"=>"Ы","YE"=>"Э","YU"=>"Ю","YA"=>"Я"));
 return $str;
}
$msg = hack_to_good(htmlspecialchars(stripslashes($_POST['msg'])));
$foruser= hack_to_good(htmlspecialchars(stripslashes($_POST['foruser'])));
$realtime= hack_to_good(htmlspecialchars(stripslashes($realtime)));
if ($_POST[msgtrans]==1)
{
$msg = tr_to_win($msg);
}

if (!empty($_SESSION['login']))
{
	 if ($act=="send")
	 	{
		if (!empty($foruser) and !empty($msg))
		{$m = mysql_query("select * from `users` where name='".$foruser."';");
		$count = mysql_num_rows($m);
		if ($count==1)
		{$realtime=time()+$sdvigclock*3600;
		mysql_query("insert into `letters` values(0,'".$foruser."','".$msg."','".$realtime."','".$_SESSION['login']."','in','no');");
		mysql_query("insert into `letters` values(0,'".$foruser."','".$msg."','".$realtime."','".$_SESSION['login']."','out','no');");
		echo"Письмо отправлено!";
		} else {echo "<div>Такого пользователя не существует</div>";}
		}
		else
		{echo "<div>Не введено имя пользователя или сообщение!</div>";
		}
	}












	if ($act=="write")
	{if (!empty($otv))
	{$messages = mysql_query("select * from `users` where id='".intval($otv)."';");
	$user = mysql_fetch_array($messages);
	}
		echo "<div>Написать письмо";
echo   "<form action='letters.php?act=send' method='post'>
	 Для<br/>
<input type='text' name='foruser' value='".$user['name']."' />
      <br /> Cообщение<br />
        <textarea rows='5' name='msg'></textarea><br/><br />
        <input type='checkbox' name='msgtrans' value='1' /> Транслит сообщения
      <br/>
      <input type='submit' value='добавить' />
  </form>";
  echo "<a href='letters.php?act=trans'>Транслит</a><br /></div>";
	}



	if ($act=="in")
	{
$messages = mysql_query("select * from `letters` where user='$_SESSION[login]' and type='in' order by time desc;");
 echo "<div class='c'>Входящие</div>";
   while($massiv = mysql_fetch_array($messages))
   { $mas = mysql_fetch_array(@mysql_query("select * from `users` where `name`='$massiv[author]';"));
     echo "<hr /><a href='../../search.php?user=".$mas[id]."'>$massiv[author]</a> ".date("d.m.y H:i",$massiv[time])."<br />$massiv[text]<br/><a href='letters.php?act=write&amp;otv=".$mas[id]."'>Ответить</a><br/><a href='letters.php?act=delmess&amp;del=".$massiv[id]."'>Удалить</a>";
   if ($massiv['read']=="no")
      { mysql_query("update `letters` set `read`='yes' where `id`='".$massiv['id']."';");
      }
    }
	}

	if ($act=="delmess")
	{mysql_query("delete from `letters` where `id`='".intval($del)."';");
	echo "<div>Сообщение удалено!</div>";}

	 if ($act=="out")
	{
$messages = mysql_query("select * from `letters` where author='".$_SESSION['login']."' and type='out' order by time desc;");
echo "<div class='c'>Исходящие</div>";
   while($massiv = mysql_fetch_array($messages))
   {
   echo "<div><div class='b'>Для: $massiv[user] ".date("d.m.y H:i",$massiv[time])."</div>$massiv[text]<br/><a href='letters.php?act=delmess&amp;del=".$massiv[id]."'>Удалить</a></div>";
	}
	}
	echo "<hr/><div><a href='index.php'>В письма</a><br />";
    echo "<a href='letters.php?act=write'>Написать</a></div>";

}
  if ($_GET[act]=="trans")
   {

      echo "<div>Правила транслита";

echo "<br/>
а - a<br/>
б - b<br/>
в - v<br/>
г - g<br/>
д - d<br/>
е - e<br/>
ё - yo<br/>
ж - zh<br/>
з - z<br/>
и - i<br/>
к - k<br/>
л - l<br/>
м - m<br/>
н - n<br/>
о - o<br/>
п - p<br/>
р - r<br/>
с - s<br/>
т - t<br/>
у - u<br/>
ф - f<br/>
х - h<br/>
ц - c<br/>
ч - ch<br/>
ш - sh<br/>
щ - sch<br/>
ъ - q<br/>
ы - x<br/>
ь - %<br/>
э - ye<br/>
ю - yu<br/>
я - ya<br/><br/>
А - A<br/>
Б - B<br/>
В - V<br/>
Г - G<br/>
Д - D<br/>
Е - E<br/>
Ё - YO<br/>
Ж - ZH<br/>
З - Z<br/>
И - I<br/>
К - K<br/>
Л - L<br/>
М - M<br/>
Н - N<br/>
О - O<br/>
П - P<br/>
Р - R<br/>
С - S<br/>
Т - T<br/>
У - U<br/>
Ф - F<br/>
Х - H<br/>
Ц - C<br/>
Ч - CH<br/>
Ш - SH<br/>
Щ - SCH<br/>
Ъ - Q<br/>
Ы - X<br/>
Э - YE<br/>
Ю - YU<br/>
Я - YA<br/>
";
   }
   echo "</div>";
require ('../../foot.php');
?>