Файл: vsime.com/journal/index.php
Строк: 290
<?php
$title = 'Журнал';
include('../system/includes/system.php');
ex_head();
if_user('is_reg');
$count_journal = mysqli_result("SELECT COUNT(*) FROM `journal` WHERE `id_kont` = '$user[id]' AND `read` = '0'");
$array_diary = array();
$query = mysqli_query($dbi, "SELECT * FROM `diary` WHERE `id_user` = '$user[id]'");
while ($post = mysqli_fetch_array($query))
{
if (mysqli_num_rows(mysqli_query($dbi, "SELECT * FROM `diary_komm` WHERE `id_diary` = '$post[id]' AND `id_user` != '$user[id]' AND `time` > '$post[a_time]'"))!=0)
{
$array_diary[] = $post['id'];
}
}
$count_journal_diary = count($array_diary);
$where_journal_diary = implode("' OR `id` = '", $array_diary);
$array_files = array();
$query = mysqli_query($dbi, "SELECT * FROM `files` WHERE `id_user` = '$user[id]' AND `type` = 'file'");
while ($post = mysqli_fetch_array($query))
{
if (mysqli_num_rows(mysqli_query($dbi, "SELECT * FROM `files_komm` WHERE `id_file` = '$post[id]' AND `id_user` != '$user[id]' AND `time` > '$post[a_time]'"))!=0)
{
$array_files[] = $post['id'];
}
}
$count_journal_files = count($array_files);
$where_journal_files = implode("' OR `id` = '", $array_files);
$array_fotos = array();
$query = mysqli_query($dbi, "SELECT * FROM `foto` WHERE `id_user` = '$user[id]' AND `type` = 'foto'");
while ($post = mysqli_fetch_array($query))
{
if (mysqli_num_rows(mysqli_query($dbi, "SELECT * FROM `foto_komm` WHERE `id_foto` = '$post[id]' AND `id_user` != '$user[id]' AND `time` > '$post[a_time]'"))!=0)
{
$array_fotos[] = $post['id'];
}
}
$count_journal_fotos = count($array_fotos);
$where_journal_fotos = implode("' OR `id` = '", $array_fotos);
$sort = intval(@$_GET['sort']);
if (!in_array($sort, array(1, 2, 3, 4)))$sort = 4;
echo "<div class='grand_h'>n";
echo "<table>n";
echo "<td style='width: 25%;'>".($sort!=1?"<a href='?sort=1'>":NULL)."<span class='block_l'>Дневник".($count_journal_diary > 0?" <span class='spared'>(+$count_journal_diary)</span>":null)."</span>".($sort!=1?"</a>":NULL)."</td>n";
echo "<td style='width: 25%;'>".($sort!=2?"<a href='?sort=2'>":NULL)."<span class='block_l'>Фото".($count_journal_fotos>0?" <span class='spared'>(+$count_journal_fotos)</span>":null)."</span>".($sort!=2?"</a>":NULL)."</td>n";
echo "<td style='width: 25%;'>".($sort!=3?"<a href='?sort=3'>":NULL)."<span class='block_l'>Файлы".($count_journal_files>0?" <span class='spared'>(+$count_journal_files)</span>":null)."</span>".($sort!=3?"</a>":NULL)."</td>n";
echo "<td style='width: 25%;'>".($sort!=4?"<a href='?sort=4'>":NULL)."<span class='block_l'>Прочее".($count_journal>0?" <span class='spared'>(+$count_journal)</span>":null)."</span>".($sort!=4?"</a>":NULL)."</td>n";;
echo "</table>n";
echo "</div>n";
if($sort == 1)
{
if($count_journal_diary == 0)
{
echo "<div class='list'>n";
echo "Нет новых событийn";
echo "</div>n";
} else {
$count_results = mysqli_num_rows(mysqli_query($dbi, "SELECT * FROM `diary` WHERE `id_user` = '$user[id]' AND (`id` = '$where_journal_diary')"));
$count_pages = count_pages($count_results);
$page = page();
$start = start_pages();
$query = mysqli_query($dbi, "SELECT * FROM `diary` WHERE `id_user` = '$user[id]' AND (`id` = '$where_journal_diary') ORDER BY `a_time` DESC LIMIT $start, $config[rop]");
while($post = mysqli_fetch_array($query))
{
$komm = mysqli_fetch_array(mysqli_query($dbi, "SELECT * FROM `diary_komm` WHERE `id_diary` = '$post[id]' ORDER BY `time` DESC LIMIT 1"));
$ank = profile($komm['id_user']);
echo "<div class='list'>n";
echo "<a href='/diary/?act=diary&id=$post[id]'>";
if($post['name']!=NULL)$diary_name = $post['name'];
else $diary_name = str_cut($post['text'], 10, 100);
echo hsc($diary_name);
echo "</a>";
echo " <span class='spared'>(+".mysqli_result("SELECT COUNT(*) FROM `diary_komm` WHERE `id_diary` = '$post[id]' AND `time` > '$post[a_time]' AND `id_user` != '$user[id]'").")</span>n";
echo "<br/>n";
echo "$ank[nick] (".vremja($komm['time']).")n";
echo "</div>";
}
pages_show("?sort=1&");
}
echo "<div class='foot'>n";
echo image_back()." <a href='$config[profile_page]?id=$user[id]'>Моя страничка</a>n";
echo "</div>n";
ex_foot();
}
if ($sort == 2)
{
if($count_journal_fotos == 0)
{
echo "<div class='list'>n";
echo "Нет новых событийn";
echo "</div>n";
} else {
$count_results = mysqli_result("SELECT COUNT(*) FROM `foto` WHERE `id_user` = '$user[id]' AND `type` = 'foto' AND (`id` = '$where_journal_fotos')");
$count_pages = count_pages($count_results);
$page = page();
$start = start_pages();
$query = mysqli_query($dbi, "SELECT * FROM `foto` WHERE `id_user` = '$user[id]' AND `type` = 'foto' AND (`id` = '$where_journal_fotos') ORDER BY `a_time` DESC LIMIT $start, $config[rop]");
while($post = mysqli_fetch_array($query))
{
$komm = mysqli_fetch_array(mysqli_query($dbi, "SELECT * FROM `foto_komm` WHERE `id_foto` = '$post[id]' ORDER BY `time` DESC LIMIT 1"));
$ank = profile($komm['id_user']);
echo "<div class='list'>n";
$post['link'] = "/fotos/?foto=$post[id]";
echo "<a href='$post[link]'>n";
echo hsc("$post[name].$post[ras]");
echo "</a>";
echo " <span class='spared'>(+".mysqli_result("SELECT COUNT(*) FROM `foto_komm` WHERE `id_foto` = '$post[id]' AND `time` > '$post[a_time]'").")</span>n";
echo "<br/>n";
echo "$ank[nick] (".vremja($komm['time']).")n";
echo "</div>";
}
pages_show("?sort=3&");
}
echo "<div class='foot'>n";
echo image_back()." <a href='$config[profile_page]?id=$user[id]'>Моя страничка</a>n";
echo "</div>n";
ex_foot();
}
if ($sort == 3)
{
if($count_journal_files == 0)
{
echo "<div class='list'>n";
echo "Нет новых событийn";
echo "</div>n";
} else {
$count_results = mysqli_num_rows(mysqli_query($dbi, "SELECT * FROM `files` WHERE `id_user` = '$user[id]' AND `type` = 'file' AND (`id` = '$where_journal_files')"));
$count_pages = count_pages($count_results);
$page = page();
$start = start_pages();
$query = mysqli_query($dbi, "SELECT * FROM `files` WHERE `id_user` = '$user[id]' AND `type` = 'file' AND (`id` = '$where_journal_files') ORDER BY `a_time` DESC LIMIT $start, $config[rop]");
while($post = mysqli_fetch_array($query))
{
$komm = mysqli_fetch_array(mysqli_query($dbi, "SELECT * FROM `files_komm` WHERE `id_file` = '$post[id]' ORDER BY `time` DESC LIMIT 1"));
$ank = profile($komm['id_user']);
echo "<div class='list'>n";
$post['link'] = "/files/?file=$post[id]";
echo "<a href='$post[link]'>n";
echo hsc("$post[name].$post[ras]");
echo "</a>";
echo " <span class='spared'>(+".mysqli_num_rows(mysqli_query($dbi, "SELECT * FROM `files_komm` WHERE `id_file` = '$post[id]' AND `time` > '$post[a_time]'")).")</span>n";
echo "<br/>n";
echo "$ank[nick] (".vremja($komm['time']).")n";
echo "</div>";
}
pages_show("?sort=2&");
}
echo "<div class='foot'>n";
echo image_back()." <a href='$config[profile_page]?id=$user[id]'>Моя страничка</a>n";
echo "</div>n";
ex_foot();
}
$count_results = mysqli_result("SELECT COUNT(*) FROM `journal` WHERE `id_kont` = '$user[id]' AND `read` = '0'");
$count_pages = count_pages($count_results);
$page = page();
$start = start_pages();
if($count_results == 0)
{
echo "<div class='list'>n";
echo "Нет новых событийn";
echo "</div>n";
}
$query = mysqli_query($dbi, "SELECT * FROM `journal` WHERE `id_kont` = '$user[id]' AND `read` = '0' ORDER BY `time` DESC LIMIT $start, $config[rop]");
while ($post = mysqli_fetch_array($query))
{
$type = $post['type'];
$cat = $post['cat'];
echo "<div class='list'>n";
if($cat == 'guestbook')
{
if(mysqli_num_rows(mysqli_query($dbi, "SELECT * FROM `guestbook` WHERE `id` = '$post[id_object]'"))==0)
{
mysqli_query($dbi, "DELETE FROM `journal` WHERE `id` = '$post[id]'");
echo "<span class='spared'>Комментарий удален</span>n";
}
else
{
$mkomm = mysqli_fetch_array(mysqli_query($dbi, "SELECT * FROM `guestbook` WHERE `id` = '$post[id_object]'"));
$guser = profile($mkomm['id_user_adm']);
$last_komm = mysqli_fetch_array(mysqli_query($dbi, "SELECT * FROM `guestbook` WHERE `id_user_adm` = '$guser[id]' ORDER BY `time` DESC LIMIT 1"));
$ank = profile($last_komm['id_user']);
if($post['last_time'] > $mkomm['time'])$nt = $post['last_time']; else $nt = $mkomm['time'];
$kcount = mysqli_num_rows(mysqli_query($dbi, "SELECT * FROM `guestbook` WHERE `id_user_adm` = '$guser[id]' AND `time` > '$nt'"));
echo "<a href='/guestbook/?id=$guser[id]'>".hsc(str_cut($mkomm['msg'], 10, 100))."</a> <span class='spared'>(+$kcount)</span> (".vremja($mkomm['time']).")n";
echo "<br/>n";
echo "$ank[nick] (".vremja($last_komm['time']).")n";
}
}
elseif($cat=='fotos')
{
if(!mysqli_result("SELECT COUNT(*) FROM `foto_komm` WHERE `id` = '$post[id_object]'"))
{
mysqli_query($dbi, "DELETE FROM `journal` WHERE `id` = '$post[id]'");
echo "<span class='spared'>Комментарий удален</span>";
}
else
{
$mkomm = mysqli_fetch_array(mysqli_query($dbi, "SELECT * FROM `foto_komm` WHERE `id` = '$post[id_object]'"));
$foto = mysqli_fetch_array(mysqli_query($dbi, "SELECT * FROM `foto` WHERE `id` = '$mkomm[id_foto]' AND `type` = 'foto'"));
$foto['link'] = "/fotos/?foto=$foto[id]";
$last_komm = mysqli_fetch_array(mysqli_query($dbi, "SELECT * FROM `foto_komm` WHERE `id_foto` = '$foto[id]' ORDER BY `time` DESC LIMIT 1"));
$ank = profile($last_komm['id_user']);
if ($post['last_time'] > $mkomm['time'])$nt = $post['last_time']; else $nt = $mkomm['time'];
$kcount = mysqli_result("SELECT COUNT(*) FROM `foto_komm` WHERE `id_foto` = '$foto[id]' AND `time` > '$nt'");
echo "<a href='$foto[link]'>".hsc(str_cut($mkomm['msg'], 10, 100))."</a> <span class='spared'>(+$kcount)</span> (".vremja($mkomm['time']).")n";
echo "<br/>n";
echo "$ank[nick] (".vremja($last_komm['time']).")n";
}
}
elseif($cat=='files')
{
if(mysqli_num_rows(mysqli_query($dbi, "SELECT * FROM `files_komm` WHERE `id` = '$post[id_object]'"))==0)
{
mysqli_query($dbi, "DELETE FROM `journal` WHERE `id` = '$post[id]'");
echo "<span class='spared'>Комментарий удален</span>";
}
else
{
$mkomm = mysqli_fetch_array(mysqli_query($dbi, "SELECT * FROM `files_komm` WHERE `id` = '$post[id_object]'"));
$file = mysqli_fetch_array(mysqli_query($dbi, "SELECT * FROM `files` WHERE `id` = '$mkomm[id_file]' AND `type` = 'file'"));
$file['link'] = "/files/?file=$file[id]";
$last_komm = mysqli_fetch_array(mysqli_query($dbi, "SELECT * FROM `files_komm` WHERE `id_file` = '$file[id]' ORDER BY `time` DESC LIMIT 1"));
$ank = profile($last_komm['id_user']);
if ($post['last_time'] > $mkomm['time'])$nt = $post['last_time']; else $nt = $mkomm['time'];
$kcount = mysqli_num_rows(mysqli_query($dbi, "SELECT * FROM `files_komm` WHERE `id_file` = '$file[id]' AND `time` > '$nt'"));
echo "<a href='$file[link]'>".hsc(str_cut($mkomm['msg'], 10, 100))."</a> <span class='spared'>(+$kcount)</span> (".vremja($mkomm['time']).")n";
echo "<br/>n";
echo "$ank[nick] (".vremja($last_komm['time']).")n";
}
}
elseif($cat=='diary')
{
if(mysqli_num_rows(mysqli_query($dbi, "SELECT * FROM `diary_komm` WHERE `id` = '$post[id_object]'"))==0)
{
mysqli_query($dbi, "DELETE FROM `journal` WHERE `id` = '$post[id]'");
echo "<span class='spared'>Комментарий удален</span>";
}
else
{
$mkomm = mysqli_fetch_array(mysqli_query($dbi, "SELECT * FROM `diary_komm` WHERE `id` = '$post[id_object]'"));
$diary = mysqli_fetch_array(mysqli_query($dbi, "SELECT * FROM `diary` WHERE `id` = '$mkomm[id_diary]'"));
$last_komm = mysqli_fetch_array(mysqli_query($dbi, "SELECT * FROM `diary_komm` WHERE `id_diary` = '$diary[id]' ORDER BY `time` DESC LIMIT 1"));
$ank = profile($last_komm['id_user']);
if($post['last_time'] > $mkomm['time'])$nt = $post['last_time']; else $nt = $mkomm['time'];
$kcount = mysqli_num_rows(mysqli_query($dbi, "SELECT * FROM `diary_komm` WHERE `id_diary` = '$diary[id]' AND `time` > '$nt'"));
echo "<a href='/diary/?act=diary&id=$diary[id]'>".hsc(str_cut($mkomm['msg'], 10, 100))."</a> <span class='spared'>(+$kcount)</span> (".vremja($mkomm['time']).")";
echo "<br/>n";
echo "$ank[nick] (".vremja($last_komm['time']).")";
}
}
elseif($cat=='forum')
{
if($type=='komm')
{
if(mysqli_num_rows(mysqli_query($dbi, "SELECT * FROM `forum_komm` WHERE `id` = '$post[id_object]'"))==0)
{
mysqli_query($dbi, "DELETE FROM `journal` WHERE `id` = '$post[id]'");
echo "<span class='spared'>Комментарий удален</span>";
} else {
$mkomm = mysqli_fetch_array(mysqli_query($dbi, "SELECT * FROM `forum_komm` WHERE `id` = '$post[id_object]'"));
$topic = mysqli_fetch_array(mysqli_query($dbi, "SELECT * FROM `forum` WHERE `id` = '$mkomm[id_topic]'"));
$last_komm = mysqli_fetch_array(mysqli_query($dbi, "SELECT * FROM `forum_komm` WHERE `id_topic` = '$topic[id]' ORDER BY `time` DESC LIMIT 1"));
$ank = profile($last_komm['id_user']);
$topic['link'] = "/forum/?act=topic&id=$topic[id]";
if ($topic['id_comm'])$topic['link'] = "/comm/?act=forum&id=$topic[id_comm]&topic_show=$topic[id]";
if ($post['last_time'] > $mkomm['time'])$nt = $post['last_time']; else $nt = $mkomm['time'];
$kcount = mysqli_result("SELECT COUNT(*) FROM `forum_komm` WHERE `id_topic` = '$topic[id]' AND `time` > '$nt' AND `id_user` != '$user[id]'");
echo "<a href='$topic[link]'>".hsc(str_cut($mkomm['msg'], 10, 100))."</a> <span class='spared'>(+$kcount)</span> (".vremja($mkomm['time']).")n";
echo "<br/>n";
echo "$ank[nick] (".vremja($last_komm['time']).")n";
}
} else {
if(mysqli_num_rows(mysqli_query($dbi, "SELECT * FROM `forum` WHERE `id` = '$post[id_object]' AND `type` = 'topic'"))==0)
{
mysqli_query($dbi, "DELETE FROM `journal` WHERE `id` = '$post[id]'");
echo "<span class='spared'>Тема удалена</span>";
} else {
$topic = mysqli_fetch_array(mysqli_query($dbi, "SELECT * FROM `forum` WHERE `id` = '$post[id_object]' AND `type` = 'topic'"));
$last_komm = mysqli_fetch_array(mysqli_query($dbi, "SELECT * FROM `forum_komm` WHERE `id_topic` = '$topic[id]' ORDER BY `time` DESC LIMIT 1"));
$ank = profile($last_komm['id_user']);
$topic['link'] = "/forum/?act=topic&id=$topic[id]";
if ($topic['id_comm'])$topic['link'] = "/comm/?act=forum&id=$topic[id_comm]&topic_show=$topic[id]";
$kcount = mysqli_num_rows(mysqli_query($dbi, "SELECT * FROM `forum_komm` WHERE `id_topic` = '$topic[id]' AND `time` > '$topic[a_time]' AND `id_user` !='$user[id]'"));
echo "<a href='$topic[link]'>".hsc(str_cut($topic['msg'], 10, 100))."</a> <span class='spared'>(+$kcount)</span> (".vremja($topic['time']).")n";
echo "<br/>n";
echo "$ank[nick] (".vremja($last_komm['time']).")n";
}
}
}
echo "</div>n";
}
pages_show("?");
echo "<div class='foot'>n";
echo image_back()." <a href='$config[profile_page]?id=$user[id]'>Моя страничка</a>n";
echo "</div>n";
ex_foot();
?>