"; if (!@$_SESSION['perm']) { header("Location: /",true,303); exit(); } if (strpos(@$_REQUEST['path'],'.')!==false) $_REQUEST['path'] = ''; $_REQUEST['path'] = trim(@$_REQUEST['path']); $_REQUEST['path'] = preg_replace("|^/|","",$_REQUEST['path']); $_REQUEST['path'] = preg_replace('/\s/',"",$_REQUEST['path']); $_REQUEST['file'] = preg_replace('|\s|',"",@$_REQUEST['file']); $_REQUEST['file'] = preg_replace('|/|',"",$_REQUEST['file']); //создание подкаталога if (@$_REQUEST['createsubdir']==2) { $_REQUEST['subdir'] = preg_replace("/[^a-z0-9_\\-]/","",strtolower(@$_REQUEST['subdir'])); mkdir($base_path.'/'.$_REQUEST['path'].'/'.$_REQUEST['subdir']); mkdir($base_path.'/'.$_REQUEST['path'].'/'.$_REQUEST['subdir'].'/.thumb'); mkdir($base_path.'/'.$_REQUEST['path'].'/'.$_REQUEST['subdir'].'/.desc'); header("Location: {$_SERVER['SCRIPT_NAME']}?path={$_REQUEST['path']}",true,303); exit(); } //загрузка файла if (@$_REQUEST['loadfile']==2) { $uploaded_file = @$_FILES['filetoload']; if (!is_uploaded_file($uploaded_file['tmp_name'])) die('загруженный файл не найден!'); $type = $uploaded_file['type']; $pp = pathinfo($uploaded_file['name']); $ext = strtolower(trim($pp['extension'])); $time = time(); $filename = "{$base_path}/{$_REQUEST['path']}/$time.$ext"; for ($i=0; file_exists($filename) && $i<10; $i) { $time = time().$i.rand(0,1000); $filename = "{$base_path}/{$_REQUEST['path']}/$time.$ext"; } $preview = "{$base_path}/{$_REQUEST['path']}/.thumb/$time.$ext"; $descname = "{$base_path}/{$_REQUEST['path']}/.desc/$time.$ext.txt"; if (!move_uploaded_file($uploaded_file['tmp_name'],$filename)) die('ошибка при перемещении загруженного файла!'); //создание превью createpreview($filename,$preview,$type); //запись описания file_put_contents($descname,$_REQUEST['desc']); header("Location: {$_SERVER['SCRIPT_NAME']}?path={$_REQUEST['path']}",true,303); exit(); } //изменение файла if (@$_REQUEST['changefile']==2) { $uploaded_file = @$_FILES['filetoload']; if (!is_uploaded_file($uploaded_file['tmp_name'])) die('загруженный файл не найден!'); $type = $uploaded_file['type']; $filename = "{$base_path}/{$_REQUEST['path']}/{$_REQUEST['file']}"; $preview = "{$base_path}/{$_REQUEST['path']}/.thumb/{$_REQUEST['file']}"; $descname = "{$base_path}/{$_REQUEST['path']}/.desc/{$_REQUEST['file']}.txt"; if (!move_uploaded_file($uploaded_file['tmp_name'],$filename)) die('ошибка при перемещении загруженного файла!'); //создание превью createpreview($filename,$preview,$type); //запись описания file_put_contents($descname,$_REQUEST['desc']); header("Location: {$_SERVER['SCRIPT_NAME']}?path={$_REQUEST['path']}",true,303); exit(); } //изменить описание if (@$_REQUEST['changedesc']==2) { file_put_contents("$base_path/{$_REQUEST['path']}/.desc/{$_REQUEST['file']}.txt",$_REQUEST['desc']); header("Location: {$_SERVER['SCRIPT_NAME']}?path={$_REQUEST['path']}",true,303); exit(); } //удаление файла if (@$_REQUEST['delete']==2) { $filename = "{$base_path}/{$_REQUEST['path']}/{$_REQUEST['file']}"; $preview = "{$base_path}/{$_REQUEST['path']}/.thumb/{$_REQUEST['file']}"; $descname = "{$base_path}/{$_REQUEST['path']}/.desc/{$_REQUEST['file']}.txt"; $deldirname = "{$base_path}/{$_REQUEST['path']}/.deleted"; @mkdir($deldirname); rename($filename,"{$deldirname}/{$_REQUEST['file']}"); // @mkdir("{$deldirname}/.thumb"); // rename($preview,"{$deldirname}/.thumb/{$_REQUEST['file']}"); // @mkdir("{$deldirname}/.desc"); // rename($preview,"{$deldirname}/.desc/{$_REQUEST['file']}"); unlink($preview); unlink($descname); header("Location: {$_SERVER['SCRIPT_NAME']}?path={$_REQUEST['path']}",true,303); exit(); } //создание превью function createpreview($filename,$previewname,$type) { switch ($type) { case 'image/gif': $image = imagecreatefromgif($filename); break; case 'image/jpeg': case 'image/pjpeg': $image = imagecreatefromjpeg($filename); break; case 'image/png': case 'image/x-png': $image = imagecreatefrompng($filename); break; default: return; } $width = 300; //максимальные размеры, в которые вписывается превью $height = 200; list($width_orig,$height_orig) = getimagesize($filename); $ratio_orig = $width_orig/$height_orig; if ($width_orig>$width) { $height = $width/$ratio_orig; } else if ($height_orig>$height) { $width = $height*$ratio_orig; } else { $width = $width_orig; $height = $height_orig; } $preview = imagecreatetruecolor($width, $height); imagecopyresampled($preview,$image,0,0,0,0,$width,$height,$width_orig,$height_orig); imagejpeg($preview,$previewname,100); } ?> Список файлов $dirname\n"; else echo "$dirname\n"; foreach (glob("$p/*") as $filename) { if (is_dir($filename)) { show_tree($filename,$curp,$level+1); } } } function show_dir($p) { global $base_path, $base_url; $rel = get_rel_path($p); echo "
".($rel==""?"/":$rel)."
\n"; echo "
\n"; echo "[создать подкаталог]\n"; if ($rel!="") echo "[загрузить файл]\n"; echo "
\n"; $first = true; foreach (glob("$p/*") as $filename) { if (is_dir($filename)) continue; if ($first) echo "\n"; $first = false; $path_parts = pathinfo($filename); $name = $path_parts['basename']; $url_path = str_replace("^$base_path",$base_url,"^".$path_parts['dirname']); $url = $url_path."/".$name; $url_thumb = $url_path."/.thumb/".$name; $filename_thumb = $path_parts['dirname']."/.thumb/".$name; $filename_desc = $path_parts['dirname']."/.desc/".$name.".txt"; @$desc = file_get_contents($filename_desc); $desc = preg_replace("/\n/","
\n",htmlspecialchars($desc,ENT_COMPAT | ENT_HTML401)); echo "\n"; echo "\n"; echo "\n"; echo "\n"; } if (!$first) echo "
\n"; if (file_exists($filename_thumb)) echo ""; else echo ""; echo "\n"; echo "
"; echo "[изм. файл]"; echo "    "; echo "[изм. описание]"; echo "        "; echo "[удалить]"; echo "
\n"; echo "
$desc 
\n"; echo "
$url
\n"; echo "
\n"; echo "
"; } ?>
Имя нового подкаталога: [отменить]


[отменить]


[отменить]

[отменить]

Вы действительно хотите удалить этот файл?
[отменить]