View file downs/index.php

File size: 11.77Kb
<?php

require"../system/config.php";
require"../system/func.php";
//Заголовки загруз центра
if(!empty($_GET['id_file'])){ $tite=mysql_fetch_assoc(mysql_query("SELECT * FROM `down_files` WHERE `typer`!='dir' AND `id_file`='".$_GET['id_file']."' LIMIT 1"));
$title=$tite['nastna'].'.'.$tite['format'].' '.$tite['opis'];}

if(!empty($_GET['dir']) and empty($_GET['id_file'])){ $per=preg_replace('/\/(.*?)\//si','',$_GET['dir']); $per=str_replace('/','',$per);
$oide=mysql_fetch_assoc(mysql_query("SELECT `name` FROM `down_files` WHERE `nastna`='$per' AND `typer`='dir' LIMIT 1")); $title=$oide['name'];}

if(empty($_GET['dir']) and empty($_GET['id_file'])){$title='Загруз центр';}
require"../system/head.php";
require"../system/error.php";
if(isset($_GET['dir'])){
$dir=prov($_GET['dir']);}else{$dir='';}

echo'<div class="i">Загруз центр<br></div>'; switch($mod){
default:
echo'<div class="p"><img src="'.$dirsite.'/design/default/act.gif" alt=""> <a href="new.php">Новые файлы</a><br><img src="'.$dirsite.'/design/default/act.gif" alt=""> <a href="new_day.php?act=go">Новые по дням</a><br>';
echo'<img src="'.$dirsite.'/design/default/act.gif" alt=""> <a href="top.php">Топ файлов</a></div>'; $kateg=mysql_query("SELECT * FROM `down_files` WHERE `put`='$dir' LIMIT 1");
if(mysql_num_rows($kateg)==0){
echo'<div class="p">Тут пока нет файлов...<br></div>';
}else{

if(isset($dir)){$total=mysql_result(mysql_query("SELECT COUNT(*) FROM `down_files` WHERE `put`='$dir'"),0);}else{$total=mysql_result(mysql_query("SELECT COUNT(*) FROM `down_files` WHERE `typer`='dir' AND `put`=''"),0);}
if(!empty($dir)){
$shname=explode('/',$dir);
$votna=$shname[count($shname)-1];
$named=mysql_fetch_array(mysql_query("select * from down_files where typer='dir' and nastna='$votna' limit 1"));
echo'<div class="p">'.$named['name'].'<br></div>';
} $page = abs((int)$_GET['page']); if($page < 0 || $page > $total) $page = 0;
if(!empty($dir)){
if ($total < $page + 10) $end = $total;
else $end = $page + 10; $num=10;}else{
if ($total < $page + 20) $end = $total;
else $end = $page + 20; $num=20;}

$sfiles=mysql_query("SELECT * FROM `down_files` WHERE `put`='$dir'");
$vfiles=mysql_query("SELECT * FROM `down_files` WHERE `put`='$dir' ORDER BY `id_file` DESC LIMIT $page,$num");
$kol=mysql_num_rows($sfiles);
if($kol==0){
echo'<div class="p">Пока нет файлов в этой категории...<br></div>';
}else{
while($ofile=mysql_fetch_array($vfiles)){
//Папка
if($ofile['typer']=='dir'){

$defail=mysql_result(mysql_query("SELECT COUNT(*) FROM `down_files` WHERE `typer`='file' AND `put` LIKE '".$ofile['put']."/".$ofile['nastna']."%'"),0);
$newfl=mysql_result(mysql_query("SELECT COUNT(*) FROM `down_files` WHERE `typer`='file' AND `put` LIKE '".$ofile['put']."/".$ofile['nastna']."%' AND `dobav`>'".(time()-86400*3)."'"),0);
if($newfl!=0){$newfl='/<font color="red">+'.$newfl.'</font>';}else{$newfl='';}
if($defail==0){
$defail=0;
}
elseif($defail!=0){
$defail=$defail.$newfl;
}

echo'<div class="p"> <img src="'.$dirsite.'/img/papka.png" alt=""> <a href="?dir='.$ofile['put'].'/'.$ofile['nastna'].'">'.$ofile['name'].'</a> ['.$defail.']<br>';
if(!empty($ofile['opis'])){echo vizual($ofile['opis']).'<br>';}
echo'</div>';
}else{
//FAIL
$newcolor=mysql_num_rows(mysql_query("SELECT * FROM `down_files` WHERE `dobav`>'".(time()-86400*3)."' AND `typer`!='dir' AND `id_file`='".$ofile['id_file']."'"));

$dokuda='../down/'.$ofile['put'].'/'.$ofile['nastna'].'.'.$ofile['format'];
$vesma=round(filesize($dokuda)/1024);
if($vesma==0){$vesma='Менее 1';}
echo'<div class="p">';
if(empty($ofile['name'])){
$ofile['name']=$ofile['nastna'].'.'.$ofile['format'];
}
echo'<img src="'.$dirsite.'/img/zips.png" alt=""> <a href="'.$ofile['id_file'].'.info">';
if($newcolor==1){echo'<img src="'.$dirsite.'/img/newe.gif" alt=""> 

<font color="red">';}


echo $ofile['name'];

if($newcolor==1){echo'</font>';}

echo'</a>
<br><b>Описание: </b>'; if($ofile['opis']==""){echo'нет';}else{echo mb_substr($ofile['opis'],0,250,'UTF-8');} echo'<br>
Скачали: '.$ofile['loads'].' раз<br>';

if($ofile['format']=="gif" || $ofile['format']=="png" || $ofile['format']=="jpg" || $ofile['format']=="JPG" ||$ofile['format']=="PNG" || $ofile['format']=="GIF"){
if(file_exists('../down'.$ofile['put'].'/'.$ofile['nastna'].'.'.$ofile['format'])){echo'<img src="../down'.$ofile['put'].'/'.$ofile['nastna'].'.'.$ofile['format'].'" height="28" width="28" alt="screen"><br>';
}
if(file_exists('screen'.$ofile['put'].'/'.$ofile['nastna'].'.'.$ofile['format'].'.jpg') or file_exists('screen'.$ofile['put'].'/'.$ofile['nastna'].'.'.$ofile['format'].'.gif') or file_exists('screen'.$ofile['put'].'/'.$ofile['nastna'].'.'.$ofile['format'].'.png')
or file_exists('screen'.$ofile['put'].'/'.$ofile['nastna'].'.'.$ofile['format'].'.GIF') or file_exists('screen'.$ofile['put'].'/'.$ofile['nastna'].'.'.$ofile['format'].'.JPG') or file_exists('screen'.$ofile['put'].'/'.$ofile['nastna'].'.'.$ofile['format'].'.PNG')){echo'Скрин:
есть<br>';
}
}
echo' <img src="'.$dirsite.'/img/logos.gif" alt=""> <a href="load.php?id_load='.$ofile['id_file'].'">Скачать</a> ['.strtoupper($ofile['format']).'] ['.$vesma.'Кб]<br>
';
$koments=mysql_num_rows(mysql_query("select * from koments where type='downs' and id_kogo='".$ofile['id_file']."'"));
$koments=mysql_num_rows(mysql_query("select * from koments where type='downs' and id_kogo='".$ofile['id_file']."'"));
echo' <img src="'.$dirsite.'/img/kom.gif" alt=""> 
 <a href="../pages/koments.php?id_wm='.$ofile['id_file'].'&type=downs&">Комментарии</a> ['.$koments.']<br>
</div>';
}
}

if(empty($dir)){ 
 strpage($page, 20, $total, "index.php");}else{strpage($page, 10, $total, "index.php","dir=$dir&");} }}
if(!empty($dir)){
echo'<div class="p"><img src="../design/default/act.gif" alt="-"> <a href="?dir='.$named['put'].'&">Назад</a><br></div>';
}

break;
case'1':
if(isset($_GET['id_file'])){$id_file=cifry($_GET['id_file']);}else{$id_file=0;}



$finfo=mysql_query("SELECT * FROM `down_files` WHERE `typer`!='dir' AND `id_file`='$id_file' LIMIT 1");
if(mysql_num_rows($finfo)==0){
echo'<div class="p">Ошибка! Файла с таким ID не существует!<br></div>';
}else{
$ofile=mysql_fetch_array($finfo);

mysql_query("UPDATE `down_files` SET `prosm`=`prosm`+1 WHERE `id_file`='$id_file' AND `typer`!='dir'");

$sotg=time()-86400*3;

$imja=$ofile['id_file'];
$newcolor=mysql_num_rows(mysql_query("SELECT * FROM `down_files` WHERE `dobav`>'$sotg' AND `typer`!='dir' AND `id_file`='$imja'"));
$dokuda='../down/'.$ofile['put'].'/'.$ofile['nastna'].'.'.$ofile['format'];
$vesma=round(filesize($dokuda)/1024);
if($vesma==0){$vesma='Менее 1';}
echo'<div class="p"><img src="'.$dirsite.'/img/zips.png" alt="">';
if($newcolor==1){echo'<font color="red">';}
echo $ofile['name'];

if($newcolor==1){echo'</font>';}

echo'</div>';
echo'<div class="p">';
echo'<b>Описание:</b> '; if($ofile['opis']==""){echo'нет';}else{echo $ofile['opis'];} echo'</div>';
echo'<div class="p">';
echo'Добавил: '.nik_two($ofile['hto']).'<br>
Добавлен: '.date_fixed($ofile['dobav']).'<br>Просмотров: '.$ofile['prosm'].'<br>Скачали: '.$ofile['loads'].' раз<br>'; if($ofile['format']=="jpg" or $ofile['format']=="png" or $ofile['format']=="gif" or $ofile['format']=="PNG" or
$ofile['format']=="JPG" or $ofile['format']=="GIF"){
$imgi=getimagesize('../down/'.$ofile['put'].'/'.$ofile['nastna'].'.'.$ofile['format']); echo'Размер: '.$imgi[0].'x'.$imgi[1].'<br>';}

//Вывод скриншотов


if(file_exists('../downs/screen'.$ofile['put'].'/'.$ofile['nastna'].'.'.$ofile['format'].'.png')){echo'<b>Скриншот:</b><br><a href="../downs/screen'.$ofile['put'].'/'.$ofile['nastna'].'.'.$ofile['format'].'.png"><img src="../downs/screen'.$ofile['put'].'/'.$ofile['nastna'].'.'.$ofile['format'].'.png"
height="120" width="115" alt="screen"></a><br>';
}
if(file_exists('../downs/screen'.$ofile['put'].'/'.$ofile['nastna'].'.'.$ofile['format'].'.jpg')){echo'<b>Скриншот:</b><br><a href="../downs/screen'.$ofile['put'].'/'.$ofile['nastna'].'.'.$ofile['format'].'.jpg"><img src="../downs/screen'.$ofile['put'].'/'.$ofile['nastna'].'.'.$ofile['format'].'.jpg"
height="120" width="115" alt="screen"></a><br>';
} if(file_exists('../downs/screen'.$ofile['put'].'/'.$ofile['nastna'].'.'.$ofile['format'].'.PNG')){echo'<b>Скриншот:</b><br><a href="../downs/screen'.$ofile['put'].'/'.$ofile['nastna'].'.'.$ofile['format'].'.PNG"><img src="../downs/screen'.$ofile['put'].'/'.$ofile['nastna'].'.'.$ofile['format'].'.PNG"
height="120" width="115" alt="screen"></a><br>';
}
if(file_exists('../downs/screen'.$ofile['put'].'/'.$ofile['nastna'].'.'.$ofile['format'].'.GIF')){echo'<b>Скриншот:</b><br><a href="../downs/screen'.$ofile['put'].'/'.$ofile['nastna'].'.'.$ofile['format'].'.GIF"><img src="../downs/screen'.$ofile['put'].'/'.$ofile['nastna'].'.'.$ofile['format'].'.GIF"
height="120" width="115" alt="screen"></a><br>';
}

if(file_exists('../downs/screen'.$ofile['put'].'/'.$ofile['nastna'].'.'.$ofile['format'].'.JPG')){echo'<b>Скриншот:</b><br><a href="../downs/screen'.$ofile['put'].'/'.$ofile['nastna'].'.'.$ofile['format'].'.JPG"><img src="../downs/screen'.$ofile['put'].'/'.$ofile['nastna'].'.'.$ofile['format'].'.JPG"
height="120" width="115" alt="screen"></a><br>';
}



if(file_exists('../downs/screen'.$ofile['put'].'/'.$ofile['nastna'].'.'.$ofile['format'].'.gif')){echo'<b>Скриншот:</b><br><a href="../downs/screen'.$ofile['put'].'/'.$ofile['nastna'].'.'.$ofile['format'].'.gif"><img src="../downs/screen'.$ofile['put'].'/'.$ofile['nastna'].'.'.$ofile['format'].'.gif"
height="120" width="115" alt="screen"></a><br>';
}
echo'<img src="'.$dirsite.'/img/logos.gif" alt=""><a href="load.php?id_load='.$ofile['id_file'].'">Скачать</a> ['.strtoupper($ofile['format']).'] ['.$vesma.'Кб]<br><b>Скопировать:</b><br><input type="text" size="18" name="n" value="'.$dirsite.'/down'.$ofile['put'].'/'.$ofile['nastna'].'.'.$ofile['format'].'"
class="form"/></div>
';
$koments=mysql_num_rows(mysql_query("select * from koments where type='downs' and id_kogo='".$ofile['id_file']."'"));
echo'<div class="p">'; if($ofile['format']=="zip"){echo'<img src="/design/default/act.gif" alt=""> <a href="zip.php?arh='.base64_encode('../down'.$ofile['put'].'/'.$ofile['nastna'].'.'.$ofile['format']).'">Просмотр архива</a><br>';}
echo'<img src="'.$dirsite.'/img/kom.gif" alt=""> 
 <a href="../pages/koments.php?id_wm='.$ofile['id_file'].'&type=downs&">Комментарии</a> ['.$koments.']<br>
</div>';

//Функции админа

if($vhod==1){  if($adm_pr==4){echo'<div class="p"><img src="/design/default/act.gif" alt=""> <a href="/downs/?mod=8&id='.$ofile['id_file'].'">Удалить файл</a></div>';}}

if(!empty($dir)){
echo'<div class="p"> <img src="../design/default/act.gif" alt="-"> <a href="?dir='.$dir.'">Назад</a><br></div>';} }
break;
case'8':

if($vhod!=1){ header("Location: index.php"); exit;} if($adm_pr!=4){header("Location: index.php"); exit;}
$id=(int)$_GET['id'];
$y=prov($_GET['y']);
if(empty($y)){echo'<div class="p">Вы действительно хотите удалить этот файл?<br><a href="?mod=8&id='.$id.'&y=y"><input type="submit" value="Да"/></a> <a href="'.$id.'.info">Нет</a></div>';}else{
$er=mysql_query("SELECT * FROM `down_files` WHERE `typer`='file' AND `id_file`='$id' LIMIT 1");
if(mysql_num_rows($er)==1){
$ed=mysql_fetch_assoc($er);
unlink('../down'.$ed['put'].'/'.$ed['nastna'].'.'.$ed['format']);
mysql_query("DELETE FROM `down_files` WHERE `id_file`='$id'");
echo'Файл успешно удален';}else{ echo'Ошибка удаления';}}
break;

}
echo'<div class="p"><img src="'.$dirsite.'/design/default/act.gif" alt=""> <a href="search.php?act=go">Поиск файлов</a></div>';
require"../system/foot.php";
?>