Просмотр файла up/admin/file.php

Размер файла: 3.21Kb
<?php
require_once"../../template/start.php";
require_once"../../template/regglobals.php";
require_once"../../template/config.php";
require_once"../../template/functions.php";
require_once"../../template/antidos.php";
require_once"../../template/cookies.php";
require_once"../../template/gzip.php";
require_once"../../template/header.php";
require_once"../../template/referer.php";
include_once"../../themes/$config_themes/index.php";
include_once"../../template/isset.php";

require_once "../moduls/config.php";
require_once "../moduls/functions.php";
require_once "../moduls/connect.php";

$downtime = time();

if ($dostup==101){

$id = abs((int)$_GET['id']);
$action = $_GET['action'];

$info = mysql_fetch_array(mysql_query("SELECT * FROM `".$preff."_files` WHERE `id` = '".$id."';"));

if(!is_file("../$info[path]")) {header ("Location: ../index.php?".SID); exit;}

if ($action=="del"){

$data = mysql_fetch_array(mysql_query("SELECT * FROM `".$preff."_files` WHERE `id` = '".$id."'"));

$file = $data['fname'];
$format = $data['format'];
$fid = $file.'.'.$format;
$path = "../$data[path]";

unlink("$path");
if(is_file("$path.jpg")) unlink("$path.jpg");
if(is_file("$path.gif")) unlink("$path.gif");
if(is_file("$path.jpeg")) unlink("$path.jpeg");
if(is_file("$path.png")) unlink("$path.png");

echo 'Файл <b>'.$fid.'</b> успешно удален!<br>';
$res = mysql_query("DELETE FROM `".$preff."_files` WHERE `id` = '".$val."'");
}

if($_GET['action']=="about"){

echo '<img src="../../images/img/partners.gif" alt=""> <b>Редактирование описания файла</b><br><br>';

echo '<form action="file.php?id='.$id.'&amp;action=aboutedit&amp;'.SID.'" method=post>';

$list = mysql_fetch_array(mysql_query("SELECT * FROM `".$preff."_files` WHERE `id` = '".$id."'"));

echo '<textarea name="opis" cols="50" rows="10">'.nosmiles($list['about']).'</textarea><br>';

echo 'Название Файла:<br><input type="text" name="imya" value="'.$list['name'].'"><br>';
echo '<input type="submit" value="Редактировать"></form>';

}elseif($_GET['action']=="aboutedit"){

echo '<img src="../../images/img/partners.gif" alt=""> <b>Редактирование описания файла</b><br><br>';

$list = mysql_fetch_array(mysql_query("SELECT * FROM `".$preff."_files` WHERE `id` = '".$id."'"));

$opis = mysql_real_escape_string(check($_POST['opis']));
$opis = antimat($opis);
$opis = smiles($opis);
$opis = no_br($opis,"<br>");
$imya = mysql_real_escape_string(check($_POST['imya']));

$fp=fopen("../$list[path].txt","w");
flock ($fp,LOCK_EX);
fputs($fp,$opis);
flock ($fp,LOCK_UN);
fclose($fp);
chmod("../$list[path].txt", 0666);

mysql_query("UPDATE `".$preff."_files` SET `name`='".$imya."', `about`='".$opis."' WHERE `id`='".$id."'");

echo 'Описание изменено!<br>';
}

} else {header ("Location: ../../index.php?isset=404&".SID); exit;}

echo '<br><img src="../../images/img/reload.gif" alt=""> <a href="../index.php?'.SID.'">К разделам</a><br>';
echo '<img src="../../images/img/homepage.gif" alt=""> <a href="../../index.php?'.SID.'">На главную</a><br>';

include_once"../../themes/$config_themes/foot.php";
?>