File size: 1.46Kb
<?php
/**********************************
* @package: PerfCMS *
* @year: 2012 *
* @author: Artas *
* @link: http://perfcms.pp.ua *
**********************************/
$mail_r = $db->query("SELECT * FROM `mail` WHERE `id` = '".abs(intval($_GET['id'])) ."'")->fetch();
if(isset($user) && $mail_r['who_id'] == $user['id']) {
if(isset($_POST['send']) && $_GET['act'] == 'send') {
$message = input($_POST['text']);
if(!empty($message)) { $text = substr($message, 0, 5000); } else { $err = 'Message is empty'; }
if(!isset($err)) {
$db->query("INSERT INTO `mail` SET `user_id` = '". $user['id'] ."', `who_id` = '". $mail_r['user_id'] ."', `text` = '$text', `time` = '". time() ."', `read` = '0'");
go('/mail/');
}
}
$db->query("UPDATE `mail` SET `read` = '1' WHERE `id` = '".abs(intval($_GET['id'])) ."'");
$locate = 'in_cabinet';
$title = $lang->word('u_mail');
require_once(SYS.'/view/header.php');
$tpl->div('title', $lang->word('u_mail'));
$tpl->div('post', nick($mail_r['user_id']).' '.rtime($mail_r['time']).' <br/>'.output($mail_r['text']));
$tpl->div('menu', '<b>'.$lang->word('reply') .'</b>:<br/>
<form action="/mail/'.$_GET['id'].'/?act=send" method="post">
<textarea name="text" rows="5" cols="26"></textarea><br/>
<input name="send" type="submit" value="'. $lang->word('send').'"/>
</form>');
$tpl->div('block', HICO. '<a href="/">'. $lang->word('home') .'</a>');
require_once(SYS.'/view/footer.php');
} else { go('/'); }
?>