<?php

/* DCMS Special
 * Дата последнего редактирования 03.01.2016
 * Модифицировал densnet
 */

foreach (array('start', 'compress', 'sess', 'settings', 'db_connect', 'ipua', 'fnc', 'user') as $inc) {
    require_once "../../sys/inc/$inc.php";
}

$doc->Title('Новые видео');

require_once H . 'sys/inc/thead.php';

aut(); // форма авторизации
#Навигация
echo "<div class='list-group-item-null list-group-item-grey'><small>";
echo "<a href='/' class='hint--right' data-hint='" . lang('На главную') . "'><i class='fa fa-home fa-lg'></i></a> <i class='fa fa-angle-right fa-fw'></i> ";
echo "<a href='/modules/videos/'>" . lang('Видео') . "</a> <i class='fa fa-angle-right fa-fw'></i> ";
echo lang('Новое видео');
echo "</small></div><br />";

$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `videos`"), 0);
$k_page = k_page($k_post, $set['p_str']);
$page = page($k_page);
$start = $set['p_str'] * $page - $set['p_str'];

$q = mysql_query("SELECT * FROM `videos` ORDER BY `time` DESC  LIMIT $start, $set[p_str]");
if (mysql_num_rows($q) == 0) {
    $doc->NoResult();
}

while ($res = mysql_fetch_array($q)) {

    $like = mysql_result(mysql_query("SELECT COUNT(*) FROM `videos_like` WHERE `id_videos` = '" . $res['id'] . "'  LIMIT 1"), 0);
    $pokz = mysql_result(mysql_query("SELECT COUNT(*) FROM `videos_views` WHERE `id_videos` = '" . $res['id'] . "'  LIMIT 1"), 0);
    $comm = mysql_result(mysql_query("SELECT COUNT(*) FROM `videos_komm` WHERE `id_videos` = '" . $res['id'] . "'  LIMIT 1"), 0);

    echo "<table class='list-group-item-null'><tr><td class='icon14'>";
    echo '<img src="http://i.ytimg.com/vi/' . $res['kod'] . '/1.jpg" width="70" alt="screen" />';
    echo "</td><td class='null'>";
    echo '<a href="video.php?id=' . $res['id'] . '"> ' . $res['name'] . '</a><br/>';

    echo "<i class='fa fa-heart fa-fw'></i> $like ";
    echo "<i class='fa fa-eye fa-fw'></i> $pokz ";
    echo "<i class='fa fa-comments fa-fw'></i> $comm ";

    echo "</td></tr></table>";
    echo "<div class='hr'></div>";
}

if ($k_page > 1) {
    str("?", $k_page, $page);
}

require_once H . 'sys/inc/tfoot.php';
