Файл: loads/info.php
Строк: 205
<?php
require '../system/sid.php';
require '../system/config.php';
include '../system/user.php';
include '../system/head.php';
include '../system/navigator.php';
whorm(0, 'loads');
echo $div_title . 'WAP-скрипты / Файл' . $div_end;
$do = isset($_GET['do']) ? $_GET['do'] : NULL;
switch($do)
{
default:
if (isset($_GET['del'])) {
$del = my_int($_GET['del']);
if ($user['level'] != 5) {
header('Location: info-' . $del);
die();
}
$sql = mysql_query("SELECT * FROM `loads_f` WHERE `id` = '$del' LIMIT 1");
if (mysql_num_rows($sql) != FALSE) {
$info = mysql_fetch_assoc($sql);
$TXT = '<small>(' . date('d-m-y в H:i:s') . ')</small><br/>' . elite($user['id']) . ' ' . $user['user'] . ' удалил файл <b>' . $info['title'] . '</b> из ЗЦ.';
mysql_query("INSERT INTO admin_logs SET text = '$TXT'");
if (file_exists($info['url'])) unlink($info['url']);
if (file_exists($info['screen'])) unlink($info['screen']);
// удаление файла
mysql_query("DELETE FROM `loads_f` WHERE `id` = '$del' LIMIT 1");
// удаление рейтинга
mysql_query("DELETE FROM `rating_loads` WHERE `uid` = '$del'");
// удаление комментов
mysql_query("DELETE FROM `loads_komm` WHERE `uid` = '$del'");
header('Location: index.php');
} else {
header('Location: index.php');
}
}
$i = my_int($_GET['i']);
$file = mysql_query("SELECT * FROM `loads_f` WHERE `id` = '$i' LIMIT 1");
if (mysql_num_rows($file) == FALSE) {
err('Такого файла не существует!');
} else {
$info = mysql_fetch_assoc($file);
if ($user['level'] < 5 && $info['activity'] > $user['activity'])
{
err('Для скачивания этого файла, вам необходимо ' . $info['activity'] . '% активности!');
include '../system/foot.php';
exit();
}
//-------------------------------------------//
$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_loads` WHERE `uid` = '$i' AND `who` = '$user[id]' LIMIT 1");
if (mysql_num_rows($prv) != FALSE) {
err('Вы уже голосовали!');
} else {
mysql_query("INSERT INTO `rating_loads` SET `uid` = '$i', `who` = '$user[id]', `like` = '1'");
msg('Ваш голос принят!');
}
}
// отрицательный голос
if (isset($_GET['dlike']))
{
$prv = mysql_query("SELECT `id` FROM `rating_loads` WHERE `uid` = '$i' AND `who` = '$user[id]' LIMIT 1");
if (mysql_num_rows($prv) != FALSE) {
err('Вы уже голосовали!');
} else {
mysql_query("INSERT INTO `rating_loads` SET `uid` = '$i', `who` = '$user[id]', `dlike` = '1'");
msg('Ваш голос принят!');
}
}
echo $div_tworazdel . itime($info['time'], 0) . $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 `loads_f` SET `clicks` = `clicks` + '1' WHERE `id` = '$info[id]' LIMIT 1");
header('Location: ' . $info['url']);
}
$_down = ($user['level'] == 5 ? '<img src="../ico/delete.png" alt=""/> <a href="info.php?del='.$i.'">Удалить</a><br/>
<img src="../ico/edit.png" alt=""/> <a href="change-'.$i.'">Изменить архив</a><br/>' : '') . ' ' . ($ext == '.zip' ? '<img src="../ico/zip.gif" alt=""/> <a href="unzip-'.$i.'">Просмотр архива</a><br/>' : '') . '
<img src="../ico/d.gif" alt=""/> <a href="download-'.$i.'">Скачать(' . $size . ')</a><br/>
<input type="text" value="http://'.$site.'/loads/'.$info['url'].'"/>';
if (!empty($info['screen']))
{
echo '<a href="'.$info['screen'].'"><img src="../resize.php?img=loads/'.$info['screen'].'&width=100&height=0" alt=""/></a><br/>';
}
if (isset($_GET['full']) && mb_strlen($opis, 'UTF8') > 400)
{
$subMsg = $opis . '<br/><a href="info-'.$i.'"><span class="next">«Свернуть</span></a>';
}
elseif (!isset($_GET['full']) && mb_strlen($opis, 'UTF8') > 400 || mb_strlen($opis, 'UTF8') > 400)
{
$subMsg = mb_substr($opis, 0, 400, 'UTF8') . '...<br/><a href="info-'.$i.'&full"><span class="next">Прочесть полностью»</span></a>';
}
else
{
$subMsg = $opis;
}
echo $div_tworazdel . $format . $info['title'] . $div_end . smiles(bb_code($subMsg)) . $div_tworazdel . $_down . '
<br/>
Скачан: ' . $info['clicks'] . plural($info['clicks'], ' раз', ' раза', ' раз') . '<br/>
Необходимо активности: ' . (empty($info['activity']) ? '0.00%' : $info['activity'] . '%') . $div_end;
// Голосование //
$i_vote = mysql_query("SELECT `id` FROM `rating_loads` 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_loads` WHERE `uid` = '$i'"));
echo 'Рейтинг: ' . ($like['t'] - $like['c']) . '<br/>';
if ($like['t'] - $like['c'] >= 1) echo '<img src="../ico/rating1.gif" alt=""/><br/>';
elseif ($like['t'] - $like['c'] >= 3) echo '<img src="../ico/rating1.gif" alt=""/><br/>';
elseif ($like['t'] - $like['c'] >= 5) echo '<img src="../ico/rating1.gif" alt=""/><br/>';
elseif ($like['t'] - $like['c'] >= 7) echo '<img src="../ico/rating1.gif" alt=""/><br/>';
elseif ($like['t'] - $like['c'] >= 10) echo '<img src="../ico/rating1.gif" alt=""/><br/>';
elseif ($like['t'] - $like['c'] >= 12) echo '<img src="../ico/rating1.gif" alt=""/><br/>';
elseif ($like['t'] - $like['c'] >= 15) echo '<img src="../ico/rating1.gif" alt=""/><br/>';
elseif ($like['t'] - $like['c'] >= 17) echo '<img src="../ico/rating1.gif" alt=""/><br/>';
elseif ($like['t'] - $like['c'] >= 20) echo '<img src="../ico/rating1.gif" alt=""/><br/>';
elseif ($like['t'] - $like['c'] >= 25) echo '<img src="../ico/rating1.gif" alt=""/><br/>';
else echo '<img src="../ico/rating0.gif" alt=""/><br/>';
if (mysql_num_rows($i_vote) == FALSE)
{
echo '<a href="info-'.$i.'&like">
<img src="../ico/plus.png" alt="+"/></a><a href="vote-whovote-'.$i.'-1"> ' . ($like['t'] != 0 ? $like['t'] : 0) . '</a> |
<a href="info-'.$i.'&dlike">
<img src="../ico/minus.png" alt="-"/></a><a href="vote-whovote-'.$i.'-2"> ' . ($like['c'] != 0 ? $like['c'] : 0) . '</a>';
}
else
{
echo '<img src="../ico/plus.png" alt="+"/><a href="vote-whovote-'.$i.'-1"> ' . ($like['t'] != 0 ? $like['t'] : 0) . '</a> |
<img src="../ico/minus.png" alt="-"/><a href="vote-whovote-'.$i.'-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 `loads_komm` WHERE `id` = '$del' LIMIT 1");
if (mysql_num_rows($empt) != FALSE && $user['level'] >= 2 && $user['level'] <= 5) {
mysql_query("DELETE FROM `loads_komm` WHERE `id` = '$del' LIMIT 1");
header('Location: info-' . $i);
} else {
header('Location: info-' . $i);
}
}
$koms = mysql_result(mysql_query("SELECT COUNT(id) FROM `loads_komm` WHERE `uid` = '$i'"), 0);
if ($koms != FALSE) {
echo $div_tworazdel . 'Комментарии:' . $div_end;
$n = new navigator($koms, 10, 'info-'.$i.'&');
$_in = mysql_query("SELECT * FROM `loads_komm` WHERE `uid` = '$i' ORDER BY `id` DESC {$n->limit}");
while($q = mysql_fetch_assoc($_in)) {
$otv = ' <a href="answ-'.$i.'-'.$q['user'].'#down">[отв]</a>';
if ($user['level'] >= 2 && $user['level'] <= 5) {
$dk = '<a href="delcom-'.$i.'-'.$q['id'].'"><img src="../ico/delete.png" alt="x"/></a> ';
}
echo $div_razdel . $dk . us($q['user']) . $otv . '<br/>(' . itime($q['date'], 0) . ')' . $div_end . smiles(bb_code($q['msg'])) . '<br/>';
}
echo $n->navi();
} else {
echo $div_tworazdel . 'Комментариев нет.' . $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("/(ws|,|.|*|_|-|+)+$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="loads/info-'.$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="loads/info-'.$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 `loads_komm` SET
`msg` = '$mes',
`uid` = '$i',
`user` = '$user[id]',
`date` = '" . time() . "'");
header('Location: info-' . $i);
}
}
$Komu = (isset($_GET['k'])) ? '[b]Ответ: ' . user_inf(my_int($_GET['k']), 'user') . '[/b], ' : '';
echo '<a name="down"></a>
<FORM method="POST" action="info-'.$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 loads_f 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_loads WHERE uid = '$id' AND $var = '1'"), 0);
if ($sel != 0)
{
$n = new navigator($sel, 10, 'vote-whovote-'.$id.'-'.$v.'&');
$res = mysql_query("SELECT * FROM rating_loads WHERE uid = '$id' AND $var = '1' ORDER BY id DESC {$n->limit}");
$i = 0;
while($a = mysql_fetch_assoc($res))
{
echo ($i ++ % 2) ? $div_razdel : $div_tworazdel;
echo us($a['who']) . $div_end;
}
echo $n->navi();
} else {
echo 'За этот вариант никто не голосовал.<br/>';
}
}
echo '« <a href="info-'.$id.'">Назад</a>';
break;
}
echo '<br/>« <a href="r-'.$info['cat'].'">В раздел</a>';
include '../system/foot.php';
?>