Файл: diary.php
Строк: 575
<?php
require('connect.php');
$location = 'diary';
switch($_GET['act'])
{
//~~~~~~~~~Создание записи~~~~~~~~~~~~~~~//
case 'add':
if(!$u['id']){
header ("Location: registration.php?err=1");
exit;
}
$title = $title.' | Дневники';
require('head.php');
require('core/panel.php');
echo '<div class="title"><img src="ico/notes.png" alt="!"/> <a href = "diary.php">Дневники</a> <b>Новая запись</b></div>';
$flood = mysql_query("SELECT `time` FROM `diary_messages` WHERE `user` = '".$u['id']."' AND `time` > '" . (time() - $system['diary_antiflud']) . "'");
if (mysql_num_rows($flood)) {
error(' <b>Ошибка</b>!</br> Можно добавлять дневники только раз в '.$system['diary_antiflud'].' сек.');
require('foot.php');
exit;
}
if (isset($_POST['submit']) && $_POST['name'] && $_POST['message']) {
$name = check(substr($_POST['name'], 0, 100));
$message = check(substr($_POST['message'], 0, 10000));
$priv = num($_POST['priv']);
$comm_priv = num($_POST['comm_priv']);
$sex = num($_POST['18']);
if (empty($name)){
echo ' Ошибка , так делать нельзя !<br/>'; $error = '1';
}
if (empty($error)){
mysql_query("INSERT INTO `diary_messages` SET
`user` = '".$u['id']."',
`name` = '$name',
`message` = '$message',
`priv` = '$priv',
`comm_priv` = '$comm_priv',
`18` = '$sex',
`time` = '".time()."',
`rating` = '0',
`view` = '0'
");
$id = mysql_insert_id();
if($u['sex'] == 'm'){
$action[0] = 'Опубликовал';
} else {
$action[0] = 'Опубликовала';
}
$text = $action[0].' <a href = "diary.php?act=message&id='.$id.'&link=1">дневник</a>.';
mysql_query("INSERT INTO `lenta` SET
`user` = '".$u['id']."',
`text` = '$text',
`time` = '".time()."',
`forum` = '0',
`blog` = '0',
`foto` = '0',
`diary` = '1',
`comm` = '0'
");
mysql_query("UPDATE `users` SET `rating` = `rating`+10 WHERE `id` = '".$u['id']."'");
$name = check(substr($_POST['name'], 0, 100));
ok('Запись <a href = "diary.php?act=message&id='.$id.'&link=1"><b>'.$name.'</b></a> успешно добавлена в <a href = "diary.php?act=view">Ваш дневник!</a>');
}
} else {
echo '<div class="div">';
echo '<form action="diary.php?act=add" method="post" name="form">';
echo 'Название: 100 символов:<br/><input type="text" name="name" maxlength="50"placeholder="Название дневника..."><br/>';
echo 'Текст: 10000 символов:<br/>';
echo ''.panel().'';
echo '<textarea cols="20" rows="3" name="message"placeholder="Описание..."></textarea><br/>';
echo '</div>';
echo '<div class="div">';
echo 'Помощь: <small><a href = "smiles.php">Смайлы</a> | <a href = "code.php">BB-коды</a></small>';
echo '</div>';
echo '<div class="div">';
echo 'Доступен: <br/><select name="priv">
<option value="0">Всем</option>
<option value="1">Друзьям</option>
<option value="2">Только мне</option>
</select><br/>
Комментирование разрешено: <br/><select name="comm_priv">
<option value="0">Да</option>
<option value="1">Нет</option>
</select></div>';
echo '<div class="div">Внимание! Все материалы эротического содержания, а также содержащие ненормативную лексику должны
в обязательном порядке снабжаться меткой <span style="color:red;">(18+)</span> "Для взрослых".</br>
<span style="color:red;">За нарушение правил, ваш ник может быть заблокирован навсегда.</span>
</div><div class="div">';
echo '<input name="18" type="checkbox" value="1"/> Только для взрослых<br/>';
echo '<input type="submit" name="submit" value="Добавить" class="submit white"></form>';
}
echo '</div>';
require('foot.php');
break;
//~~~~~~~~~~~~~~~~Дневник пользователя~~~~~~~~~~~~~~~~~~~~~~~//
case 'view':
$id=num($_GET['id']); if($id == 0) $id=$u['id'];
$req = mysql_query("SELECT * FROM `users` WHERE `id` = '$id' LIMIT 1");
if (mysql_num_rows($req))$user = mysql_fetch_assoc($req); else header ("Location: index.php");
$title = $title.' | Дневники';
require('head.php');
if(ban($user['id']) || ($user['delete'] == 1)){
error('Автор данного дневника был заблокирован !');
require('foot.php');
exit;
}
if($user['id'] == $u['id'])$zag = 'Мой дневник';else $zag = 'Дневник <a href = "/'.$user['id'].'">'.$user['login'].'</a>';
echo '<div class="title"><img src="ico/notes.png" alt="!"/> <a href = "diary.php">Дневники</a> '.$zag.' <b>Просмотр</b></div>';
if($u)echo '<div class="nav"><a href = "diary.php?act=view">Мой дневник</a> | <a href = "diary.php?act=add">Новая запись</a></div>';
$all = mysql_result(mysql_query("SELECT COUNT(*) FROM `diary_messages` WHERE `user` = '".$user['id']."'"), 0);
if($all > 0){
$total = num(($all - 1) / 10) + 1;
$page = num($_GET['page']);
if(empty($page) or $page < 0) $page = 1;
if($page > $total) $page = $total;
$start = $page * 10 - 10;
$result = mysql_query("SELECT * FROM `diary_messages` WHERE `user` = '".$user['id']."' ORDER BY `time` DESC LIMIT $start, 10");
while($message = mysql_fetch_assoc($result)){
echo $i % 2 ? '<div class="div">' : '<div class="div">';
$user = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '".$message['user']."' LIMIT 1"));
$name = checkout($message['name']);
$msg = checkout($message['message']);
if (iconv_strlen($msg, 'UTF-8') > 50) {
$msg = iconv_substr($msg, 0, 1, 'UTF-8');
$msg=''.$msg.'...';
}
$ccomm = mysql_result(mysql_query("SELECT COUNT(*) FROM `diary_comm` WHERE `diary` = '".$message['id']."'"), 0);
if(ban($user['id']) || ($user['delete'] == 1)){
echo ico($user['sex'],$user['admin']).' <a href = "/'.$user['id'].'"><del>'.$user['login'].'</del></a> ';
} else {
echo ico($user['sex'],$user['admin']).' <a href = "/'.$user['id'].'">'.$user['login'].'</a> ';
}
if($user['rating']>=1000 && $user['rating']<=1999)echo "<img src='ico/b.png' alt='' class='icon'</a>n";
if($user['rating']>=2000 && $user['rating']<=2999)echo "<img src='ico/s.png' alt='' class='icon'</a>n";
if($user['rating']>=3000)echo "<img src='ico/z.png' alt='' class='icon'</a>n";
echo '/ <a href = "diary.php?act=message&id='.$message['id'].'&link=1">'.$name.'</a> / <span style="font-size: small; color:#209143">'.vremya($message['time']).'</span>';
if($message['18'] == 1) echo ' <font color="red">18+</font>';
echo '<br/>';
if($message['priv'] == 2 || $message['priv'] == 1 || $message['18'] == 1) {
echo 'Просмотр недоступен !';
if($message['priv'] == 2 || $message['priv'] == 1) echo ' <img src="ico/lock.gif" alt="image" /> ';
} else {
echo ''.$msg.'';
}
echo '</br><img src="ico/comment.png" alt="!" /> <a href = "diary.php?act=message&id='.$message['id'].'&link=1">Комментарии</a> ('.$ccomm.')</br>';
if (($message['user'] == $u['id']) || ($u['admin'] == 1 || $u['admin'] == 2)) {
echo '<small> [<a href = "diary.php?act=edit&id='.$message['id'].'">Ред</a>]
[<a href = "diary.php?act=delete&id='.$message['id'].'"><b><font color="red">x</font></b> Удал</a>]</small>'; }
echo '</div>';
$i++;
}
echo '</div>';
echo '</div>';
navigation($page, $total,'diary.php?act=view&id='.$user['id'].'&sort='.$sort.'&');
}else{
error(' Записей пока нет !');
}
echo '</div>';
require('foot.php');
break;
//~~~~~~~~~~~~~~~~Редактирование~~~~~~~~~~~~~~~~~~~~//
case 'edit':
if(!$u['id']){
header ("Location: registration.php?err=1");
exit;
}
if(isset($_GET['id'])){
$id=num($_GET['id']);
$req = mysql_query("SELECT * FROM `diary_messages` WHERE `id` = '$id' LIMIT 1");
if (mysql_num_rows($req)){
$msg = mysql_fetch_assoc($req);
} else {
require('head.php');
echo '<div class="title"><img src="ico/notes.png" alt="!"/> <a href = "diary.php">Дневники</a> <b>Ошибка</b></div>';
error(' Ошибка, такого дневника нет !');
require('foot.php');
exit;
}
} else {
header ("Location: diary.php");
exit;
}
if($u['admin'] == 1 || $u['admin'] == 2 || $msg['user'] == $u['id']){
$title = $title.' | Дневники';
require('head.php');
require('core/panel.php');
echo '<div class="title"><img src="ico/notes.png" alt="!"/> <a href = "diary.php">Дневники</a> <b>Редактирование</b></div>';
$cdiary = mysql_result(mysql_query("SELECT COUNT(*) FROM `diary_messages` WHERE `user` = '".$u['id']."'"), 0);
echo '<div class="nav"><a href = "diary.php?act=view">Мой дневник</a> ('.$cdiary.')</div>';
if (isset($_POST['submit']) and $_POST['name'] and $_POST['message']) {
$name = check(substr($_POST['name'], 0, 100));
$decer = check(substr($_POST['message'], 0, 10000));
$priv = num($_POST['priv']);
$comm_priv = num($_POST['comm_priv']);
$sex = num($_POST['18']);
$who = num($_POST['who']);
if (empty($name)){
echo ' Ошибка , так делать нельзя !<br/>'; $error = '1';
}
if (empty($error)){
mysql_query("UPDATE `diary_messages` SET
`name` = '$name',
`message` = '$decer',
`priv` = '$priv',
`comm_priv` = '$comm_priv',
`18` = '$sex',
`who` = '".$u['id']."',
`cedit` = `cedit`+1,
`etime` = '".time()."'
WHERE `id` = '$id'
");
if($u['admin'] == 1 || $u['admin'] == 2 and $msg['user'] != $u['id']) {
if($u['sex'] == 'm'){
$action[0] = 'Отредактировал';
} else {
$action[0] = 'Отредактировала';
}
$text = $action[0].' <a href = "diary.php?act=message&id='.$msg['id'].'&link=1">дневник</a>.';
mysql_query("INSERT INTO `admin_jurnal` SET
`user` = '".$u['id']."',
`text` = '$text',
`time` = '".time()."',
`news` = '0',
`forum` = '0',
`diary` = '1',
`chat` = '0',
`blog` = '0',
`foto` = '0',
`ban` = '0',
`edit` = '0',
`new` = '1'
");
}
ok(' Изменения сохранены !');
}
} else {
$name = $msg['name'];
$message = $msg['message'];
echo '<div class="div">';
echo '<form action="diary.php?act=edit&id='.$id.'" method="post" name="form">';
echo 'Название: 100 символов:<br/><textarea cols="20" rows="1" name="name"style="width: 30%;height: 20px;">'.$name.'</textarea><br/>';
echo 'Текст:10000 символов:<br/>';
echo ''.panel().'';
echo '<textarea cols="20" rows="3" name="message" >'.$message.'</textarea><br/>';
echo '</div>';
echo '<div class="div">';
echo 'Помощь: <small><a href = "smiles.php">Смайлы</a> | <a href = "code.php">BB-коды</a></small>';
echo '</div>';
echo '<div class="div">';
echo 'Доступен: <br/><select name="priv">
<option value="0"' . ($msg['priv'] == '0' ? ' selected="selected"' : '') . '>Всем</option>
<option value="1"' . ($msg['priv'] == '1' ? ' selected="selected"' : '') . '>Друзьям</option>
<option value="2"' . ($msg['priv'] == '2' ? ' selected="selected"' : '') . '>Только мне</option>
</select><br/>';
echo 'Комментирование разрешено: <br/><select name="comm_priv">
<option value="0"' . ($msg['comm_priv'] == '0' ? ' selected="selected"' : '') . '>Да</option>
<option value="1"' . ($msg['comm_priv'] == '1' ? ' selected="selected"' : '') . '>Нет</option>
</select><br/></div>';
echo '<div class="div">Внимание! Все материалы эротического содержания, а также содержащие ненормативную лексику должны
в обязательном порядке снабжаться меткой <span style="color:red;">(18+)</span> "Для взрослых".</br>
<span style="color:red;">За нарушение правил, ваш ник может быть заблокирован навсегда.</span>
</div><div class="div">';
echo '<input name="18" type="checkbox" value="1"' . ($msg["18"] == 1 ? ' checked' : '') . '/> Только для взрослых<br/>';
echo '<input type="submit" name="submit" value="Сохранить" class="submit white"/>';
echo '</form></div>';
}
echo '</div>';
require('foot.php');
} else {
require('head.php');
echo '<div class="title"><img src="ico/notes.png" alt="!"/> <a href = "diary.php">Дневники</a> <b>Ошибка</b></div>';
error(' Отказано в доступе !');
require('foot.php');
exit;
}
break;
//~~~~~~~~~~~~~~~~~Удаление~~~~~~~~~~~~~~~~~~~~~~~~//
case 'delete':
if(!$u['id']){
header ("Location: registration.php?err=1");
exit;
}
if(isset($_GET['id'])){
$id=num($_GET['id']);
$req = mysql_query("SELECT * FROM `diary_messages` WHERE `id` = '$id' LIMIT 1");
if (mysql_num_rows($req)){
$message = mysql_fetch_assoc($req);
} else {
require('head.php');
echo '<div class="title"><img src="ico/notes.png" alt="!"/> <a href = "diary.php">Дневники</a> <b>Ошибка</b></div>';
error(' Ошибка, такого дневника нет !');
require('foot.php');
exit;
}
} else {
header ("Location: diary.php");
exit;
}
if($u['admin'] == 1 || $u['admin'] == 2 || $message['user'] == $u['id'])
{
$title = $title.' | Дневники';
require('head.php');
echo '<div class="title"><img src="ico/notes.png" alt="!"/> <a href = "diary.php">Дневники</a> <b>Удаление</b></div>';
echo '<div class="nav"><a href = "diary.php?act=view">Мой дневник</a></div>';
if (isset($_POST['submit'])) {
mysql_query("DELETE FROM `diary_messages` WHERE `id` = '".$id."'");
mysql_query("DELETE FROM `diary_like` WHERE `diary` = '".$id."'");
mysql_query("DELETE FROM `diary_view` WHERE `diary` = '".$id."'");
mysql_query("DELETE FROM `diary_comm` WHERE `diary` = '".$id."'");
if($u['admin'] == 1 || $u['admin'] == 2 and $message['user'] != $u['id']) {
if($u['sex'] == 'm'){
$action[0] = 'Удалил';
} else {
$action[0] = 'Удалила';
}
$text = $action[0].' <a href = "diary.php?act=message&id='.$message['id'].'&link=1">дневник</a>.';
mysql_query("INSERT INTO `admin_jurnal` SET
`user` = '".$u['id']."',
`text` = '$text',
`time` = '".time()."',
`news` = '0',
`forum` = '0',
`diary` = '1',
`chat` = '0',
`blog` = '0',
`foto` = '0',
`ban` = '0',
`edit` = '0',
`new` = '1'
");
}
ok(' Запись удалена !');
} else {
$name = $message['name'];
echo '<div class="div">';
echo 'Вы уверены, что хотите удалить запись <a href = "diary.php?act=message&id='.$message['id'].'">'.$name.'</a>?';
echo '<form action="diary.php?act=delete&id='.$id.'" method="post">';
echo '<input type="submit" name="submit" value="Да, удалить" class="submit white"/>';
echo '</form>';
echo '</div>';
}
echo '</div>';
require('foot.php');
} else {
require('head.php');
echo '<div class="title"><img src="ico/notes.png" alt="!"/> <a href = "diary.php">Дневники</a> <b>Ошибка</b></div>';
error(' Отказано в доступе !');
require('foot.php');
}
break;
//~~~~~~~~~~~~~~~~Ответ~~~~~~~~~~~~~~~//
case 'answer':
if(!$u['id']){
header ("Location: registration.php?err=1");
exit;
}
if(isset($_GET['id'])){
$id=num($_GET['id']);
$req = mysql_query("SELECT * FROM `diary_comm` WHERE `id` = '$id' LIMIT 1");
if (mysql_num_rows($req)) {
$msg = mysql_fetch_assoc($req);
}
}
if ($msg){
$diary = mysql_fetch_assoc(mysql_query("SELECT * FROM `diary_messages` WHERE `id` = '".$msg['diary']."' LIMIT 1"));
if (isset($_POST['submit']) and $_POST['message']) {
$message = check(substr($_POST['message'], 0, 10000));
if (empty($message)){
require('head.php');
error(' Ошибка , так делать нельзя !'); $error = '1';
require('foot.php');
}
if (empty($error)){
mysql_query("INSERT INTO `diary_comm` SET
`user` = '".$u['id']."',
`message` = '$message',
`time` = '".time()."',
`diary` = '".$diary['id']."'
");
if($u['sex'] == 'm'){
$action[0] = 'Прокомментировал';
} else {
$action[0] = 'Прокомментировала';
}
$text = $action[0].' <a href = "diary.php?act=message&id='.$diary['id'].'&link=1">Дневник</a>.';
mysql_query("INSERT INTO `lenta` SET
`user` = '".$u['id']."',
`text` = '$text',
`time` = '".time()."',
`forum` = '0',
`blog` = '0',
`foto` = '0',
`diary` = '1',
`comm` = '1'
");
if($diary['user'] != $msg['user']){
if($u['sex'] == 'm'){
$action[0] = 'Оставил';
} else {
$action[0] = 'Оставила';
}
$text = $action[0].' комментарий к вашей <a href = "diary.php?act=message&id='.$diary['id'].'">записи</a> в дневнике.';
mysql_query("INSERT INTO `jurnal` SET
`user` = '".$diary['user']."',
`outuser` = '".$u['id']."',
`text` = '$text',
`time` = '".time()."',
`new` = '1'
");
}
if($msg['id'] != $u['id']){
if($u['sex'] == 'm'){
$action[0] = 'Ответил';
} else {
$action[0] = 'Ответила';
}
$text = $action[0].' вам в <a href = "diary.php?act=message&id='.$diary['id'].'">дневнике</a>.';
mysql_query("INSERT INTO `jurnal` SET
`user` = '".$msg['user']."',
`outuser` = '".$u['id']."',
`text` = '$text',
`time` = '".time()."',
`new` = '1'
");
}
mysql_query("UPDATE `users` SET `rating` = `rating`+1 WHERE `id` = '".$u['id']."'");
header ("Location: diary.php?act=message&id=".$diary['id']."");
}
} else {
if($msg['user'] == $u['id']) {
require('head.php');
echo '<div class="title"><img src="ico/notes.png" alt="!"/> <a href = "diary.php">Дневники</a> <b>Ошибка</b></div>';
error(' Отказано в доступе !');
require('foot.php');
exit;
}
$title = $title.' | Дневники';
require('head.php');
require('core/panel.php');
echo '<div class="title"><img src="ico/notes.png" alt="!"/> <a href = "diary.php">Дневники</a> <b>Ответ <a href = "/'.$msg['user'].'">'.login($msg['user']).'</b></div>';
echo '<div class="app">';
echo ''.panel().'';
echo '<form action="diary.php?act=answer&id='.$id.'" method="post" name="form">';
echo '<textarea cols="20" rows="3" name="message" style="width: 97%">[u]'.login($msg['user']).'[/u] , </textarea><br/>';
echo '<input type="submit" name="submit" value="Сохранить" class="submit white"/>';
echo '<small> 10000 <a href = "smiles.php">Смайлы</a> | <a href = "code.php">BB-коды</a></small>';
echo '</form>';
echo '</div>';
require('foot.php');
}
} else {
require('head.php');
echo '<div class="title"><img src="ico/notes.png" alt="!"/> <a href = "diary.php">Дневники</a> <b>Ошибка</b></div>';
error(' Ошибка, такого сообщения нет !');
require('foot.php');
}
break;
//~~~~~~~~~~~~~~~Просмотр записи~~~~~~~~~~~~~~~~~~~//
case 'message':
if(isset($_GET['id'])){
$id=num($_GET['id']);
$req = mysql_query("SELECT * FROM `diary_messages` WHERE `id` = '$id' LIMIT 1");
if (mysql_num_rows($req)){
$message = mysql_fetch_assoc($req);
} else {
require('head.php');
echo '<div class="title"><img src="ico/notes.png" alt="!"/> <a href = "diary.php">Дневники</a> <b>Ошибка</b></div>';
error(' Ошибка, такого дневника нет !');
require('foot.php');
exit;
}
} else {
header ("Location: diary.php");
exit;
}
$user = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '".$message['user']."' LIMIT 1"));
if($u['id'] and $_POST['message']){
$msg = check(substr($_POST['message'], 0, 5000));
if (empty($msg)){
require('head.php');
error(' Ошибка , так делать нельзя !'); $error = '1';
require('foot.php');
exit;
}
$flood = mysql_query("SELECT `time` FROM `diary_comm` WHERE `user` = '".$u['id']."' AND `time` > '" . (time() - 3) . "'");
if (mysql_num_rows($flood) > 0) {
header ("Location: diary.php?act=message&id=".$message['id']."");
exit;
}
if (empty($error) and ($message['comm_priv'] == 0)){
mysql_query("INSERT INTO `diary_comm` SET
`user` = '".$u['id']."',
`message` = '$msg',
`time` = '".time()."',
`diary` = '".$message['id']."'
");
if($u['sex'] == 'm'){
$action[0] = 'Прокомментировал';
} else {
$action[0] = 'Прокомментировала';
}
$text = $action[0].' <a href = "diary.php?act=message&id='.$message['id'].'&link=1">Дневник</a>.';
mysql_query("INSERT INTO `lenta` SET
`user` = '".$u['id']."',
`text` = '$text',
`time` = '".time()."',
`new` = '1'
");
mysql_query("UPDATE `users` SET `rating` = `rating`+1 WHERE `id` = '".$u['id']."'");
if($message['user'] != $u['id']){
if($u['sex'] == 'm'){
$action[0] = 'Оставил';
} else {
$action[0] = 'Оставила';
}
$text = $action[0].' комментарий к Вашей <a href = "diary.php?act=message&id='.$message['id'].'">записи</a> в дневнике.';
mysql_query("INSERT INTO `jurnal` SET
`user` = '".$user['id']."',
`outuser` = '".$u['id']."',
`text` = '$text',
`time` = '".time()."',
`forum` = '0',
`blog` = '0',
`foto` = '0',
`diary` = '1',
`comm` = '1'
");
}
}
header ("Location: diary.php?act=message&id=".$message['id']."");
}
if($u['id']){
$req = mysql_query("SELECT * FROM `diary_view` WHERE `user` = '".$u['id']."' AND `diary` = '".$message['id']."' LIMIT 1");
if (!mysql_num_rows($req)) {
mysql_query("INSERT INTO `diary_view` SET
`user` = '".$u['id']."',
`view` = '1',
`last_time` = '".time()."',
`time` = '".time()."',
`diary` = '".$message['id']."'
");
mysql_query("UPDATE `diary_messages` SET
`view` = `view`+1
WHERE `id` = '".$message['id']."'
");
$message['view']++;
} else {
$view = mysql_fetch_assoc($req);
mysql_query("UPDATE `diary_view` SET
`view` = `view`+1,
`last_time` = '".time()."'
WHERE `id` = '".$view['id']."'
");
}
}
if($_GET['like'] && $u['id']){
$req = mysql_query("SELECT * FROM `diary_like` WHERE `user` = '".$u['id']."' AND `diary` = '".$message['id']."' LIMIT 1");
if (!mysql_num_rows($req)) {
$message['rating']++;
mysql_query("INSERT INTO `diary_like` SET
`user` = '".$u['id']."',
`time` = '".time()."',
`diary` = '".$message['id']."'
");
mysql_query("UPDATE `diary_messages` SET
`rating` = '".$message['rating']."'
WHERE `id` = '".$message['id']."'
");
header ("Location: diary.php?act=message&id=".$message['id']."");
if($message['user'] != $u['id']){
if($u['sex'] == 'm'){
$action[0] = 'Отметил';
$action[1] = 'ему';
} else {
$action[0] = 'Отметила';
$action[1] = 'ей';
}
$text = $action[0].' что '.$action[1].' понравилась ваша <a href = "diary.php?act=message&id='.$message['id'].'">запись</a> в дневнике.';
mysql_query("INSERT INTO `jurnal` SET
`user` = '".$user['id']."',
`outuser` = '".$u['id']."',
`text` = '$text',
`time` = '".time()."',
`new` = '1'
");
}
}
}
if(ban($user['id']) || ($user['delete'] == 1)){
require('head.php');
error ('Автор данного дневника был заблокирован !');
require('foot.php');
exit;
}
if($message['priv'] == 2 and $user['id'] != $u['id']) {
require('head.php');
echo '<div class="title"><img src="ico/notes.png" alt="!"/> <a href = "diary.php">Дневники</a> <b>Просмотр</b></div>';
error(' Ошибка, доступ к записи закрыт .');
require('foot.php');
exit;
}
if($message['priv'] == 1 and $user['id'] != $u['id']){
$req = mysql_query("SELECT * FROM `friends` WHERE `user` = '".$u['id']."' and friend = '".$user['id']."' LIMIT 1");
if(mysql_num_rows($req)){
} else {
require('head.php');
echo '<div class="title"><img src="ico/notes.png" alt="!"/> <a href = "diary.php">Дневники</a> <b>Просмотр</b></div>';
error(' Ошибка, доступ к записи открыт только для друзей .');
require('foot.php');
exit;
}
}
$title = $title.' | Дневники';
require('head.php');
require('core/bb_code.php');
require('core/panel.php');
$name = $message['name'];
$msg = checkout($message['message']);
echo '<div class="title"><img src="ico/notes.png" alt="!"/> <a href = "diary.php">Дневники</a> <a href = "diary.php?act=message&id='.$message['id'].'">'.$name.'</a> <b>Просмотр</b></div>';
if(!$u['id'])echo '<div class="nav">Чтобы создать дневник нужно пройти регистрацию!</div>';
if($_GET['link'] and $message['18'] == 1) {
echo '<div class="div"> <font color="red">
Внимание! Это содержимое только для взрослых!</font></br>
Нажимая ДА, Вы подтверждаете, что Вам 18 или более лет.</br>
Если Вам менее 18 лет - нажмите НЕТ.</br>
<a href = "diary.php?act=message&id='.$message['id'].'">Да</a> |
<a href = "diary.php?">Нет</a>
</div>';
require('foot.php');
exit;
}
if (($message['user'] == $u['id']) || ($u['admin'] == 1 || $u['admin'] == 2)) {
echo '<div class="nav"><a href = "diary.php?act=edit&id='.$message['id'].'">Редактировать</a> |
<a href = "diary.php?act=delete&id='.$message['id'].'">Удалить</a></div>';
}
echo '<div class="div">';
echo ''.ico($user['sex'],$user['admin']).' <a href = "/'.$message['user'].'"><u>'.login($message['user']).'</u></a> / <span style="font-size: small; color:#209143">'.vremya($message['time']).'</span> / ';
if($message['priv'] >= 1) {
echo '<b>'.$name.'</b> <img src="ico/lock.gif" alt="image" />';
} else {
echo '<b>'.$name.'</b> ';
}
if($message['18'] == 1) echo ' <font color="red">18+</font>';
echo '<br/>'.smile(links(bb_code($msg))).'</div><div class="div">';
$req = mysql_query("SELECT * FROM `diary_like` WHERE `user` = '".$u['id']."' AND `diary` = '".$message['id']."' LIMIT 1");
if (!mysql_num_rows($req)) echo '<img src = "ico/like.png"> <a href = "diary.php?act=message&id='.$message['id'].'&like=1">Мне нрав</a> ('.$message['rating'].')';
else echo '<img src = "ico/like.png"> Понравелось: '.$message['rating'].'';
echo '<br/><img src = "ico/view.gif"> Просмотров: '.$message['view'].'';
echo '</br>';
if($message['cedit'] == 1)echo '<img src="ico/edit.png" alt="!"/> Последний раз редактировалось: <a href = "/'.$message['who'].'">'.login($message['who']).'</a>('.vremya($message['etime']).') ['.$message['cedit'].' раз]';
echo '</div>';
if($u['id']){
if($message['comm_priv'] == 1) {
error(' Автор ограничил комментирование этой записи.');
} else {
echo '<div class="app">';
echo ''.panel().'';
echo '<form action="diary.php?act=message&id='.$message['id'].'" method="post" name="form">';
echo '<textarea cols="20" rows="2" name="message">';
echo '</textarea><br/>';
echo '<input type="submit" title="Нажмите для отправки" name="submit" value="Написать" class="submit white"/>
<small>5000 <a href = "smiles.php">Смайлы</a>
| <a href = "code.php">BB-коды</a></small>
</form></div>';
}
} else {
echo '<div class="zona">Извините, добавление комментариев доступно только зарегистрированным пользователям.
Регистрация быстрая и бесплатная.</div>';
}
if(isset($_GET['del'])){
$del = num($_GET['del']);
$req = mysql_query("SELECT * FROM `diary_comm` WHERE `id` = '$del' LIMIT 1");
if (mysql_num_rows($req)){
$del_comm = mysql_fetch_assoc($req);
if(($u['admin'] >= 1) || $del_comm['diary'] == $u['id']){
mysql_query("DELETE FROM `diary_comm` WHERE `id` = '$del'");
header ("Location: diary.php?act=message&id=".$message['id']."");
}
}
}
$all = mysql_result(mysql_query("SELECT COUNT(*) FROM `diary_comm` WHERE `diary` = '".$message['id']."'"), 0);
if($all > 0){
$total = num(($all - 1) / 10) + 1;
$page = num($_GET['page']);
if(empty($page) or $page < 0) $page = 1;
if($page > $total) $page = $total;
$start = $page * 10 - 10;
echo '<div class="nav">';
echo ' Комментарии: ('.$all.')';
echo '</div>';
if ($all >= 11)echo '<div class="title">';
if ($page != $total) {
echo '<a name="page-up" style="float: right; text-decoration: none;" href="#page-down"><img src = "ico/page_down.png"></a>';
}
$sort = check($_GET['sort']);
if($sort == 'message') {
$sortq = 'ASC';
if ($all >= 11)echo '<a href = "diary.php?act=message&id='.$message['id'].'&sort=time&page='.$page.'">Новые</a> | <b>Поcледние</b>';
}
if($sort == 'time' || empty($sortq)) {
$sort = 'time';
$sortq = 'DESC';
if ($all >= 11)echo '<b>Новые</b> | <a href = "diary.php?act=message&id='.$message['id'].'&sort=message&page='.$page.'">Поcледние</a>';
}
if ($all >= 11)echo '</div>';
$result = mysql_query("SELECT * FROM `diary_comm` WHERE `diary` = '".$message['id']."' ORDER BY `time` $sortq LIMIT $start, 10");
while($comm = mysql_fetch_assoc($result)){
echo $i % 2 ? '<div class="div">' : '<div class="div">';
$user = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '".$comm["user"]."'"));
$msg = checkout($comm['message']);
if($message['user'] == $user['id'])echo '<span style="float: right; font-size: x-small; color: grey">Автор</span>';
if(ban($user['id']) || ($user['delete'] == 1)){
echo ico($user['sex'],$user['admin']).' <a href = "/'.$user['id'].'"><del>'.$user['login'].'</del></a> '.online($user['online']).'';
} else {
echo ico($user['sex'],$user['admin']).' <a href = "/'.$user['id'].'">'.$user['login'].'</a> '.online($user['online']).'';
}
if($user['rating']>=1000 && $user['rating']<=1999)echo " <img src='ico/b.png' alt='' class='icon'</a>n";
if($user['rating']>=2000 && $user['rating']<=2999)echo " <img src='ico/s.png' alt='' class='icon'</a>n";
if($user['rating']>=3000)echo " <img src='ico/z.png' alt='' class='icon'</a>n";
if($user['vip'] == 1)echo "<img src='ico/vip.gif' alt='' class='icon'</a>n";
echo '<small>'. vremya($comm['time']).'</small>';
echo '<br/>'.censored(smile(links(bb_code($msg)))).'<br/>';
echo '<small>';
if($message['comm_priv'] == 0 and $user['id'] != $u['id']) {
echo '[<a href = "diary.php?act=answer&id='.$comm['id'].'">Отв</a>] ';
}
if($u['admin'] == 1 || $u['admin'] == 2 || $comm['diary'] == $u['id']) echo '[<a href = "diary.php?act=message&id='.$message['id'].'&del='.$comm['id'].'">Удал</a>]';
if($u['admin'] >= 1){
if(ban($user['id'])){
if($comm['user'] != $u['id'])echo ' [<a href = "adminka.php?act=delban_users&id='.$user['id'].'"><font color="red">Разбанить</font></a>]';
} else {
if($comm['user'] != $u['id'])echo ' [<a href = "adminka.php?act=ban_users&id='.$user['id'].'"><font color="red">Бан</font></a>]';
}
}
echo '</small>';
echo '</div>';
$i++;
}
if ($all >= 11)echo '<div class="title">';
if ($page != $total) {
echo '<a name="page-down" style="float: right; text-decoration: none;" href="#page-up"><img src = "ico/page_up.png"></a>';
}
if($sort == 'message') {
$sortq = 'ASC';
if ($all >= 11)echo '<a href = "diary.php?act=message&id='.$message['id'].'&sort=time&page='.$page.'">Новые</a> | <b>Поcледние</b>';
}
if($sort == 'time' || empty($sortq)) {
$sort = 'time';
$sortq = 'DESC';
if ($all >= 11)echo '<b>Новые</b> | <a href = "diary.php?act=message&id='.$message['id'].'&sort=message&page='.$page.'">Поcледние</a>';
}
if ($all >= 11)echo '</div>';
echo '</div>';
navigation($page, $total,'diary.php?act=message&id='.$message['id'].'&sort='.$sort.'&');
}else{
error(' Комментариев еще нет !');
}
echo '</div>';
require('foot.php');
break;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Новые~~~~~~~~~~~~~~~~~~~~~~//
case 'new':
$title = $title.' | Дневники';
require('head.php');
echo '<div class="title"><img src="ico/notes.png" alt="!"/> <a href = "diary.php">Дневники</a> <b>Новые</b></div>';
$all_msg = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `diary_messages`"), 0);
$all = mysql_result(mysql_query("SELECT COUNT(*) FROM `diary_messages` WHERE `time` > '".(time()-(60*60*24))."'"), 0);
if($all > 0){
$total = num(($all - 1) / 10) + 1;
$page = num($_GET['page']);
if(empty($page) or $page < 0) $page = 1;
if($page > $total) $page = $total;
$start = $page * 10 - 10;
echo '<div class="nav"><img src = "ico/diary_messages.png"> <a href = "diary.php?">Все записи</a> ('.$all_msg.')</div>';
$result = mysql_query("SELECT * FROM `diary_messages` WHERE `time` > '".(time()-(60*60*24))."' ORDER BY `time` DESC LIMIT $start, 10");
while($message = mysql_fetch_assoc($result)){
echo $i % 2 ? '<div class="div">' : '<div class="div">';
$user = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '".$message['user']."' LIMIT 1"));
$name = checkout($message['name']);
$msg = checkout($message['message']);
if (iconv_strlen($msg, 'UTF-8') > 50) {
$msg = iconv_substr($msg, 0, 1, 'UTF-8');
$msg=''.$msg.'...';
}
$comm = mysql_result(mysql_query("SELECT COUNT(*) FROM `diary_comm` WHERE `diary` = '".$message['id']."'"), 0);
if(ban($user['id']) || ($user['delete'] == 1)){
echo ico($user['sex'],$user['admin']).' <a href = "/'.$user['id'].'"><del>'.$user['login'].'</del></a> ';
} else {
echo ico($user['sex'],$user['admin']).' <a href = "/'.$user['id'].'">'.$user['login'].'</a> ';
}
if($user['rating']>=1000 && $user['rating']<=1999)echo "<img src='ico/b.png' alt='' class='icon'</a>n";
if($user['rating']>=2000 && $user['rating']<=2999)echo "<img src='ico/s.png' alt='' class='icon'</a>n";
if($user['rating']>=3000)echo "<img src='ico/z.png' alt='' class='icon'</a>n";
echo '/ <a href = "diary.php?act=message&id='.$message['id'].'&link=1">'.$name.'</a> / <span style="font-size: small; color:#209143">'.vremya($message['time']).'</span>';
if($message['18'] == 1) echo ' <font color="red">18+</font>';
echo '<br/>';
if($message['priv'] == 2 || $message['priv'] == 1 || $message['18'] == 1) {
echo 'Просмотр недоступен !';
if($message['priv'] == 2 || $message['priv'] == 1) echo ' <img src="ico/lock.gif" alt="image" /> ';
} else {
echo ''.$msg.'';
}
echo '</br><img src="ico/comment.png" alt="!" /> <a href = "diary.php?act=message&id='.$message['id'].'&link=1">Комментарии</a> ('.$comm.')</br>';
if (($message['user'] == $u['id']) || ($u['admin'] == 1 || $u['admin'] == 2)) {
echo '<small> [<a href = "diary.php?act=edit&id='.$message['id'].'">Ред</a>]
[<a href = "diary.php?act=delete&id='.$message['id'].'">Удал</a>]</small>'; }
echo '</div>';
$i++;
}
navigation($page, $total,'diary.php?act=new&');
}else{
error(' Записей пока нет !');
}
require('foot.php');
break;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Поиск~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
case search:
$title = $title.' | Поиск';
require('head.php');
echo '<div class="title"><img src="ico/notes.png" alt="!"/> <a href = "diary.php">Дневники</a> <b>Поиск</b></div>';
if (isset($_POST['ok'])) {
$s = check($_POST['s']);
if (empty($s)) {
header('Location: diary.php?act=search');
} else {
$all = mysql_result(mysql_query("SELECT COUNT(*) FROM `diary_messages` WHERE `name` LIKE '%$s%'"), 0);
if($all > 0){
$total = intval(($all - 1) / $count) + 1;
$page = num($_GET['page']);
if(empty($page) or $page < 0) $page = 1;
if($page > $total) $page = $total;
$start = $page * $count - $count;
echo '<div class="nav"><center>Результатов поиска <b>'.$s .'</b> найдено '.$all.' дневников !</center></div>';
$result = mysql_query("SELECT * FROM `diary_messages` WHERE `name` LIKE '%$s%' ORDER BY `id` DESC LIMIT $start, 10");
while($diary = mysql_fetch_assoc($result)) {
echo $i % 2 ? '<div class="div">' : '<div class="div">';
$name = $diary['name'];
$who = $diary['login'];
$msg = $diary['message'];
$user = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '".$diary['user']."' LIMIT 1"));
if (iconv_strlen($msg, 'UTF-8') > 11) {
$msg = iconv_substr($msg, 0, 10, 'UTF-8');
$msg=''.$msg.'...';
}
$ccomm = mysql_result(mysql_query("SELECT COUNT(*) FROM `diary_comm` WHERE `diary` = '".$diary['id']."'"), 0);
if(ban($user['id']) || ($user['delete'] == 1)){
echo ico($user['sex'],$user['admin']).' <a href = "/'.$user['id'].'"><del>'.$user['login'].'</del></a> ';
} else {
echo ico($user['sex'],$user['admin']).' <a href = "/'.$user['id'].'">'.$user['login'].'</a> ';
}
if($user['rating']>=1000 && $user['rating']<=1999)echo "<img src='ico/b.png' alt='' class='icon'</a>n";
if($user['rating']>=2000 && $user['rating']<=2999)echo "<img src='ico/s.png' alt='' class='icon'</a>n";
if($user['rating']>=3000)echo "<img src='ico/z.png' alt='' class='icon'</a>n";
echo '/ <a href = "diary.php?act=message&id='.$diary['id'].'&link=1">'.$name.'</a> / <span style="font-size: small; color:#209143">'.vremya($diary['time']).'</span>';
if($diary['18'] == 1) echo ' <font color="red">18+</font>';
echo '<br/>';
if($diary['priv'] == 2 || $diary['priv'] == 1 || $diary['18'] == 1) {
echo 'Просмотр недоступен !';
if($diary['priv'] == 2 || $diary['priv'] == 1) echo ' <img src="ico/lock.gif" alt="image" /> ';
} else {
echo ''.$msg.'';
}
echo '</br><img src="ico/comment.png" alt="!" /> <a href = "diary.php?act=message&id='.$diary['id'].'&link=1">Комментарии</a> ('.$ccomm.')</br>';
if (($diary['user'] == $u['id']) || ($u['admin'] == 1 || $u['admin'] == 2)) {
echo '<small> [<a href = "diary.php?act=edit&id='.$diary['id'].'">Ред</a>]
[<a href = "diary.php?act=delete&id='.$diary['id'].'">Удал</a>]</small>'; }
echo '</div>';
$i++;
}
navigation($page, $total,'diary.php?act=search&');
} else {
error(' По запросу <b>' . $s . '</b> ничего не найдено !');
}
}
} else {
error('Ошибка ! ');
}
require('foot.php');
break;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~Все записи ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
default:
$title = $title.' | Дневники';
require('head.php');
echo '<div class="title"><img src="ico/notes.png" alt="!"/> <a href = "diary.php">Дневники</a> <b>Просмотр</b></div>';
$new = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `diary_messages` WHERE `time` > '".(time()-(60*60*24))."'"), 0);
echo '<div class="app"><img src = "ico/new.gif"> <a href = "diary.php?act=new">Новые</a> ('.$new.')';
echo '<br/></div>';
$all = mysql_result(mysql_query("SELECT COUNT(*) FROM `diary_messages`"), 0);
if($all > 0){
$total = intval(($all - 1) / 10) + 1;
$page = num($_GET['page']);
if(empty($page) or $page < 0) $page = 1;
if($page > $total) $page = $total;
$start = $page * 10 - 10;
if ($all >= 11)echo '<div class="title">';
if ($page != $total) {
echo '<a name="page-up" style="float: right; text-decoration: none;" href="#page-down"><img src = "ico/page_down.png"></a>';
}
$sort = check($_GET['sort']);
if($sort == 'message') {
$sortq = 'ASC';
if ($all >= 11)echo '<a href = "diary.php?&sort=time&page='.$page.'">Новые</a> | <b>Поcледние</b>';
}
if($sort == 'time' || empty($sortq)) {
$sort = 'time';
$sortq = 'DESC';
if ($all >= 11)echo '<b>Новые</b> | <a href = "diary.php?&sort=message&page='.$page.'">Поcледние</a>';
}
if ($all >= 11)echo '</div>';
echo '<div class="nav">
Поиск в дневниках:
<FORM method="POST" action="diary.php?act=search&ok=1">
<input type="text" name="s" value="" placeholder="Введите пару слов для поиска..." style="width: 60%" />
<input type="submit" name="ok" value="Найти"/>
</form>
</div>';
$result = mysql_query("SELECT * FROM `diary_messages` ORDER BY `time` $sortq LIMIT $start, 10");
while($message = mysql_fetch_assoc($result)){
echo $i % 2 ? '<div class="div">' : '<div class="div">';
$user = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '".$message['user']."' LIMIT 1"));
$name = checkout($message['name']);
$msg = checkout($message['message']);
if (iconv_strlen($msg, 'UTF-8') > 11) {
$msg = iconv_substr($msg, 0, 10, 'UTF-8');
$msg=''.$msg.'...';
}
$ccomm = mysql_result(mysql_query("SELECT COUNT(*) FROM `diary_comm` WHERE `diary` = '".$message['id']."'"), 0);
if(ban($user['id']) || ($user['delete'] == 1)){
echo ico($user['sex'],$user['admin']).' <a href = "/'.$user['id'].'"><del>'.$user['login'].'</del></a> ';
} else {
echo ico($user['sex'],$user['admin']).' <a href = "/'.$user['id'].'">'.$user['login'].'</a> ';
}
if($user['rating']>=1000 && $user['rating']<=1999)echo "<img src='ico/b.png' alt='' class='icon'</a>n";
if($user['rating']>=2000 && $user['rating']<=2999)echo "<img src='ico/s.png' alt='' class='icon'</a>n";
if($user['rating']>=3000)echo "<img src='ico/z.png' alt='' class='icon'</a>n";
echo ' / <a href = "diary.php?act=message&id='.$message['id'].'&link=1">'.$name.'</a> / <span style="font-size: small; color:#209143">'.vremya($message['time']).'</span>';
if($message['18'] == 1) echo ' <font color="red">18+</font>';
echo '<br/>';
if($message['priv'] == 2 || $message['priv'] == 1 || $message['18'] == 1) {
echo 'Просмотр недоступен !';
if($message['priv'] == 2 || $message['priv'] == 1) echo ' <img src="ico/lock.gif" alt="image" /> ';
} else {
echo ''.$msg.'';
}
echo '</br><img src="ico/comment.png" alt="!" /> <a href = "diary.php?act=message&id='.$message['id'].'&link=1">Комментарии</a> ('.$ccomm.')</br>';
if (($message['user'] == $u['id']) || ($u['admin'] == 1 || $u['admin'] == 2)) {
echo '<small> [<a href = "diary.php?act=edit&id='.$message['id'].'">Ред</a>]
[<a href = "diary.php?act=delete&id='.$message['id'].'"><b><font color="red">x</font></b> Удал</a>]</small>'; }
echo '</div>';
$i++;
}
if ($all >= 11)echo '<div class="title">';
if ($page != $total) {
echo '<a name="page-down" style="float: right; text-decoration: none;" href="#page-up"><img src = "ico/page_up.png"></a>';
}
if($sort == 'message') {
$sortq = 'ASC';
if ($all >= 11)echo '<a href = "diary.php?&sort=time&page='.$page.'">Новые</a> | <b>Поcледние</b>';
}
if($sort == 'time' || empty($sortq)) {
$sort = 'time';
$sortq = 'DESC';
if ($all >= 11)echo '<b>Новые</b> | <a href = "diary.php?&sort=message&page='.$page.'">Поcледние</a>';
}
if ($all >= 11)echo '</div>';
echo '</div>';
navigation($page, $total,'diary.php?&sort='.$sort.'&');
}else{
error(' Записей пока нет !');
}
require('foot.php');
break;
}
?>