Просмотр файла download/files.php

Размер файла: 5.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'];}
$files = mysql_fetch_array(mysql_query("SELECT * FROM `download_file` WHERE `id`='$id'"));
$shcmsengine['title'] =  $files['names'];
include_once'../template/head.php';
        switch($act):
	/*
	* Функция вывода файла
	*/
	
    case '':
        if(!$id) {
            errors('Файл не найден');
            header("Refresh: 1; url=/download/");
            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/>'; 

			
	    }
		$filepath = 'files_obmen/'.$screen_file['name'];  
		Comments_Shcms();
		
		
		
		
		
		if($files['message'] > 0)
		{
            echo 'Описание: '.$files['message'].'<br/>';
		}
		else
		{
	
		}
            echo '<div class="posts">Добавил: <a href="'.DIR_SHCMS.'change_view.php?id='.$files['user_id'].'">'.$files['author'].'</a> ('.$timedate->times($files['time']).')<br/>';
            echo 'Размер файла: '.size($files['size']).'<br/>';
            echo 'Скачано: '.$files['cou'].'раз(а)<br/>';
            echo '</div>';
    files::file($files['type'],$files['name']);

    $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/'.$files['name'].'"></div>';
            echo '<div class="posts"><a href="loading.php?id='.$files['id'].'">Скачать</a><br/>';
            echo '<a href="comment.php?id='.$files['id'].'">Комментарии</a> ('.$komm .')<br/>';
	    if($files['type'] == 'zip' or $files['type'] == 'rar' or $files['type'] == 'php' or $files['type'] == 'txt' or $files['type'] == 'css' or $files['type'] == 'dat' or $files['type'] == 'aspx' or $files['type'] == 'asp')
		{
            echo '<a href="zip.php?id='.$files['id'].'">Посмотреть архив<br/>';
		}	
        if($user_id == $files['user_id'])
        {
            echo'<a href="?id='.$id.'&edit">Редактирова файл</a>';
            echo'<br/><a href="?act=delete&id='.$id.'">Удалить файл</a>';
        }
            echo '</div>';
			
        if(isset($_GET['edit']))
        {
            if($user_id == $files['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>';
            }
        }
    break;
	
	/*
	* Функция удаление файлов
	*/
	
    case'delete':
        $delw = mysql_fetch_array(mysql_query("SELECT * FROM `download_file` WHERE `id`=`$id`"));
                if($_POST['delete_dir'])
				{
				    $delete_dir = $_POST['delete_dir'];
				}
                    if(isset($delete_dir))
                    {
                        $delete = mysql_query("DELETE FROM `download_file` WHERE `id`='$id'");
						
                            if($delete == true){
                                echo '<div class="actshcms">Файл '.$delw['name'].' успешно удалена</div>';
                                header("Refresh:1; url=/download/");
								include_once'../template/foot.php';
                                exit();
                            }
							else
                            {
                                echo '<div class="errors">Ошибка удаление файла</div>';
                                header("Refresh:1; url=/download/");
								include_once'../template/foot.php';
                                exit();
                            }
                    }

            echo '<form action="?act=delete&id='.$id.'" method="post">';
            echo '<input type="submit" name="delete_dir" value="Удалить">';
            echo '</form>';
    break;

        endswitch;

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