Файл: top.php
Строк: 152
<?php
// mod Gemorroj
require 'moduls/config.php';
require 'moduls/header.php';
###############Если топ выключен###############
if (!$setup['top_change']) {
error('Not found');
}
###############Проверка переменных###############
$title .= str_replace('%files%', $setup['top_num'], $_SESSION['language']['top20']);
if(@$_REQUEST['go_cat']){
header('Location: '.DIRECTORY.'top/'.int(@$_REQUEST['go_cat']).'/load');
}
$onpage = get2ses('onpage');
if ($onpage < 3) {
$onpage = $setup['onpage'];
}
$prew = get2ses('prew');
if ($prew != 0 && $prew != 1) {
$prew = $setup['preview'];
}
$id = isset($_GET['id']) ? abs($_GET['id']) : 0;
$page = isset($_GET['page']) ? abs($_GET['page']) : 1;
if ($page < 1) {
$page = 1;
}
$out = '';
$banner='';
$Reklames = new Reklames(); // Создаем экземпляр класса Reklames
$banner.= $Reklames->Bottom();
$banner.=$Reklames->Banner();
if(@$_GET['cat']) $cate=int(@$_GET['cat']).'/'; else $cate='';
$mode = '`t1`.`dir` = "0" AND `t1`.`loads` > 0 AND `t1`.`hidden` = "0" AND `t1`.`fileid`="0" ORDER BY `t1`.`loads`';
if(@$_GET['cat']){
$result=mysql_result(mysql_query("SELECT `path` FROM `files` WHERE `id`='".int(@$_GET['cat'])."' LIMIT 1",$mysql),0);
$nomm='`t1`.`path` LIKE "'.$result.'%" AND ';
}else{
$nomm='';
}
###############Получаем список файлов###############
if ($_SESSION['langpack'] == 'russian') {
$sql = mysql_query('
SELECT SQL_CALC_FOUND_ROWS `t1`.`id`,
`t1`.`path`,
`t1`.`infolder`,
`t1`.`rus_name` AS `name`,
`t1`.`size`,
`t1`.`loads`,
`t1`.`timeupload`,
`t1`.`yes`,
`t1`.`no`,
`t2`.`id` AS `back`
FROM `files` AS `t1`
LEFT JOIN `files` AS `t2` ON `t2`.`path` = `t1`.`infolder`
WHERE ' . $nomm . $mode . ' DESC
LIMIT ' . (($page * $onpage) - $onpage) . ', ' . $onpage,
$mysql);
} else {
$sql = mysql_query('
SELECT SQL_CALC_FOUND_ROWS `t1`.`id`,
`t1`.`path`,
`t1`.`infolder`,
`t1`.`name`,
`t1`.`size`,
`t1`.`loads`,
`t1`.`timeupload`,
`t1`.`yes`,
`t1`.`no`,
`t2`.`id` AS `back`
FROM `files` AS `t1`
LEFT JOIN `files` AS `t2` ON `t2`.`path` = `t1`.`infolder`
WHERE ' . $nomm . $mode . ' DESC
LIMIT ' . (($page * $onpage) - $onpage) . ', ' . $onpage,
$mysql);
}
$all = mysql_fetch_row(mysql_query('SELECT FOUND_ROWS();', $mysql));
$all = $all[0] > $setup['top_num'] ? $setup['top_num'] : $all[0];
$onpage = $onpage > $all ? $all : $onpage;
###############Вывод###############
$out .= '<div class="mainzag">' . str_replace('%files%', $setup['top_num'], $_SESSION['language']['top20']) . ':</div>';
$out.= $Reklames->Top();
$nomin='';
$sqle=mysql_query("SELECT `rus_name`,`id`,`name` FROM `files` WHERE `infolder`='".$setup['nomination']."' AND `dir`!='0' ORDER BY `id`",$mysql);
$nomin.='<form action="'.DIRECTORY.'top.php" method="post">'.$_SESSION['language']['nomination'].': <select name="go_cat">';
while($da=mysql_fetch_array($sqle)){
$nomin.='<option value="'.$da['id'].'">'.($_SESSION['langpack'] == 'russian' ? htmlspecialchars($da['rus_name'], ENT_NOQUOTES) : htmlspecialchars($da['name'], ENT_NOQUOTES)).'</option>';
}
$nomin.='</select> <input class="buttom" type="submit" value="' . $_SESSION['language']['go'] . '"/></form>';
$out.='<div class="sort">'.$nomin.'</div>';
###############Cтраницы###############
$pages = ceil($all / $onpage);
if (!$pages) {
$pages = 1;
}
###############Если их нет...###########
if (!$all) {
$out .= $_SESSION['language']['empty2'];
}
###############Вывод списка#############
$bool = true;
$new = 86400 * $setup['day_new'];
while ($v = mysql_fetch_assoc($sql)) {
$bool != $bool;
if ($bool) {
$out .= '<div class="row">';
} else {
$out .= '<div class="row2">';
}
$ext = strtolower(pathinfo($v['path'], PATHINFO_EXTENSION));
//Красивый размер
$v['size'] = '(' . size($v['size']) . ')';
//Новизна файла
if (($v['timeupload'] + $new) >= $_SERVER['REQUEST_TIME'] && $setup['day_new']) {
$new_info = ' <span class="yes">' . $_SESSION['language']['new'] . '</span>';
} else {
$new_info = '';
}
//Предосмотр
$pre = '';
if ($prew) {
$prev_pic = str_replace('/', '--', iconv_substr(strstr($v['path'], '/'), 1));
if ($setup['screen_change'] && ($ext == 'gif' || $ext == 'jpeg' || $ext == 'jpg' || $ext == 'png' || $ext == 'bmp')) {
if (file_exists($setup['picpath'] . '/' . $prev_pic . '.gif')) {
$pre .= '<img style="margin: 1px;" src="' . DIRECTORY . $setup['picpath'] . '/' . htmlspecialchars($prev_pic) . '.gif" alt=""/><br/>';
} else {
$pre .= '<img style="margin: 1px;" src="' . DIRECTORY . 'im/' . $v['id'] . '" alt=""/><br/>';
}
} else if ($setup['screen_change'] && ($ext == 'avi' || $ext == '3gp' || $ext == 'mp4' || $ext == 'flv') && extension_loaded('ffmpeg')) {
$wh = explode('*', $setup['prev_size']);
if (file_exists($setup['ffmpegpath'] . '/' . $prev_pic . '_frame_' . $setup['ffmpeg_frame'] . '.gif')) {
$pre .= '<img style="margin: 1px; width:' . $wh[0] . '; height:' . $wh[1] . ';" src="' . DIRECTORY . $setup['ffmpegpath'] . '/' . htmlspecialchars($prev_pic) . '_frame_' . $setup['ffmpeg_frame'] . '.gif" alt=""/><br/>';
} else {
$pre .= '<img style="margin: 1px; width:' . $wh[0] . '; height:' . $wh[1] . ';" src="' . DIRECTORY . 'ffmpeg/' . $v['id'] . '" alt=""/><br/>';
}
} else if ($setup['screen_change'] && ($ext == 'thm' || $ext == 'nth' || $ext == 'utz' || $ext == 'sdt' || $ext == 'scs')) {
if (file_exists($setup['tpath'] . '/' . $prev_pic . '.gif')) {
$pre .= '<img style="margin: 1px;" src="' . DIRECTORY . $setup['tpath'] . '/' . htmlspecialchars($prev_pic) . '.gif" alt=""/><br/>';
} else if ($setup['swf_change'] && file_exists($setup['tpath'] . '/' . $prev_pic . '.gif.swf')) {
$pre .= '<object style="width:128px; height:128px;"><param name="movie" value="' . DIRECTORY . $setup['tpath'] . '/' . htmlspecialchars($prev_pic) . '.gif.swf"><embed src="' . DIRECTORY . $setup['tpath'] . '/' . htmlspecialchars($prev_pic) . '.gif.swf" style="width:128px; height:128px;"></embed></param></object><br/>';
} else if (!file_exists($setup['tpath'] . '/' . $prev_pic . '.gif.swf')) {
$pre .= '<img style="margin: 1px;" src="' . DIRECTORY . 'theme/' . $v['id'] . '" alt=""/><br/>';
}
} else if ($setup['jar_change'] && $ext == 'jar') {
if (file_exists($setup['ipath'] . '/' . $prev_pic . '.png')) {
$pre .= '<img style="margin: 1px;" src="' . DIRECTORY . $setup['ipath'] . '/' . htmlspecialchars($prev_pic) . '.png" width="16" height="16" alt=""/>';
} else if (jar_ico($v['path'], $setup['ipath'] . '/' . $prev_pic . '.png')) {
$pre .= '<img style="margin: 1px;" src="' . DIRECTORY . $setup['ipath'] . '/' . htmlspecialchars($prev_pic) . '.png" width="16" height="16" alt=""/>';
}
} else if ($setup['apk_change'] && $ext == 'apk') {
if (file_exists($setup['apkpath'] . '/' . $prev_pic . '.png')) {
$pre .= '<img style="margin: 1px;" src="' . DIRECTORY . $setup['apkpath'] . '/' . htmlspecialchars($prev_pic) . '.png" width="16" height="16" alt=""/>';
} else if (apk_ico($v['path'], $setup['apkpath'] . '/' . $prev_pic . '.png')) {
$pre .= '<img style="margin: 1px;" src="' . DIRECTORY . $setup['apkpath'] . '/' . htmlspecialchars($prev_pic) . '.png" width="16" height="16" alt=""/>';
}
} else if ($setup['swf_change'] && $ext == 'swf') {
$pre .= '<object style="width:128px; height:128px;"><param name="movie" value="' . DIRECTORY . htmlspecialchars($v['v']) . '"><embed src="' . DIRECTORY . htmlspecialchars($v['v']) . '" style="width:128px; height:128px;"></embed></param></object><br/>';
}
}
//Иконка к файлу
if (!$pre && file_exists('ext/' . $ext . '.png')) {
$ico = '<img src="' . DIRECTORY . 'ext/' . $ext . '.png" alt=""/> ';
} elseif(!$pre && !file_exists('ext/' . $ext . '.png')) {
$ico = '<img src="' . DIRECTORY . 'ext/stand.png" alt=""/> ';
}elseif($pre && file_exists('ext/' . $ext . '.png')){
$ico = '';
}
//Собсвенно вывод
$out .= $pre . ' ' . $ico . '<strong><a href="' . DIRECTORY . 'view/' . $v['id'] . '">' . htmlspecialchars($v['name'], ENT_NOQUOTES) . '</a></strong>' .$v['size']. $new_info.'</div>';
}
//------------------------------------------------------------------------------------------
if ($pages > 1) {
$out .= '<div class="row">' . $_SESSION['language']['pages'] . ': ';
$asd = $page - 2;
$asd2 = $page + 3;
if ($asd < $all && $asd > 0 && $page > 3) {
$out .= '<a href="' . DIRECTORY . 'top/' . $cate . $sort . '/1">1</a> ... ';
}
for ($i = $asd; $i < $asd2; ++$i) {
if($i < $all && $i > 0) {
if ($i > $pages ) {
break;
}
if ($page == $i) {
$out .= '<strong>' . $i . '</strong>, ';
} else {
$out .= '<a href="' . DIRECTORY . 'top/' . $cate . $sort . '/' . $i . '">' . $i . '</a>, ';
}
}
}
if ($i <= $pages) {
if ($asd2 < $all) {
$out .= ' ... <a href="' . DIRECTORY . 'top/' . $cate . $sort . '/' . $pages . '">' . $pages . '</a>';
}
}
$out .= '</div>';
}
//------------------------------------------------------------------------------------------
echo $out . '<div class="foot"><a href="' . DIRECTORY . '">' . $_SESSION['language']['downloads'] . '</a> |</div>'.$banner;
require 'moduls/foot.php';
?>