View file download/files.php

File size: 2.95Kb
<?php
/*
=============================================
Движок: SHCMS Engine
=============================================
Название файла: Обменник
=============================================
Official website: http://shcms.ru
=============================================
*/
define('SHCMS', true);
include_once'../system/inc/basic_settings.php';
if($_GET['id']){$id = $_GET['id'];}
$rfil = mysql_fetch_array(mysql_query("SELECT * FROM download_file WHERE id=$id"));
$shcmsengine['title'] = ''.$rfil['names'].'';

include_once'../template/head.php';
if(!$id)
{
echo 'Ошибка';
header("Refresh: 1; url=/download/index.php");
include_once '../template/foot.php';
exit();
}
$screen_file = mysql_fetch_array(mysql_query("SELECT * FROM download_file WHERE id=$id"));
if(!$screen_file['screen'] == null)
echo '<img src="/download/screen/'.$screen_file['screen'].'"/><br/>';
echo 'Описание: '.$rfil['message'].'<br/>';
echo 'Добавил: <a href="'.DIR_SHCMS.'change_view.php?id='.$rfil['user_id'].'">'.$rfil['author'].'</a> ('.date('d.m.y',$rfil['time']).' в '.date('H:i:s',$rfil['time']).')<br/>';
echo 'Размер файла: '.size($rfil['size']).'<br/>';


echo '<hr/>';

$komm = mysql_result(mysql_query("SELECT COUNT(*) FROM down_comment WHERE id_file = $id"),0);

echo '<div class="posts">Скопировать ссылку:<br/><input type="text" value="http://'.$_SERVER['HTTP_HOST'].'/download/files_obmen/'.$rfil['name'].'"></div>';

echo '<div class="posts"><a href="loading.php?id='.$rfil['id'].'">Скачать</a> ('.$rfil['cou'].')<br/>';
echo '<a href="comment.php?id='.$rfil['id'].'">Комментарии</a> ('.$komm .')<br/>';
if($user_id == $rfil['user_id'])
{
echo'<a href="?id='.$id.'&edit">Изменить файл</a>';
}
echo '</div>';
if(isset($_GET['edit']))
{
if($user_id == $rfil['user_id'])
{
$edit_files = mysql_fetch_array(mysql_query("SELECT * FROM download_file WHERE id=$id"));
echo '<div class="user_foot">Редактировать файл</div><br/>';

if(isset($_POST['submit_edit']))
{
if(isset($_POST['texta'])){$texta = $_POST['texta'];}
if(isset($_POST['names'])){$names = $_POST['names'];}
$ok_edi = mysql_query("UPDATE download_file SET message='$texta',names='$names' WHERE id=$id");
if($ok_edi == true)
{
echo '<div class="actshcms">Файл успешно изменен</div>';
header("Refresh: 1; url=?id=$id");
include_once'../template/foot.php';
exit();
}
else
{
echo '<div class="errors">Файл не изменен</div>';
header("Refresh: 1; url=?id=$id");
include_once'../template/foot.php';
exit();
}
}
echo '<form action="?id='.$id.'&edit" method="post">';
echo '<input type="text" name="names" value="'.$edit_files['names'].'"><br/>';
echo '<textarea name="texta">'.$edit_files['message'].'</textarea>';
echo '<input type="submit" name="submit_edit" value="Изменить">';
echo '</form>';
}
}

include_once'../template/foot.php';
?>