<?php
/*~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!
!		!!! Разработка сайтов и отдельных модулей на PHP !!!
!	* - Автор скрипата   :  lugaro
!	* - E-mail           :  lugaro@bk.ru
!	* - Сайт             :  wapNEW.ru
!	* - ICQ              :  2000882
~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!*/
/*Топ 100 новых*/
$tpl->assign_file('mod', 'tpl/inc/top_new.tpl');
$tpl->assign('linc', 'mod=top_new&amp;page=' . (int)$_GET['page']);
// Удаление фото
if (isset($_GET['del_file']) && ($admin || $moder)) {
    $del_file = (int)$_GET['del_file'];
    $file = $db->assoc($db->query("SELECT * FROM `foto_file` WHERE `id` = '$del_file'"));
    $file = 'files/' . $file['id_dir'] . '/' . $file['id_albom'] . '/' . $file['id'] . '.' . $file['ext'];
    if (is_file($file)) unlink($file);
    $db->query("DELETE FROM `foto_file` WHERE `id` = '$del_file'");
	$com = new comments_class_by_lugaro('fotoalbom', $del_file);
	$com->del_group();
}

$all = $db->result($db->query("
		SELECT COUNT(*) FROM `foto_file` WHERE
		(
			(`close` = 0 OR `close` = 1 )
			OR
			(`id_user` = '$user_id' AND close = 2)
		)
		AND
		(`id_user` = '$user_id' OR `mod` = 0)
		AND time > " . (time() - $konf_albom['new_time']) . "
		 ORDER BY `time` DESC LIMIT 100
	"));

if ($all) {
    $n = new navigator($all, $konf_albom['navi'], '?mod=top_new&amp;');
    $n->no_button = true;
    $tpl->assign('page', $n->page);
    // Настройки предпросмотра
    $tpl->parse('index.top_new.prev');
    if (isset($_GET['prev'])) $_SESSION['AlbomPrev'] = $_GET['prev'];

    $sql = $db->query("
			SELECT *  FROM `foto_file` WHERE
			(
				(`close` = 0 OR `close` = 1 )
				OR
				(`id_user` = '$user_id' AND close = 2)
			)
			AND
			(`id_user` = '$user_id' OR `mod` = 0)
			AND time > " . (time() - $konf_albom['new_time']) . "
			ORDER BY `time` DESC LIMIT {$n->start()},{$konf_albom['navi']}
		");

    while (false != ($res = $db->assoc($sql))) {
        $res['color'] = $res['ocenka'] < 0 ? '#FF5353' : '#00FF80';
        $tpl->assign($res);
        if (($admin || $moder) && $vid_adm) $tpl->parse('index.top_new.while.admin');
        if ($res['mod']) $tpl->parse('index.top_new.while.foto_mod'); //На модерации
        $tpl->parse('index.top_new.while');
    }
    $tpl->assign('navi', $n->navi());
} else {
    $tpl->parse('index.top_new.no_file');
}

$tpl->parse('index.top_new');

?>