<?
session_start();
require_once('../connect/connect.php');
include_once('../lib/lib.php');
require('../admin/pdk.php');

$titl="Переписка";
require ('../admin/top.php'); 

echo '<p><a href="mess.php?ms=old"><font color=red>Удалить старые сообщения</font></a></p>';

if($_REQUEST['ms']=='pr')
echo '<p><a href="mess.php?ms=otvet&vizavi=-1"><font size=+1>Написать сообщение для всех пользователей</font></a></p>';

if($_REQUEST['ms']=='history')
{
$vizavi=intval($_GET['vizavi']);
if($vizavi != -1)
echo '<p><a href="mess.php?ms=otvet&vizavi='.$vizavi.'"><font size=+1>Написать ответ этому пользователю</font></a></p>';
$lok = " ((komu = '0' AND ot_kogo = '".$vizavi."') OR (komu = '".$vizavi."' AND ot_kogo = '0')) AND pr='0' ";
include_once('mess_history.php');
$dop='&ms=history&vizavi='.$vizavi;
}

elseif($_REQUEST['ms']=='otvet')
{
$vizavi=intval($_REQUEST['vizavi']);
include_once('mess_otvet.php');
}

elseif($_REQUEST['ms']=='vhod')
{
$x='От кого: ';
$y='ot_kogo';
$z='autor';
$lok = " komu = '0' AND pr='0' ";
include_once('mess_len.php');
$dop='&ms=vhod';
}

elseif($_REQUEST['ms']=='pr')
{
if($_GET['pr']) $pr=intval($_GET['pr']);
if($pr)
	{
	$rw=mysql_query("SELECT * FROM mess WHERE id_mess='".$pr."' AND pr='1'");
	$nrw=mysql_num_rows($rw);
	if($nrw)
		{
		mysql_query("UPDATE mess SET pr='0', data=NOW() WHERE id_mess='".$pr."'");
		}
	}
$x='Кому: ';
$y='komu';
$z='autor_komu';
$lok = " ot_kogo = '0' AND pr='1' ";
include_once('mess_len.php');
$dop='&ms=pr';
}

elseif($_REQUEST['ms']=='ishod')
{
$x='Кому: ';
$y='komu';
$z='autor_komu';
$lok = " ot_kogo = '0' AND pr='0' ";
include_once('mess_len.php');
$dop='&ms=ishod';
}

elseif($_REQUEST['ms']=='edit' && $_GET['pr'])
{
$pr=intval($_GET['pr']);
$lok = " ot_kogo = '0' AND id_mess='".$pr."' AND pr='1' ";
$per='mess.php?ms=edit&pr='.$pr;
$perr='mess.php?ms=pr';
include_once('mess_edit.php');
}

elseif($_REQUEST['ms']=='del' && $_GET['pr'])
{
$pr=intval($_GET['pr']);
$lok = " ot_kogo = '0' AND id_mess='".$pr."' AND pr='1' ";
$perr='mess.php?ms=pr';
include_once('mess_del.php');
}

elseif($_REQUEST['ms']=='old')
{
include_once('mess_old.php');
}

pages3(15, $totalPages_Recordset1, $_GET['pn'], $dop);

require('../admin/bottom.php');

?>