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

Размер файла: 3.69Kb
<?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";

set_time_limit(0);

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

if ($dostup==101){

echo '<img src="../../images/img/partners.gif" alt=""> <b>Импорт файлов</b><br><br>';

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

$did = "../$info[path]";

if(!isset($did)){header ("Location: ../index.php?".SID); exit;}
if(!is_dir("../$info[path]")){header ("Location: ../index.php?".SID); exit;}
if(!$info['oform']){header ("Location: ../index.php?".SID); exit;}

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

$too = $_POST['too'];
$opis = $_POST['opis'];
$imya = $_POST['imya'];
$url = $_POST['url'];

if ($opis!="" && $imya!="" && $too!="" && $url!="" && ereg("^(http:\/\/)+[a-zA-Z_0-9/.&=?-]+$",$url)){
$url = trim($url);
$too = trim($too);
$import = str_replace($too,"$did/".$too,$too);

$format=explode(":", $info[oform]);
if(in_array(format($import), $format)){
if(!file_exists($import)){
if(copy($url,$import)){

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

$fp=fopen("$did/$too.txt","w");
flock ($fp,LOCK_EX);
fputs($fp,$opis);
flock ($fp,LOCK_UN);
fclose($fp);
chmod("$did/$too.txt", 0666);

$dir = str_replace("../", "", $did);
$ex = pathinfo("$did/$too");
$ex = $ex[extension];
$rr = str_replace(".".$ex,"",$too);
$size = filesize("$did/$too");
$query = mysql_query("INSERT INTO `".$preff."_files` (`path`, `fname`, `infolder`, `size` , `timeupload`, `format` , `uploader` , `name` , `about`) VALUES ('$dir/$too', '$rr', '$dir' , '$size' , '$sitetime', '$ex', '$log', '$imya', '$opis');");
echo '<center><b>Файл успешно импортирован!</b></center><br><br>';
} else {echo "Импорт не удался!<br><br>";}
} else {echo "Ошибка! Такой файл уже существует!<br><br>";}
} else {echo "Ошибка! Данный формат файла запрещен!<br><br>";}
} else {echo "Ошибка! Отсутствуют важные данные!<br><br>";}
}
if(!isset($action)){
echo '<form action="import.php?action=import&amp;id='.$id.'&amp;'.SID.'" method="post">
<b>URL файла</b>:<br><input type="text" name="url" value="http://"><br>
Сохранить как (file.zip):<br><input type="text" name="too"><br>
Описание файла:<br>
<textarea name="opis" cols=50 rows=10></textarea><br>
Название файла для отображения:<br>
<input type="text" name="imya"><br>
<input type="submit" value="Импортировать"></form><br>';}

} else {header ("Location: ../../index.php?isset=404&".SID);}
echo '<img src="../../images/img/back.gif" alt=""> <a href="../index.php?id='.$id.'&amp;'.SID.'">Назад</a><br>';
echo '<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";
?>