Просмотр файла sea/index.php

Размер файла: 10.47Kb
<?
#-----------------------------------------------------#
#     ============ЗАГРУЗ-ЦЕНТР=============           #
#             	 Автор  :  Sea                   	  #
#               E-mail  :  [email protected]              #
#                  ICQ  :  355152215                   #
#   Вы не имеете права распространять данный скрипт.  #
#   		По всем вопросам пишите в ICQ.            #
#-----------------------------------------------------#
include 'moduls/ini.php';
include 'moduls/head.php';
include 'moduls/fun.php';
include 'moduls/connect.php';
include 'moduls/header.php';
###############Проверка переменных###############
$onpage = get2ses('onpage');
$prew   = get2ses('prew');
$sort   = get2ses('sort');
is_num($id,'id');
is_num($onpage,'onpage');
is_num($page,'page');
is_num($start,'start');
is_num($prew,'prew');
if(!isset($start)) $start = 0;
if(!isset($prew) or $prew != 0 and $prew != 1) $prew = $setup[preview];
$valid_sort = array('name' => '','data' => '','load' => '','size' => '','eval' =>'');
if(!isset($valid_sort[$sort]) )  die($hackmess);
if($sort == 'name') $MODE = '`priority` DESC,`name` ASC';
if($sort == 'data') $MODE = '`priority` DESC,`timeupload` DESC';
if($sort == 'size') $MODE = '`priority` DESC,`size` ASC';
if($sort == 'load') $MODE = '`priority` DESC,`loads` DESC';
if($sort == 'eval' and $setup['eval_change']==1) $MODE = '`priority` DESC,`yes` DESC ,`no` ASC';
###############Получаем текущий каталог#############
if(!$id) $d['path'] = $setup['path']."/"; else $d = mysql_fetch_array(mysql_query('SELECT * FROM `files` WHERE `id` = "'.$id.'"'));
if(!is_dir ($d['path'])) die('Такой категории не существует.');
###############Онлайн#############
$online = mysql_fetch_array(mysql_query('SELECT * FROM `online` WHERE `ip` = "'.clean($ip).'";'));
if(empty($online['id'])) $query = mysql_query("INSERT INTO `online` (`ip`,`time`) VALUES ( '".clean($ip)."','$time');");
else $query = mysql_query("UPDATE `online` SET `time`='$time' WHERE `id` = '".$online['id']."';");
$query = mysql_query("DELETE FROM `online` WHERE '$time' - `time` > '".intval($setup['online_time'])."' AND `id`<>'1';");
$all_online = mysql_fetch_array(mysql_query('SELECT COUNT(*) FROM `online` WHERE `id`<>"1";'));
$max_online = mysql_fetch_array(mysql_query('SELECT `time` FROM `online` WHERE `id` = "1";'));
if($all_online[0] > $max_online[0]) $query = mysql_query("UPDATE `online` SET `time`='$all_online[0]' WHERE `id` = '1';");
###############Постраничная навигация###############
$all = mysql_fetch_array(mysql_query('SELECT COUNT(*) FROM `files` WHERE `infolder` = "'.$d['path'].'"'));
$all = $all[0];
$pages = ceil($all/$onpage);
if(!$pages) $pages = 1;
if($page>$pages or $page<=0) $page=1;
if($start>$all or $start<=0) $start = 0;
if($page) $start = ($page - 1) * $onpage; else $start = 0;
###############Получаем список файлов###############
$query = mysql_query("SELECT `id` FROM `files` WHERE `infolder` = '".$d['path']."' ORDER BY $MODE LIMIT ".$start.", ".$onpage."");
while($list_sw = mysql_fetch_array($query)) $array_id[] = $list_sw['id'];
###############Готовим заголовок###################
$ex = explode('/',$d['path']);
foreach($ex as $k=>$v)
{
	if($v!='' and $v!='.' and $v!='..' and $v!=$setup['path'])
	{
  		$s = mysql_fetch_array(mysql_query("SELECT `id`,`name` FROM `files` WHERE `path` LIKE '%".clean($v)."/' AND `size` = '0'"));
  		$s['name'] = str_replace('*','',$s['name']);
  		if($k >= count($ex)-2) $put .= $s['name'];
  		else $put .= "<a href='index.php?id=".$s['id']."'>".$s['name']."</a>&raquo;";
 	}
}
##############Заголовок##########################
echo '<div class="mainzag">';
echo '<img src="dis/load.png" alt=""><a href="index.php">Загрузки</a>&raquo;'.$put.'</div>';
###############Вывод рекламы###############
if($setup['buy_change']==1)
{
    echo '<div class="iblock">';
	$list = explode("\n",$setup['buy']);
    if($setup['randbuy']==1) echo bbcode($list[mt_rand(0,count($list)-1)]);
    else foreach($list as $value) echo bbcode($value).'<br>';
	echo '</div>';
}
############################################
if($setup['search_change']==1 or $setup['top_change']==1) echo '<div class="iblock">';
if($setup['search_change']==1) echo '<a href="search.php">Поиск файлов</a><br>';
if($setup['top_change']==1)    echo '<a href="top.php">ТОП '.$setup['top_num'].' файлов</a></div>';
###############Список фалов и папок###############
if ($all == 0) echo '<div class="mainzag"><b>[Раздел пуст]</b></div>';
foreach($array_id as $key => $value)
{
 	$file_info = mysql_fetch_array(mysql_query('SELECT `id`,`name`,`path`,`fastabout`,`timeupload`,`infolder`,`size`,`loads`,`yes`,`no` FROM `files` WHERE `id` = "'.$value.'";'));
 	if(is_integer($key / 2)) $row = '<div class="mainzag">'; else $row = '<div class="row">';
 	if (!empty($file_info['fastabout'])) $file_info['about'] = str_replace("\n", "<br>",$file_info['about']);
	if(is_dir($file_info['path']))
 	{
   		//Кол-во новых файлов в папке
   		$new_all="";
        $stime=$time-(3600*24*$setup['day_new']);
   		//NOT USE//$new_all = mysql_fetch_array(mysql_query('SELECT COUNT(*) FROM `files` WHERE `timeupload` > "'.$stime.'" AND `infolder` REGEXP "'.$file_info['path'].'*" AND `size` > "0";'));
   		if($setup['day_new']!=0) $new_all = mysql_fetch_array(mysql_query('SELECT COUNT(*) FROM `files` WHERE `timeupload` > "'.$stime.'" AND `infolder` LIKE  "'.$file_info['path'].'%" AND `size` > "0";'));
		if($new_all[0] and $setup['day_new']!=0) $new_all = '(<font color="#00FF00">+'.$new_all[0].'</font>)'; else $new_all="";
   		//Всего файлов в папке
   		//NOT USE//$allinfolder = mysql_fetch_array(mysql_query('SELECT COUNT(*) FROM `files` WHERE `infolder` REGEXP "'.$file_info['path'].'*" AND `size` > "0";'));
   		$allinfolder = mysql_fetch_array(mysql_query('SELECT COUNT(*) FROM `files` WHERE `infolder` LIKE  "'.$file_info['path'].'%" AND `size` > "0";'));
		$name = str_replace("*","",$file_info['name']);
		//Иконка к папке
		if(!file_exists($file_info['path'].'folder.png')) $ico = '<img src="ext/dir.png" alt="">'; else $ico = "<img src='".$file_info['path']."folder.png' alt=''>";
		//Собсвенно вывод
   		echo $row;
   		echo $ico.'<b><a href="index.php?id='.$file_info[id].'">'.$name.'</a></b>('.$allinfolder[0].')'.$new_all;
        if(!empty($file_info['fastabout'])) echo '<br>'.str_replace("\n", "<br>",$file_info['fastabout']);
   		echo '</div>';
 	}
 	elseif(is_file($file_info['path']))
 	{
  		$ex = pathinfo($file_info['path']);
 		$ext = strtolower($ex['extension']);
  		//Предосмотр
  		$pre = "";
  		if ($prew==1)
  		{
   			if ($ext == 'bmp') $pre = "Предосмотр невозможен <br/>";
   			if ($ext == 'gif' or $ext == 'jpeg' or $ext == 'jpg' or $ext == 'png') $pre = '<img style="margin: 1px;" src="im.php?id='.$file_info['id'].'" alt=""/> <br/>';
  		}
  		//Komments and loads
  		$all_komments = @mysql_fetch_array(mysql_query('SELECT COUNT(*) FROM `komments` WHERE file_id = "'.$file_info['id'].'"'));
  		$all_komments = $all_komments[0];
  		$all_loads = $file_info['loads'];
  		$file_time = date("d.m.y", $file_info['timeupload']);
  		if ($sort=='name'or $sort=='size') $info = '';
  		if($sort=='load') $info = '(<font color="#FFFF00">'.$all_loads.'</font>)';
  		if ($sort=='data') $info = "($file_time)";
  		if ($sort=='eval' and $setup['eval_change']==1) $info = '(<font color="#800000">'.$file_info[yes].'</font>/<font color="#004080">'.$file_info[no].'</font>)';
  		//Новизна файла
  		$new_info="";
  		$filtime2 = $file_info['timeupload']+(3600*24*$setup['day_new']);
  		if($filtime2>=$time and $setup['day_new']!=0) $new_info = '<font color="black">Новинка!</font>';
  		//Красивый размер
  		if($file_info['size'] < 1024) $file_info['size'] = "(".$file_info['size']."b)";
  		if($file_info['size'] < 1048576 and $file_info['size'] >= 1024) $file_info['size'] = '('.round($file_info['size']/1024, 2).'Kb)';
  		if($file_info['size'] > 1048576) $file_info['size'] = '('.round($file_info['size']/1024/1024, 2).'Mb)';
  		//Иконка к файлу
  		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;
  		echo $pre.$ico.'<a href="view.php?id='.$file_info[id].'"><b>'.$file_info['name'].'</b></a>'.$extension.$file_info['size'].$info.'[<a href="load.php?id='.$file_info[id].'"><font color="#FFFF00">L</font></a>]'.$new_info.'<br>';
  		if(!empty($file_info['fastabout'])) echo str_replace("\n", '<br>',$file_info['fastabout']);
  		echo '</div>';
 	}
}
###############Постраничная навигация########
echo '<div class="iblock">Страницы: ';
$asd= $page - 2;
$asd2= $page + 3;
if($asd<$all && $asd>0 && $page>3) echo "<a href=\"index.php?id=$id&amp;page=1\">1</a> ... ";
for($i=$asd; $i<$asd2;$i++)
{
	if($i<$all && $i>0)
 	{
  		if ($i > $pages )  break;
  		if ($page==$i) echo "<b>[$i]</b> ";
  		else echo "<a href=\"index.php?id=".$id."&amp;page=$i\">$i</a> ";
 	}
}
if ($i <= $pages)
{
 	if($asd2<$all) echo " ... <a href=\"index.php?id=$id&amp;page=$pages\">$pages</a>";
}
echo '<br/>';
###############Ручной ввод страниц###############
if ($pages>$setup['pagehand'] and $setup['pagehand_change'] == 1)
{
 	echo "Страница $page из $pages:<br/>";
 	echo '<form action="index.php?id='.$id.'" method="post">';
 	echo '<input class=enter name="page" type="text" maxlength="4" size="8" value="">';
 	echo '&nbsp;<input class=buttom type="submit" value="Перейти">';
 	echo '</form>';
}
echo '</div>';
echo '<div class=iblock>';
echo '- <a href="user.php?id='.$id.'">Настройки</a><br>';
if($setup['stat_change'] == 1) echo '- <a href="stat.php">Статистика</a><br>';
if($setup['zakaz'] == 1) echo '- <a href="table.php">Стол заказов</a><br>';
echo '- <a href="'.$setup['site_url'].'">На главную</a>';
if($setup['online'] == 1)echo '<br>- Online: <b>'.$all_online[0].'</b><br>';
echo '</div>';
include 'moduls/foot.php';
?>