Файл: vsime.com/system/includes/count_panel.php
Строк: 330
<?
$count_panel = array();
$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);
$count_panel['journal'] = $count_journal;
$query_sort_lenta_count = mysqli_query($dbi, "SELECT * FROM `lenta` WHERE `id_user` = '$user[id]' AND `trash` = '0' AND `read` = '0' ORDER BY `time` DESC");
$no_ilist_lenta_count = array();
$where_lenta_count = array();
$no_in_list_lenta_count = array();
$lenta_stday_time_lenta_count = 0;
$lenta_ntday_time_lenta_count = $time;
while ($post_lenta_count = mysqli_fetch_array($query_sort_lenta_count))
{
$lenta_stday_time_lenta_count = mktime(0,0,0, date('m', $post_lenta_count['time']), date('d', $post_lenta_count['time']), date('Y', $post_lenta_count['time']));
$lenta_ntday_time_lenta_count = $lenta_stday_time_lenta_count+(3600*24);
if (!isset($no_ilist_lenta_count[$post_lenta_count['id']]))
{
if ($post_lenta_count['type']=='diary')
{
$ank_lenta_count = profile($post_lenta_count['id_ank']);
$diary_lenta_count = mysqli_fetch_array(mysqli_query($dbi, "SELECT * FROM `diary` WHERE `id` = '$post_lenta_count[id_object]'"));
if(($diary_lenta_count['access']=='all' || $diary_lenta_count['access']=='friends' && is_friend($ank_lenta_count['id'], $user['id']) || $diary_lenta_count['access']=='pass') || isset($moderate_diary))$where_lenta_count[] = $post_lenta_count['id'];
}
if ($post_lenta_count['type']=='topic')
{
$ank_lenta_count = profile($post_lenta_count['id_ank']);
$topic_lenta_count = mysqli_fetch_array(mysqli_query($dbi, "SELECT * FROM `forum` WHERE `id` = '$post_lenta_count[id_object]' AND `type` = 'topic'"));
$where_lenta_count[] = $post_lenta_count['id'];
}
if ($post_lenta_count['type']=='file')
{
$files_lenta_lenta_count[$post_lenta_count['id']] = array();
$file_lenta_count = mysqli_fetch_array(mysqli_query($dbi, "SELECT * FROM `files` WHERE `id` = '$post_lenta_count[id_object]'"));
$dir_lenta_count = dir_files_info($file_lenta_count['id_dir']);
if (!dir_files_access($dir_lenta_count, NULL, 1))$no_in_list_lenta_count[] = $post_lenta_count['id'];
$query_files_lenta_count = mysqli_query($dbi, "SELECT * FROM `lenta` WHERE `id_object2` = '$dir_lenta_count[id]' AND `type` = 'file' AND `id_user` = '$user[id]' AND (`time` > '$lenta_stday_time_lenta_count' OR `time` = '$lenta_stday_time_lenta_count') AND (`time` < '$lenta_ntday_time_lenta_count' OR `time` = '$lenta_ntday_time_lenta_count') AND `trash` = '0' AND `read` = '0' ORDER BY `time` DESC");
while ($post_files_lenta_count = mysqli_fetch_array($query_files_lenta_count))
{
$files_lenta_lenta_count[$post_lenta_count['id']][] = $post_files_lenta_count['id'];
$no_ilist_lenta_count[$post_files_lenta_count['id']] = 0;
}
$where_lenta_count[] = $post_lenta_count['id'];
}
if ($post_lenta_count['type']=='foto')
{
$fotos_lenta_lenta_count[$post_lenta_count['id']] = array();
$foto_lenta_count = mysqli_fetch_array(mysqli_query($dbi, "SELECT * FROM `foto` WHERE `id` = '$post_lenta_count[id_object]'"));
$dir_lenta_count = dir_fotos_info($foto_lenta_count['id_dir']);
if (!dir_fotos_access($dir_lenta_count, NULL, 1))$no_in_list_lenta_count[] = $post_lenta_count['id'];
$query_fotos_lenta_count = mysqli_query($dbi, "SELECT * FROM `lenta` WHERE `id_object2` = '$dir_lenta_count[id]' AND `type` = 'foto' AND `id_user` = '$user[id]' AND (`time` > '$lenta_stday_time_lenta_count' OR `time` = '$lenta_stday_time_lenta_count') AND (`time` < '$lenta_ntday_time_lenta_count' OR `time` = '$lenta_ntday_time_lenta_count') AND `trash` = '0' AND `read` = '0' ORDER BY `time` DESC");
while ($post_fotos_lenta_count = mysqli_fetch_array($query_fotos_lenta_count))
{
$fotos_lenta_lenta_count[$post_lenta_count['id']][] = $post_fotos_lenta_count['id'];
$no_ilist_lenta_count[$post_fotos_lenta_count['id']] = 0;
}
$where_lenta_count[] = $post_lenta_count['id'];
}
}
}
if (count($no_in_list_lenta_count)>0)
{
$no_in_list_lenta_count = implode("' AND `id` != '", $no_in_list_lenta_count);
$no_in_list_lenta_count = " AND `id` != '$no_in_list_lenta_count'";
}
else $no_in_list_lenta_count = NULL;
if (count($where_lenta_count)>0)
{
$where_lenta_count = implode("' OR `id` = '", $where_lenta_count);
if ($where_lenta_count!=NULL)$where_lenta_count = " AND (`id` = '$where_lenta_count')";
}
else $where_lenta_count = NULL;
if ($count_panel['journal'] > 0)$journal_new = "<span class='newevent'> +".$count_panel['journal']."</span>"; else $journal_new = NULL;
$count_panel['lenta'] = mysqli_result("SELECT COUNT(*) FROM `lenta` WHERE `id_user` = '$user[id]' AND `trash` = '0' AND `read` = '0'$where_lenta_count$no_in_list_lenta_count");
if ($count_panel['lenta'] > 0)$lenta_new = "<span class='newevent'> +".$count_panel['lenta']."</span>"; else $lenta_new = NULL;
$count_panel['mail'] = mysqli_result("SELECT COUNT(*) FROM `mail` WHERE `id_user` = '$user[id]' AND `type` = 'to' AND `read` = '0'");
if ($count_panel['mail'] > 0)$mail_new = "<span class='newevent'> +".$count_panel['mail']."</span>"; else $mail_new = NULL;
?>