<?php
########################################
## WAP-ENGINE ##
########################################
## ##
## Автор : CHUMA (Токарев Владимир) ##
## e-mail : [email protected] ##
## WAP : http://wap-engine.ru ##
## ##
########################################
## ВЫ НЕ ИМЕЕТЕ ПРАВО ##
## ИЗМЕНЯТЬ КОД СКРИПТА ##
## ДЛЯ ДАЛЬНЕЙШЕГО РАСПРОСТРАНЕНИЯ! ##
########################################
include ('../../config.php');
include ('../../templates/run.php');
include ('../../templates/func.php');
$title_page = 'Загрузки';
$m_polozhenie = 'В загрузках';
####################
if ($portal=='off')
{
include '../../themes/'.$themes.'.php';
echo'<p align="center">'.$offmes.'</p>';
}
if ($portal=='on')
{
$file_get = stripslashes(trim($_GET['file']));
$kat = stripslashes(trim($_GET['kat']));
if(empty($kat))
{
$kat = '.';
}
if((!isset($passw) || $_SESSION['sespass'] != $passw) && $dostup_files == 0)
{
include '../../themes/'.$themes.'.php';
echo'<p class="err">Вы не авторизованы!!! Войдите в личный кабинет.<br /></p>';
echo'<p><a href="../kabinet/index.php?'.session_name().'='.session_id().'">В кабинет</a><br /></p>';
include ("../../templates/foot.php");
exit;
}
if(!empty($_GET['kat']) && (!preg_match("#^[^><|?*\:\"]+$#", $kat) || preg_match("#(\.\.)+|^(\/)+|^(\.)+$|^(\.\/)+$|^(\.\/\.)+$|(\/\/)+#", $kat)))
{
include '../../themes/'.$themes.'.php';
echo"<p class=\"err\">Ошибка!!! Неправильное название категории.</p>";
echo"<p><a href=\"index.php?".session_name()."=".session_id()."\">В загрузки</a><br /></p>";
include ("../../templates/foot.php");
exit;
}
if(!file_exists("../../modules/zagruz/$kat"))
{
include '../../themes/'.$themes.'.php';
echo"<p class=\"err\">Ошибка!!! Данная категория не существует.</p>";
echo"<p><a href=\"index.php?".session_name()."=".session_id()."\">В загрузки</a><br /></p>";
include ("../../templates/foot.php");
exit;
}
if(!empty($_GET['file']) && (!preg_match("#^[^><|?*/\:\"]+$#", $file_get) || preg_match("#(\.\.)+#", $file_get) || empty($_GET['kat'])))
{
include '../../themes/'.$themes.'.php';
echo"<p class=\"err\">Ошибка!!! Неправильное название файла.</p>";
echo"<p><a href=\"index.php?".session_name()."=".session_id()."\">В загрузки</a><br /></p>";
include ("../../templates/foot.php");
exit;
}
if(!file_exists("../../modules/zagruz/$kat/$file_get"))
{
include '../../themes/'.$themes.'.php';
echo"<p class=\"err\">Ошибка!!! Данный файл не существует.</p>";
echo"<p><a href=\"index.php?".session_name()."=".session_id()."\">В загрузки</a><br /></p>";
include ("../../templates/foot.php");
exit;
}
####################
$file_get = filter($file_get);
$kat = filter($kat);
$kat_name = @file($kat.'/op/op.txt');
$kat_name = trim($kat_name[0]);
if($_GET['view'] == 1)
{
$title_kat_name = ' » '.$kat_name.' » Загрузки';
}
elseif($kat != '.')
{
$title_kat_name = $kat_name.' » Загрузки';
}
else
{
$title_kat_name = 'Загрузки';
}
preg_match("#^([^><|?*/\:\"]+)\.([a-z0-9]{0,4})$#", $file_get, $repl);
$file_tr = $repl[1];
$file_f = @file($kat.'/op/'.$file_tr.'.txt');
$file_name = trim($file_f[0]);
if(empty($file_name))
{
$file_name = $file_tr;
}
$title_page = ''.$file_name.$title_kat_name;
include '../../themes/'.$themes.'.php';
####################
function dir_list($kat, $file_get)
{
global $color_red;
include ('../../config.php');
$dir = $kat;
$dir_kat = opendir ($dir);
$dir_file = opendir ($dir);
if($dir != '.')
{
$dir_exp = explode('/', $dir);
$dir_exp_count = count($dir_exp);
echo'<p class="modul_name"><a href="index.php?'.session_name().'='.session_id().'">Загрузки</a>';
for($i=0; $i < $dir_exp_count; $i++)
{
if($dir_exp[$i] != '.')
{
$dir_plus = $dir_plus.'/'.$dir_exp[$i];
$kat_name = @file('.'.$dir_plus.'/op/op.txt');
$kat_name = trim($kat_name[0]);
if('.'.$dir_plus == $dir && $_GET['view'] == 1)
{
echo" » <a href=\"index.php?kat=.$dir_plus&".session_name()."=".session_id()."\">$kat_name</a>";
}
elseif('.'.$dir_plus == $dir)
{
echo' » '.$kat_name;
}
else
{
echo" » <a href=\"index.php?kat=.$dir_plus&".session_name()."=".session_id()."\">$kat_name</a>";
}
}
}
echo'</p>';
}
else
{
echo'<p class="modul_name">Загрузки</p>';
}
if($dir == '.')
{
echo'<p align="center"class="b"><a href="kom.php?act=last_mes&'.session_name().'='.session_id().'">Последние комментарии</a><br /></p>';
}
if($_GET['view'] == 1)
{
preg_match("#^([^><|?*/\:\"]+)\.([a-z0-9]{0,4})$#", $file_get, $repl);
$file_tr = $repl[1];
$file_f = @file($dir.'/op/'.$file_tr.'.txt');
$file_name = trim($file_f[0]);
if(empty($file_name))
{
$file_name = $file_tr;
}
$sizef = stat(filter($dir.'/'.$file_get));
$kb = 1024;
$size_file = round($sizef[7] / $kb, 2);
$date_zag = date ('d/m/Y H:i:s', filemtime(filter($dir.'/'.$file_get)));
$date_zag_2 = filemtime(filter($dir.'/'.$file_get));
$datanew = $date_zag_2 + 432000;
$datenow = time();
$load_data = @file($kat.'/op/'.$file_get.'_load.txt');
$loads = trim($load_data[0]);
if(empty($loads))
{ $loads = 0; }
if(preg_match('#[0-9]*(?:2|3|4)$#', $loads))
{ $raz = 'раза'; } else { $raz = 'раз'; }
echo '<p class="b">';
if($datanew > $datenow)
{
echo '<font color="'.$color_red.'">Новый файл</font><br />';
}
echo 'Имя: '.$file_name.'<br />';
echo 'Тип: '.$repl[2].'<br />';
echo 'Файл загружен:<br />'.$date_zag.'<br />';
echo 'Размер: '.$size_file.' Кб<br />';
echo 'Скачали: '.$loads.' '.$raz.'<br />';
if(!preg_match('#\.jar$#', $file_get))
{
if(preg_match('#\.gif$|\.jpg$|\.jpeg$|\.jpe$|\.png$#', $file_get))
{
$pic = urldecode(htmlspecialchars(str_replace('./', '', $dir.'/'.$file_get)));
$size_img = getimagesize($pic);
echo "<img src=\"/images/st/dload.gif\"alt=\"\"/> <a href=\"dload.php?kat=$dir&file=$file_get&".session_name()."=".session_id()."\">Скачать</a>(оригинал: $size_img[0]x$size_img[1])<br />";
}
else
{
echo "<img src=\"/images/st/dload.gif\"alt=\"\"/> <a href=\"dload.php?kat=$dir&file=$file_get&".session_name()."=".session_id()."\">Скачать</a><br />";
}
}
if(preg_match('#\.jar$#', $file_get))
{
$jad = str_replace('.jar', '.jad', $file_get);
echo "<img src=\"/images/st/dload.gif\"alt=\"\"/> <a href=\"dload.php?kat=$dir&file=$file_get&".session_name()."=".session_id()."\">Скачать JAR</a><br />";
if(file_exists("$dir/$jad"))
{
echo "<img src=\"/images/st/dload.gif\"alt=\"\"/> <a href=\"dload.php?kat=$dir&file=$jad&".session_name()."=".session_id()."\">Скачать JAD</a><br />";
}
}
if (file_exists($dir.'/op/'.$file_tr.'.txt'))
{
echo '<br />Описание:<br />';
$opis_arr = file($dir.'/op/'.$file_tr.'.txt');
$count_opis = count($opis_arr);
for ($i = 1; $i < $count_opis; $i++)
{
$text_opis .= trim($opis_arr[$i]).'<br />';
}
if($text_opis == "")
{
echo" (нет описания)";
}
else
{
echo" $text_opis";
}
}
if (file_exists("$dir/op/$file_tr.gif"))
{
echo "<br />Скриншот: ";
echo "<br /><img src=\"img.php?img=$dir/op/$file_tr.gif&wid=240\" alt=\"prev\" />";
echo "<br />";
}
if (file_exists("$dir/op/$file_tr.jpg"))
{
echo "<br />Скриншот: ";
echo "<br /><img src=\"img.php?img=$dir/op/$file_tr.jpg&wid=240\" alt=\"prev\" />";
echo "<br />";
}
if (file_exists("$dir/op/$file_tr.png"))
{
echo "<br />Скриншот: ";
echo "<br /><img src=\"img.php?img=$dir/op/$file_tr.png&wid=240\" alt=\"prev\" />";
echo "<br />";
}
echo "</p>";
if(preg_match("#\.gif$|\.jpg$|\.jpeg$|\.jpe$|\.png$#", $file_get))
{
echo "<p class=\"b\">Просмотр: ";
echo "<br /><img src=\"img.php?img=$dir/$file_get\" alt=\"prev\" />";
echo "<br />Скачать для вашего экрана:";
echo "<br />
<a href=\"img.php?kat=$dir&file=$file_get&hei=80&".session_name()."=".session_id()."\">101x80</a>|<a href=\"img.php?kat=$dir&file=$file_get&hei=90&".session_name()."=".session_id()."\">128x90</a><br />
<a href=\"img.php?kat=$dir&file=$file_get&wid=128&".session_name()."=".session_id()."\">128x128</a>|<a href=\"img.php?kat=$dir&file=$file_get&wid=128&".session_name()."=".session_id()."\">128x160</a><br />
<a href=\"img.php?kat=$dir&file=$file_get&wid=132&".session_name()."=".session_id()."\">132x176</a>|<a href=\"img.php?kat=$dir&file=$file_get&hei=144&".session_name()."=".session_id()."\">176x144</a><br />
<a href=\"img.php?kat=$dir&file=$file_get&wid=176&".session_name()."=".session_id()."\">176x208</a>|<a href=\"img.php?kat=$dir&file=$file_get&wid=176&".session_name()."=".session_id()."\">176x220</a><br />
<a href=\"img.php?kat=$dir&file=$file_get&wid=208&".session_name()."=".session_id()."\">208x208</a>|<a href=\"img.php?kat=$dir&file=$file_get&wid=240&".session_name()."=".session_id()."\">240x266</a><br />
<a href=\"img.php?kat=$dir&file=$file_get&wid=240&".session_name()."=".session_id()."\">240x320</a>|<a href=\"img.php?kat=$dir&file=$file_get&wid=320&".session_name()."=".session_id()."\">320x240</a><br />";
echo "</p>";
echo "<form action=\"img.php?".session_name()."=".session_id()."\" method=\"get\"><p class=\"b\">";
echo "Уникальный размер:<br />
Ширина: <input type=\"text\" name=\"wid\" size=\"4\" maxlength=\"4\" value=\"\" /><br />
Высота: <input type=\"text\" name=\"hei\" size=\"4\" maxlength=\"4\" value=\"\" /><br />
<input type=\"hidden\" name=\"kat\" value=\"$dir\" />
<input type=\"hidden\" name=\"file\" value=\"$file_get\" />
<input type=\"submit\" value=\"Скачать\" /><br />";
echo "</p></form>";
}
$dir = str_replace('./', '', $dir);
echo '<p class="b">
Ссылка:<br /><input type="text" size="20" value="'.$home.'/modules/zagruz/dload.php?kat='.$dir.'&file='.$file_get.'" /><br />
BB код:<br /><input type="text" size="20" value="[url='.$home.'/modules/zagruz/index.php?kat='.$dir.'&file='.$file_get.'&view=1]'.$file_name.'[/url] ('.$size_file.' Кб)" /><br /></p>';
if(file_exists("$dir/op/".$file_get."_kom.txt"))
{
$preview="$dir/op/".$file_get."_kom.txt";
$preview = file($preview);
$countkom = trim(count($preview));
}
else
{
$countkom = trim('0');
}
echo "<p class=\"b\"><a href=\"kom.php?kat=$dir&file=$file_get&".session_name()."=".session_id()."\">Комментарии</a> ($countkom)<br /></p>";
}
else
{
while ($file = readdir($dir_kat))
{
if(is_dir($dir.'/'.$file) && $file != '.' && $file != '..' && $file != 'op')
{
$files[] = $file;
}
}
$file_co = count($files);
@natsort($files);
if(!empty($files))
{
foreach($files as $val)
{
$files2[] = $val;
}
$files = $files2;
}
for ($i=0; $i < $file_co; $i++)
{
if(is_dir($dir.'/'.$files[$i]) && $files[$i] != '.' && $files[$i] != '..' && $files[$i] != 'op')
{
$kat_file_op = @file("$dir/$files[$i]/op/op.txt");
$kat_name = trim($kat_file_op[0]);
$kat_files = trim($kat_file_op[1]);
$kat_files_new = trim($kat_file_op[2]);
if(!empty($kat_name))
{
echo "<p class=\"a\" style=\"margin: 1px;\">";
echo "<img src=\"../../images/dir.gif\" alt=\"i\" /> <a href=\"index.php?kat=$dir/$files[$i]&".session_name()."=".session_id()."\" class=\"aa\">$kat_name</a> ($kat_files";
if($kat_files_new > 0)
{
echo '|<font color="'.$color_red.'">'.$kat_files_new.'</font>';
}
echo ')';
echo '</p>';
$a++;
}
}
}
#if(!empty($a)){echo '<p><br /></p>';}
while ($file1 = readdir($dir_file))
{
if(is_file("$dir/$file1") && $file1 != "Thumbs.db" && $file1 != ".htaccess" && $file1 != "index.php" && $file1 != "kol.php" && $file1 != "img.php" && $file1 != "admin.php" && $file1 != "kom.php" && $file1 != "dload.php" && $file1 != "op.txt")
{
$load_data = @file("$dir/op/".$file1."_load.txt");
if(!empty($load_data[0]))
{
$loads = trim($load_data[0]);
}
else
{
$loads = 0;
}
if($_GET['sort'] == 'alfa')
{
$file_array[] = '||'.$file1;
}
elseif($_GET['sort'] == 'loads')
{
$file_array[] = $loads.'||'.$file1;
}
elseif($_GET['sort'] == 'data' || empty($_GET['sort']))
{
$file_array[] = filemtime($dir.'/'.$file1).'||'.$file1;
}
}
}
if(!empty($file_array))
{
echo"<p class=\"b\" align=\"center\">Сортировка файлов<br />
<a href=\"index.php?sort=alfa&kat=$kat&".session_name()."=".session_id()."\">По алфавиту</a><br />
<a href=\"index.php?sort=loads&kat=$kat&".session_name()."=".session_id()."\">По колличеству скачиваний</a><br />
<a href=\"index.php?sort=data&kat=$kat&".session_name()."=".session_id()."\">По дате добавления файла</a></p>";
echo"<p align=\"center\"class=\"a\">Список файлов</p>";
}
$sort = filter($_GET['sort']);
if($sort == 'alfa')
{
@natsort($file_array);
if(!empty($file_array))
{
foreach($file_array as $val)
{
$file_array2[] = $val;
}
$file_array = $file_array2;
}
}
if($sort == 'loads')
{
@natsort($file_array);
@rsort($file_array);
if(!empty($file_array))
{
foreach($file_array as $val)
{
$file_array2[] = $val;
}
$file_array = $file_array2;
}
}
if($sort == 'data' || empty($sort))
{
@rsort($file_array);
}
$count_files = count($file_array);
$stranic = ceil($count_files/$kolfiles);
if(empty($_GET['page']))
{
$page_get = 1;
}
else
{
$page_get = filter($_GET['page']);
}
if($page_get < 0)
{
$page_get = 1;
}
if($page_get > $stranic)
{
$page_get = $stranic;
}
$do = $kolfiles * ($page_get - 1);
$end = $kolfiles * $page_get;
$page_nazad = $page_get - 1;
$page_dalee = $page_get + 1;
for($i = $do; $i < $end; $i++)
{
if(!empty($file_array[$i]) && !preg_match("#\.jad$#", $file_array[$i]))
{
$file_win_arr = explode("||", $file_array[$i]);
preg_match("#^([^><|?*/\:\"]+)\.[a-z0-9]{0,4}$#s", $file_win_arr[1], $repl);
$file_tr = "$repl[1]";
$file_f = @file("$dir/op/$file_tr.txt");
$file_name = trim($file_f[0]);
if(empty($file_name))
{
$file_name = $file_tr;
}
echo '<p class="b">';
if(file_exists("$dir/op/$file_tr.jpg"))
{
echo "<img src=\"img.php?img=$dir/op/$file_tr.jpg&prev=1\" alt=\"prev\" /><br />";
}
elseif(file_exists("$dir/op/$file_tr.gif"))
{
echo "<img src=\"img.php?img=$dir/op/$file_tr.gif&prev=1\" alt=\"prev\" /><br />";
}
elseif(file_exists("$dir/op/$file_tr.png"))
{
echo "<img src=\"img.php?img=$dir/op/$file_tr.png&prev=1\" alt=\"prev\" /><br />";
}
if(preg_match("#\.zip$#", $file_win_arr[1]))
{
echo "<img src=\"../../images/zip.gif\" alt=\"i\" /> ";
}
elseif(preg_match("#\.rar$|\.jar$#", $file_win_arr[1]))
{
echo "<img src=\"../../images/rar.gif\" alt=\"i\" /> ";
}
elseif(preg_match("#\.mp3$|\.mid$|\.mmf$|\.wav$|\.ogg$|\.amr$#", $file_win_arr[1]))
{
echo "<img src=\"../../images/melody.gif\" alt=\"i\" /> ";
}
elseif(preg_match("#\.txt$#", $file_win_arr[1]))
{
echo "<img src=\"../../images/txt.gif\" alt=\"i\" /> ";
}
elseif(preg_match("#\.exe$|\.sis$|\.sisx$#", $file_win_arr[1]))
{
echo "<img src=\"../../images/exe.gif\" alt=\"i\" /> ";
}
elseif(preg_match("#\.mp4$|\.avi$|\.3gp$#", $file_win_arr[1]))
{
echo "<img src=\"../../images/avi.gif\" alt=\"i\" /> ";
}
elseif(preg_match("#\.swf$#", $file_win_arr[1]))
{
echo "<img src=\"../../images/swf.gif\" alt=\"i\" /> ";
}
elseif(preg_match("#\.gif$|\.jpg$|\.jpeg$|\.jpe$|\.png$#", $file_win_arr[1]))
{
echo "<img src=\"img.php?img=$dir/$file_win_arr[1]&prev=1\" alt=\"prev\" /><br /><img src=\"../../images/img.gif\" alt=\"i\" /> ";
}
else
{
echo "<img src=\"../../images/file.gif\" alt=\"i\" /> ";
}
$datanew = $file_win_arr[0]+ 432000;
$datenow = time();
$sizef = stat("$dir/$file_win_arr[1]");
$kb = 1024;
$size_file = round($sizef[7] / $kb, 2);
if($datanew > $datenow)
{
echo '<img src="/images/st/new.gif"alt="new"/> ';
}
echo "<a href=\"index.php?kat=$dir&file=$file_win_arr[1]&view=1&".session_name()."=".session_id()."\">$file_name</a> ($size_file Кб)</p>";
}
}
if($stranic > 1)
{
echo "<p align=\"center\" class=\"d\">";
echo "Страницы:";
echo "<br />";
if($page_get > 4)
{
echo "<a href=\"index.php?page=1&kat=$kat&sort=$sort&".session_name()."=".session_id()."\">1</a>...";
}
$start_1 = $page_get - 3;
$end_1 = $page_get - 1;
if($start_1 < 1)
{
$start_1 = 1;
}
for($i = $start_1; $i <= $end_1; $i++)
{
echo"<a href=\"index.php?page=$i&kat=$kat&sort=$sort&".session_name()."=".session_id()."\">$i</a> ";
}
echo"$page_get";
$start_2 = $page_get + 1;
$end_2 = $page_get + 3;
if($start_2 < 1)
{
$start_2 = 1;
}
if($end_2 > $stranic)
{
$end_2 = $stranic;
}
for($i = $start_2; $i <= $end_2; $i++)
{
echo" <a href=\"index.php?page=$i&kat=$kat&sort=$sort&".session_name()."=".session_id()."\">$i</a>";
}
if($stranic > $page_get && $page_get < ($stranic-3))
{
echo "...<a href=\"index.php?page=$stranic&kat=$kat&sort=$sort&".session_name()."=".session_id()."\">$stranic</a>";
}
echo '<br />';
if($page_get > 1)
{
echo "<a href=\"index.php?page=$page_nazad&kat=$kat&sort=$sort&".session_name()."=".session_id()."\">Назад</a>";
}
echo ' | ';
if($stranic > $page_get)
{
echo "<a href=\"index.php?page=$page_dalee&kat=$kat&sort=$sort&".session_name()."=".session_id()."\">Дальше</a>";
}
echo '<br /></p>';
}
if(!empty($a) || $count_files > 0)
{
echo '<p class="d">';
if(!empty($a))
{
echo 'Категорий: '.$a.'<br />';
}
if($count_files > 0)
{
echo 'Файлов: '.$count_files;
}
echo '</p>';
}
if(empty($a) and $count_files == 0)
{
echo '<p class="err">В данной категории нет файлов и других категорий.</p>';
}
}
closedir ($dir_kat);
closedir ($dir_file);
}
####################
dir_list ($kat, $file_get);
####################
}
include '../../templates/foot.php';
?>