34 $ilias = $DIC[
'ilias'];
38 $this->
ilias = $ilias;
40 $this->main_dir = $a_main_directory;
41 $this->post_dir_path =
false;
45 $this->file_labels =
array();
46 $this->label_enable =
false;
47 $this->ctrl->saveParameter($this, self::CDIR);
48 $lng->loadLanguageModule(
"content");
62 $this->allowed_suffixes = $a_suffixes;
82 $this->forbidden_suffixes = $a_suffixes;
123 $this->allow_directories = $a_val;
133 return $this->allow_directories;
143 $this->post_dir_path = $a_val;
153 return $this->post_dir_path;
163 $this->table_id = $a_val;
173 return $this->table_id;
183 $this->title = $a_val;
203 $this->use_upload_directory = $a_val;
224 if (!is_array($pars)) {
227 $_SESSION[
"fsys"][
"lastcomm"] = array_merge(
228 array(
"cmd" => $command),
250 $next_class = $this->ctrl->getNextClass($this);
251 $cmd = $this->ctrl->getCmd(
"listFiles");
253 switch ($next_class) {
256 if (substr($cmd, 0, 11) ==
"extCommand_") {
259 $ret = $this->$cmd();
278 $i = count($this->commands);
280 $this->commands[
$i][
"object"] = $a_obj;
281 $this->commands[
$i][
"method"] = $a_func;
282 $this->commands[
$i][
"name"] = $a_name;
283 $this->commands[
$i][
"single"] = $a_single;
284 $this->commands[
$i][
"allow_dir"] = $a_allow_dir;
294 $this->commands =
array();
302 $this->file_labels[$a_file][] = $a_label;
310 $this->label_enable = $a_act;
311 $this->label_header = $a_label_header;
325 if ($new_subdir ==
"..") {
326 $cur_subdir = substr($cur_subdir, 0, strrpos($cur_subdir,
"/"));
328 if (!empty($new_subdir)) {
329 if (!empty($cur_subdir)) {
330 $cur_subdir = $cur_subdir .
"/" . $new_subdir;
332 $cur_subdir = $new_subdir;
337 $cur_subdir = str_replace(
"..",
"", $cur_subdir);
338 $cur_dir = (!empty($cur_subdir))
339 ? $this->main_dir .
"/" . $cur_subdir
342 return array(
"dir"=>$cur_dir,
"subdir"=>$cur_subdir);
349 $entries = (is_dir($a_dir))
351 :
array(
array(
"type" =>
"dir",
"entry" =>
".."));
354 foreach ($entries as $e) {
355 if (($e[
"entry"] ==
".") ||
356 ($e[
"entry"] ==
".." && empty($a_subdir))) {
360 $cfile = (!empty($a_subdir))
361 ? $a_subdir .
"/" . $e[
"entry"]
366 "entry" => $e[
"entry"],
367 "type" => $e[
"type"],
368 "size" => $e[
"size"],
369 "hash" => md5($e[
"entry"])
378 $sel_files = $hashes =
array();
379 if (isset(
$_POST[
"file"])) {
381 } elseif (isset(
$_GET[
"fhsh"])) {
385 if (
sizeof($hashes)) {
387 $all_files = $this->
getFileList($dir[
"dir"], $dir[
"subdir"]);
388 foreach ($hashes as $hash) {
389 foreach ($all_files as
$file) {
390 if ($file[
"hash"] == $hash) {
410 if (!count($selected)) {
412 $this->ctrl->redirect($this,
"listFiles");
416 if (count($selected) > 1 && $this->commands[$a_nr][
"single"]) {
418 $this->ctrl->redirect($this,
"listFiles");
425 foreach ($selected as
$file) {
427 $file = (!empty($cur_subdir))
428 ? $cur_subdir .
"/" . $file
432 if (@is_dir($this->main_dir .
"/" . $file) &&
433 !$this->commands[$a_nr][
"allow_dir"]) {
435 $this->ctrl->redirect($this,
"listFiles");
441 if ($this->commands[$a_nr][
"single"]) {
445 $obj = $this->commands[$a_nr][
"object"];
446 $method = $this->commands[$a_nr][
"method"];
448 return $obj->$method(
$files);
456 $this->directory_creation = $a_val;
464 return $this->directory_creation;
472 $this->file_creation = $a_val;
480 return $this->file_creation;
492 $ilToolbar = $DIC[
'ilToolbar'];
498 $this->ctrl->setParameter($this, self::CDIR, $dir[
"subdir"]);
501 $ilToolbar->setFormAction(
$ilCtrl->getFormAction($this),
true);
502 include_once(
"./Services/Form/classes/class.ilTextInputGUI.php");
505 $ti =
new ilTextInputGUI($this->lng->txt(
"cont_new_dir"),
"new_dir");
508 $ilToolbar->addInputItem($ti,
true);
509 $ilToolbar->addFormButton(
$lng->txt(
"create"),
"createDirectory");
511 $ilToolbar->addSeparator();
514 include_once(
"./Services/Form/classes/class.ilFileInputGUI.php");
516 $fi =
new ilFileInputGUI($this->lng->txt(
"cont_new_file"),
"new_file");
518 $ilToolbar->addInputItem($fi,
true);
519 $ilToolbar->addFormButton(
$lng->txt(
"upload"),
"uploadFile");
522 include_once
'Services/FileSystem/classes/class.ilUploadFiles.php';
524 $ilToolbar->addSeparator();
526 $options[
""] =
$lng->txt(
"cont_select_from_upload_dir");
528 $file = htmlspecialchars($file, ENT_QUOTES,
"utf-8");
531 include_once(
"./Services/Form/classes/class.ilSelectInputGUI.php");
534 $ilToolbar->addInputItem(
$si,
true);
535 $ilToolbar->addFormButton(
$lng->txt(
"copy"),
"uploadFile");
538 $fs_table = $this->
getTable($dir[
"dir"], $dir[
"subdir"]);
541 $fs_table->setTitle($this->
getTitle());
543 if (
$_GET[
"resetoffset"] == 1) {
544 $fs_table->resetOffset();
546 $this->tpl->setContent($fs_table->getHTML());
557 include_once(
"./Services/FileSystem/classes/class.ilFileSystemTableGUI.php");
582 $file = $this->main_dir .
"/" . $a_file;
584 $this->ctrl->setParameter($this,
"old_name", basename($a_file));
587 include_once(
"Services/Form/classes/class.ilPropertyFormGUI.php");
594 $ti->setValue(basename($a_file));
598 $form->addCommandButton(
"renameFile",
$lng->txt(
"rename"));
599 $form->addCommandButton(
"cancelRename",
$lng->txt(
"cancel"));
600 $form->setFormAction(
$ilCtrl->getFormAction($this,
"renameFile"));
602 if (@is_dir(
$file)) {
603 $form->setTitle($this->lng->txt(
"cont_rename_dir"));
605 $form->setTitle($this->lng->txt(
"rename_file"));
608 $this->tpl->setContent(
$form->getHTML());
620 $new_name = str_replace(
"/",
"", $new_name);
621 if ($new_name ==
"") {
622 $this->
ilias->raiseError($this->lng->txt(
"enter_new_name"), $this->
ilias->error_obj->MESSAGE);
625 $pi = pathinfo($new_name);
626 $suffix = $pi[
"extension"];
629 $this->ctrl->redirect($this,
"listFiles");
633 $dir = (!empty($cur_subdir))
634 ? $this->main_dir .
"/" . $cur_subdir .
"/" 635 : $this->main_dir .
"/";
641 include_once(
"./Services/Utilities/classes/class.ilFileUtils.php");
647 $this->ctrl->redirect($this,
"listFiles");
652 if (@is_dir($dir . $new_name)) {
655 "new_name" => $new_name));
659 "new_name" => $new_name));
661 $this->ctrl->redirect($this,
"listFiles");
669 $this->ctrl->redirect($this,
"listFiles");
682 $cur_dir = (!empty($cur_subdir))
683 ? $this->main_dir .
"/" . $cur_subdir
687 $new_dir = str_replace(
"/",
"", $new_dir);
689 if (!empty($new_dir)) {
691 if (is_dir($cur_dir .
"/" . $new_dir)) {
698 $this->ctrl->saveParameter($this, self::CDIR);
699 $this->ctrl->redirect($this,
'listFiles');
713 $cur_dir = (!empty($cur_subdir))
714 ? $this->main_dir .
"/" . $cur_subdir
719 $pi = pathinfo($_FILES[
"new_file"][
"name"]);
720 $suffix = $pi[
"extension"];
723 $this->ctrl->redirect($this,
"listFiles");
726 if (is_file($_FILES[
"new_file"][
"tmp_name"])) {
728 $tgt_file = $cur_dir .
"/" .
$name;
730 ilUtil::moveUploadedFile($_FILES[
"new_file"][
"tmp_name"],
$name, $tgt_file);
731 } elseif (
$_POST[
"uploaded_file"]) {
732 include_once
'Services/FileSystem/classes/class.ilUploadFiles.php';
741 } elseif (trim($_FILES[
"new_file"][
"name"]) ==
"") {
745 if ($tgt_file && is_file($tgt_file)) {
749 include_once(
"./Services/Utilities/classes/class.ilMimeTypeUtil.php");
751 $this->ctrl->setParameter($this,
"upfile", basename($tgt_file));
752 $url = $this->ctrl->getLinkTarget($this,
"unzipFile");
753 $this->ctrl->setParameter($this,
"upfile",
"");
755 include_once
"Services/UIComponent/Button/classes/class.ilLinkButton.php";
757 $unzip->setCaption(
"unzip");
758 $unzip->setUrl(
$url);
759 $unzip =
" " . $unzip->render();
766 array(
"name" => substr($tgt_file, strlen($this->main_dir)+1))
770 $this->ctrl->saveParameter($this, self::CDIR);
774 $this->ctrl->redirect($this,
'listFiles');
787 include_once(
"./Services/Utilities/classes/class.ilConfirmationGUI.php");
789 $cgui->setFormAction(
$ilCtrl->getFormAction($this));
790 $cgui->setHeaderText(
$lng->txt(
"info_delete_sure"));
791 $cgui->setCancel(
$lng->txt(
"cancel"),
"listFiles");
792 $cgui->setConfirm(
$lng->txt(
"delete"),
"deleteFile");
794 foreach ($a_files as
$i) {
795 $cgui->addItem(
"file[]", $i, $i);
798 $tpl->setContent($cgui->getHTML());
809 if (!isset(
$_POST[
"file"])) {
810 $this->
ilias->raiseError($this->lng->txt(
"no_checkbox"), $this->
ilias->error_obj->MESSAGE);
813 foreach (
$_POST[
"file"] as $post_file) {
815 $this->
ilias->raiseError($this->lng->txt(
"no_checkbox"), $this->
ilias->error_obj->MESSAGE);
820 $cur_dir = (!empty($cur_subdir))
821 ? $this->main_dir .
"/" . $cur_subdir
823 $pi = pathinfo($post_file);
826 if (@is_file(
$file)) {
830 if (@is_dir(
$file)) {
836 $this->ctrl->saveParameter($this, self::CDIR);
850 $this->ctrl->redirect($this,
'listFiles');
863 isset(
$_GET[
"upfile"])) {
864 $a_file = basename(
$_GET[
"upfile"]);
868 $cur_dir = (!empty($cur_subdir))
869 ? $this->main_dir .
"/" . $cur_subdir
871 $a_file = $this->main_dir .
"/" . $a_file;
873 if (@is_file($a_file)) {
874 include_once(
"./Services/Utilities/classes/class.ilFileUtils.php");
887 $diff = array_diff($new_files, $cur_files);
888 $diff_r = array_diff($new_files_r, $cur_files_r);
891 foreach ($diff_r as $f =>
$d) {
893 if (!is_dir($f) && !$this->
isValidSuffix(strtolower($pi[
"extension"]))) {
901 include_once(
"./Services/Utilities/classes/class.ilFileUtils.php");
902 $new_files =
array();
904 foreach ($diff as $new_item) {
905 if (is_dir($cur_dir .
"/" . $new_item)) {
910 if (is_array($new_files[
"path"])) {
911 foreach ($new_files[
"path"] as $idx =>
$path) {
912 $path = substr(
$path, strlen($this->main_dir)+1);
913 $diff[] =
$path . $new_files[
"file"][$idx];
920 array(
"name" => substr(
$file, strlen($this->main_dir)+1),
928 $this->ctrl->saveParameter($this, self::CDIR);
930 $this->ctrl->redirect($this,
"listFiles");
938 $file = $this->main_dir .
"/" . $a_file;
944 $this->ctrl->saveParameter($this, self::CDIR);
945 $this->ctrl->redirect($this,
"listFiles");
957 $ilCtrl->setParameter($this,
"resetoffset", 1);
958 $tabs_gui->addTarget(
960 $this->ctrl->getLinkTarget($this,
"listFiles"),
964 $ilCtrl->setParameter($this,
"resetoffset",
"");
972 return $this->commands;
980 $this->commands =
array(
983 "method" =>
"downloadFile",
984 "name" => $this->lng->txt(
"download"),
990 "method" =>
"confirmDeleteFile",
991 "name" => $this->lng->txt(
"delete"),
997 "method" =>
"unzipFile",
998 "name" => $this->lng->txt(
"unzip"),
1004 "method" =>
"renameFileForm",
1005 "name" => $this->lng->txt(
"rename"),
1006 "allow_dir" =>
true,
1021 return str_replace(
"..",
"",
ilUtil::stripSlashes($DIC->http()->request()->getQueryParams()[self::CDIR]));
downloadFile($a_file)
delete object file
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
listFiles($a_table_gui=null)
List files.
setTitle($a_val)
Set title.
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.
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.
getTable($a_dir, $a_subdir)
Get table.
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.
executeCommand()
execute command
getTabs(&$tabs_gui)
get tabs
sanitizeCurrentDirectory()
extCommand($a_nr)
call external command
deleteFile()
delete object file
if(isset($_POST['submit'])) $form
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
isValidSuffix($a_suffix)
Is suffix valid?
Create styles array
The data for the language used.
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.
__construct($a_main_directory)
defineCommands()
Define commands available.
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.
getAllowFileCreation()
Get allowed file creation.
confirmDeleteFile(array $a_files)
Confirm file deletion.
setPerformedCommand($command, $pars="")
Set performed command.
static recursive_dirscan($dir, &$arr)
Recursively scans a given directory and writes path and filename into referenced array.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
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
for($i=6; $i< 13; $i++) for($i=1; $i< 13; $i++) $d
static deliverFile( $a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Confirmation screen class.
TableGUI class for file system.