59 lines
1.5 KiB
PHP
59 lines
1.5 KiB
PHP
|
<?php
|
||
|
if ( $_SESSION['dostup']!=='a' && $_SESSION['dostup']!=='e' )header( 'Location: /403/' );
|
||
|
function creat_path ($text) {
|
||
|
$old1 = array("---");
|
||
|
$new1 = array("/");
|
||
|
$text = str_replace($old1, $new1, $text);
|
||
|
return $text; }
|
||
|
function list_dir ( $dir ) {
|
||
|
if ( $dir [ strlen( $dir ) - 1 ] != '/' ){
|
||
|
$dir .= '/';}
|
||
|
$nDir = opendir( $dir );
|
||
|
while ( false !== ( $file = readdir( $nDir ) ) ){
|
||
|
if ( $file != "." AND $file != ".." ){
|
||
|
if ( is_dir( $dir . $file ) ){
|
||
|
$files [] = $file;
|
||
|
}}}
|
||
|
closedir( $nDir );
|
||
|
return $files;
|
||
|
}
|
||
|
function list_file ( $dir ) {
|
||
|
if ( $dir [ strlen( $dir ) - 1 ] != '/' ){$dir .= '/';}
|
||
|
$nDir = opendir( $dir );
|
||
|
while ( false !== ( $file = readdir( $nDir ) ) )
|
||
|
{
|
||
|
if ( $file != "." AND $file != ".." ){
|
||
|
if ( !is_dir( $dir . $file ) ){
|
||
|
$files [] = $file;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
closedir( $nDir );
|
||
|
return $files;
|
||
|
}
|
||
|
if (!$_GET['id'])$cat=MYDIR . '/files'; else $cat=MYDIR . '/files' . creat_path (ID);
|
||
|
if (!$_GET['id'])$cat2='/files'; else $cat2='/files' . creat_path (ID);
|
||
|
if (is_dir($cat)){
|
||
|
if ($_FILES){
|
||
|
$src = $_FILES['file']['tmp_name'];
|
||
|
$dst=$cat . '/' . $_FILES['file']['name'];
|
||
|
copy ($src, $dst);
|
||
|
}
|
||
|
if ($_POST['newcat']){
|
||
|
mkdir ($cat . '/' . $_POST['newcat'], 0700);
|
||
|
}
|
||
|
$dirs=list_dir($cat);
|
||
|
$files=list_file($cat);
|
||
|
@sort($dirs);
|
||
|
@sort($files);
|
||
|
$smarty->assign('dirs', @$dirs);
|
||
|
$smarty->assign('cat', @$cat);
|
||
|
$smarty->assign('cat2', @$cat2);
|
||
|
$smarty->assign('files', @$files);
|
||
|
}
|
||
|
/*
|
||
|
function getExtension3($filename) {
|
||
|
return substr($fileName, strrpos($fileName, '.') + 1);
|
||
|
}
|
||
|
*/
|
||
|
?>
|