<?php

/**
 * @package     JohnCMS
 * @link        http://johncms.com
 * @copyright   Copyright (C) 2008-2011 JohnCMS Community
 * @license     LICENSE.txt (see attached file)
 * @version     VERSION.txt (see attached file)
 * @author      http://johncms.com/about
 */

defined('_IN_JOHNCMS') or die('Error: restricted access');

$headmod = 'mail';
$textl = 'Личная почта';
require_once('../incfiles/head.php');

echo '<div class="phdr"><h3>Файлы</h3></div>';
//Отображаем список файлов
$total = mysql_result(mysql_query("SELECT COUNT(*) FROM `cms_mail`
WHERE (`user_id`='$user_id' OR `from_id`='$user_id') AND `delete`!='$user_id' AND `file_name`!='';"), 0);
if ($total) {
    $req = mysql_query("SELECT * FROM `cms_mail` WHERE (`user_id`='$user_id' OR `from_id`='$user_id') AND `delete`!='$user_id' AND `file_name`!=''  ORDER BY `time` DESC LIMIT " . $start . "," . $kmess);
    for ($i = 0; ($row = mysql_fetch_assoc($req)) !== false; ++$i) {
        echo $i % 2 ? '<div class="list1">' : '<div class="list2">';
        echo '<a href="index.php?act=load&amp;id=' . $row['id'] . '">' . $row['file_name'] . '</a> (' . formatsize($row['size']) . ')(' . $row['count'] . ')';
        echo '</div>';
    }
    echo '<div class="phdr">Всего: ' . $total . '</div>';
    //Навигация
    if ($total > $kmess) {
        echo '<p>' . pagenav('index.php?act=files&amp;', $start, $total, $kmess) . '</p>';
        echo '<p><form action="index.php" method="get">
		<input type="hidden" name="act" value="files"/>
		<input type="text" name="page" size="2"/>
		<input type="submit" value="К странице &gt;&gt;"/></form></p>';
    }
} else {
    echo '<div class="rmenu">Файлов нет</div>';
}
echo '<div class="bmenu"><a href="../index.php?act=cab">В кабинет</a></div>';