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

Размер файла: 10.25Kb
<?php
require_once ("../includes/start.php");
require_once ("../includes/functions.php");
require_once ("../includes/header.php");
include_once ("../themes/".$config['themes']."/index.php");

extract($HTTP_GET_VARS);
extract($HTTP_POST_VARS);

require_once"func.inc";

$text = @file("../../local/profil/$log.prof"); 
if ($text!=""){
$udata = explode(":||:",$text[0]);
$provlog=trim($udata[0]);
$provpar=trim($udata[1]);
$dostup=trim($udata[7]);}

if (is_user()){
if (is_admin(array(101,102,103))){
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if(!isset($did)){echo "Ошибка!";}
if($ren==1){if($tip!=="java"){
echo "</div><div class=b>Переименование Файла</div><form action='file.php?did=$did&ren=2&SID=$SID' method=post>
Выберите Файл:<br>";
$odir=opendir("../files$did");

list($tip,$form)=file_type("../files$did");
if ($tip != "img"){
while (($fid=readdir($odir))==true){
if ((($fid!==".")&&($fid!=="..") && ($fid != "count") && (!ereg (".txt$", "$fid")) && (!ereg (".kom$", "$fid")) && (!ereg (".dat$", "$fid")) && (!ereg (".dir$", "$fid")) && (!ereg (".jpg$", "$fid")) && (!ereg (".gif$", "$fid")) && (!ereg (".png$", "$fid")) && (!ereg (".jpeg$", "$fid")) && (!ereg (".off$", "$fid")) && (!ereg (".offs$", "$fid"))) and is_dir("../files$did/$fid")==false)
{$all_files[]="/$fid";}}
}else{
while (($fid=readdir($odir))==true){
if ((($fid!==".")&&($fid!=="..") && ($fid != "count") && (!ereg (".txt$", "$fid")) && (!ereg (".kom$", "$fid")) && (!ereg (".dat$", "$fid")) && (!ereg (".dir$", "$fid")) && (!ereg (".off$", "$fid")) && (!ereg (".offs$", "$fid"))) and is_dir("../files$did/$fid")==false)
{$all_files[]="/$fid";}}}
closedir($odir);
echo "<select name='old_name_files'>";
foreach ($all_files as $n=>$fid){
$name=str_replace("/","",$fid);		
echo "<option value=$fid>$name</option>";}
echo "</select><br>Новое имя Файла:<br>
<input type=text name=new_name_file maxlength=30><br>
<input type=submit value='Переименовать'></form><center>
[<a href='../index.php?did=$did&SID=$SID'>К папке</a>]<br>
[<a href='../index.php?did=&SID=$SID'>К загрузкам</a>]<br>
[<a href='../../index.php?SID=$SID'>На главную</a>]</center>";}}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if($ren==2){
$rn=rename("../files$did$old_name_files","../files$did/$new_name_file");
if($rn==true){
rename("../files$did$old_name_files.txt","../files$did/$new_name_file.txt");
rename("../files$did$old_name_files.dat","../files$did/$new_name_file.dat");
rename("../files$did$old_name_files.kom","../files$did/$new_name_file.kom");
rename("../files$did$old_name_files.jpg","../files$did/$new_name_file.jpg");
rename("../files$did$old_name_files.jpeg","../files$did/$new_name_file.jpeg");
rename("../files$did$old_name_files.gif","../files$did/$new_name_file.gif");
rename("../files$did$old_name_files.png","../files$did/$new_name_file.png");

$dik = str_replace("/", "", $did);
$ex = format($new_name_file);
$rr = str_replace(".".$ex,"",$new_name_file);
$ft = file("../baze/$dik.baz");
$total = count($ft);
$fp=fopen("../baze/$dik.baz","a+");
flock ($fp,LOCK_EX);
ftruncate ($fp,0);
	for($i=0; $i<=$total; $i++){
		$data = explode("|",$ft[$i]);
		if($data[11]=="$did$old_name_files"){
		fputs($fp,"$data[0]|$data[1]|$data[2]|$data[3]|$data[4]|$data[5]|$data[6]|$data[7]|$data[8]|$rr|$ex|$did/$new_name_file|\r\n");}
		else{fputs($fp,$ft[$i]);}
		fflush($fp);
	}
flock($fp,LOCK_UN);
fclose($fp);
@chmod("$fp", 0666);

echo "
Файл переименован<br> <center>
[<a href='../index.php?did=$did&SID=$SID'>К папке</a>]<br>
[<a href='../index.php?did=&SID=$SID'>К загрузкам</a>]<br>
[<a href='../../index.php?SID=$SID'>На главную</a>]
</center>";}
else {echo"Ошибка <br><center>
[<a href='?did=$did&ren=1&SID=$SID'>Еще раз</a>]<br>
[<a href='../index.php?did=$did&SID=$SID'>К папке</a>]<br>
[<a href='../index.php?did=&SID=$SID'>К загрузкам</a>]<br>
[<a href='../../index.php?SID=$SID'>На главную</a>]</center>";}
}

if($cro==1){
echo "</div><div class=b>Создание описания</div><div><form action='file.php?did=$did&cro=2' method=post>
Выберите Файл:<br>";
$odir=opendir("../files$did");
list($tip,$oform)=file_type("../files$did");
while (($fid=readdir($odir))==true){
$format=format($fid);
if ((($fid!==".")&&($fid!=="..")) and (array_search($format,$oform)==true or ($tip=="java" and $format=="jar")) and is_dir("../files$did/$fid")==false and file_exists("../files$did/$fid.txt")!==true)
{$all_files[]="$fid";}}
closedir($odir);
echo "<select name='name'>";
foreach ($all_files as $n=>$fid){
echo "<option value=$fid>$fid</option>";}
echo "</select><br>
Описание файла:<br>
<textarea name=\"opis\" cols=50 rows=10></textarea><br>
Название Файла:<br>
<input type=text name=imya value=$na><br>
<input type=submit value='Создать'></form>
<center>[<a href='../index.php?did=$did&SID=$SID'>К папке</a>]<br>
[<a href='../index.php?did=&SID=$SID'>К загрузкам</a>]<br>
[<a href='../../index.php?SID=$SID'>На главную</a>]</center>";}
if($cro==2){
$format=format($name);
$fid=$name;
$name=str_replace(".".$format,"",$name);

$opis=check($opis);
$opis=preg_replace ("|[\r\n]+|si","<br>",$opis);
$opis=str_replace("
","<br>",$opis);
$opis=str_replace("§","<br>",$opis);
$opis = antimat($opis);
$opis = smiles($opis);

$opis="$opis";
$f=fopen("../files$did/$fid.txt","w");
fputs($f,$opis);
fclose($f);
@chmod("../files$did/$fid.txt", 0666);

$dik = str_replace("/", "", $did);
$ex = format($fid);
$rr = str_replace(".".$ex,"",$fid);
$ft = file("../baze/$dik.baz");
$total = count($ft);
$fp=fopen("../baze/$dik.baz","a+");
flock ($fp,LOCK_EX);
ftruncate ($fp,0);
	for($i=0; $i<=$total; $i++){
		$data = explode("|",$ft[$i]);
		if($data[11]=="$did/$fid"){
		fputs($fp,"$data[0]|$data[1]|$data[2]|$data[3]|$data[4]|$data[5]|$data[6]|$data[7]|$imya|$data[9]|$data[10]|$data[11]|\r\n");}
		else{fputs($fp,$ft[$i]);}
		fflush($fp);
	}
flock($fp,LOCK_UN);
fclose($fp);
@chmod("$fp", 0666);

if (file("../files$did/$name.txt")){ unlink("../files$did/$name.txt");}
echo "Описание создано<br><br>
<center>[<a href='../index.php?did=$did&SID=$SID'>К папке</a>]<br>
[<a href='../index.php?did=&SID=$SID'>К загрузкам</a>]<br>
[<a href='../../index.php?SID=$SID'>На главную</a>]</center>";
}
if($edo==1){
echo "</div><div class=b>Редактирование описания</div><div><form action='file.php?did=$did&edo=2&SID=$SID' method=post>
Выберите Файл:<br>";
$odir=opendir("../files$did");
list($tip,$oform)=file_type("../files$did");
while (($fid=readdir($odir))==true){
$format=format($fid);
if ((($fid!==".")&&($fid!=="..")) and (array_search($format,$oform)==true or $format=="jar") and !is_dir("../files$did/$fid") and file_exists("../files$did/$fid.txt"))
{
	$all_files[]="$fid";
}
}
closedir($odir);
echo "<select name='fid'>";
foreach ($all_files as $n=>$fid){
echo "<option value=$fid>$fid</option>";}
echo "</select><br>
<input type=submit value='Редактировать'></form>
<br>
<center>[<a href='../index.php?did=$did&SID=$SID'>К папке</a>]<br>
[<a href='../index.php?did=&SID=$SID'>К загрузкам</a>]<br>
[<a href='../../index.php?SID=$SID'>На главную</a>]</center>";
}
if($edo==2){
echo "</div><div class=b>Редактирование описания</div><div><form action='file.php?did=$did&edo=3' method=post>";	echo "<form action='file.php?did=$did&edo=3&SID=$SID' method=post>";
$abot = @file_get_contents("../files$did/$fid.txt");
$dik = str_replace("/", "", $did);
$ft = @file("../baze/$dik.baz");
$total = count($ft);
	for($i=0; $i<=$total; $i++){
		$data = explode("|",$ft[$i]);
		if($data[11]=="$did/$fid"){$na = $data[8];}
	}
	
$abot=str_replace('<img src="../','',$abot);
$abot=str_replace('../','',$abot);
$abot=str_replace('images/smiles/',':',$abot);
$abot=str_replace('.gif" alt="">','',$abot);
$abot=str_replace ("<br>","\r\n",$abot);
$abot=str_replace ("<br />","\r\n",$abot);
$na=trim($na);	
echo "<input type=hidden name=fid value=$fid>
	<textarea name=\"opis\" cols=50 rows=10>$abot</textarea><br>
	Название Файла:<br>";
echo "<textarea name=\"imya\">$na</textarea><br>";
echo "<input type=submit value='Редактировать'></form>
	<br>
<center>[<a href='../index.php?did=$did&SID=$SID'>К папке</a>]<br>
[<a href='../index.php?did=&SID=$SID'>К загрузкам</a>]<br>
[<a href='../../index.php?SID=$SID'>На главную</a>]</center>";
}
if($edo==3){
	echo "</div><div class=b>Редактирование описания</div><div>";
	
	$opis=check($opis);
	$opis=preg_replace ("|[\r\n]+|si","<br>",$opis);
	$opis=str_replace("
","<br>",$opis);
	$opis=str_replace("§","<br>",$opis);
	$opis = antimat($opis);
	$opis = smiles($opis);
	
	$opis="$opis";
	$fp=fopen("../files$did/$fid.txt","w");
	fputs($fp,$opis);
	fclose($fp);

$dik = str_replace("/", "", $did);
$ex = format($nmf);
$rr = str_replace(".".$ex,"",$nmf);
$ft = file("../baze/$dik.baz");
$total = count($ft);
$fp=fopen("../baze/$dik.baz","a+");
flock ($fp,LOCK_EX);
ftruncate ($fp,0);
	for($i=0; $i<=$total; $i++){
		$data = explode("|",$ft[$i]);
		if($data[11]=="$did/$fid"){
		fputs($fp,"$data[0]|$data[1]|$data[2]|$data[3]|$data[4]|$data[5]|$data[6]|$data[7]|$imya|$data[9]|$data[10]|$data[11]|\r\n");}
		else{fputs($fp,$ft[$i]);}
		fflush($fp);
	}
flock($fp,LOCK_UN);
fclose($fp);
@chmod("$fp", 0666);

	echo "Описание изменено<br>
<center>[<a href='../index.php?did=$did&SID=$SID'>К папке</a>]<br>
[<a href='../index.php?did=&SID=$SID'>К загрузкам</a>]<br>
[<a href='../../index.php?SID=$SID'>На главную</a>]</center>";	
}
} else { echo"Не лезь !!! <br>
<center>[<a href='../index.php?did=$did&SID=$SID'>К папке</a>]<br>
[<a href='../index.php?did=&SID=$SID'>К загрузкам</a>]<br>
[<a href='../../index.php?SID=$SID'>На главную</a>]</center>";}
}
include_once ("../themes/".$config['themes']."/foot.php");
?>