Просмотр файла mail/write.php

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

require '../inc/func.php';
bk_head('Nhắn Tin');
require '../inc/head.php';

$mid = num($_GET['id_cont']);
if(!$user){
	header('Location: /index.php');
}

$sql = mysql_query("SELECT * FROM cont WHERE (id_ser = '$userid' OR	id_ger = '$userid') AND (id = '$mid')");
$inf = mysql_fetch_assoc($sql);
if(!mysql_num_rows($sql)){
	err (''.$write_mail['no_cont'].'</div>');
	bk_foot();
	exit;
}

if ($inf['id_ger'] == $userid) {
	$inf['id_ger'] = $inf['id_ser'];
}
echo '<div class="list1"><div class="tt">'.$write_mail['title'].'</div>';

if(isset($_POST['send']) && strlen($_POST['messages']) > 2){
	$mes = bk_check($_POST['messages']);

		mysql_query("UPDATE cont SET time = '".time()."' WHERE id = '$mid'");

		mysql_query("INSERT INTO messages SET time = '".time()."', id_ser = '$userid', id_ger = '$inf[id_ger]', msg = '$mes', cont = '$mid'");
		
		header("Location: /mail/write$mid?");

}

if(isset($_GET['smile'])) {
header('location: /smile.php');
}

?>


	<form method="post" action="write<?=$mid?>">
	<textarea name="messages"></textarea><br />
	<input type="submit" name="send" value="<?php echo $send_mail['send']; ?>" />
	&nbsp;<a href="write<?=$mid?>-smile" title="Smiles"><img src="/images/smile.gif" alt="*" /></a>
	</form><br />

<?php

###pages###
$count_m = mysql_result(mysql_query("SELECT COUNT(id) FROM messages WHERE cont = '$mid'"), 0);
$display = 5;
$count_pages = ceil($count_m/$display);
$page = (isset($_GET['page']) and is_numeric($_GET['page']) and $_GET['page']>1 and $_GET['page']<=$count_pages) ? $_GET['page'] : 1;
$start = $page*$display-$display;
###########

$qmsg = mysql_query('SELECT * FROM messages WHERE cont = '.$mid.' ORDER BY time DESC LIMIT '.$start.','.$display);

while($vmsg = mysql_fetch_assoc($qmsg)){
	if($vmsg['id_ger']==$userid && $vmsg['read']=="0"){
		mysql_query("UPDATE `messages` SET `read` = '1' WHERE `id` = '$vmsg[id]'");
	}

echo ''.user($vmsg['id_ser']).'<br />';
echo ''.smiles(tags($vmsg['msg'])).'';
echo '<br />&bull;'.time_post($vmsg['time']).'<hr><br />';
	}
if($count_m > 5 && $page < $count_pages)
{
echo '<div class="shadow">';
pages($page,$count_pages,"/mail/write$mid&page=");
echo '</div>';
}	
echo '<br /><br />';
echo '<hr><div class="shadow"><a href="/users/my.php"><b>My Menu</b></a> | <a href="/u/'.$userid.'"><b>Profile</b></a> | <a href="/exit.php"><b>LogOut</b></a></div></div>';	
bk_foot();
?>