View file down/top.php

File size: 5.33Kb
<?php
#-----------------------------------------------------#
# ============ЗАГРУЗ-ЦЕНТР============= #
# 	 Автор : Sea #
# E-mail : [email protected] #
# ICQ : 355152215 #
# Вы не имеете права распространять данный скрипт. #
# 		По всем вопросам пишите в ICQ. #
#-----------------------------------------------------#

// mod Gemorroj

require 'moduls/config.php';
require 'moduls/fun.php';
require 'moduls/header.php';
###############Если топ выключен###############
if(!$setup['top_change']) die('Not found</body></html>');
###############Проверка переменных###############

$onpage = get2ses('onpage');
$prew = get2ses('prew');
$sort = get2ses('sort');
$id = intval($_GET['id']);
$page = intval($_GET['page']);

is_num($onpage,'onpage');
is_num($prew,'prew');

if($prew != 0 and $prew != 1){
$prew = $setup['preview'];
}


$valid_sort = array('load' => '','eval' =>'');
if(!isset($valid_sort[$sort])) $sort = 'load';
if($sort == 'load') $MODE = '`loads` > 0 AND `size` > 0 ORDER BY `loads` DESC';
if($sort == 'eval' and $setup['eval_change']) $MODE = '`yes` > 0 AND `size` > 0 ORDER BY `yes` DESC';
###############Готовим заголовок###################
if($setup['eval_change']==1) $eval = '<a href="top.php?sort=eval">рейтинг</a>'; else $eval='';
if ($sort == 'load') $sortlink = $eval;
if ($sort == 'eval' and $setup['eval_change']==1) $sortlink = '<a href="top.php?sort=load">популярность</a>';
###############Получаем список файлов###############
$query = mysql_query('SELECT * FROM `files` WHERE '.$MODE.' LIMIT 0, '.$setup['top_num']);

while($list_sw = mysql_fetch_array($query)){
$array_id[] = $list_sw['id'];
}
$all = sizeof($array_id);
###############Вывод###############
echo '<div class="mblock"><img src="dis/about.png" alt="">ТОП '.$setup['top_num'].' файлов: <br>Сортировка: '.$sortlink.'</div>';
###############Cтраницы###############
if(!isset($page)) $page=1;
$n = 0;
$pages = ceil($all/$onpage);
if(!$pages) $pages = 1;
if ($page) $n = ($onpage*$page)-$onpage;
###############Если их нет...###########
if($all == 0) echo 'Пока пусто :(';
###############Вывод списка#############
for($i=1; $i<=$onpage; $i++)
{
if(!isset($array_id[$n])){
$n++;
continue;
}
if(is_integer($n / 2)) $row = '<div class="row">'; else $row = '<div class="mainzag">';
$file_info = mysql_fetch_array(mysql_query('SELECT * FROM `files` WHERE `id` = '.$array_id[$n]));
$backdir = @mysql_fetch_array(mysql_query("SELECT * FROM `files` WHERE `path` = '".clean($file_info['infolder'])."'"));
$basename = basename($file_info['path']);
$ex = pathinfo($file_info['path']);
$ext = strtolower($ex['extension']);
$name_file = str_replace('.'.$ex,'',$basename);
//Транслит
if(strpos($basename , '!') !== false){
$name_file = trans($name_file);
}
else{
$name_file = trans2($name_file);
}

//Красивый размер
if($file_info['size'] < 1024) $file_info['size'] = '('.$file_info['size'].'b)';
elseif($file_info['size'] < 1048576 and $file_info['size'] >= 1024) $file_info['size'] = '('.round($file_info['size']/1024, 2).'Kb)';
else $file_info['size'] = '('.round($file_info['size']/1024/1024, 2).'Mb)';

//Предосмотр
$pre='';
if($prew==1)
{
if($ext == 'bmp'){
$pre = 'Предосмотр невозможен<br>';
}
elseif($ext == 'gif' or $ext == 'jpeg' or $ext == 'jpe' or $ext == 'jpg' or $ext == 'png'){
$pre = '<img style="margin: 1px;" src="im.php?id='.$file_info['id'].'" alt=""/><br/>';
}
}
$new_info='';
if ($sort=='load') $info = '[<font color="#FFFF00">'.$file_info['loads'].'</font>]';
if ($sort=='eval' and $setup['eval_change']==1) $info = '[<font color="#800000">'.$file_info['yes'].'</font>/<font color="#004080">'.$file_info['no'].'</font>]';
$filtime2 = $file_info['timeupload']+(3600*24*$setup['day_new']);
if($filtime2>=$_SERVER['REQUEST_TIME']) $new_info = '(New)';
//Иконка к файлу
if(!file_exists("ext/$ext.png")) $ico = '<img src="ext/stand.png" alt="">'; else $ico = '<img src="ext/'.$ext.'.png" alt="">';
if($setup['ext']==1) $extension = '('.$ext.')'; else $extension = '';
//Собсвенно вывод
echo $row.$pre.' '.$ico.'<strong><a href="view.php?id='.$file_info['id'].'">'.$name_file.'</a></strong>'.$extension.$file_info['size'].$info.'[<a href="index.php?id='.$backdir['id'].'">В категорию</a>]<br></div>';
$n++;
}
//------------------------------------------------------------------------------------------
echo '</div><div class="iblock">Страницы: ';
$asd = $page - 2;
$asd2 = $page + 3;
if($asd<$all && $asd>0 && $page>3) echo '<a href="top.php?page=1">1</a> ... ';
for($i=$asd; $i<$asd2;$i++)
{
if($i<$all && $i>0)
{
if ($i > $pages ) break;
if ($page==$i) 	echo '<strong>['.$i.']</strong> ';
else echo '<a href="top.php?page='.$i.'">'.$i.'</a> ';
}
}

if ($i <= $pages)
{
if($asd2<$all) echo ' ... <a href="top.php?page='.$pages.'">'.$pages.'</a>';
}
//------------------------------------------------------------------------------------------
echo '</div><div class="iblock">
- <a href="index.php">Загрузки</a><br/>
- <a href="'.$setup['site_url'].'">На главную</a></div>';

require 'moduls/foot.php';
?>