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"),
 
   48                                "method" => 
"confirmDeleteFile",
 
   49                                "name" => 
$lng->txt(
"delete"),
 
   55                                "method" => 
"unzipFile",
 
   56                                "name" => 
$lng->txt(
"unzip"),
 
   61                                "method" => 
"renameFileForm",
 
   62                                "name" => 
$lng->txt(
"rename"),
 
   68                $this->file_labels = array();
 
   69                $this->label_enable = 
false;
 
   70                $this->ctrl->saveParameter($this, 
"cdir");
 
   71                $lng->loadLanguageModule(
"content");
 
   85                $this->allowed_suffixes = $a_suffixes;
 
  105                $this->forbidden_suffixes = $a_suffixes;
 
  149                $this->allow_directories = $a_val;
 
  159                return $this->allow_directories;
 
  169                $this->post_dir_path = $a_val;
 
  179                return $this->post_dir_path;
 
  189                $this->table_id = $a_val;
 
  199                return $this->table_id;
 
  209                $this->title = $a_val;
 
  229                $this->use_upload_directory = $a_val;
 
  250                if (!is_array($pars))
 
  254                $_SESSION[
"fsys"][
"lastcomm"] = array_merge(
 
  255                        array(
"cmd" => $command), $pars);
 
  275                $next_class = $this->ctrl->getNextClass($this);
 
  276                $cmd = $this->ctrl->getCmd(
"listFiles");
 
  282                                if (substr(
$cmd, 0, 11) == 
"extCommand_")
 
  300        function addCommand(&$a_obj, $a_func, $a_name, $a_single = 
true,
 
  301                $a_allow_dir = 
false)
 
  303                $i = count($this->commands);
 
  305                $this->commands[$i][
"object"] =& $a_obj;
 
  306                $this->commands[$i][
"method"] = $a_func;
 
  307                $this->commands[$i][
"name"] = $a_name;
 
  308                $this->commands[$i][
"single"] = $a_single;
 
  309                $this->commands[$i][
"allow_dir"] = $a_allow_dir;
 
  319                $this->commands = array();
 
  327                $this->file_labels[$a_file][] = $a_label;
 
  335                $this->label_enable = $a_act;
 
  336                $this->label_header = $a_label_header;
 
  344                if (isset(
$_POST[
"file"]))
 
  347                        foreach (
$_POST[
"file"] as $k => $v)
 
  349                                if (
$_POST[
"file"][$k] == 
"..")
 
  351                                        unset(
$_POST[
"file"][$k]);
 
  358                        $this->
ilias->raiseError($this->lng->txt(
"no_checkbox"),$this->ilias->error_obj->MESSAGE);
 
  362                if (count(
$_POST[
"file"]) > 1 && $this->commands[$a_nr][
"single"])
 
  364                        $this->
ilias->raiseError($this->lng->txt(
"cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
 
  371                foreach (
$_POST[
"file"] as $k => $v)
 
  373                        $file = (!empty($cur_subdir))
 
  378                        if (@is_dir(
$file) && !$this->commands[$a_nr][
"allow_dir"])
 
  380                                $this->
ilias->raiseError($this->lng->txt(
"select_a_file"),$this->ilias->error_obj->MESSAGE);
 
  382                        $file = (!empty($cur_subdir))
 
  388                if ($this->commands[$a_nr][
"single"])
 
  393                $obj =& $this->commands[$a_nr][
"object"];
 
  394                $method = $this->commands[$a_nr][
"method"];
 
  396                return $obj->$method($files);
 
  404                $this->directory_creation = $a_val;
 
  412                return $this->directory_creation;
 
  420                $this->file_creation = $a_val;
 
  428                return $this->file_creation;
 
  446                if($new_subdir == 
"..")
 
  448                        $cur_subdir = substr($cur_subdir, 0, strrpos($cur_subdir, 
"/"));
 
  452                        if (!empty($new_subdir))
 
  454                                if (!empty($cur_subdir))
 
  456                                        $cur_subdir = $cur_subdir.
"/".$new_subdir;
 
  460                                        $cur_subdir = $new_subdir;
 
  465                $cur_subdir = str_replace(
"..", 
"", $cur_subdir);
 
  466                $cur_dir = (!empty($cur_subdir))
 
  467                        ? $this->main_dir.
"/".$cur_subdir
 
  470                $this->ctrl->setParameter($this, 
"cdir", $cur_subdir);
 
  473                $ilToolbar->setFormAction(
$ilCtrl->getFormAction($this), 
true);
 
  474                include_once(
"./Services/Form/classes/class.ilTextInputGUI.php");
 
  478                        $ti = 
new ilTextInputGUI($this->lng->txt(
"cont_new_dir"), 
"new_dir");
 
  479                        $ti->setMaxLength(80);
 
  481                        $ilToolbar->addInputItem($ti, 
true);
 
  482                        $ilToolbar->addFormButton(
$lng->txt(
"create"), 
"createDirectory");
 
  484                        $ilToolbar->addSeparator();
 
  487                include_once(
"./Services/Form/classes/class.ilFileInputGUI.php");
 
  490                        $fi = 
new ilFileInputGUI($this->lng->txt(
"cont_new_file"), 
"new_file");
 
  492                        $ilToolbar->addInputItem($fi, 
true);
 
  493                        $ilToolbar->addFormButton(
$lng->txt(
"upload"), 
"uploadFile");
 
  496                include_once 
'Services/FileSystem/classes/class.ilUploadFiles.php';
 
  499                        $ilToolbar->addSeparator();
 
  501                        $options[
""] = 
$lng->txt(
"cont_select_from_upload_dir"); 
 
  502                        foreach($files as 
$file)
 
  504                                $file = htmlspecialchars(
$file, ENT_QUOTES, 
"utf-8");
 
  507                        include_once(
"./Services/Form/classes/class.ilSelectInputGUI.php");
 
  510                        $ilToolbar->addInputItem(
$si, 
true);
 
  511                        $ilToolbar->addFormButton(
$lng->txt(
"copy"), 
"uploadFile");
 
  515                include_once(
"./Services/FileSystem/classes/class.ilFileSystemTableGUI.php");
 
  517                        $this->label_enable, $this->file_labels, $this->label_header, $this->commands,
 
  521                        $fs_table->setTitle($this->
getTitle());
 
  523                if (
$_GET[
"resetoffset"] == 1)
 
  525                        $fs_table->resetOffset();
 
  527                $this->tpl->setContent($fs_table->getHTML());
 
  537                if (!isset(
$_POST[
"file"]))
 
  539                        $this->
ilias->raiseError($this->lng->txt(
"no_checkbox"),$this->ilias->error_obj->MESSAGE);
 
  542                if (count(
$_POST[
"file"]) > 1)
 
  544                        $this->
ilias->raiseError($this->lng->txt(
"cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
 
  549                        $this->
ilias->raiseError($this->lng->txt(
"select_a_file"),$this->ilias->error_obj->MESSAGE);
 
  553                $file = (!empty($cur_subdir))
 
  559                include_once(
"Services/Form/classes/class.ilPropertyFormGUI.php");
 
  564                $ti->setMaxLength(200);
 
  570                $form->addCommandButton(
"renameFile", 
$lng->txt(
"rename"));
 
  571                $form->addCommandButton(
"cancelRename", 
$lng->txt(
"cancel"));
 
  572                $form->setFormAction(
$ilCtrl->getFormAction($this, 
"renameFile"));
 
  576                        $form->setTitle($this->lng->txt(
"cont_rename_dir"));
 
  580                        $form->setTitle($this->lng->txt(
"rename_file"));
 
  583                $this->tpl->setContent($form->getHTML());
 
  594                $new_name = str_replace(
"/", 
"", $new_name);
 
  597                        $this->
ilias->raiseError($this->lng->txt(
"enter_new_name"),$this->ilias->error_obj->MESSAGE);
 
  600                $pi = pathinfo($new_name);
 
  601                $suffix = $pi[
"extension"];
 
  605                        $this->ctrl->redirect($this, 
"listFiles");
 
  609                $dir = (!empty($cur_subdir))
 
  610                        ? $this->main_dir.
"/".$cur_subdir.
"/" 
  611                        : $this->main_dir.
"/";
 
  613                rename($dir.ilUtil::stripSlashes(
$_GET[
"old_name"]), $dir.$new_name);
 
  616                if (@is_dir($dir.$new_name))
 
  620                                "new_name" => $new_name));
 
  626                                "new_name" => $new_name));
 
  628                $this->ctrl->redirect($this, 
"listFiles");
 
  636                $this->ctrl->redirect($this, 
"listFiles");
 
  648                $cur_dir = (!empty($cur_subdir))
 
  649                        ? $this->main_dir.
"/".$cur_subdir
 
  653                $new_dir = str_replace(
"/", 
"", $new_dir);
 
  655                if (!empty($new_dir))
 
  658                        if (is_dir($cur_dir.
"/".$new_dir))
 
  668                $this->ctrl->saveParameter($this, 
"cdir");
 
  669                $this->ctrl->redirect($this, 
"listFiles");
 
  681                $cur_dir = (!empty($cur_subdir))
 
  682                        ? $this->main_dir.
"/".$cur_subdir
 
  687                $pi = pathinfo($_FILES[
"new_file"][
"name"]);
 
  688                $suffix = $pi[
"extension"];
 
  692                        $this->ctrl->redirect($this, 
"listFiles");
 
  695                if (is_file($_FILES[
"new_file"][
"tmp_name"]))
 
  699                        move_uploaded_file($_FILES[
"new_file"][
"tmp_name"], $tgt_file);
 
  702                elseif (
$_POST[
"uploaded_file"])
 
  704                        include_once 
'Services/FileSystem/classes/class.ilUploadFiles.php';
 
  715                else if (trim($_FILES[
"new_file"][
"name"]) == 
"")
 
  720                if($tgt_file && is_file($tgt_file))
 
  725                        include_once(
"./Services/Utilities/classes/class.ilMimeTypeUtil.php");                                  
 
  728                                $this->ctrl->setParameter($this, 
"upfile", basename($tgt_file));
 
  729                                $url = $this->ctrl->getLinkTarget($this, 
"unzipFile");
 
  730                                $this->ctrl->setParameter($this, 
"upfile", 
"");
 
  732                                include_once 
"Services/UIComponent/Button/classes/class.ilLinkButton.php";
 
  734                                $unzip->setCaption(
"unzip");
 
  735                                $unzip->setUrl($url);
 
  736                                $unzip = 
" ".$unzip->render();
 
  742                                array(
"name" => substr($tgt_file, strlen($this->main_dir)+1)));         
 
  745                $this->ctrl->saveParameter($this, 
"cdir");
 
  749                $this->ctrl->redirect($this, 
"listFiles");
 
  759                if (!is_array(
$_POST[
"file"]) || count(
$_POST[
"file"]) == 0)
 
  762                        $ilCtrl->redirect($this, 
"listFile");
 
  766                        include_once(
"./Services/Utilities/classes/class.ilConfirmationGUI.php");
 
  768                        $cgui->setFormAction(
$ilCtrl->getFormAction($this));
 
  769                        $cgui->setHeaderText(
$lng->txt(
"info_delete_sure"));
 
  770                        $cgui->setCancel(
$lng->txt(
"cancel"), 
"listFiles");
 
  771                        $cgui->setConfirm(
$lng->txt(
"delete"), 
"deleteFile");
 
  773                        foreach (
$_POST[
"file"] as $i)
 
  775                                $cgui->addItem(
"file[]", $i, $i);
 
  778                        $tpl->setContent($cgui->getHTML());
 
  789                if (!isset(
$_POST[
"file"]))
 
  791                        $this->
ilias->raiseError($this->lng->txt(
"no_checkbox"),$this->ilias->error_obj->MESSAGE);
 
  794                foreach (
$_POST[
"file"] as $post_file)
 
  798                                $this->
ilias->raiseError($this->lng->txt(
"no_checkbox"),$this->ilias->error_obj->MESSAGE);
 
  803                        $cur_dir = (!empty($cur_subdir))
 
  804                                ? $this->main_dir.
"/".$cur_subdir
 
  820                $this->ctrl->saveParameter($this, 
"cdir");
 
  833                $this->ctrl->redirect($this, 
"listFiles");
 
  843                if (isset(
$_GET[
"upfile"]))
 
  849                        if (!isset(
$_POST[
"file"]))
 
  851                                $this->
ilias->raiseError($this->lng->txt(
"no_checkbox"),$this->ilias->error_obj->MESSAGE);
 
  854                        if (count(
$_POST[
"file"]) > 1)
 
  856                                $this->
ilias->raiseError($this->lng->txt(
"cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
 
  863                $cur_dir = (!empty($cur_subdir))
 
  864                        ? $this->main_dir.
"/".$cur_subdir
 
  870                        include_once(
"./Services/Utilities/classes/class.ilFileUtils.php");
 
  872                        $cur_files_r = iterator_to_array(
new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($cur_dir)));
 
  884                        $new_files_r = iterator_to_array(
new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($cur_dir)));
 
  886                        $diff = array_diff($new_files, $cur_files);
 
  887                        $diff_r = array_diff($new_files_r, $cur_files_r);
 
  890                        foreach ($diff_r as $f => 
$d)
 
  893                                if (!is_dir($f) && !$this->
isValidSuffix(strtolower($pi[
"extension"])))
 
  904                                        include_once(
"./Services/Utilities/classes/class.ilFileUtils.php");
 
  905                                        $new_files = array();
 
  907                                        foreach($diff as $new_item)
 
  909                                                if(is_dir($cur_dir.
"/".$new_item))
 
  915                                        if(is_array($new_files[
"path"]))
 
  917                                                foreach($new_files[
"path"] as $idx => 
$path)
 
  919                                                        $path = substr(
$path, strlen($this->main_dir)+1);
 
  920                                                        $diff[] = 
$path.$new_files[
"file"][$idx];                                                       
 
  926                                        array(
"name" => substr(
$file, strlen($this->main_dir)+1),                                               
 
  933                $this->ctrl->saveParameter($this, 
"cdir");
 
  935                $this->ctrl->redirect($this, 
"listFiles");
 
  943                if (!isset(
$_POST[
"file"]))
 
  945                        $this->
ilias->raiseError($this->lng->txt(
"no_checkbox"),$this->ilias->error_obj->MESSAGE);
 
  948                if (count(
$_POST[
"file"]) > 1)
 
  950                        $this->
ilias->raiseError($this->lng->txt(
"cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
 
  954                $cur_dir = (!empty($cur_subdir))
 
  955                        ? $this->main_dir.
"/".$cur_subdir
 
  963                        if($entry[
"type"] == 
"file" &&
 
  964                                $cur_dir.
"/".$entry[
"entry"] == 
$file)
 
  978                        $this->ctrl->saveParameter($this, 
"cdir");
 
  979                        $this->ctrl->redirect($this, 
"listFiles");
 
  990                $ilCtrl->setParameter($this, 
"resetoffset", 1);
 
  991                $tabs_gui->addTarget(
"cont_list_files",
 
  992                        $this->ctrl->getLinkTarget($this, 
"listFiles"), 
"listFiles",
 
  994                $ilCtrl->setParameter($this, 
"resetoffset", 
"");
 
Confirmation screen class.
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.
createDirectory()
create directory
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.
unzipFile()
delete object file
setPerformedCommand($command, $pars="")
Set performed command.
addCommand(&$a_obj, $a_func, $a_name, $a_single=true, $a_allow_dir=false)
Add command.
isValidSuffix($a_suffix)
Is suffix valid?
deleteFile()
delete object file
cancelRename()
cancel renaming a file
& executeCommand()
execute command
getForbiddenSuffixes()
Get Accepted Suffixes.
& extCommand($a_nr)
call external command
setAllowFileCreation($a_val)
Set allowed file creation.
renameFile()
rename a file
setAllowedSuffixes($a_suffixes)
Set allowed Suffixes.
downloadFile()
delete object file
getLastPerformedCommand()
Get performed command.
ilFileSystemGUI($a_main_directory)
clearCommands()
Clear commands.
confirmDeleteFile()
Confirm file deletion.
setTitle($a_val)
Set title.
getTabs(&$tabs_gui)
get tabs
setTableId($a_val)
Set table id.
renameFileForm()
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.
recursive_dirscan($dir, &$arr)
Recursively scans a given directory and writes path and filename into referenced array.
static getMimeType($a_file="", $a_filename="", $a_mime="")
Get Mime type.
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 sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
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 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 deliverFile($a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
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.
redirection script todo: (a better solution should control the processing via a xml file)
if(!is_array($argv)) $options