View file priv.php

File size: 2.6Kb
<?
include $_SERVER['DOCUMENT_ROOT']."/template/head.php";

$priv = $_GET['priv'];
$otpr = $_GET['otpr'];
$mail = $_GET['mail'];

$user_prof = mysql_query("select * from `prof` where `id`='$mail'") or die(mysql_error());
	

	if(!empty($otpr))
	{
	$data = $den.' '.$mesac.' '.$god.'г.<br/>'.$time;
	if(mysql_query("insert into `priv`(`komu`,`ot_kogo`,`data`,`text`) values('".check($otpr)."','$id','$data','".check($_POST[text])."');")){echo "Сообщение добавлено!<br/>";} else {echo mysql_error();}

	}

	echo'<div class="e"><p><a href="priv.php?priv=prin">Входящие</a></p>
	<p><a href="priv.php?priv=otpr">Отправленые</a></p></div>
	</td><td valign="top" width="500" align="left">';


while ($str = mysql_fetch_array($user_prof)) 
{
	if(!empty($mail) && empty($otpr))
	{
			echo"<form action=\"priv.php?otpr=$mail\" method=\"post\">
			Получатель $str[name] $str[fam]<br/>
			сообщение:<br/>
			<textarea cols=\"25\" rows=\"3\" name=\"text\"></textarea><br/>
			<input value=\"Отправить\" type=\"submit\" /><br/>
			</form>";
	}
}

	if(empty($mail) && empty($otpr))
	{
	if(empty($priv)){$priv="prin";}
	$max_mess=30;
	$page=$_GET[page];
	if(empty($page)){$page=0;}
	if($priv == "otpr"){$result_sten = mysql_query("select * from `priv` where ot_kogo='$id' ORDER BY `id` DESC  LIMIT ".$page." ,".$max_mess."");}
	if($priv == "prin"){$result_sten = mysql_query("select * from `priv` where komu='$id' ORDER BY `id` DESC  LIMIT ".$page." ,".$max_mess."");}
	$count_sten = mysql_fetch_array($result_sten)
	if($count_sten == 0){echo'Нет сообщений!';}
	while ($mess_sten = mysql_fetch_array($result_sten)) 
	{
		echo '<br/><div class="f"><table><tr><td valign="top" width="30%" align="left">';
		if($priv == "otpr"){$result_sten_log = mysql_query("select * from `prof` where id='$mess_sten[komu]'");}
		if($priv == "prin"){$result_sten_log = mysql_query("select * from `prof` where id='$mess_sten[ot_kogo]'");}
		while ($sten_log = mysql_fetch_array($result_sten_log)) 
		{	
			echo'';
			photo_sten($sten_log[foto],$sten_log[id]);
			echo '</td><td valign="top" width="60%" align="left">';
			echo '<b>'.$sten_log[name].' '.$sten_log[fam].'<br/>'.$mess_sten[data].'<p/>';
			//echo on($sten_log[0]).'<br/>';
			echo $mess_sten[text].'</b><br/>';
			echo '</td><td valign="top" width="10%">';
			if($priv == "prin"){echo'<a href="./priv.php?mail='.$mess_sten[ot_kogo].'">ответить</a><p>';}
			echo'';
		}
			echo '</td></tr></table></div>';
	}	
	}






include $_SERVER['DOCUMENT_ROOT']."/template/foot.php";
?>