Файл: system/microblog.php
Строк: 384
<?
include 'connect.php';
if(!$u['id']){
header ("Location: registration.php?err=1");
exit;
}
if(ban($u['id'])){
header ("Location: /");
}
$my_msg = mysql_result(mysql_query("SELECT COUNT(*) FROM `microblog_messages` WHERE `user` = '".$u['id']."'"), 0);
switch($_GET['act'])
{
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Редактирование~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
case 'edit':
if (isset($_GET['id'])) {
$id=num($_GET['id']);
if($u['admin']==1 || $u['admin']==2 || $microblog['user'] == $u['id'])
$req = mysql_query("SELECT * FROM `microblog_messages` WHERE `id` = '$id' LIMIT 1");
else
$req = mysql_query("SELECT * FROM `microblog_messages` WHERE `id` = '$id' AND `user` = '".$u['id']."' LIMIT 1");
if (mysql_num_rows($req)) {
$microblog = mysql_fetch_assoc($req);
$user = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '".$microblog['user']."' LIMIT 1"));
}
}
if(empty($microblog)){
include 'head.php';
echo '<div class="title">';
echo '<img src= "ico/status.png"> <a href = "microblog.php">Микроблоги</a> <b>Ошибка</b>';
echo '</div>';
echo '<div class="txt">';
echo '<img src="ico/error.gif" alt="Ошибка" /> Ошибка!</div>';
echo '</div>';
include 'foot.php';
exit;
}
if (isset($_POST['submit']) && $_POST['message']) {
$message = check(substr($_POST['message'], 0, 500));
if (empty($message)){
include 'head.php';
echo '<div class="div"> Ошибка , так делать нельзя!</div>'; $error = '1';
include 'foot.php';
exit;
}
if (empty($error)){
mysql_query("UPDATE `microblog_messages` SET
`message` = '$message'
WHERE `id` = '$id'
");
header ("Location: microblog.php?id=".$user['id']."");
exit;
}} else {
include 'head.php';
echo '<div class="title"><img src= "ico/status.png"><a href = "microblog.php"> Мой микроблог</a>
<a href = "microblog.php">Все записи </a>
<b>Редактирование</b></div>';
echo '<div class="nav">';
if($microblog['user'] == $u['id']) {echo '<a href = "microblog.php">Мой микроблог</a> ('.$my_msg.')';}
else {$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `microblog_messages` WHERE `user` = '".$user['id']."'"), 0);
echo '<a href = "microblog.php?id='.$user['id'].'">Микроблог '.login($microblog['user']).'</a> ('.$count.')';}
echo '</div>';
echo '<div class="app">';
$text = $microblog['message'];
echo '<form action="microblog.php?act=edit&id=' . $id . '" method="post">';
echo '<textarea cols="20" rows="3" name="message">'.$text.'</textarea><br/>';
echo '<input type="submit" name="submit" value="Сохранить" class="submit white"/>';
echo ' <small>500 <a href = "smiles.php">Смайлы</a>
| <a href = "code.php">BB-коды</a></small>';
echo '</form></div>';
echo '</div>';
include 'foot.php';
}
break;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Новый статус ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
case 'new':
$flood = mysql_query("SELECT `time` FROM `microblog_messages` WHERE `user` = '".$u['id']."' AND `time` > '" . (time() - $system['microblog_antiflud']) . "'");
if (mysql_num_rows($flood)) {
include 'head.php';
echo '<div class = "div"><table><tr><td VALIGN=center><img src = "ico/close.png"></td><td VALIGN=center>
<b>Ошибка</b>!</br> Можно добавлять микроблоги только раз в '.$system['microblog_antiflud'].' сек.
</table>
</div>';
include 'foot.php';
exit;
}
if (isset($_POST['submit']) and $_POST['message']) {
$message = check(substr($_POST['message'], 0, 500));
if (empty($message)){
include 'head.php';
echo '<div class="div"> Ошибка , так делать нельзя!</div>'; $error = '1';
include 'foot.php';
exit;
}
if (empty($error)){
mysql_query("UPDATE `microblog_messages` SET `main` = '0' WHERE `user` = '".$u['id']."'");
mysql_query("INSERT INTO `microblog_messages` SET
`user` = '".$u['id']."',
`message` = '$message',
`time` = '".time()."',
`main` = '1'
");
$id = mysql_insert_id();
mysql_query("UPDATE `users` SET `rating` = `rating`+15 WHERE `id` = '".$u['id']."'");
if($u['sex'] == 'm'){
$action[0] = 'Опубликовал';
} else {
$action[0] = 'Опубликовала';
}
$text = $action[0].' <a href = "microblog.php?act=view&id='.$id.'&show=comm">микроблог</a>.';
mysql_query("INSERT INTO `lenta` SET
`user` = '".$u['id']."',
`text` = '$text',
`time` = '".time()."',
`new` = '1'
");
if($u['sex'] == 'm'){
$action[0] = 'Опубликовал';
} else {
$action[0] = 'Опубликовала';
}
$text = $action[0].' <a href = "microblog.php?act=view&id='.$id.'&show=comm">микроблог</a>.';
mysql_query("INSERT INTO `lenta_blog` SET
`user` = '".$u['id']."',
`text` = '$text',
`time` = '".time()."',
`new` = '1'
");
header ("Location: microblog.php");
exit;
}} else {
include 'head.php';
echo '<div class="title"><img src= "ico/status.png"><a href = "microblog.php"> Мой микроблог</a>
<a href = "microblog.php">Все записи </a>
<b>Новая запись</b></div>';
echo '<div class="nav">';
echo '<a href = "microblog.php">Мой микроблог </a> ('.$my_msg.')';
echo '</div>';
echo '<div class="app">';
echo '<form action="microblog.php?act=new" method="post">';
echo '<br/><textarea cols="20" rows="3" name="message"></textarea><br/>';
echo '<input type="submit" name="submit" value="Добавить" class="submit white"/>';
echo ' <small>500 <a href = "smiles.php">Смайлы</a>
| <a href = "code.php">BB-коды</a></small>';
echo '</form></div>';
echo '</div>';
include 'foot.php';
}
break;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Убрать ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
case 'close':
if (isset($_GET['id'])) {
$id=num($_GET['id']);
$req = mysql_query("SELECT * FROM `microblog_messages` WHERE `id` = '$id' AND `user` = '".$u['id']."' LIMIT 1");
if (mysql_num_rows($req)) {
$microblog = mysql_fetch_assoc($req);
mysql_query("UPDATE `microblog_messages` SET `main` = '0' WHERE `id` = '".$microblog['id']."'");
header ("Location: /");
}
}
if(empty($microblog)){
header ("Location: microblog.php");
exit;
}
break;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Просмотр~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
case 'view':
if (isset($_GET['id'])) {
$id=num($_GET['id']);
$req = mysql_query("SELECT * FROM `microblog_messages` WHERE `id` = '$id' LIMIT 1");
if (mysql_num_rows($req)) {
$microblog = mysql_fetch_assoc($req);
$user = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '".$microblog['user']."' LIMIT 1"));
}
}
if(empty($microblog)){
include 'head.php';
echo '<div class="title">';
echo '<img src= "ico/status.png"> <a href = "microblog.php">Микроблоги</a> <b>Ошибка</b>';
echo '</div>';
echo '<div class="div">';
echo ' Ошибка !</div>';
echo '</div>';
include 'foot.php';
exit;
}
if(ban($user['id'])){
include 'head.php';
echo '<div class = "div"><table><tr><td VALIGN=center><img src = "ico/close.png"></td><td VALIGN=center>
Пользователь заблокирован!
</table>
</div>';
include 'foot.php';
exit;
}
if(isset($_GET['show'])) if($_GET['show']=='comm' || $_GET['show']=='like' || $_GET['show']=='view' ) $show = $_GET['show'];
if(isset($_GET['like'])) if($_GET['like']=='yes' || $_GET['like']=='no') $like = $_GET['like'];
if(isset($like)){
if($like=='yes'){
$req = mysql_query("SELECT * FROM `microblog_like` WHERE `user` = '".$u['id']."' AND `microblog` = '".$microblog['id']."' LIMIT 1");
if (!mysql_num_rows($req)) {
$microblog['likes']++;
mysql_query("INSERT INTO `microblog_like` SET
`user` = '".$u['id']."',
`time` = '".time()."',
`microblog` = '".$microblog['id']."'
");
mysql_query("UPDATE `microblog_messages` SET
`likes` = '".$microblog['likes']."'
WHERE `id` = '".$microblog['id']."'
");
if($microblog['user'] != $u['id']){
if($u['sex'] == 'm'){
$action[0] = 'Отметил';
$action[1] = 'ему';
} else {
$action[0] = 'Отметила';
$action[1] = 'ей';
}
$text = $action[0].' что '.$action[1].' понравилась ваша <a href = "microblog.php?act=view&id='.$microblog['id'].'">запись</a>.';
mysql_query("INSERT INTO `jurnal` SET
`user` = '".$user['id']."',
`outuser` = '".$u['id']."',
`text` = '$text',
`time` = '".time()."',
`new` = '1'
");
header ("Location: microblog.php?act=view&id=$id&show=comm");
}
}
} else {
$req = mysql_query("SELECT * FROM `microblog_like` WHERE `user` = '".$u['id']."' AND `microblog` = '".$microblog['id']."' LIMIT 1");
if (mysql_num_rows($req)) {
$flood = mysql_query("SELECT `time` FROM `microblog_like` WHERE `user` = '".$u['id']."' AND `time` > '" . (time() - $system['microblog_like_antiflud']) . "'");
if (mysql_num_rows($flood)) {
header ("Location: microblog.php?act=view&id=$id&show=comm");
exit;
}
mysql_query("DELETE FROM `microblog_like` WHERE `user` = '".$u['id']."' AND `microblog` = '".$microblog['id']."' LIMIT 1");
$microblog['likes']--;
mysql_query("UPDATE `microblog_messages` SET
`likes` = '".$microblog['likes']."'
WHERE `id` = '".$microblog['id']."'
");
header ("Location: microblog.php?act=view&id=$id&show=comm");
}
}
}
if(isset($_GET['del_like'])){
if($microblog['user']==$u['id']){
$del_like=num($_GET['del_like']);
$req = mysql_query("SELECT * FROM `microblog_like` WHERE `user` = '$del_like' AND `microblog` = '".$microblog['id']."' LIMIT 1");
if (mysql_num_rows($req)) {
mysql_query("DELETE FROM `microblog_like` WHERE `user` = '$del_like' AND `microblog` = '".$microblog['id']."' LIMIT 1");
$microblog['likes']--;
mysql_query("UPDATE `microblog_messages` SET
`likes` = '".$microblog['likes']."'
WHERE `id` = '".$microblog['id']."'
");
}
}
}
$req = mysql_query("SELECT * FROM `microblog_view` WHERE `user` = '".$u['id']."' AND `microblog` = '".$microblog['id']."' LIMIT 1");
if (!mysql_num_rows($req)) {
mysql_query("INSERT INTO `microblog_view` SET
`user` = '".$u['id']."',
`view` = '1',
`last_time` = '".time()."',
`time` = '".time()."',
`microblog` = '".$microblog['id']."'
");
mysql_query("UPDATE `microblog_messages` SET
`view` = `view`+1
WHERE `id` = '".$microblog['id']."'
");
$microblog['view']++;
} else {
$view = mysql_fetch_assoc($req);
mysql_query("UPDATE `microblog_view` SET
`view` = `view`+1,
`last_time` = '".time()."'
WHERE `id` = '".$view['id']."'
");
}
if($_POST['comm_message']){
$message = check(substr($_POST['comm_message'], 0, 500));
if (empty($message)){
include 'head.php';
echo '<div class="div"> Ошибка , так делать нельзя!</div>'; $error = '1';
include 'foot.php';
exit;
}
$flood = mysql_query("SELECT `time` FROM `microblog_comm` WHERE `user` = '".$u['id']."' AND `time` > '" . (time() - $system['microblog_comm_antiflud']) . "'");
if (mysql_num_rows($flood)) {
header ("Location: microblog.php?act=view&id=$id&show=comm&flud=1");
exit;
}
$req = mysql_query("SELECT * FROM `microblog_comm` WHERE `user` = '".$u['id']."' ORDER BY `time` DESC");
$res = mysql_fetch_array($req);
if ($res['message'] == $message) {
header("Location: microblog.php?act=view&id=$id&show=comm");
exit;
}
if (empty($error)){
mysql_query("INSERT INTO `microblog_comm` SET
`user` = '".$u['id']."',
`message` = '$message',
`time` = '".time()."',
microblog = '$id'
");
mysql_query("UPDATE `users` SET `rating` = `rating`+1 WHERE `id` = '".$u['id']."'");
if($u['sex'] == 'm'){
$action[0] = 'Прокомментировал';
} else {
$action[0] = 'Прокомментировала';
}
$text = $action[0].'<a href = "microblog.php?act=view&id='.$id.'&show=comm"> микроблог</a>.';
mysql_query("INSERT INTO `lenta` SET
`user` = '".$u['id']."',
`text` = '$text',
`time` = '".time()."',
`new` = '1'
");
if($u['sex'] == 'm'){
$action[0] = 'Прокомментировал';
} else {
$action[0] = 'Прокомментировала';
}
$text = $action[0].'<a href = "microblog.php?act=view&id='.$id.'&show=comm"> микроблог</a>.';
mysql_query("INSERT INTO `lenta_blog` SET
`user` = '".$u['id']."',
`text` = '$text',
`time` = '".time()."',
`new` = '1'
");
mysql_query("UPDATE `microblog_messages` SET `comm` = `comm`+1 WHERE `id` = '".$microblog['id']."'");
header("Location: microblog.php?act=view&id=$id&show=comm");
}}
include 'head.php';
require('core/bb_code.php');
if($microblog['user'] == $u['id']){
echo '<div class="title"><img src= "ico/status.png"><a href = "microblog.php"> Мой микроблог</a>
<a href = "microblog.php">Все записи </a>
<b>Просмотр записи</b></div>';
}else{
echo '<div class="title"><img src= "ico/status.png"> Микроблог <a href = "/'.$microblog['user'].'">'.login($microblog['user']).'</a>
<a href = "microblog.php?id='.$user['id'].'">Все записи </a>
<b>Просмотр записи</b></div>';
}
if(($u['admin']==1 || $u['admin']==2) || $microblog['user'] == $u['id']){
echo '<div class="nav">';
echo '<a href = "microblog.php?act=edit&id='.$microblog['id'].'">Редактировать</a> |
<a href = "microblog.php?act=delete&id='.$microblog['id'].'"><font color="red"><b>x</b></font> Удалить</a>';
echo '</div>';
}
$message = checkout($microblog['message']);
echo '<div class="div">';
echo '<img src= "ico/status.png"> '.smile(bb_code(links($message))).' </div><div class="div">
<img src= "ico/clock.png"> '.vremya($microblog['time']).'';
echo '</br>';
$req = mysql_query("SELECT * FROM `microblog_like` WHERE `user` = '".$u['id']."' AND `microblog` = '".$microblog['id']."' LIMIT 1");
if (!mysql_num_rows($req))
echo '<img src = "ico/like.png"> <a href = "microblog.php?act=view&id='.$microblog['id'].'&like=yes">Мне нравится</a>';
else
echo '<img src = "ico/like.png"> Понравилось: ('.$microblog['likes'].')
</br><img src = "ico/like_off.png"> <a href = "microblog.php?act=view&id='.$microblog['id'].'&like=no">Мне не нравится</a>';
echo '</div>';
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Комментарии ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
switch($show)
{
case 'comm':
echo '<div class = "nav"><b>Комм ('.$microblog['comm'].')</b> | <a href = "microblog.php?act=view&id='.$id.'&show=like">Кому нравится ('.$microblog['likes'].')</a> | <a href = "microblog.php?act=view&id='.$id.'&show=view">Просмотры ('.$microblog['view'].')</a></div>';
echo '<div class="app">';
echo'<form action="microblog.php?act=view&id='.$id.'" method="post">';
echo '<textarea cols="20" rows="3" name="comm_message">';
echo '</textarea><br/>';
echo "<input type='submit' title='Нажмите для отправки' name='submit' value='Написать' class='submit white'/> <small>500 <a href = 'smiles.php'>Смайлы</a>
| <a href = 'code.php'>BB-коды</a></small>
</form></div>";
if(isset($_GET['del'])){
$del = num($_GET['del']);
$req = mysql_query("SELECT * FROM `microblog_comm` WHERE `id` = '$del' LIMIT 1");
if (mysql_num_rows($req)) {
$del_comm = mysql_fetch_assoc($req);
$del_microblog = mysql_fetch_assoc(mysql_query("SELECT * FROM `microblog_messages` WHERE `id` = '".$del_comm['microblog']."'"));
if($u['admin'] == 1 || $u['admin'] == 2){
mysql_query("DELETE FROM `microblog_comm` WHERE `id` = '$del'");
mysql_query("UPDATE `microblog_messages` SET `comm` = `comm`-1 WHERE `id` = '".$id."'");
echo '<div class = "div"> Комментарий удален !</div>';
}else{
if($del_comm['user'] == $u['id'] || $del_microblog['user'] == $u['id']){
mysql_query("DELETE FROM `microblog_comm` WHERE `id` = '$del'");
mysql_query("UPDATE `microblog_messages` SET `comm` = `comm`-1 WHERE `id` = '".$id."'");
echo '<div class = "div"> Комментарий удален !</div>';
}
}
}
}
$all = mysql_result(mysql_query("SELECT COUNT(*) FROM `microblog_comm` WHERE `microblog` = '".$microblog['id']."'"), 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;
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';
echo '<a href = "microblog.php?act=view&id='.$id.'&show=comm&sort=time&page='.$page.'">Новые</a> | <b>Поcледние</b>';
}
if($sort == 'time' || empty($sortq)) {
$sort = 'time';
$sortq = 'DESC';
echo '<b>Новые</b> | <a href = "microblog.php?act=view&id='.$id.'&show=comm&sort=message&page='.$page.'">Поcледние</a>';
}
echo '</div>';
$result = mysql_query("SELECT * FROM `microblog_comm` WHERE `microblog` = '".$microblog['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(ban($user['id'])){
echo ico($user['sex'],$user['admin']).' <a href = "/'.$user['id'].'"><del>'.$user['login'].'</del></a> '.onl($user['online'],$system['online_time']);
} else {
echo ico($user['sex'],$user['admin']).' <a href = "/'.$user['id'].'">'.$user['login'].'</a> '.onl($user['online'],$system['online_time']);
}
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 ' <small>'.vremya($comm['time']).'</small>';
echo '<br/><font color = "#000">'.smile($msg).'</font><br/>';
echo '<small>';
if(($u['admin'] == 1 || $u['admin'] == 2) || ($comm['user'] == $u['id'] || $microblog['user'] == $u['id'])) {
echo '[<a href = "microblog.php?act=view&id='.$id.'&show=comm&del='.$comm['id'].'"><font color="red"><b>x</b></font> Удал</a>]';}
if($u['admin'] == 1 || $u['admin'] == 2){
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++;
}
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';
echo '<a href = "microblog.php?act=view&id='.$id.'&show=comm&sort=time&page='.$page.'">Новые</a> | <b>Поcледние</b>';
}
if($sort == 'time' || empty($sortq)) {
$sort = 'time';
$sortq = 'DESC';
echo '<b>Новые</b> | <a href = "microblog.php?act=view&id='.$id.'&show=comm&sort=message&page='.$page.'">Поcледние</a>';
}
echo '</div>';
echo '</div>';
navigation($page, $total,'microblog.php?act=view&id='.$id.'&show=comm&sort='.$sort.'&');
}else{
echo '<div class = "div"> Комментариев еще нет!</div>';
}
echo '</div>';
break;
//~~~~~~~~~~~~~~~~~~~~~~Мне нравится~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
case 'like':
echo '<div class = "nav"><a href = "microblog.php?act=view&id='.$id.'&show=comm">Комм ('.$microblog['comm'].')</a>
| <b>Кому нравится ('.$microblog['likes'].')</b>
| <a href = "microblog.php?act=view&id='.$id.'&show=view">Просмотры ('.$microblog['view'].')</a></div>';
$all = mysql_result(mysql_query("SELECT COUNT(*) FROM `microblog_like` WHERE `microblog` = '".$microblog['id']."'"), 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;
$result = mysql_query("SELECT * FROM `microblog_like` WHERE `microblog` = '".$microblog['id']."' ORDER BY `time` DESC LIMIT $start, 10");
while($likes = mysql_fetch_assoc($result)){
echo $i % 2 ? '<div class="div">' : '<div class="div">';
$user = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '".$likes["user"]."'"));
if(ban($user['id'])){
echo ico($user['sex'],$user['admin']).' <a href = "/'.$user['id'].'"><del>'.$user['login'].'</del></a> '.onl($user['online'],$system['online_time']);
} else {
echo ico($user['sex'],$user['admin']).' <a href = "/'.$user['id'].'">'.$user['login'].'</a> '.onl($user['online'],$system['online_time']);
}
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 '</div>';
$i++;
}
echo '</div>';
navigation($page, $total,'microblog.php?act=view&id='.$id.'&show=like&');
}else{
echo '<div class = "div"> Запись пока никому не понравилась !</div>';
}
echo '</div>';
break;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Просмотры~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
case 'view':
echo '<div class = "nav"><a href = "microblog.php?act=view&id='.$id.'&show=comm">Комм ('.$microblog['comm'].')</a> | <a href = "microblog.php?act=view&id='.$id.'&show=like">Кому нравится ('.$microblog['likes'].')</a> | <b>Просмотры ('.$microblog['view'].')</b></div>';
$all = mysql_result(mysql_query("SELECT COUNT(*) FROM `microblog_view` WHERE `microblog` = '".$microblog['id']."'"), 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;
$result = mysql_query("SELECT * FROM `microblog_view` WHERE `microblog` = '".$microblog['id']."' ORDER BY `time` DESC LIMIT $start, 10");
while($view = mysql_fetch_assoc($result)){
echo $i % 2 ? '<div class="div">' : '<div class="div">';
$user = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '".$view["user"]."'"));
if(ban($user['id'])){
echo ico($user['sex'],$user['admin']).' <a href = "/'.$user['id'].'"><del>'.$user['login'].'</del></a> '.onl($user['online'],$system['online_time']);
} else {
echo ico($user['sex'],$user['admin']).' <a href = "/'.$user['id'].'">'.$user['login'].'</a> '.onl($user['online'],$system['online_time']);
}
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 '<small> '.vremya($view['last_time']).'</small></br>';
echo '</div>';
$i++;
}
echo '</div>';
navigation($page, $total,'microblog.php?act=view&id='.$id.'&show=view&');
}else{
echo '<div class = "div"><img src="ico/error.gif" alt="Ошибка" /> Запись пока никто не просматривал!</div>';
}
echo '</div>';
break;
default:
echo '<div class = "nav"><a href = "microblog.php?act=view&id='.$id.'&show=comm">Комм ('.$microblog['comm'].')</a> | <a href = "microblog.php?act=view&id='.$id.'&show=like">Кому нравится ('.$microblog['likes'].')</a> | <a href = "microblog.php?act=view&id='.$id.'&show=view">Просмотры ('.$microblog['view'].')</a></div>';
}
echo '</div>';
include 'foot.php';
break;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Удаление~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
case 'delete':
if (isset($_GET['id'])) {
$id=num($_GET['id']);
if($u['admin']==1 || $u['admin']==2 || $u['admin']==3)
$req = mysql_query("SELECT * FROM `microblog_messages` WHERE `id` = '$id' LIMIT 1");
else
$req = mysql_query("SELECT * FROM `microblog_messages` WHERE `id` = '$id' AND `user` = '".$u['id']."' LIMIT 1");
if (mysql_num_rows($req)) {
$microblog = mysql_fetch_assoc($req);
$user = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '".$microblog['user']."' LIMIT 1"));
}
}
if(empty($microblog)){
include 'head.php';
echo '<div class="title">';
echo '<img src= "ico/status.png"> <a href = "microblog.php">Микроблоги</a> <b>Ошибка</b>';
echo '</div>';
echo '<div class="txt">';
echo ' Ошибка !</div>';
echo '</div>';
include 'foot.php';
exit;
}
include 'head.php';
echo '<div class="title"><img src= "ico/status.png"> <a href = "microblog.php">Микроблоги</a> <b>Удаление записи</b></div>';
if($microblog['user'] == $u['id']) {echo '<div class="nav"><a href = "microblog.php">Мой микроблог</a> ('.$my_msg.')</div>';}
else {$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `microblog_messages` WHERE `user` = '".$user['id']."'"), 0);
echo '<div class="nav"><a href = "microblog.php?id='.$user['id'].'">Микроблог '.login($microblog['user']).'</a> ('.$count.')';}
echo '</div>';
if (isset($_POST['submit'])) {
mysql_query("DELETE FROM `microblog_messages` WHERE `id` = '".$id."'");
mysql_query("DELETE FROM `microblog_like` WHERE `microblog` = '".$id."'");
mysql_query("DELETE FROM `microblog_view` WHERE `microblog` = '".$id."'");
mysql_query("DELETE FROM `microblog_comm` WHERE `microblog` = '".$id."'");
echo '<div class = "app">Запись удалена!</div>';
} else {
echo '<div class="txt">';
echo 'Вы уверены, что хотите удалить <a href = "microblog.php?act=view&id='.$microblog['id'].'">эту запись</a> из микроблога?';
echo '<form action="microblog.php?act=delete&id='.$id.'" method="post">';
echo '<input type="submit" name="submit" value="Да, удалить" class="submit white"/>';
echo '</form>';
}
echo '</div>';
include 'foot.php';
break;
//~~~~~~~~~~~~~~~~~~~~~~~~~Все~~~~~~~~~~~~~~~~~~~~~~~//
case 'all':
$title = $title.' | Люди пишут';
include 'head.php';
echo '<div class="title"><img src= "ico/status.png"> <a href = "microblog.php">Микроблоги</a> <b>Люди пишут</b></div>';
$all = mysql_result(mysql_query("SELECT COUNT(*) FROM `microblog_messages`"), 0);
$all_comm = mysql_result(mysql_query("SELECT COUNT(*) FROM `microblog_comm`"), 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;
echo '<div class="zona">';
echo ' • Микроблогов '.$all.'</br>';
echo ' • Комментариев '.$all_comm.'</br>';
echo '</div>';
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';
echo '<a href = "microblog.php?act=all&sort=time&page='.$page.'">Новые</a> | <b>Поcледние</b>';
}
if($sort == 'time' || empty($sortq)) {
$sort = 'time';
$sortq = 'DESC';
echo '<b>Новые</b> | <a href = "microblog.php?act=all&sort=message&page='.$page.'">Поcледние</a>';
}
echo '</div>';
$result = mysql_query("SELECT * FROM `microblog_messages` ORDER BY `time` $sortq LIMIT $start, 10");
while($microblog = mysql_fetch_assoc($result)){
echo $i % 2 ? '<div class="div">' : '<div class="div">';
$message = checkout($microblog['message']);
if (iconv_strlen($message, 'UTF-8') > 30) {
$message = iconv_substr($message, 0, 10, 'UTF-8');
$message=''.$message.'...';
}
echo'<img src = "ico/status.png"> <a href="microblog.php?act=view&id='.$microblog['id'].'&show=comm">
'.$message.'</a></br>
<small><font color ="green"> '.vremya($microblog['time']).' </font></small><br>
<img src = "ico/view.png"> '.$microblog['view'].'
<img src = "ico/like.png"> '.$microblog['likes'].'
<img src = "ico/comm.png"> '.$microblog['comm'].'
';
echo '</br>';
if(($u['admin']==1 || $u['admin']==2)){
echo '<small>';
echo '[<a href = "microblog.php?act=edit&id='.$microblog['id'].'">Ред</a> ]
[<a href = "microblog.php?act=delete&id='.$microblog['id'].'"><font color="red"><b>x</b></font> Удал</a>]';
echo '</small>';
}
echo '</div>';
$i++;
}
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';
echo '<a href = "microblog.php?act=all&sort=time&page='.$page.'">Новые</a> | <b>Поcледние</b>';
}
if($sort == 'time' || empty($sortq)) {
$sort = 'time';
$sortq = 'DESC';
echo '<b>Новые</b> | <a href = "microblog.php?act=all&sort=message&page='.$page.'">Поcледние</a>';
}
echo '</div>';
navigation($page, $total,'microblog.php?act=all&sort='.$sort.'&');
}else{
echo '<div class = "div"> Записей пока нет !</div>';
}
echo '</div>';
include 'foot.php';
break;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Все записи~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
default:
$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 {
include 'head.php';
echo '<div class="title">';
echo '<img src= "ico/status.png"> <a href = "microblog.php">Микроблоги</a> <b>Ошибка</b>';
echo '</div>';
echo '<div class="txt">';
echo '<img src="ico/error.gif" alt="Ошибка" /> Ошибка , такого пользователя нет!</div>';
echo '</div>';
include 'foot.php';
exit;
}
if(ban($user['id'])){
include 'head.php';
echo '<div class = "div"><table><tr><td VALIGN=center><img src = "ico/close.png"></td><td VALIGN=center>
Пользователь заблокирован!
</table>
</div>';
include 'foot.php';
exit;
}
$title = $title.' | Микроблог';
include 'head.php';
if($user['id'] == $u['id'])$zag = '<a href = "microblog.php"> Мой микроблог</a>';else $zag = 'Микроблог <a href = "/'.$user['id'].'">'.$user['login'].'</a>';
echo '<div class="title"><img src= "ico/status.png"> '.$zag.' <b>Просмотр</b></div>';
if($user['id'] != $u['id'])echo '<div class="nav"><a href = "microblog.php">Мой микроблог</a> ('.$my_msg.')</div>';
else echo '<div class="nav"><img src="ico/dirnew.png" alt="!"/> <a href = "microblog.php?act=new">Новая запись</a></div>';
$all = mysql_result(mysql_query("SELECT COUNT(*) FROM `microblog_messages` WHERE `user` = '".$user['id']."'"), 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;
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';
echo '<a href = "microblog.php?id='.$user['id'].'&sort=time&page='.$page.'">Новые</a> | <b>Поcледние</b>';
}
if($sort == 'time' || empty($sortq)) {
$sort = 'time';
$sortq = 'DESC';
echo '<b>Новые</b> | <a href = "microblog.php?id='.$user['id'].'&sort=message&page='.$page.'">Поcледние</a>';
}
echo '</div>';
$result = mysql_query("SELECT * FROM `microblog_messages` WHERE `user` = '".$user['id']."' ORDER BY `time` $sortq LIMIT $start, 10");
while($microblog = mysql_fetch_assoc($result)){
echo $i % 2 ? '<div class="div">' : '<div class="div">';
$message = checkout($microblog['message']);
if (iconv_strlen($message, 'UTF-8') > 30) {
$message = iconv_substr($message, 0, 10, 'UTF-8');
$message=''.$message.'...';
}
echo'<img src = "ico/status.png"> <a href="microblog.php?act=view&id='.$microblog['id'].'&show=comm">
'.$message.'</a></br>
<small><font color ="green"> '.vremya($microblog['time']).' </font></small><br>
<img src = "ico/view.png"> '.$microblog['view'].'
<img src = "ico/like.png"> '.$microblog['likes'].'
<img src = "ico/comm.png"> '.$microblog['comm'].'
';
echo '</br>';
if(($u['admin']==1 || $u['admin']==2) || $microblog['user'] == $u['id']){
echo '<small>';
echo '[<a href = "microblog.php?act=edit&id='.$microblog['id'].'">Ред</a> ]
[<a href = "microblog.php?act=delete&id='.$microblog['id'].'"><font color="red"><b>x</b></font> Удал</a>]';
echo '</small>';
}
echo '</div>';
$i++;
}
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';
echo '<a href = "microblog.php?id='.$user['id'].'&sort=time&page='.$page.'">Новые</a> | <b>Поcледние</b>';
}
if($sort == 'time' || empty($sortq)) {
$sort = 'time';
$sortq = 'DESC';
echo '<b>Новые</b> | <a href = "microblog.php?id='.$user['id'].'&sort=message&page='.$page.'">Поcледние</a>';
}
echo '</div>';
navigation($page, $total,'microblog.php?id='.$user['id'].'&sort='.$sort.'&');
}else{
echo '<div class = "div"> Записей пока нет !</div>';
}
echo '</div>';
include 'foot.php';
}
?>