Файл: files.php
Строк: 70
<?php
require 'sid.php';
require 'config.php';
$link = connect_db();
list($user, $id, $ps) = check_login($link);
whorm(0, 'fo');
include 'head.php';
include 'navigator.php';
$do = (isset($_GET['do'])) ? $_GET['do'] : NULL;
switch($do) {
default:
$nk = my_int($_GET['nk']);
if (!user_inf($nk)) {
header('Location: index.php?' . $ref);
die();
}
echo $div_title . 'Файлы/' . us($nk) . $div_end . $div_left;
$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `fo_files` WHERE `moder` = '0' AND `author` = '$nk'"), 0);
if ($count != FALSE) {
$select = mysql_query("SELECT DISTINCT `fo_pod` .*,
(SELECT COUNT(*) FROM `fo_files` WHERE `fo_files`.`cat` = `fo_pod`.`id` AND `fo_files`.`rid` = `fo_pod`.`cid` AND `fo_files`.`moder` = '0' AND `fo_files`.`author` = '$nk') AS c
FROM `fo_pod`
LEFT JOIN `fo_files`
ON(`fo_pod`.`cid` = `fo_files`.`rid`
AND `fo_pod`.`id` = `fo_files`.`cat`)
WHERE `fo_files`.`moder` = '0'
AND `fo_files`.`author` = '$nk'");
$i = 0;
while($a = mysql_fetch_assoc($select)) {
echo ($i ++ % 2) ? $div_tworazdel : $div_razdel;
echo '<img src="ico/dir.gif" alt=""/> <a href="files.php?do=look&nk='.$nk.'&r='.$a['id'].'">' . $a['title'] . '</a> (' . $a['c'] . ')' . $div_end;
}
} else {
echo 'Файлов не найдено!<br/>';
}
echo $div_end;
break;
case look:
$nk = my_int($_GET['nk']);
if (!user_inf($nk)) {
header('Location: index.php?' . $ref);
die();
}
echo $div_title . 'Файлы ' . us($nk) . $div_end . $div_left;
$r = my_int($_GET['r']);
$empty = mysql_query("SELECT `id` FROM `fo_files` WHERE `cat` = '$r' LIMIT 1");
if (mysql_num_rows($empty) == FALSE) {
header('Location: index.php?' . $ref);
die();
}
$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `fo_files` WHERE `moder` = '0' AND `author` = '$nk' AND `cat` = '$r'"), 0);
if ($count != FALSE) {
$n = new navigator($count, 10, '?nk='.$nk.'&');
$select = mysql_query("SELECT DISTINCT `t1`.* FROM `fo_files` AS `t1`
JOIN `fo_pod` AS `t2`
ON
(`t1`.`cat` = `t2`.`id`
AND
`t1`.`rid` = `t2`.`cid`)
WHERE
`t1`.`moder` = '0'
AND
`author` = '$nk'
AND
`cat` = '$r'
ORDER BY `t1`.`id` DESC {$n->limit}");
$i = 0;
while($a = mysql_fetch_assoc($select)) {
$ex = pathinfo($a['url']);
$ext = strtolower($ex['extension']);
#######################
if ($ext == '3gp') $format = '<img src="fo/img/3gp.gif" alt="*"/>';
elseif ($ext == 'avi') $format = '<img src="fo/img/avi.gif" alt="*"/>';
elseif ($ext == 'gif') $format = '<img src="fo/img/gif.gif" alt="*"/>';
elseif ($ext == 'jpg') $format = '<img src="fo/img/jpg.gif" alt="*"/>';
elseif ($ext == 'mp3') $format = '<img src="fo/img/mp3.gif" alt="*"/>';
elseif ($ext == 'zip') $format = '<img src="fo/img/zip.gif" alt="*"/>';
elseif ($ext == 'jar') $format = '<img src="fo/img/jar.gif" alt="*"/> ';
else $format = '<img src="fo/img/unknown.gif" alt="*"/>';
#######################
$inf_file = (!empty($a['info'])) ? $a['info'] : 'Без описания';
if ($ext == 'jpg' || $ext == 'gif' || $ext == 'png' || $ext == 'bmp' || $ext == 'jpeg' || $ext == 'ico' || $ext == 'iso' || $ext == 'imy' || $ext == 'wbmp')
{
$prev = '<img src="resize.php?img=fo/'.$a['url'].'&width=40&height=0&i=0" alt="*"/>';
}
elseif ($ext == 'nth' || $ext == 'thm') {
$prev = '<img src="fo/theme.php?i='.$a['id'].'" width="40" height="40" alt=""/>';
}
else $prev = '';
echo ($i ++ % 2) ? $div_tworazdel : $div_razdel;
echo $prev . '<br/>
' . $format . '
<a href="fo/info.php?i='.$a['id'].'">' . $a['title'] . '</a>
<br/>
' . $inf_file . $div_end;
}
echo $n->navi();
} else {
echo 'Файлов не найдено!<br/>';
}
echo $div_end;
break;
}
include 'foot.php';
?>