<?php

/* DCMS Special
 * Дата последнего редактирования 16.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 = $db->super_query("SELECT COUNT(*) as count FROM videos");
$k_post = $k_post['count'];
$k_page = k_page($k_post, $set['p_str']);
$page = page($k_page);
$start = $set['p_str'] * $page - $set['p_str'];

$q = $db->query("SELECT * FROM `videos` WHERE `id_user` = '$user[id]' ORDER BY `time` DESC  LIMIT $start, $set[p_str]");
if ($db->num_rows($q) == 0) {
    $doc->NoResult();
}

while ($res = $db->get_array($q)) {
    $k = $db->super_query("SELECT COUNT(*) as count FROM `videos_like` WHERE `id_videos` = '" . $res['id'] . "'  LIMIT 1");
    $like = $k['count'];
    $k = $db->super_query("SELECT COUNT(*) as count FROM `videos_views` WHERE `id_videos` = '" . $res['id'] . "'  LIMIT 1");
    $pokz = $k['count'];
    $k = $db->super_query("SELECT COUNT(*) as count FROM `videos_komm` WHERE `id_videos` = '" . $res['id'] . "'  LIMIT 1");
    $comm = $k['count'];

    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';
