Файл: BlogExl_v_3/modules/my/mail.php
Строк: 65
<?
if(!isset($user['id'])){header('location:/');}
$id = $func->num($_GET['id']);
head('Почта');
info();
echo '<div class="post2"><a href="?in">Входящие письма</a> ('.$dbs->query("SELECT * FROM `mail` WHERE `komu` = '$user[id]'")->num_rows.'/<b>'.$dbs->query("SELECT * FROM `mail` WHERE `komu` = '$user[id]' AND `read` = '0'")->num_rows.'</b>)</div>';
echo '<div class="post2"><a href="?out">Исходящие письма</a> ('.$dbs->query("SELECT * FROM `mail` WHERE `kto` = '$user[id]'")->num_rows.')</div>';
if(isset($_GET['del'])){
$dbs->query("DELETE FROM `mail` where `id` = '$id' limit 1");
header('location:?');
}
if(isset($_GET['in'])){
$ram = $dbs->query("SELECT * FROM `mail` where `komu` = '$user[id]'")->num_rows;
$num = 10;
$total = intval(($ram - 1) / $num) + 1;
$page = abs(intval($_GET['page']));
if(empty($page) or $page < 0) $page = 1;
if($page > $total) $page = $total;
$start = $page * $num - $num;
$q = $dbs->query("SELECT * FROM `mail` WHERE `komu` = '$user[id]' ORDER BY `time` DESC LIMIT $start,$num");
if(!$q->num_rows){$func->msg('Пока пусто...');}
while($m = $q->fetch_assoc()){
$dbs->query("UPDATE `mail` SET `read` = '1' WHERE `id` = '$m[id]' limit 1");
echo '<div class="text_stat">
От: '.$func->nik($m['kto']).' '.($m['read']==0?'<font color="red">(не прочитано)</font>':'<font color="green">(прочитано)</font>').'<br/>Отправлено: '.times($m['time']).'<br />Текст: '.$func->out($m['msg']).'<br/><a href="?send&id='.$m['kto'].'">Ответить</a> | <a href="?id='.$m['id'].'&del">Удалить</a></div>';
}
str('?in&');
}
if(isset($_GET['send'])){
$id = $func->num($_GET['id']);
$q = $dbs->query("SELECT id,login FROM `blogger` WHERE `id` = '$id'");
if(!$q->num_rows>0 OR $user['id'] == $id){header('Location: ?');}
$a = $q->fetch_assoc();
echo '<div class="text_stat"><form action="?send&id='.$id.'&go" method="post">
Кому: <b>'.$a['login'].'</b><br/>
Сообщение (3-1000):<br /><textarea name="msg" rows="3" cols="20"></textarea><br/><input type="submit" value="Отправить"/></form></div>';
}
if(isset($_GET['go'])){
$msg = $func->txt($_POST['msg']);
if(mb_strlen($msg)>2 AND mb_strlen($msg)<1000){$err .='Не верная длина сообщения!';}
if(isset($err)){
$dbs->query("INSERT INTO `mail` SET `kto` = '$user[id]', `komu` = '$id', `msg` = '$msg', `time` = '$time', `read` = '0'");
echo '<div class="post2">Сообщение отправлено!</div>';foot();exit();}
}
if(isset($_GET['out'])){
$ram = $dbs->query("SELECT * FROM `mail` where `kto` = '$user[id]'")->num_rows;
$num = 10;
$total = intval(($ram - 1) / $num) + 1;
$page = abs(intval($_GET['page']));
if(empty($page) or $page < 0) $page = 1;
if($page > $total) $page = $total;
$start = $page * $num - $num;
$q = $dbs->query("SELECT * FROM `mail` WHERE `kto` = '$user[id]' ORDER BY `time` DESC LIMIT $start,$num");
if(!$q->num_rows){$func->msg('Пусто...');}
while($m = $q->fetch_assoc()){
echo '<div class="post2">Кому: '.$func->nik($m['komu']).'
('.times($m['time']).')'.($m['read']==0?'<font color="red">(не прочитано)</font>':'<font color="green">(прочитано)</font>').'<br />Текст: '.$func->out($m['msg']).'<br/><a href="?send&id='.$m['komu'].'">Написать еще</a> | <a href="?id='.$m['id'].'&del">Удалить</a></div>';
}
str('?out&');
}
$func->error($err);
foot();
?>