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"])) {
 
  382            $hashes = array(
$_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");
 
  506            $ti->setMaxLength(80);
 
  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");
 
  527            foreach (
$files as $file) {
 
  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");
 
  592        $ti->setMaxLength(200);
 
  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)) {
 
  653            ilUtil::sendSuccess(
$lng->txt(
"cont_dir_renamed"), 
true);
 
  655                "new_name" => $new_name));
 
  657            ilUtil::sendSuccess(
$lng->txt(
"cont_file_renamed"), 
true);
 
  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)) {
 
  692                ilUtil::sendSuccess(
$lng->txt(
"cont_dir_created"), 
true);
 
  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();
 
  762            ilUtil::sendSuccess(
$lng->txt(
"cont_file_created") . $unzip, 
true);
 
  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);
 
  838            ilUtil::sendSuccess(
$lng->txt(
"cont_dir_deleted"), 
true);
 
  844            ilUtil::sendSuccess(
$lng->txt(
"cont_file_deleted"), 
true);
 
  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");
 
  876            $cur_files_r = iterator_to_array(
new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($cur_dir)));
 
  885            $new_files_r = iterator_to_array(
new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($cur_dir)));
 
  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);
 
  929        ilUtil::sendSuccess(
$lng->txt(
"cont_file_unzipped"), 
true);
 
  930        $this->ctrl->redirect($this, 
"listFiles");
 
  938        $file = $this->main_dir . 
"/" . $a_file;
 
  940        if (@is_file($file) && !(@is_dir($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,
 
An exception for terminatinating execution or to throw for unit testing.
Confirmation screen class.
Base class for ILIAS Exception handling.
File System Explorer GUI class.
getAllowedSuffixes()
Get allowed Suffixes.
getUseUploadDirectory()
Get use upload directory.
setForbiddenSuffixes($a_suffixes)
Set forbidden Suffixes.
getAllowDirectoryCreation()
Get allowed directory creation.
setAllowDirectories($a_val)
Set allow directories.
getTable($a_dir, $a_subdir)
Get table.
sanitizeCurrentDirectory()
createDirectory()
create directory
defineCommands()
Define commands available.
getAllowDirectories()
Get allow directories.
setPostDirPath($a_val)
Set post dir path.
getTableId()
Get table id.
labelFile($a_file, $a_label)
label a file
getPostDirPath()
Get post dir path.
confirmDeleteFile(array $a_files)
Confirm file deletion.
setPerformedCommand($command, $pars="")
Set performed command.
addCommand(&$a_obj, $a_func, $a_name, $a_single=true, $a_allow_dir=false)
Add command.
__construct($a_main_directory)
isValidSuffix($a_suffix)
Is suffix valid?
deleteFile()
delete object file
listFiles($a_table_gui=null)
List files.
cancelRename()
cancel renaming a file
extCommand($a_nr)
call external command
getForbiddenSuffixes()
Get Accepted Suffixes.
downloadFile($a_file)
delete object file
setAllowFileCreation($a_val)
Set allowed file creation.
renameFile()
rename a file
setAllowedSuffixes($a_suffixes)
Set allowed Suffixes.
getFileList($a_dir, $a_subdir=null)
executeCommand()
execute command
getLastPerformedCommand()
Get performed command.
unzipFile($a_file=null)
delete object file
clearCommands()
Clear commands.
setTitle($a_val)
Set title.
getTabs(&$tabs_gui)
get tabs
setTableId($a_val)
Set table id.
renameFileForm($a_file)
list files
setUseUploadDirectory($a_val)
Set use upload directory.
setAllowDirectoryCreation($a_val)
Set allowed directory creation.
activateLabels($a_act, $a_label_header)
activate file labels
getAllowFileCreation()
Get allowed file creation.
TableGUI class for file system.
static recursive_dirscan($dir, &$arr)
Recursively scans a given directory and writes path and filename into referenced array.
static rename($a_source, $a_target)
Rename a file.
static getMimeType($a_file='', $a_filename='', $a_mime='')
This class represents a text property in a property form.
static _getUploadFiles()
Get a list of readable files in the upload directory.
static _copyUploadFile($a_file, $a_target, $a_raise_errors=true)
copy an uploaded file to the target directory (including virus check)
static _checkUploadFile($a_file)
Check if a file exists in the upload directory and is readable.
static _getUploadDirectory()
Get the directory with uploaded files.
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static getDir($a_dir, $a_rec=false, $a_sub_dir="")
get directory
static deliverFile( $a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
static unzip($a_file, $overwrite=false, $a_flat=false)
unzip file
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
static renameExecutables($a_dir)
Rename uploaded executables for security reasons.
for( $i=6;$i< 13;$i++) for($i=1; $i< 13; $i++) $d
redirection script todo: (a better solution should control the processing via a xml file)
if(isset($_POST['submit'])) $form