Файл: vsime.com/lenta/inc/act_index.php
Строк: 368
<?
$links_hist['name'] = "$user[nick] / Лента";
$links_hist['link'] = "/lenta/";
ex_head();
// сортировка
$sortq = NULL;
if (isset($_GET['sort']))
{
$sort = intval($_GET['sort']);
if ($sort==2)$sortq .= " AND (`type` = 'diary' OR `type` = 'topic')";
elseif ($sort==3)$sortq .= " AND (`type` = 'file' OR `type` = 'foto')";
else $sort = 1;
} else $sort = 1;
if (isset($_GET['user']) && mysqli_result("SELECT COUNT(*) FROM `user` WHERE `id` = '".intval($_GET['user'])."'")!=0)
{
if (mysqli_result("SELECT COUNT(*) FROM `readers` WHERE `id_user` = '$user[id]' AND `id_ank` = '".intval($_GET['user'])."'")!=0)
{
$author = profile(intval($_GET['user']));
$sortq .= " AND `id_ank` = '$author[id]'";
}
}
// выводим записи для предварительной сортировки на разделы, на самом деле тут все просто
// просто нужно немноооооожко напрягти свои мозги
$query_sort = mysqli_query($dbi, "SELECT * FROM `lenta` WHERE `id_user` = '$user[id]' AND `trash` = '0'$sortq ORDER BY `time` DESC");
$no_ilist = array();
$where = array();
$no_in_list = array();
$lenta_stday_time = 0;
$lenta_ntday_time = $time;
while ($post = mysqli_fetch_array($query_sort))
{
$lenta_stday_time = mktime(0,0,0, date('m', $post['time']), date('d', $post['time']), date('Y', $post['time']));
$lenta_ntday_time = $lenta_stday_time+(3600*24);
if (!isset($no_ilist[$post['id']])) // создал массив, в котором можно укакзть записи, которые не нужно выводить
{
$ank = profile($post['id_ank']);
if ($post['type']=='diary') // если это днев
{
$diary = mysqli_fetch_array(mysqli_query($dbi, "SELECT * FROM `diary` WHERE `id` = '$post[id_object]'"));
if(($diary['access']=='all' || $diary['access']=='friends' && is_friend($ank['id'], $user['id']) || $diary['access']=='pass') || isset($moderate_diary))$where[] = $post['id'];
}
if ($post['type']=='topic') // если это тема
{
$topic = mysqli_fetch_array(mysqli_query($dbi, "SELECT * FROM `forum` WHERE `id` = '$post[id_object]' AND `type` = 'topic'"));
$where[] = $post['id'];
}
if ($post['type']=='file') // если ъто файл, здесь мозг напрягаем
{
$files_lenta[$post['id']] = array(); // создаем массив, для записи в него файлов из папки
$file = mysqli_fetch_array(mysqli_query($dbi, "SELECT * FROM `files` WHERE `id` = '$post[id_object]'"));
$no_hack = 1;
$_GET['id'] = $ank['id'];
$dir = dir_files_info($file['id_dir']); // достаем инфу о папке
if (!dir_files_access($dir, NULL, 1))$no_in_list[] = $post['id']; // если папка нам доступна
// теперь выводим остальные записи ленты о тех файлах, которые добавлены в эту же папку
$query_files = mysqli_query($dbi, "SELECT * FROM `lenta` WHERE `id_object2` = '$dir[id]' AND `type` = 'file' AND `id_user` = '$user[id]' AND `id_ank` = '$ank[id]' AND (`time` > '$lenta_stday_time' OR `time` = '$lenta_stday_time') AND (`time` < '$lenta_ntday_time' OR `time` = '$lenta_ntday_time') AND `trash` = '0'$sortq ORDER BY `time` DESC");
while ($post_files = mysqli_fetch_array($query_files))
{
$files_lenta[$post['id']][] = $post_files['id']; // записываем файл в мвссив
$no_ilist[$post_files['id']] = 0; // добавляем в массив не выводащихся записей
}
$where[] = $post['id'];
}
// с фото все так же, как и с файлами
if ($post['type']=='foto')
{
$fotos_lenta[$post['id']] = array();
$foto = mysqli_fetch_array(mysqli_query($dbi, "SELECT * FROM `foto` WHERE `id` = '$post[id_object]'"));
$no_hack = 1;
$_GET['id'] = $ank['id'];
$dir = dir_fotos_info($foto['id_dir']);
if (!dir_fotos_access($dir, NULL, 1))$no_in_list[] = $post['id'];
$query_fotos = mysqli_query($dbi, "SELECT * FROM `lenta` WHERE `id_object2` = '$dir[id]' AND `type` = 'foto' AND `id_user` = '$user[id]' AND `id_ank` = '$ank[id]' AND (`time` > '$lenta_stday_time' OR `time` = '$lenta_stday_time') AND (`time` < '$lenta_ntday_time' OR `time` = '$lenta_ntday_time') AND `trash` = '0'$sortq ORDER BY `time` DESC");
while ($post_fotos = mysqli_fetch_array($query_fotos))
{
$fotos_lenta[$post['id']][] = $post_fotos['id'];
$no_ilist[$post_fotos['id']] = 0;
}
$where[] = $post['id'];
}
}
}
if (count($no_in_list)>0)
{
$no_in_list = implode("' AND `id` != '", $no_in_list);
$no_in_list = " AND `id` != '$no_in_list'";
}
else $no_in_list = NULL;
if (count($where)>0)
{
$where = implode("' OR `id` = '", $where);
if ($where!=NULL)$where = " AND (`id` = '$where')";
}
else $where = NULL;
if (isset($author))
{
echo "<div class='foot'>n";
echo "<div class='left'>n";
echo show_avatar($author['id'], 'small');
echo "</div>n";
echo "<div class='overfl_hid'>n";
echo profile_icon($author['id']).profile_nick($author['id'], 1);
echo " | <a href='?act=author_settings&id=$author[id]'>Настройки</a>n";
echo "</div>n";
echo "<div class='clear'></div>n";
echo "</div>n";
}
if (isset($_POST['delete']))
{
if ($_POST['mdp'] == $mdp)
{
$count_deleted = 0;
foreach ($_POST as $key => $value)
{
if (preg_match('#^lenta_d([0-9]*)$#', $key, $kid) && $value=='1')
{
$lenta = mysqli_fetch_array(mysqli_query($dbi, "SELECT * FROM `lenta` WHERE `id` = '".intval($kid[1])."' AND `id_user` = '$user[id]'"));
if ($lenta)
{
if ($lenta['type'] == 'diary' || $lenta['type'] == 'topic')
{
mysqli_query($dbi, "UPDATE `lenta` SET `trash` = '1' WHERE `id` = '$lenta[id]'");
}
if ($lenta['type']=='file')
{
foreach ($files_lenta[$lenta['id']] AS $key => $lenta_id)
{
mysqli_query($dbi, "UPDATE `lenta` SET `trash` = '1' WHERE `id` = '$lenta_id'");
}
}
if ($lenta['type']=='foto')
{
foreach ($fotos_lenta[$lenta['id']] AS $key => $lenta_id)
{
mysqli_query($dbi, "UPDATE `lenta` SET `trash` = '1' WHERE `id` = '$lenta_id'");
}
}
$count_deleted++;
}
}
}
if ($count_deleted > 0)msg_sess("Удалено ".sklon_text($count_deleted, array('запись', 'записи', 'записей')));
header("Location: ?act=user");
exit();
} else hacked_by_Killer();
}
$count_results = mysqli_result("SELECT COUNT(*) FROM `lenta` WHERE `id_user` = '$user[id]' AND `trash` = '0'$where$no_in_list$sortq");
$count_pages = count_pages($count_results);
$page = page();
$start = start_pages();
$num = 0;
$page_ololo = 1;
$query = mysqli_query($dbi, "SELECT * FROM `lenta` WHERE `id_user` = '$user[id]' AND `trash` = '0'$where$no_in_list$sortq ORDER BY `time` DESC");
while ($post = mysqli_fetch_array($query))
{
$num++;
if ($num > $config['rop'])
{
$page_ololo++;
$num = 1;
}
if ($page_ololo==$page)
{
$lenta_stday_time = mktime(0,0,0, date('m', $post['time']), date('d', $post['time']), date('Y', $post['time']));
$lenta_ntday_time = $lenta_stday_time+(3600*24);
break;
}
}
if ($count_results != 0)
{
echo "<form method='POST' action='?act=user&' class='multi'>n";
}
echo "<div class='grand_h'>n";
echo "<table>n";
echo "<td>".($sort!=1?"<a href='?".(isset($author)?"user=$author[id]&":NULL)."sort=1'".title_link('Все записи').">":NULL)."<span class='block_l'>Все</span>".($sort!=1?"</a>":NULL)."</td> <td>".($sort!=2?"<a href='?".(isset($author)?"user=$author[id]&":NULL)."sort=2'".title_link('Только записи').">":NULL)."<span class='block_l'>Записи</span></a></td> <td>".($sort!=3?"<a href='?".(isset($author)?"user=$author[id]&":NULL)."sort=3'".title_link('Только файлы').">":NULL)."<span class='block_l'>Файлы</span>".($sort!=3?"</a>":NULL)."</td>n";
echo "</table>n";
echo "</div>n";
if ($count_results == 0)
{
echo "<div class='list_empty'>n";
echo "Нет новых записей";
echo "</div>n";
}
$num = 0;
mysqli_query($dbi, "UPDATE `lenta` SET `read` = '1' WHERE `id_user` = '$user[id]' AND `read` = '0'$no_in_list");
$query = mysqli_query($dbi, "SELECT * FROM `lenta` WHERE `id_user` = '$user[id]' AND `trash` = '0'$where$no_in_list$sortq ORDER BY `time` DESC LIMIT $start, $config[rop]");
while ($post = mysqli_fetch_array($query))
{
$num++;
$ank = profile($post['id_ank']);
echo "<div class='list'>n";
if ($lenta_stday_time > $post['time'] || $num == 1)echo "<span class='right'>".vremja_lenta($post['time'])."</span><br />n";
$lenta_stday_time = mktime(0,0,0, date('m', $post['time']), date('d', $post['time']), date('Y', $post['time']));
$lenta_ntday_time = $lenta_stday_time+(3600*24);
if ($post['type'] == 'diary')
{
$diary = mysqli_fetch_array(mysqli_query($dbi, "SELECT * FROM `diary` WHERE `id` = '$post[id_object]'"));
$count_komms = mysqli_num_rows(mysqli_query($dbi, "SELECT * FROM `diary_komm` WHERE `id_diary` = '$diary[id]'"));
echo "<div class='left'>n";
echo "<span class='left'><input type='checkbox' name='lenta_d$post[id]' value='1'></span> n";
if (!isset($author) || $author['id']!=$ank['id'])show_avatar($ank['id'], 'small');
echo "</div>n";
echo "<div class='overfl_hid'>n";
echo "<span class='right'><a href='?act=delete&id=$post[id]'>$config[code_delete]</a></span>n";
if (!isset($author) || $author['id']!=$ank['id'])echo profile_nick($ank['id'],1,1,"?user=$ank[id]");
echo " создал запись <a href='/diary/?act=diary&id=$diary[id]'>".($diary['name']!=NULL?hsc($diary['name']):str_cut($diary['text'], 5, 50))."</a><br />n";
echo output_text(str_cut($diary['text'], 20, 200), $ank['id']);
echo "<br />n";
echo image_ww('/i/site/message.png')." <a href='/diary/?act=diary&id=$diary[id]#komms'>Обсудить".($count_komms!=0?" ($count_komms)":null)."</a><br/>n";
echo "</div>n";
}
if ($post['type'] == 'topic')
{
$topic = mysqli_fetch_array(mysqli_query($dbi, "SELECT * FROM `forum` WHERE `id` = '$post[id_object]' AND `type` = 'topic'"));
$topic['link'] = "/forum/?act=topic&id=$topic[id]";
if ($topic['id_comm'])$topic['link'] = "/comm/?act=forum&id=$topic[id_comm]&cat_show=$topic[id_cat]&topic_show=$topic[id]";
echo "<div class='left'>n";
echo "<span class='left'><input type='checkbox' name='lenta_d$post[id]' value='1'></span> n";
if (!isset($author) || $author['id']!=$ank['id'])show_avatar($ank['id'], 'small');
echo "</div>n";
echo "<div class='overfl_hid'>n";
echo "<span class='right'><a href='?act=delete&id=$post[id]'>$config[code_delete]</a></span>n";
if (!isset($author) || $author['id']!=$ank['id'])echo profile_nick($ank['id'],1,1,"?user=$ank[id]");
echo " создал тему <a href='$topic[link]'>".hsc($topic['name'])."</a><br />n";
echo output_text(str_cut($topic['msg'], 20, 200), $ank['id']);
echo "</div>n";
}
if ($post['type']=='file')
{
$file = mysqli_fetch_array(mysqli_query($dbi, "SELECT * FROM `files` WHERE `id` = '$post[id_object]'"));
$dir = dir_files_info($file['id_dir']); // достаем инфу о папке
echo "<div class='left'>n";
echo "<span class='left'><input type='checkbox' name='lenta_d$post[id]' value='1'></span> n";
if (!isset($author) || $author['id']!=$ank['id'])show_avatar($ank['id'], 'small');
echo "</div>n";
echo "<div class='overfl_hid'>n";
echo "<span class='right'><a href='?act=delete&id=$post[id]'>$config[code_delete]</a></span>n";
if (!isset($author) || $author['id']!=$ank['id'])echo profile_nick($ank['id'],1,1,"?user=$ank[id]");
echo " добавил файл в <a href='/files/?dir=$dir[id]&id=$ank[id]'>".hsc($dir['name'])."</a><br />n";
//print_r($files_lenta[$post['id']]);
$num_item = 0;
//print_r($files_lenta[$post['id']]);
foreach ($files_lenta[$post['id']] AS $key => $file_id)
{
$num_item++;
$lenta = mysqli_fetch_array(mysqli_query($dbi, "SELECT * FROM `lenta` WHERE `id` = '$file_id' AND `trash` = '0'$sortq"));
$file = mysqli_fetch_array(mysqli_query($dbi, "SELECT * FROM `files` WHERE `id` = '$lenta[id_object]'"));
if (ffs_screen($file['id'], 'file', WapWeb_show(48, 96), WapWeb_show(48, 96)))
{
if (isset($last_item) && $last_item == 'no_screen')echo "<br />n";
echo "<a href='/files/?file=$file[id]'>".ffs_screen($file['id'], 'file', WapWeb_show(48, 96), WapWeb_show(48, 96))."</a>n";
$last_item = 'screen';
} else {
if (isset($last_item))echo "<br />n";
echo "<b class='none'>·</b> <a href='/files/?file=$file[id]'>".hsc($file['name'].'.'.$file['ras'])."</a>n";
$last_item = 'no_screen';
}
if ($num_item >= 4)break;
}
if (count($files_lenta[$post['id']]) > 4)
{
echo "<br />n";
echo "<a href='?act=more&id=$post[id]'>Ещё ".(count($files_lenta[$post['id']]) - 4)." →</a>n";
}
if (isset($last_item))unset($last_item);
echo "</div>n";
}
if ($post['type']=='foto')
{
$foto = mysqli_fetch_array(mysqli_query($dbi, "SELECT * FROM `foto` WHERE `id` = '$post[id_object]'"));
$dir = dir_fotos_info($foto['id_dir']); // достаем инфу о папке
echo "<div class='left'>n";
echo "<span class='left'><input type='checkbox' name='lenta_d$post[id]' value='1'></span> n";
if (!isset($author) || $author['id']!=$ank['id'])show_avatar($ank['id'], 'small');
echo "</div>n";
echo "<div class='overfl_hid'>n";
echo "<span class='right'><a href='?act=delete&id=$post[id]'>$config[code_delete]</a></span>n";
if (!isset($author) || $author['id']!=$ank['id'])echo profile_nick($ank['id'],1,1,"?user=$ank[id]");
echo " добавил фото в <a href='/fotos/?dir=$dir[id]&id=$ank[id]'>".hsc($dir['name'])."</a><br />n";
//print_r($files_lenta[$post['id']]);
$num_item = 0;
foreach ($fotos_lenta[$post['id']] AS $key => $foto_id)
{
$num_item++;
$lenta = mysqli_fetch_array(mysqli_query($dbi, "SELECT * FROM `lenta` WHERE `id` = '$foto_id' AND `trash` = '0'$sortq"));
$foto = mysqli_fetch_array(mysqli_query($dbi, "SELECT * FROM `foto` WHERE `id` = '$lenta[id_object]'"));
if (ffs_screen($foto['id'], 'foto', WapWeb_show(48, 96), WapWeb_show(48, 96)))
{
if (isset($last_item) && $last_item == 'no_screen')echo "<br />n";
echo "<a href='/fotos/?foto=$foto[id]'>".ffs_screen($foto['id'], 'foto', WapWeb_show(48, 96), WapWeb_show(48, 96))."</a>n";
$last_item = 'screen';
} else {
if (isset($last_item))echo "<br />n";
echo "<b class='none'>·</b> <a href='/fotos/?foto=$foto[id]'>".hsc($foto['name'].'.'.$foto['ras'])."</a>n";
$last_item = 'no_screen';
}
if ($num_item >= 4)break;
}
if (count($fotos_lenta[$post['id']]) > 4)
{
echo "<br />n";
echo "<a href='?act=more&id=$post[id]'>Ещё ".(count($fotos_lenta[$post['id']]) - 4)." →</a>n";
}
if (isset($last_item))unset($last_item);
echo "</div>n";
}
echo "<div class='clear'></div>n";
echo "</div>n";
}
if ($count_results != 0)
{
echo "<div class='mod_grad'>n";
echo "<input type='hidden' name='mdp' value='$mdp' />n";
echo "<input type='submit' name='delete' value='Удалить отмеченные' />n";
echo "</div>n";
echo "</form>n";
}
pages_show("?".(isset($author)?"user=$author[id]&":NULL)."sort=$sort&");
echo "<div class='mod_grad'>n";
echo "<img src='/i/site/soo.gif' /> <a href='?act=authors_list'>Список авторов</a><br />n";
echo "<img src='/i/site/trash.png' /> <a href='?act=trash'>Корзина</a><br />n";
echo "</div>n";
echo "<div class='foot'>n";
echo image_back()." <a href='".(isset($author)?"/lenta":"/user")."'>Назад</a>n";
echo "</div>n";
ex_foot();
?>