Файл: profiwm.pp.ua/fo/info.php
Строк: 157
<?php
require '../system/sid.php';
require '../system/config.php';
include '../system/user.php';
include '../system/head.php';
include '../system/navigator.php';
whorm(0, 'fo');
echo $div_title . 'Обменник / Файл' . $div_end;
$do = isset($_GET['do']) ? $_GET['do'] : NULL;
switch($do)
{
default:
$i = my_int($_GET['i']);
$file = mysql_query("SELECT * FROM `fo_files` WHERE `id` = '$i' AND `moder` = '0' LIMIT 1");
if (mysql_num_rows($file) == FALSE) {
err('Такого файла не существует!');
} else {
$info = mysql_fetch_assoc($file);
//-------------------------------------------//
$sqlLenta = mysql_query("SELECT id FROM lenta WHERE user = '$user[id]' AND `read` = '1' AND type = 'comments' AND uid = 'fo$i' LIMIT 1");
if (mysql_num_rows($sqlLenta) != false)
{
mysql_query("UPDATE lenta SET `read` = '0' WHERE user = '$user[id]' AND `read` = '1' AND type = 'comments' AND uid = 'fo$i' LIMIT 1");
}
//-------------------------------------------//
// положительный голос
if (isset($_GET['like']))
{
$prv = mysql_query("SELECT `id` FROM `rating_files` WHERE `uid` = '$i' AND `who` = '$user[id]' LIMIT 1");
if (mysql_num_rows($prv) != FALSE) {
err('Вы уже голосовали!');
} else {
mysql_query("INSERT INTO `rating_files` SET `uid` = '$i', `who` = '$user[id]', `like` = '1'");
msg('Ваш голос принят!');
}
}
// отрицательный голос
if (isset($_GET['dlike']))
{
$prv = mysql_query("SELECT `id` FROM `rating_files` WHERE `uid` = '$i' AND `who` = '$user[id]' LIMIT 1");
if (mysql_num_rows($prv) != FALSE) {
err('Вы уже голосовали!');
} else {
mysql_query("INSERT INTO `rating_files` SET `uid` = '$i', `who` = '$user[id]', `dlike` = '1'");
msg('Ваш голос принят!');
}
}
if (!empty($info['parol']) && my_int($_REQUEST['parol']) != $info['parol'] && !isset($_SESSION["parol$i"])) {
$_SESSION['parol$i'] = '';
if (isset($_POST['ok_pass']) && my_int($_REQUEST['parol']) != $info['parol']) {
err('Пароль неверный!');
} else {
err('Файл защищен паролем!');
}
if ($user['level'] == 4 || $user['level'] == 5) {
echo '<span class="color:#FF0000;">Пароль: ' . $info['parol'] . '</span>' . $block;
}
echo '<FORM method="POST" action="info.php?i='.$i.'">
<label>Введите пароль:</label><br/>
<input type="text" name="parol"/>
<br/>
<input type="submit" name="ok_pass" value="Войти"/>
</FORM>
<a href="index.php?">Назад</a>';
include '../system/foot.php';
exit();
} else {
$_SESSION["parol$i"] = my_int($_REQUEST['parol']);
}
echo $div_tworazdel . date('d.m.Y') . ' ' . date('H:i', $info['time']) . $div_end;
#######################
$ext = strtolower(strrchr($info['url'], '.'));
if ($ext == '.zip') $format = '<img src="img/zip.gif" alt="*"/> ';
elseif ($ext == '.rar') $format = '<img src="img/rar.gif" alt="*"/> ';
elseif ($ext == '.gz') $format = '<img src="img/gz.gif" alt="*"/> ';
elseif ($ext == '.tar') $format = '<img src="img/tar.gif" alt="*"/> ';
else $format = '<img src="img/unknown.gif" alt="*"/> ';
#######################
$opis = (!empty($info['info'])) ? $info['info'] : 'Без описания';
$size = filesize($info['url']);
$size = get_size($size);
// скачивание
if (isset($_GET['download'])) {
mysql_query("UPDATE `fo_files` SET `clicks` = `clicks` + '1' WHERE `id` = '$info[id]' LIMIT 1");
header('Location: ' . $info['url']);
}
if ($ext == '.zip')
{
$openZip = '<img src="../ico/zip.gif" alt=""/> <a href="zip.php?id='.$i.'">Просмотр архива</a><br/>';
}
$_down = $openZip . '<img src="../ico/d.gif" alt=""/> <a href="info.php?download&i='.$i.'">Скачать(' . $size . ')</a><br/>
<input type="text" value="http://'.$site.'/fo/'.$info['url'].'"/>';
echo $div_tworazdel . $format . $info['title'] . $div_end . '
' . $opis . $div_tworazdel . $_down . '
<br/>
Скачан: ' . $info['clicks'] . plural($info['clicks'], ' раз', ' раза', ' раз') . '
' . $div_end;
// Голосование //
$i_vote = mysql_query("SELECT `id` FROM `rating_files` WHERE `uid` = '$i' AND `who` = '$user[id]' LIMIT 1");
$like = mysql_fetch_assoc(mysql_query("SELECT SUM(`like`) AS t, SUM(`dlike`) AS c FROM `rating_files` WHERE `uid` = '$i'"));
if (mysql_num_rows($i_vote) == FALSE)
{
echo '<a href="info.php?i='.$i.'&like">
<img src="../ico/plus.gif" alt="+"/></a><a href="?do=whovote&id='.$i.'&v=1"> ' . ($like['t'] != 0 ? $like['t'] : 0) . '</a> |
<a href="info.php?i='.$i.'&dlike">
<img src="../ico/minus.gif" alt="-"/></a><a href="?do=whovote&id='.$i.'&v=2"> ' . ($like['c'] != 0 ? $like['c'] : 0) . '</a>';
}
else
{
echo '<img src="../ico/plus.gif" alt="+"/><a href="?do=whovote&id='.$i.'&v=1"> ' . ($like['t'] != 0 ? $like['t'] : 0) . '</a> |
<img src="../ico/minus.gif" alt="-"/><a href="?do=whovote&id='.$i.'&v=2"> ' . ($like['c'] != 0 ? $like['c'] : 0) . '</a>';
}
// Голосование //
echo $div_tworazdel . 'Добавил: ' . us($info['author']) . $div_end;
if (isset($_GET['del'])) {
$del = my_int($_GET['del']);
$empt = mysql_query("SELECT `id` FROM `fo_komm` WHERE `id` = '$del' LIMIT 1");
if (mysql_num_rows($empt) != FALSE && $user['level'] >= 2 && $user['level'] <= 5) {
mysql_query("DELETE FROM `fo_komm` WHERE `id` = '$del' LIMIT 1");
header('Location: info.php?i=' . $i);
} else {
header('Location: info.php?i=' . $i);
}
}
$koms = mysql_result(mysql_query("SELECT COUNT(id) FROM `fo_komm` WHERE `uid` = '$i'"), 0);
if ($koms != FALSE) {
echo $div_razdel . 'Комментарии:' . $div_end;
$n = new navigator($koms, 10, '?i='.$i.'&');
$_in = mysql_query("SELECT * FROM `fo_komm` WHERE `uid` = '$i' ORDER BY `id` DESC {$n->limit}");
$dv = 0;
while($q = mysql_fetch_assoc($_in)) {
$otv = ' <a href="info.php?i='.$i.'&k='.$q['user'].'&#down">[отв]</a>';
if ($user['level'] >= 2 && $user['level'] <= 5) {
$dk = '<a href="info.php?i='.$i.'&del='.$q['id'].'"><img src="../ico/delete.gif" alt="x"/></a> ';
}
echo ($dv ++ % 2) ? $div_tworazdel : $div_razdel;
echo $dk . us($q['user']) . $otv . '<br/>' . date('d.m.y H:i', $q['date']) . '<br/>' . smiles(bb_code($q['msg'])) . $div_end;
}
echo $n->navi();
} else {
echo $div_razdel . 'Комментариев нет.' . $div_end;
}
if (isset($_POST['addkom'])) {
$mes = trim(mysql_real_escape_string(check($_POST['mes'])));
if (empty($mes)) {
err('Не заполнен комментарий!');
} else {
// Антиреклама
$_ant = mysql_fetch_assoc(mysql_query("SELECT `on_rekl`, `text_rekl` FROM `setting` WHERE `ids` = '1'"));
if ($_ant['on_rekl'] == 1 && filesize($_SERVER['DOCUMENT_ROOT'] . '/domains.dat') > 0) {
$ex = explode(',', file_get_contents('../domains.dat'));
foreach($ex as $value) {
if ($user['level'] != 4 && $user['level'] != 5 && !preg_match('/[url=http://(.*)[/url]/si', $mes)) {
$mes = preg_replace("/(w)(s|,|.|*|_|-|+)+$value/si", $_ant['text_rekl'], $mes);
}
}
}
// транслит
if ($user['translit'] == 1) {
$mes = trun_to_rus($mes);
}
// антимат
$ant = mysql_fetch_array(mysql_query("SELECT `antimat` FROM `setting` WHERE `ids` = '1'"));
$mes = ($ant[0] == 1) ? mat($mes) : $mes;
if (isset($_POST['komu']) && user_inf(my_int($_POST['komu']), 'comm_files') == 1 && my_int($_POST['komu']) != $user['id']) {
$message = cvetnik($user['id']) . ' ответил на Ваш комментарий к <a href="fo/info.php?i='.$i.'">файлу</a>!';
mysql_query("INSERT INTO `lenta` SET
`user` = '" . my_int($_POST['komu']) . "',
`text` = '$message',
`type` = 'comments',
`date` = '" . time() . "',
`uid` = 'fo$i',
`read` = '1'");
}
elseif (user_inf($info['author'], 'comm_files') == 1 && $info['author'] != $user['id']) {
$message = cvetnik($user['id']) . ' оставил комментарий к Вашему <a href="fo/info.php?i='.$i.'">файлу</a>!';
mysql_query("INSERT INTO `lenta` SET
`user` = '$info[author]',
`text` = '$message',
`type` = 'comments',
`date` = '" . time() . "',
`uid` = 'fo$i',
`read` = '1'");
}
mysql_query("INSERT INTO `fo_komm` SET
`msg` = '$mes',
`uid` = '$i',
`user` = '$user[id]',
`date` = '" . time() . "'");
header('Location: info.php?&i=' . $i);
}
}
$Komu = (isset($_GET['k'])) ? '[b]Ответ: ' . user_inf(my_int($_GET['k']), 'user') . '[/b], ' : '';
echo '<a name="down"></a>
<FORM method="POST" action="info.php?i='.$i.'">
<label><b>Комментарий:</b></label>
<br/>
<textarea name="mes" cols="50" rows="5" style="width: 99%;">' . $Komu . '</textarea>
<br/>
<input type="hidden" name="komu" value="' . my_int($_GET['k']) . '"/>
<input type="submit" name="addkom" value="Добавить"/>
</FORM>';
}
break;
case whovote:
$id = my_int($_GET['id']);
$v = my_int($_GET['v']);
$sql = mysql_query("SELECT id FROM fo_files WHERE id = '$id' LIMIT 1");
if (mysql_num_rows($sql) == false)
{
err('Ошибка!');
} elseif ($v != 1 && $v != 2) {
err('Ошибка!');
} else {
$var = ($v == 1) ? '`like`' : 'dlike';
$sel = mysql_result(mysql_query("SELECT COUNT(id) FROM rating_files WHERE uid = '$id' AND $var = '1'"), 0);
if ($sel != 0)
{
$n = new navigator($sel, 10, '?do=whovote&id='.$id.'&v='.$v.'&');
$res = mysql_query("SELECT * FROM rating_files WHERE uid = '$id' AND $var = '1' ORDER BY id DESC {$n->limit}");
while($a = mysql_fetch_assoc($res))
{
echo us($a['who']) . '<br/>';
}
echo $n->navi();
} else {
echo 'За этот вариант никто не голосовал.<br/>';
}
}
echo '« <a href="?i='.$id.'">Назад</a>';
break;
}
include '../system/foot.php';
?>