Файл: index.php
Строк: 199
<?php
// mod Gemorroj
require 'moduls/config.php';
require 'moduls/header.php';
###############Проверка переменных###############
$onpage = get2ses('onpage');
$prew = get2ses('prew');
$id = isset($_GET['id']) ? int($_GET['id']) : 0;
$page = isset($_GET['page']) ? int($_GET['page']) : 0;
$start = isset($_GET['start']) ? int($_GET['start']) : 0;
$out = '';
$banner = '';
if ($onpage < 3) {
$onpage = $setup['onpage'];
}
if ($prew != 0 && $prew != 1) {
$prew = $setup['preview'];
}
$mode = '`priority` DESC, `timeupload` DESC';
###############Получаем текущий каталог#############
if ($id) {
$d = mysql_fetch_assoc(mysql_query('
SELECT `t1`.`path`,
COUNT(`t2`.`id`) AS `all`
FROM `files` AS `t1`
LEFT JOIN `files` AS `t2` ON `t2`.`infolder` = `t1`.`path`
WHERE `t1`.`id` = ' . $id . '
AND `t1`.`hidden` = "0"
GROUP BY `t1`.`id`
ORDER BY NULL
',
$mysql));
} else {
$d['path'] = $setup['path'] . '/';
$d['all'] = mysql_result(mysql_query('SELECT COUNT(1) FROM `files` WHERE `infolder` = "' . mysql_real_escape_string($d['path'], $mysql) . '" AND `hidden` = "0"', $mysql), 0);
}
if (!is_dir($d['path'])) {
error('Folder not found.');
}
###############Онлайн#############
mysql_query("REPLACE INTO `online` (`ip`, `time`) VALUES ('" . $_SERVER['HTTP_USER_AGENT'] . "', NOW());", $mysql);
mysql_query('DELETE FROM `online` WHERE `time` < (NOW() - INTERVAL ' . $setup['online_time'] . ' SECOND)', $mysql);
$online = mysql_fetch_row(mysql_query('SELECT COUNT(1) FROM online', $mysql));
if ($online[0] > $setup['online_max']) {
mysql_query("REPLACE INTO `setting`(`name`, `value`) VALUES('online_max', '" . $online[0] . "');", $mysql);
mysql_query("REPLACE INTO `setting`(`name`, `value`) VALUES('online_max_time', NOW());", $mysql);
}
###############Постраничная навигация###############
$pages = ceil($d['all'] / $onpage);
if (!$pages) {
$pages = 1;
}
if ($page > $pages || $page < 1) {
$page = 1;
}
$start = ($page - 1) * $onpage;
if ($start > $d['all'] || $start < 0) {
$start = 0;
}
###############Готовим заголовок###################
$ex = explode('/', $d['path']);
$sz = sizeof($ex) - 2;
$nav_dir = $setup['path'] . '/';
unset($ex[0], $ex[$sz + 1]);
$path = $setup['path'] . '/';
$put = '';
if ($ex) {
$implode = 'SELECT ' . ($_SESSION['langpack'] == 'russian' ? '`id`, `rus_name`' : '`id`, `name`') . ' FROM `files` WHERE `path` IN(';
foreach ($ex as $v) {
$path .= $v . '/';
$implode .= '"' . mysql_real_escape_string($path, $mysql) . '",';
}
$q = mysql_query(rtrim($implode, ',') . ')', $mysql);
while ($s = mysql_fetch_row($q)) {
$put .= '<a href="' . DIRECTORY . $s[0] . '">' . htmlspecialchars($s[1], ENT_NOQUOTES) . '</a> | ';
$title .= '/' . htmlspecialchars($s[1], ENT_NOQUOTES);
$descript .= htmlspecialchars($s[1], ENT_NOQUOTES);
$keyword .= htmlspecialchars($s[1], ENT_NOQUOTES);
}
}
##############################
/*
if($id >= 1)
$out.='<div class="ttl" align="center">'.nam($put).'</div>';
*/
###############Вывод рекламы###############
$banner .= $Reklames->Bottom();
$banner .= $id < 1 ? $Reklames->Banner(1) : $Reklames->Banner();
// только если корень
if ($id < 1) {
$str = '';
}
###############Список файлов и папок###############
if (!$d['all']) {
$out .= '<div class="<div class="listing nonebg"><p>[' . $_SESSION['language']['empty'] . ']</p></div>';
}
$dn = 86400 * $setup['day_new'];
$key = false;
$limit = $id < 1 ? '' : 'LIMIT ' . $start . ', ' . $onpage;
if ($_SESSION['langpack'] == 'russian') {
$query = mysql_query('
SELECT
`id`,
`dir`,
`dir_count`,
`path` as `v`,
`rus_name` AS `name`,
`size`,
`loads`,
`timeupload`,
`yes`,
`no`,
`3d_dir`,`bt_dir`,`top_dir`,`vendor_dir`,`alp_dir`,`new_dir`,
(SELECT COUNT(1) FROM `files` WHERE `infolder`=`v` AND `timeupload` > "' . ($_SERVER['REQUEST_TIME'] - $dn) . '" AND `dir` = "0" AND `hidden` = "0" AND `fileid`="0") AS `count`
FROM `files`
WHERE `infolder` = "' . mysql_real_escape_string($d['path'], $mysql) . '"
AND `hidden` = "0"
AND `fileid` = "0"
ORDER BY ' . $mode . '
' . $limit, $mysql);
} else {
$query = mysql_query(
'SELECT
`id`,
`dir`,
`dir_count`,
`path` as `v`,
`name`,
`size`,
`loads`,
`timeupload`,
`yes`,
`no`,
`3d_dir`,`bt_dir`,`top_dir`,`vendor_dir`,`alp_dir`,`new_dir`,
(SELECT COUNT(1) FROM `files` WHERE `infolder`=`v` AND `timeupload` > "' . ($_SERVER['REQUEST_TIME'] - $dn) . '" AND `dir` = "0" AND `hidden` = "0" AND `fileid`="0") AS `count`
FROM `files`
WHERE `infolder` = "' . mysql_real_escape_string($d['path'], $mysql) . '"
AND `hidden` = "0"
AND `fileid` = "0"
ORDER BY ' . $mode . '
' . $limit, $mysql);
}
while ($v = mysql_fetch_assoc($query)) {
$pre = $desc = $info = $new_info = '';
$screen = strstr($v['v'], '/'); // убираем папку с загрузками
if ($v['dir']) {
//Собсвенно вывод
$out .= '<a class="menu" href="' . DIRECTORY . $v['id'] . '">' . $ico . ' ' . htmlspecialchars($v['name'], ENT_NOQUOTES) . ' <span>' . $v['dir_count'] . '</span>' . $new_all . '</a></div>';
} else {
$prev_pic = str_replace('/', '--', iconv_substr($screen, 1));
$ext = strtolower(pathinfo($v['v'], PATHINFO_EXTENSION));
$pre = '';
//Предосмотр
if ($prew) {
if ($setup['screen_change'] && ($ext == 'gif' || $ext == 'jpeg' || $ext == 'jpg' || $ext == 'png' || $ext == 'bmp')) {
if (file_exists($setup['picpath'] . '/' . $prev_pic . '.gif')) {
$pre .= '<img style="margin: 1px;" src="' . DIRECTORY . $setup['picpath'] . '/' . htmlspecialchars($prev_pic) . '.gif" alt=""/>';
} else {
$pre .= '<img style="margin: 1px;" src="' . DIRECTORY . 'im/' . $v['id'] . '" alt=""/>';
}
} else if ($setup['screen_change'] && ($ext == 'avi' || $ext == '3gp' || $ext == 'mp4' || $ext == 'flv') && extension_loaded('ffmpeg')) {
$wh = explode('*', $setup['prev_size']);
if (file_exists($setup['ffmpegpath'] . '/' . htmlspecialchars($prev_pic) . '_frame_' . $setup['ffmpeg_frame'] . '.gif')) {
$pre .= '<img style="margin: 1px;" src="' . DIRECTORY . $setup['ffmpegpath'] . '/' . htmlspecialchars($prev_pic) . '_frame_' . $setup['ffmpeg_frame'] . '.gif" alt=""/>';
} else {
$pre .= '<img style="margin: 1px;" src="' . DIRECTORY . 'ffmpeg/' . $v['id'] . '" alt=""/>';
}
}
}
if ($setup['screen_change']) {
$th_gif = file_exists($setup['spath'] . $screen . '.thumb.gif');
$th_jpg = file_exists($setup['spath'] . $screen . '.thumb.jpg');
if (file_exists($setup['spath'] . $screen . '.gif') && !$th_gif) {
img_resize($setup['spath'] . $screen . '.gif', $setup['spath'] . $screen . '.thumb.gif', 0, 0, $setup['marker']);
} else if (file_exists($setup['spath'] . $screen . '.jpg') && !$th_gif) {
img_resize($setup['spath'] . $screen . '.jpg', $setup['spath'] . $screen . '.thumb.gif', 0, 0, $setup['marker']);
}
if ($th_gif) {
$pre .= '<img style="margin: 1px;" src="' . DIRECTORY . $setup['spath'] . htmlspecialchars($screen) . '.thumb.gif" height="100" alt=""/> ';
} else if ($th_jpg) {
$pre .= '<img style="margin: 1px;" src="' . DIRECTORY . $setup['spath'] . htmlspecialchars($screen) . '.thumb.jpg" height="100" alt=""/> ';
}
}
if ($pre) {
$pre .= '<br/>';
}
if ($setup['desc'] && file_exists($setup['opath'] . $screen . '.txt')) {
$desc .= '<br/>' . iconv_substr(trim(file_get_contents($setup['opath'] . $screen . '.txt')), 0, $setup['desc']);
}
/*
<div class="listing nonebg">
<a href="/-/video/morgan_moon_gets_dp_and_anal___playvision">Morgan Moon Gets DP and Anal - Playvision</a><br>
<a href="/-/video/morgan_moon_gets_dp_and_anal___playvision"><img src="http://go.xxxsummer.net/i/morgan_moon_gets_dp_and_anal___playvision.small.jpg" alt="Morgan Moon Gets DP and Anal - Playvision" height="100"></a><br>
<a href="/-/video/download/morgan_moon_gets_dp_and_anal___playvision" class="button">Download</a>
</div>
*/
//Собственно вывод
$out .= '
<div class="listing nonebg">
<a href="' . DIRECTORY . 'view/' . $v['id'] . '">' . htmlspecialchars($v['name'], ENT_NOQUOTES) . '<br />' . $pre . '</a>
<a href="' . DIRECTORY . 'load/' . $v['id'] . '" class="button">Скачать</a>
</div>';
#$out .= $pre . '<strong><a href="' . DIRECTORY . 'view/' . $v['id'] . '">' . htmlspecialchars($v['name'], ENT_NOQUOTES) . '</a></strong><br/></div>';
}
}
###############Постраничная навигация########
if ($pages > 1 && $limit != '') {
$out .= '<div class="row">' . $_SESSION['language']['pages'] . ': ';
$asd = $page - 2;
$asd2 = $page + 3;
if ($asd < $d['all'] && $asd > 0 && $page > 3) {
$out .= '<a href="' . DIRECTORY . $id . '/1">1</a> ... ';
}
for ($i = $asd; $i < $asd2; ++$i) {
if ($i < $d['all'] && $i > 0) {
if ($i > $pages) {
break;
}
if ($page == $i) {
$out .= '<strong>' . $i . '</strong> ';
} else {
$out .= ' <a href="' . DIRECTORY . $id . '/' . $i . '">' . $i . '</a>,';
}
}
}
if ($i <= $pages) {
if ($asd2 < $d['all']) {
$out .= ' ... <a href="' . DIRECTORY . $id . '/' . $pages . '">' . $pages . '</a>';
}
}
$out .= '<br/></div>';
}
if ($d['all'] && $id >= 1) {
if ($setup['onpage_change']) {
$out .= '<div class="sort">' . $_SESSION['language']['files on page'] . ': ';
for ($i = 5; $i < 25; $i += 5) {
if (isset($_SESSION['onpage']) && $_SESSION['onpage'] == $i) {
$out .= '<strong>' . $i . '</strong> ';
} else {
$out .= '<a href="' . DIRECTORY . 'onpage/' . $i . '/' . $id . '">' . $i . '</a> ';
}
}
$out .= '</div>';
}
}
echo $out . $banner;
require 'moduls/foot.php';