<?PHP
include"../tools.php";
include"../head.php";
include"config.php";
//начало функции навигации
$pages=hacker($_GET['pages']);
if (empty($_GET['pages']))
{
$pages=hacker($_POST['pages']);
}
if ($pages<=0)
{$pages=1;}
function tr_to_win($str)
{
$str=strtr($str,array("__"=>" ","_"=>"","a"=>"а","b"=>"б","v"=>"в","g"=>"г","d"=>"д","e"=>"е","yo"=>"ё","zh"=>"ж","z"=>"з","i"=>"и","j"=>"й","k"=>"к","l"=>"л","m"=>"м","n"=>"н","o"=>"о","p"=>"п","r"=>"р","s"=>"с","t"=>"т","u"=>"у","f"=>"ф","h"=>"х","c"=>"ц","ch"=>"ч","sh"=>"ш","sch"=>"щ","q"=>"ъ","x"=>"ы","%"=>"ь","ye"=>"э","yu"=>"ю","ya"=>"я",
"A"=>"А","B"=>"Б","V"=>"В","G"=>"Г","D"=>"Д","E"=>"Е","YO"=>"Ё","ZH"=>"Ж","Z"=>"З","I"=>"И","J"=>"Й","K"=>"К","L"=>"Л","M"=>"М","N"=>"Н","O"=>"О","P"=>"П","R"=>"Р","S"=>"С","T"=>"Т","U"=>"У","F"=>"Ф","H"=>"Х","C"=>"Ц","CH"=>"Ч","SH"=>"Ш","SCH"=>"Щ","Q"=>"Ъ","X"=>"Ы","YE"=>"Э","YU"=>"Ю","YA"=>"Я"));
return $str;
}
///////////редактирование комментария к файлу///
if ($_GET['act']=="descr")
{
$qw = mysql_fetch_array(mysql_query("SELECT * FROM `administration` where `iduser`='".$_SESSION['iduser']."'"));
if (mysql_affected_rows()=="1")
{$r="ok";}
if ($qw['type']=="999" and $r=="ok")
{
$qfile = mysql_fetch_array(mysql_query("SELECT * FROM `".$namebase."` where `file`='".hacker($_GET['file'])."' && `type`='file';"));
echo "<div class='contur_rek'>
<div class='header_rek'><span style='color:#c00000;'><b>Редактирование описания!<br/>".$_GET['file']." </b></span></div></div>";
echo "<div><form action='index.php?act=okdescr&kateg=".$_GET['kateg']."&file=".$_GET['file']."' method='post'>
<textarea name='img'>".$qfile['descr']."</textarea><br/>
<input type='submit' value='Назначить'/>
</form></div>";
include"../foot.php";
exit;
}
}
////////////////////////////
if ($_GET['act']=="okdescr")
{
$qw = mysql_fetch_array(mysql_query("SELECT * FROM `administration` where `iduser`='".$_SESSION['iduser']."'"));
if (mysql_affected_rows()=="1")
{$r="ok";}
if ($qw['type']=="999" and $r=="ok")
{
echo "<div class='contur_rek'>
<div class='header_rek'><span style='color:#c00000;'><b>Редактирование описания!</b></span></div></div>";
if (!empty($_POST['img']))
{
if (mysql_query("UPDATE `".$namebase."` SET `descr` = '".hacker($_POST['img'])."' WHERE `file` ='".hacker($_GET['file'])."' && `type`='file' LIMIT 1 ;")){ echo "<div>Успешно отредактировано<br/><a href='index.php?kateg=".$_GET['kateg']."&file=".$_GET['file']."'>К файлу</a></div>";}
}
include"../foot.php";
exit;
}
}
////////////редактирование картинки файла//////////////
if ($_GET['act']=="img")
{
$qw = mysql_fetch_array(mysql_query("SELECT * FROM `administration` where `iduser`='".$_SESSION['iduser']."'"));
if (mysql_affected_rows()=="1")
{$r="ok";}
if ($qw['type']=="999" and $r=="ok")
{
$qfile = mysql_fetch_array(mysql_query("SELECT * FROM `".$namebase."` where `file`='".hacker($_GET['file'])."' && `type`='file';"));
echo "<div class='contur_rek'>
<div class='header_rek'><span style='color:#c00000;'><b>Редактирование картинки!<br/>".$_GET['file']." </b></span></div></div>";
echo "<div><form action='index.php?act=okimg&kateg=".$_GET['kateg']."&file=".$_GET['file']."' method='post'>
<input type='text' name='img' value='".$qfile['image']."' /><br/>
<input type='submit' value='Назначить'/>
</form></div>";
include"../foot.php";
exit;
}
}
////////////////////////////
if ($_GET['act']=="okimg")
{
$qw = mysql_fetch_array(mysql_query("SELECT * FROM `administration` where `iduser`='".$_SESSION['iduser']."'"));
if (mysql_affected_rows()=="1")
{$r="ok";}
if ($qw['type']=="999" and $r=="ok")
{
echo "<div class='contur_rek'>
<div class='header_rek'><span style='color:#c00000;'><b>Редактирование описания!</b></span></div></div>";
if (mysql_query("UPDATE `".$namebase."` SET `image` = '".hacker($_POST['img'])."' WHERE `file` ='".hacker($_GET['file'])."' && `type`='file' LIMIT 1 ;")){ echo "<div>Успешно отредактировано<br/><a href='index.php?kateg=".$_GET['kateg']."&file=".$_GET['file']."'>К файлу</a></div>";}
include"../foot.php";
exit;
}
}
/////////////////////////
//////////переименование файла
if ($act=="rename")
{ $qw = mysql_fetch_array(mysql_query("SELECT * FROM `administration` where `iduser`='".$_SESSION['iduser']."'"));
if (mysql_affected_rows()=="1")
{$r="ok";}
if ($qw['type']=="999" and $r=="ok")
{ $name=explode(".", $_GET['file']);
echo "<div class='contur_rek'>
<div class='header_rek'><span style='color:#c00000;'><b>Редактирование названия файла!</b></span></div></div>";
echo "<div class='contur'>
<div class='header'><form action='index.php?act=renameok&kat=".$_GET['kat']."&file=".$_GET['file']."' method='post'>
<input type='text' name='newname' value='".$name['0']."'/><br/>
<input type='submit' value='ok'/>
</form></div></div>";
include"../foot.php";
exit;
}
}
/////////////////////////////
if ($act=="renameok")
{ $qw = mysql_fetch_array(mysql_query("SELECT * FROM `administration` where `iduser`='".$_SESSION['iduser']."'"));
if (mysql_affected_rows()=="1")
{$r="ok";}
if ($qw['type']=="999" and $r=="ok")
{ $rassh=explode(".",$_GET['file']);
if (!file_exists("".trim($_GET['kat'])."/".trim($_POST['newname']).".".$rassh['1'].""))
{ if (file_exists("".trim($_GET['kat'])."/".trim($_GET['file']).""))
{
if ( rename ("".trim($_GET['kat'])."/".trim($_GET['file'])."", "".trim($_GET['kat'])."/".trim($_POST['newname']).".".$rassh['1'].""))
{
$fa=mysql_query("UPDATE `".$namebase."` set `file`='".trim($_POST['newname']).".".$rassh['1']."' where `file`='".trim($_GET['file'])."' && `type`='file'");
echo "<div class='contur'>
<div class='header'>Переименовано!</div></div>";}
} else {echo "<div class='contur'>
<div class='header'>Такого файла не существует!</div></div>";}
}
else
{echo "<div class='contur'>
<div class='header'>Такое имя уже существует в базе!!</div></div>";}
}
}
/////////////////////////////
/////////////удаление файла
if ($act=="del")
{ $qw = mysql_fetch_array(mysql_query("SELECT * FROM `administration` where `iduser`='".$_SESSION['iduser']."'"));
if (mysql_affected_rows()=="1")
{$r="ok";}
if ($qw['type']=="999" and $r=="ok")
{
$delpre=mysql_fetch_array(mysql_query("select * from `".$namebase."` where `file`='".hacker($_GET['file'])."' && `type`='file';"));
if(unlink("".$_GET['kat']."/".$_GET['file']."") && unlink("preview/".$delpre['image'].""))
{
echo "<div style='color: red'>Файл ".$_GET['file']." удалён! </div>";
mysql_query("delete from `".$namebase."` where file='".hacker(trim($_GET['file']))."';");
echo "<div style='color: red'>Комментарии ".$_POST['file']." удалены! </div>";
}
}
}
/////////////удаление файла конец
if (empty($kateg))
{echo "<div class='contur_rek'>
<div class='header_rek'><span style='color:#c00000;'><p align='center'><big><b>".$nazvanie."</b></big></p></span></div></div>";
/////////блок баннеров в загрузе
echo "<div class='contur_t'>";
$qwer = mysql_query("SELECT * FROM `bannerszag`;");
$i="1";
$aray=array();
while($mne = mysql_fetch_array($qwer))
{
$aray[]=$mne['id'];
}
shuffle($aray);
for ($iii=0; $iii<=2; $iii++)
{
$qwer = mysql_fetch_array(mysql_query("SELECT * FROM `bannerszag` where `id`='".$aray["$iii"]."';"));
echo "<div style='text-align:".$qwer['type'].";'>".$qwer['text']."</div>";
}
echo "</div>";
////////конец блок баннеров в загрузе
$papka = opendir (".");
while ($file = readdir ($papka))
{ if ($file!="index.php" && $file!=".." && $file!="." && $file!="count.php" && $file!="comm.php" && $file!="loadfile.php" && $file!="preview" && $file!=".htaccess" && $file!="config.php")
{$tfiles="0";
echo "<div class='contur'>
<div class='header'><img src='preview/f.gif' alt='fold' /> <a href='?kateg=".$file."'>".tr_to_win($file)."</a>";
$dh = opendir( "$file/" ) or die("Could not open directory");
while ( ! ( ( $file1 = readdir( $dh ) ) === false ) ) {
if ( is_file( "$file/$file1" ) and (!in_array($file,$not_include)) )
{
if ($file1!="index.php")
{
$tfiles=$tfiles+1;
}
}
}
echo " [".$tfiles."] </div></div>";
}
}
}
if (!empty($kateg))
{
print "<div class='contur_rek'>
<div class='header_rek'><div style='text-align:center'><b>Файлы доступные для скачивания<br/>Раздел: ".tr_to_win($kateg)."</b></div></div></div>";
/////////блок баннеров в загрузе
echo "<div class='contur_t'>";
$qwer = mysql_query("SELECT * FROM `bannerszag`;");
while($mne = mysql_fetch_array($qwer))
{
echo "<div style='text-align:".$mne['type'].";'>".$mne['text']."</div>";
}
echo "</div>";
////////конец блок баннеров в загрузе
$tfiles = 1;
///////посчёт файлов в директории/////
$dh = opendir( $kateg ) or die("Could not open directory");
while ( ! ( ( $file = readdir( $dh ) ) === false ) )
{
if ( is_file( "$kateg/$file" ) and (!in_array($file,$not_include)) )
{if ($file!="index.php")
{$rt=$rt+1;}
}
}
///////////////
$ert = ceil($rt/10);
if ($ert<$pages)
{ echo "<div class='contur'><div class='header'>Такой страницы не существует!!!</div></div>";
header("Location: index.php?kateg=".$_GET['kateg']."");
}
if ($ert>=1)
{
echo "<div class='contur'><div class='header'>Страниц:
".$ert."(Вы на: <span style='color:red; text-decoration:blink;'>".$pages."</span>)</div></div>";
}
$dh = opendir( $kateg ) or die("Could not open directory");
while ( ! ( ( $file = readdir( $dh ) ) === false ) ) {
if ( is_file( "$kateg/$file" ) and (!in_array($file,$not_include)) )
{if ($file!="index.php")
{
if ($i<$pages*10 & $i>=($pages-1)*10)
{
$tfiles++;
$file_exist=mysql_query("select * from `".$namebase."` where file='".$file."' && `type`='file' ;");
if (mysql_affected_rows()=="0")
{
mysql_query("INSERT INTO `".$namebase."` ( `id` , `file` , `text` , `time` , `author` , `type` , `image` , `descr` ) VALUES ('', '".$file."', '0', '".time()."', 'Admin', 'file', '', 'Отсутствует');");
}
$messages = mysql_query("select * from `".$namebase."` where `file`='".$file."' && `type`='comm' ;");
$count = mysql_num_rows($messages);
$ii=$i+1;
$file_im = mysql_fetch_array(mysql_query("select * from `".$namebase."` where file='".$file."' && `type`='file' ;"));
print "<div class='contur'><div class='header'>".$ii.". ".$file."<br/>";
echo "<a href='loadfile.php?kat=".$kateg."&id=".$file_im['id']."' >Скачать</a><br/>";
if (!empty($file_im['image']))
{
//здесь сделать проверку тумбс и если нет тубсы то её создать :)
$trumb_dir = "preview";
$filethumb="".$trumb_dir."/small_".$file_im['image']."";
if (!file_exists($filethumb))
{
//это по тумбсу
$jpg_quality = 40;
$trumb_size_y = 100;
$dir_ret = opendir("./$trumb_dir/");
closedir ($dir_ret);
if($dir_ret == False ) mkdir($trumb_dir);
$size = getimagesize("".$trumb_dir."/".$file_im['image']."");
$b=imagecreatefromjpeg("".$trumb_dir."/".$file_im['image'].""); $t=imagecreatetruecolor(($trumb_size_y)*($size[0]/$size[1]),$trumb_size_y);
imagecopyresized($t,$b,0,0,0,0,($trumb_size_y)*($size[0]/$size[1]),$trumb_size_y,$size[0],$size[1]);
if(eregi(".jpg$|.jpeg$","".$trumb_dir."/".$file_im['image']."")) imagejpeg($t,"".$trumb_dir."/small_".$file_im['image']."");
if(eregi(".gif$","".$trumb_dir."/".$file_im['image']."")) imagegif($t,"".$trumb_dir."/small_".$file_im['image']."");
if(eregi(".png$","".$trumb_dir."/".$file_im['image']."")) imagepng($t,"".$trumb_dir."/small_".$file_im['image']."");
}//это по тумбсу
echo "<a href='preview/".$file_im['image']."'><img src='preview/small_".$file_im['image']."' /></a><br/>";
}
echo "Размер:";
$size = "".filesize ("$kateg/$file")."";
$size = "".round(($size/1024), 2)."";
print "<font color='red'> $size KB </font> <br/>Описание: ".$file_im['descr']."<br/><a href='comm.php?name=".$file."&kateg=".$kateg."&pages=".$pages."'>Комментарии</a>(".$count.") ";
$qw = mysql_fetch_array(mysql_query("SELECT * FROM `administration`where `iduser`='".$_SESSION['iduser']."'"));
if (mysql_affected_rows()=="1")
{$r="ok";}
$zagruzok = mysql_query("select * from `".$namebase."` where file='".$file."' && `type`='file' ;");
if (mysql_affected_rows()=="1")
{
$zgrz=mysql_fetch_array($zagruzok);
echo "Скачивали:".$zgrz['text']." раз.<br/>Последний раз: ".date("d.m.Y(H:i)", $zgrz['time'])."";
}
if ($qw['type']=="999" and $r=="ok")
{
echo "<br/><a href='index.php?act=rename&kat=".$kateg."&file=".$file."'>[rename]</a> ";
echo "<a href='index.php?act=del&kat=".$kateg."&file=".$file."'>[del]</a> ";
echo "<a href='index.php?act=img&kateg=".$kateg."&file=".$file."'>[img]</a> ";
echo "<a href='index.php?act=descr&kateg=".$kateg."&file=".$file."'>[descr]</a>";
}
echo "</div></div>";
}
++$i;
}
}
}
$ert = ceil($rt/10);
if ($ert>=1)
{
echo "<div class='contur'><div class='header'>Страниц:
".$ert."<form action='index.php?kateg=".$_GET['kateg']."' method='post'><input type='text' size='3' name='pages'/><input type='submit' value='ok'/></form></div></div>";
}
if ($tfiles>10)
{
$next=$pages+1;
print "<div><a href='index.php?pages=".$next."&kateg=".$_GET[kateg]."'>Далее</a></div>";
}
$prev=$pages-1;
if ($prev!=0)
{print "<div><a href='index.php?pages=".$prev."&kateg=".$_GET[kateg]."'>Назад</a></div>";}
print "<div><a href='index.php'>В разделы</a></div>";
closedir( $dh );
}
echo "<div class='contur'><div class='header'><a href='../index.php'>На главную</a></div></div>";
require ("../foot.php");
?>