Файл: modules/forum/download_file.php
Строк: 36
<?php
/****
* @package LiveCMS
* @link livecms.org
* @author MyZik
* @version See attached file VERSION.txt
* @license See attached file LICENSE.txt
* @copyright Copyright (C) LiveCMS Development Team
****/
ob_start();
$lang_forum = load_lng('forum'); // Подключаем файл языка
$title = $lang_forum['forum']; // Заголовок страницы
$module = 'forum'; // Модуль
/**
* Проверяем, задан ли параметр
**/
if (!isset($_GET['id']) || empty($_GET['id']) || !is_numeric($_GET['id'])) {
require_once(HOME .'/incfiles/header.php');
echo '<div class="error">' . $lang['error_parameter'] . '</div>';
echo '<div class="home">' .
'<img src="/design/themes/' . $set_user['theme'] . '/images/back.png" alt="" /> <a href="index.php">' . $lang['back'] . '</a>' .
'</div>';
require_once(HOME .'/incfiles/footer.php');
}
/**
* Проверяем наличие файла
**/
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_files` WHERE `id` = '" . num($_GET['id']) . "'"), 0) == 0) {
require_once(HOME .'/incfiles/header.php');
echo '<div class="error">' . $lang_forum['file_not_exists'] . '</div>';
echo '<div class="home">' .
'<img src="/design/themes/' . $set_user['theme'] . '/images/back.png" alt="" /> <a href="index.php">' . $lang['back'] . '</a>' .
'</div>';
require_once(HOME .'/incfiles/footer.php');
}
$ID = num($_GET['id']);
$f = mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_files` WHERE `id` = '$ID' LIMIT 1"));
$post = mysql_fetch_assoc(mysql_query("SELECT * FROM `cms_forum_messages` WHERE `id` = '" . $f['post_id'] . "' LIMIT 1"));
$file = mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_files` WHERE `id` = '$ID' LIMIT 1"));
if (file_exists(HOME . '/files/forum/' . $file['name'])) {
mysql_query("UPDATE `forum_files` SET `downloads` = '" . ($file['downloads'] + 1) . "' WHERE `id` = '$ID'");
header("Location: /files/forum/" . $file['name']);
}
ob_end_flush();
?>