35 $this->
ilias =& $ilias;
37 $this->main_dir = $a_main_directory;
38 $this->post_dir_path =
false;
39 $this->commands = array(
42 "method" =>
"downloadFile",
43 "name" => $lng->txt(
"download"),
49 "method" =>
"confirmDeleteFile",
50 "name" => $lng->txt(
"delete"),
56 "method" =>
"unzipFile",
57 "name" => $lng->txt(
"unzip"),
63 "method" =>
"renameFileForm",
64 "name" => $lng->txt(
"rename"),
71 $this->file_labels = array();
72 $this->label_enable =
false;
73 $this->ctrl->saveParameter($this,
"cdir");
74 $lng->loadLanguageModule(
"content");
88 $this->allowed_suffixes = $a_suffixes;
108 $this->forbidden_suffixes = $a_suffixes;
152 $this->allow_directories = $a_val;
162 return $this->allow_directories;
172 $this->post_dir_path = $a_val;
182 return $this->post_dir_path;
192 $this->table_id = $a_val;
202 return $this->table_id;
212 $this->title = $a_val;
232 $this->use_upload_directory = $a_val;
253 if (!is_array($pars))
257 $_SESSION[
"fsys"][
"lastcomm"] = array_merge(
258 array(
"cmd" => $command), $pars);
278 $next_class = $this->ctrl->getNextClass($this);
279 $cmd = $this->ctrl->getCmd(
"listFiles");
285 if (substr(
$cmd, 0, 11) ==
"extCommand_")
303 function addCommand(&$a_obj, $a_func, $a_name, $a_single =
true,
304 $a_allow_dir =
false)
306 $i = count($this->commands);
308 $this->commands[$i][
"object"] =& $a_obj;
309 $this->commands[$i][
"method"] = $a_func;
310 $this->commands[$i][
"name"] = $a_name;
311 $this->commands[$i][
"single"] = $a_single;
312 $this->commands[$i][
"allow_dir"] = $a_allow_dir;
322 $this->commands = array();
330 $this->file_labels[$a_file][] = $a_label;
338 $this->label_enable = $a_act;
339 $this->label_header = $a_label_header;
353 if($new_subdir ==
"..")
355 $cur_subdir = substr($cur_subdir, 0, strrpos($cur_subdir,
"/"));
359 if (!empty($new_subdir))
361 if (!empty($cur_subdir))
363 $cur_subdir = $cur_subdir.
"/".$new_subdir;
367 $cur_subdir = $new_subdir;
372 $cur_subdir = str_replace(
"..",
"", $cur_subdir);
373 $cur_dir = (!empty($cur_subdir))
374 ? $this->main_dir.
"/".$cur_subdir
377 return array(
"dir"=>$cur_dir,
"subdir"=>$cur_subdir);
384 $entries = (is_dir($a_dir))
386 : array(array(
"type" =>
"dir",
"entry" =>
".."));
389 foreach ($entries as $e)
391 if(($e[
"entry"] ==
".") ||
392 ($e[
"entry"] ==
".." && empty($a_subdir)))
397 $cfile = (!empty($a_subdir))
398 ? $a_subdir.
"/".$e[
"entry"]
403 "entry" => $e[
"entry"],
404 "type" => $e[
"type"],
405 "size" => $e[
"size"],
406 "hash" => md5($e[
"entry"])
415 $sel_files = $hashes = array();
416 if (isset(
$_POST[
"file"]))
420 else if(isset(
$_GET[
"fhsh"]))
422 $hashes = array(
$_GET[
"fhsh"]);
428 $all_files = $this->
getFileList($dir[
"dir"], $dir[
"subdir"]);
429 foreach($hashes as $hash)
431 foreach($all_files as
$file)
433 if($file[
"hash"] == $hash)
454 if(!count($selected))
457 $this->ctrl->redirect($this,
"listFiles");
461 if (count($selected) > 1 && $this->commands[$a_nr][
"single"])
464 $this->ctrl->redirect($this,
"listFiles");
471 foreach ($selected as
$file)
474 $file = (!empty($cur_subdir))
475 ? $cur_subdir.
"/".$file
479 if (@is_dir($this->main_dir.
"/".$file) &&
480 !$this->commands[$a_nr][
"allow_dir"])
483 $this->ctrl->redirect($this,
"listFiles");
489 if ($this->commands[$a_nr][
"single"])
491 $files = array_shift($files);
494 $obj = $this->commands[$a_nr][
"object"];
495 $method = $this->commands[$a_nr][
"method"];
497 return $obj->$method($files);
505 $this->directory_creation = $a_val;
513 return $this->directory_creation;
521 $this->file_creation = $a_val;
529 return $this->file_creation;
541 $this->ctrl->setParameter($this,
"cdir", $dir[
"subdir"]);
544 $ilToolbar->setFormAction($ilCtrl->getFormAction($this),
true);
545 include_once(
"./Services/Form/classes/class.ilTextInputGUI.php");
549 $ti =
new ilTextInputGUI($this->lng->txt(
"cont_new_dir"),
"new_dir");
552 $ilToolbar->addInputItem($ti,
true);
553 $ilToolbar->addFormButton($lng->txt(
"create"),
"createDirectory");
555 $ilToolbar->addSeparator();
558 include_once(
"./Services/Form/classes/class.ilFileInputGUI.php");
561 $fi =
new ilFileInputGUI($this->lng->txt(
"cont_new_file"),
"new_file");
563 $ilToolbar->addInputItem($fi,
true);
564 $ilToolbar->addFormButton($lng->txt(
"upload"),
"uploadFile");
567 include_once
'Services/FileSystem/classes/class.ilUploadFiles.php';
570 $ilToolbar->addSeparator();
572 $options[
""] = $lng->txt(
"cont_select_from_upload_dir");
573 foreach($files as
$file)
575 $file = htmlspecialchars($file, ENT_QUOTES,
"utf-8");
578 include_once(
"./Services/Form/classes/class.ilSelectInputGUI.php");
581 $ilToolbar->addInputItem(
$si,
true);
582 $ilToolbar->addFormButton($lng->txt(
"copy"),
"uploadFile");
586 include_once(
"./Services/FileSystem/classes/class.ilFileSystemTableGUI.php");
588 $this->label_enable, $this->file_labels, $this->label_header, $this->commands,
592 $fs_table->setTitle($this->
getTitle());
594 if (
$_GET[
"resetoffset"] == 1)
596 $fs_table->resetOffset();
598 $this->tpl->setContent($fs_table->getHTML());
609 $file = $this->main_dir.
"/".$a_file;
611 $this->ctrl->setParameter($this,
"old_name", basename($a_file));
614 include_once(
"Services/Form/classes/class.ilPropertyFormGUI.php");
621 $ti->setValue(basename($a_file));
625 $form->addCommandButton(
"renameFile", $lng->txt(
"rename"));
626 $form->addCommandButton(
"cancelRename", $lng->txt(
"cancel"));
627 $form->setFormAction($ilCtrl->getFormAction($this,
"renameFile"));
631 $form->setTitle($this->lng->txt(
"cont_rename_dir"));
635 $form->setTitle($this->lng->txt(
"rename_file"));
638 $this->tpl->setContent($form->getHTML());
649 $new_name = str_replace(
"/",
"", $new_name);
652 $this->
ilias->raiseError($this->lng->txt(
"enter_new_name"),$this->
ilias->error_obj->MESSAGE);
655 $pi = pathinfo($new_name);
656 $suffix = $pi[
"extension"];
660 $this->ctrl->redirect($this,
"listFiles");
664 $dir = (!empty($cur_subdir))
665 ? $this->main_dir.
"/".$cur_subdir.
"/" 666 : $this->main_dir.
"/";
669 if (is_dir($dir.ilUtil::stripSlashes(
$_GET[
"old_name"])))
671 rename($dir.ilUtil::stripSlashes(
$_GET[
"old_name"]), $dir.$new_name);
675 include_once(
"./Services/Utilities/classes/class.ilFileUtils.php");
683 $this->ctrl->redirect($this,
"listFiles");
688 if (@is_dir($dir.$new_name))
692 "new_name" => $new_name));
698 "new_name" => $new_name));
700 $this->ctrl->redirect($this,
"listFiles");
708 $this->ctrl->redirect($this,
"listFiles");
720 $cur_dir = (!empty($cur_subdir))
721 ? $this->main_dir.
"/".$cur_subdir
725 $new_dir = str_replace(
"/",
"", $new_dir);
727 if (!empty($new_dir))
730 if (is_dir($cur_dir.
"/".$new_dir))
740 $this->ctrl->saveParameter($this,
"cdir");
741 $this->ctrl->redirect($this,
"listFiles");
753 $cur_dir = (!empty($cur_subdir))
754 ? $this->main_dir.
"/".$cur_subdir
759 $pi = pathinfo($_FILES[
"new_file"][
"name"]);
760 $suffix = $pi[
"extension"];
764 $this->ctrl->redirect($this,
"listFiles");
767 if (is_file($_FILES[
"new_file"][
"tmp_name"]))
770 $tgt_file = $cur_dir.
"/".$name;
775 elseif (
$_POST[
"uploaded_file"])
777 include_once
'Services/FileSystem/classes/class.ilUploadFiles.php';
788 else if (trim($_FILES[
"new_file"][
"name"]) ==
"")
793 if($tgt_file && is_file($tgt_file))
798 include_once(
"./Services/Utilities/classes/class.ilMimeTypeUtil.php");
801 $this->ctrl->setParameter($this,
"upfile", basename($tgt_file));
802 $url = $this->ctrl->getLinkTarget($this,
"unzipFile");
803 $this->ctrl->setParameter($this,
"upfile",
"");
805 include_once
"Services/UIComponent/Button/classes/class.ilLinkButton.php";
807 $unzip->setCaption(
"unzip");
808 $unzip->setUrl(
$url);
809 $unzip =
" ".$unzip->render();
815 array(
"name" => substr($tgt_file, strlen($this->main_dir)+1)));
818 $this->ctrl->saveParameter($this,
"cdir");
822 $this->ctrl->redirect($this,
"listFiles");
832 include_once(
"./Services/Utilities/classes/class.ilConfirmationGUI.php");
834 $cgui->setFormAction($ilCtrl->getFormAction($this));
835 $cgui->setHeaderText($lng->txt(
"info_delete_sure"));
836 $cgui->setCancel($lng->txt(
"cancel"),
"listFiles");
837 $cgui->setConfirm($lng->txt(
"delete"),
"deleteFile");
839 foreach ($a_files as $i)
841 $cgui->addItem(
"file[]", $i, $i);
844 $tpl->setContent($cgui->getHTML());
854 if (!isset(
$_POST[
"file"]))
856 $this->
ilias->raiseError($this->lng->txt(
"no_checkbox"),$this->
ilias->error_obj->MESSAGE);
859 foreach (
$_POST[
"file"] as $post_file)
863 $this->
ilias->raiseError($this->lng->txt(
"no_checkbox"),$this->
ilias->error_obj->MESSAGE);
868 $cur_dir = (!empty($cur_subdir))
869 ? $this->main_dir.
"/".$cur_subdir
871 $pi = pathinfo($post_file);
886 $this->ctrl->saveParameter($this,
"cdir");
899 $this->ctrl->redirect($this,
"listFiles");
911 isset(
$_GET[
"upfile"]))
913 $a_file = basename(
$_GET[
"upfile"]);
917 $cur_dir = (!empty($cur_subdir))
918 ? $this->main_dir.
"/".$cur_subdir
920 $a_file = $this->main_dir.
"/".$a_file;
922 if (@is_file($a_file))
924 include_once(
"./Services/Utilities/classes/class.ilFileUtils.php");
926 $cur_files_r = iterator_to_array(
new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($cur_dir)));
938 $new_files_r = iterator_to_array(
new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($cur_dir)));
940 $diff = array_diff($new_files, $cur_files);
941 $diff_r = array_diff($new_files_r, $cur_files_r);
944 foreach ($diff_r as $f =>
$d)
947 if (!is_dir($f) && !$this->
isValidSuffix(strtolower($pi[
"extension"])))
949 ilUtil::sendFailure($lng->txt(
"file_some_invalid_file_types_removed").
" (".$pi[
"extension"].
")",
true);
958 include_once(
"./Services/Utilities/classes/class.ilFileUtils.php");
959 $new_files = array();
961 foreach($diff as $new_item)
963 if(is_dir($cur_dir.
"/".$new_item))
969 if(is_array($new_files[
"path"]))
971 foreach($new_files[
"path"] as $idx =>
$path)
973 $path = substr(
$path, strlen($this->main_dir)+1);
974 $diff[] =
$path.$new_files[
"file"][$idx];
980 array(
"name" => substr(
$file, strlen($this->main_dir)+1),
987 $this->ctrl->saveParameter($this,
"cdir");
989 $this->ctrl->redirect($this,
"listFiles");
997 $file = $this->main_dir.
"/".$a_file;
1006 $this->ctrl->saveParameter($this,
"cdir");
1007 $this->ctrl->redirect($this,
"listFiles");
1018 $ilCtrl->setParameter($this,
"resetoffset", 1);
1019 $tabs_gui->addTarget(
"cont_list_files",
1020 $this->ctrl->getLinkTarget($this,
"listFiles"),
"listFiles",
1022 $ilCtrl->setParameter($this,
"resetoffset",
"");
downloadFile($a_file)
delete object file
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
& executeCommand()
execute command
setTitle($a_val)
Set title.
Base class for ILIAS Exception handling.
activateLabels($a_act, $a_label_header)
activate file labels
getTableId()
Get table id.
setPostDirPath($a_val)
Set post dir path.
setAllowDirectories($a_val)
Set allow directories.
renameFileForm($a_file)
list files
getAllowDirectoryCreation()
Get allowed directory creation.
getForbiddenSuffixes()
Get Accepted Suffixes.
static unzip($a_file, $overwrite=false, $a_flat=false)
unzip file
static getDir($a_dir, $a_rec=false, $a_sub_dir="")
get directory
addCommand(&$a_obj, $a_func, $a_name, $a_single=true, $a_allow_dir=false)
Add command.
ilFileSystemGUI($a_main_directory)
static _getUploadDirectory()
Get the directory with uploaded files.
static _getUploadFiles()
Get a list of readable files in the upload directory.
getAllowedSuffixes()
Get allowed Suffixes.
setUseUploadDirectory($a_val)
Set use upload directory.
getLastPerformedCommand()
Get performed command.
createDirectory()
create directory
clearCommands()
Clear commands.
static rename($a_source, $a_target)
Rename a file.
static getMimeType($a_file='', $a_filename='', $a_mime='')
setTableId($a_val)
Set table id.
setForbiddenSuffixes($a_suffixes)
Set forbidden Suffixes.
getTabs(&$tabs_gui)
get tabs
extCommand($a_nr)
call external command
deleteFile()
delete object file
if(!is_array($argv)) $options
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
getUseUploadDirectory()
Get use upload directory.
cancelRename()
cancel renaming a file
setAllowedSuffixes($a_suffixes)
Set allowed Suffixes.
This class represents a text property in a property form.
renameFile()
rename a file
redirection script todo: (a better solution should control the processing via a xml file) ...
getAllowDirectories()
Get allow directories.
setMaxLength($a_maxlength)
Set Max Length.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static deliverFile($a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
isValidSuffix($a_suffix)
Is suffix valid?
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
setAllowDirectoryCreation($a_val)
Set allowed directory creation.
if(!file_exists(getcwd().'/ilias.ini.php')) if(isset( $_GET["client_id"]))
registration confirmation script for ilias
getPostDirPath()
Get post dir path.
getFileList($a_dir, $a_subdir=null)
setAllowFileCreation($a_val)
Set allowed file creation.
static renameExecutables($a_dir)
Rename uploaded executables for security reasons.
recursive_dirscan($dir, &$arr)
Recursively scans a given directory and writes path and filename into referenced array.
getAllowFileCreation()
Get allowed file creation.
confirmDeleteFile(array $a_files)
Confirm file deletion.
setPerformedCommand($command, $pars="")
Set performed command.
static _checkUploadFile($a_file)
Check if a file exists in the upload directory and is readable.
File System Explorer GUI class.
labelFile($a_file, $a_label)
label a file
static _copyUploadFile($a_file, $a_target, $a_raise_errors=true)
copy an uploaded file to the target directory (including virus check)
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
unzipFile($a_file=null)
delete object file
Confirmation screen class.
TableGUI class for file system.