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

$title="Переписка";
$titl=$title;

require ('../user/top.php'); 

if($_REQUEST['ms']=='pr')
echo '<p><a href="mess_u.php?ms=otvet&vizavi=0"><font size=+1>Написать письмо администратору</font></a></p>';

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

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

elseif($_REQUEST['ms']=='vhod')
{
$x='От кого: ';
$y='ot_kogo';
$z='autor';
$lok = " (komu = '".$_SESSION['ID_P'][1]."' OR komu = '-1')  AND pr='0' ";
include_once('mess_len_u.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 ot_kogo='".$_SESSION['ID_P'][1]."' 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 = '".$_SESSION['ID_P'][1]."'  AND pr='1' ";
include_once('mess_len_u.php');
$dop='&ms=pr';
}

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

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

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

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

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

?>