34                $this->
ilias = $ilias;
 
   36                $this->main_dir = $a_main_directory;
 
   37                $this->post_dir_path = 
false;
 
   38                $this->commands = array(
 
   41                                "method" => 
"downloadFile",
 
   42                                "name" => 
$lng->txt(
"download"),
 
   48                                "method" => 
"confirmDeleteFile",
 
   49                                "name" => 
$lng->txt(
"delete"),
 
   55                                "method" => 
"unzipFile",
 
   56                                "name" => 
$lng->txt(
"unzip"),
 
   62                                "method" => 
"renameFileForm",
 
   63                                "name" => 
$lng->txt(
"rename"),
 
   70                $this->file_labels = array();
 
   71                $this->label_enable = 
false;
 
   72                $this->ctrl->saveParameter($this, 
"cdir");
 
   73                $lng->loadLanguageModule(
"content");
 
   87                $this->allowed_suffixes = $a_suffixes;
 
  107                $this->forbidden_suffixes = $a_suffixes;
 
  151                $this->allow_directories = $a_val;
 
  161                return $this->allow_directories;
 
  171                $this->post_dir_path = $a_val;
 
  181                return $this->post_dir_path;
 
  191                $this->table_id = $a_val;
 
  201                return $this->table_id;
 
  211                $this->title = $a_val;
 
  231                $this->use_upload_directory = $a_val;
 
  252                if (!is_array($pars))
 
  256                $_SESSION[
"fsys"][
"lastcomm"] = array_merge(
 
  257                        array(
"cmd" => $command), $pars);
 
  277                $next_class = $this->ctrl->getNextClass($this);
 
  278                $cmd = $this->ctrl->getCmd(
"listFiles");
 
  284                                if (substr(
$cmd, 0, 11) == 
"extCommand_")
 
  302        function addCommand(&$a_obj, $a_func, $a_name, $a_single = 
true,
 
  303                $a_allow_dir = 
false)
 
  305                $i = count($this->commands);
 
  307                $this->commands[$i][
"object"] = $a_obj;
 
  308                $this->commands[$i][
"method"] = $a_func;
 
  309                $this->commands[$i][
"name"] = $a_name;
 
  310                $this->commands[$i][
"single"] = $a_single;
 
  311                $this->commands[$i][
"allow_dir"] = $a_allow_dir;
 
  321                $this->commands = array();
 
  329                $this->file_labels[$a_file][] = $a_label;
 
  337                $this->label_enable = $a_act;
 
  338                $this->label_header = $a_label_header;
 
  352                if($new_subdir == 
"..")
 
  354                        $cur_subdir = substr($cur_subdir, 0, strrpos($cur_subdir, 
"/"));
 
  358                        if (!empty($new_subdir))
 
  360                                if (!empty($cur_subdir))
 
  362                                        $cur_subdir = $cur_subdir.
"/".$new_subdir;
 
  366                                        $cur_subdir = $new_subdir;
 
  371                $cur_subdir = str_replace(
"..", 
"", $cur_subdir);
 
  372                $cur_dir = (!empty($cur_subdir))
 
  373                        ? $this->main_dir.
"/".$cur_subdir
 
  376                return array(
"dir"=>$cur_dir, 
"subdir"=>$cur_subdir);
 
  383                $entries = (is_dir($a_dir))
 
  385                        : array(array(
"type" => 
"dir", 
"entry" => 
".."));
 
  388                foreach ($entries as $e)
 
  390                        if(($e[
"entry"] == 
".") || 
 
  391                                ($e[
"entry"] == 
".." && empty($a_subdir)))
 
  396                        $cfile = (!empty($a_subdir))
 
  397                                ? $a_subdir.
"/".$e[
"entry"]
 
  402                                "entry" => $e[
"entry"],
 
  403                                "type" => $e[
"type"], 
 
  404                                "size" => $e[
"size"],
 
  405                                "hash" => md5($e[
"entry"])
 
  414                $sel_files = $hashes = array();                         
 
  415                if (isset(
$_POST[
"file"]))
 
  419                else if(isset(
$_GET[
"fhsh"]))
 
  421                        $hashes = array(
$_GET[
"fhsh"]);
 
  427                        $all_files = $this->
getFileList($dir[
"dir"], $dir[
"subdir"]);
 
  428                        foreach($hashes as $hash)
 
  430                                foreach($all_files as 
$file)
 
  432                                        if(
$file[
"hash"] == $hash)
 
  453                if(!count($selected))
 
  456                        $this->ctrl->redirect($this, 
"listFiles");
 
  460                if (count($selected) > 1 && $this->commands[$a_nr][
"single"])
 
  463                        $this->ctrl->redirect($this, 
"listFiles");
 
  470                foreach ($selected as 
$file)
 
  473                        $file = (!empty($cur_subdir))
 
  474                                ? $cur_subdir.
"/".
$file 
  478                        if (@is_dir($this->main_dir.
"/".
$file) && 
 
  479                                !$this->commands[$a_nr][
"allow_dir"])
 
  482                                $this->ctrl->redirect($this, 
"listFiles");                              
 
  488                if ($this->commands[$a_nr][
"single"])
 
  493                $obj = $this->commands[$a_nr][
"object"];
 
  494                $method = $this->commands[$a_nr][
"method"];
 
  496                return $obj->$method(
$files);
 
  504                $this->directory_creation = $a_val;
 
  512                return $this->directory_creation;
 
  520                $this->file_creation = $a_val;
 
  528                return $this->file_creation;
 
  540                $this->ctrl->setParameter($this, 
"cdir", $dir[
"subdir"]);
 
  543                $ilToolbar->setFormAction(
$ilCtrl->getFormAction($this), 
true);
 
  544                include_once(
"./Services/Form/classes/class.ilTextInputGUI.php");
 
  548                        $ti = 
new ilTextInputGUI($this->lng->txt(
"cont_new_dir"), 
"new_dir");
 
  549                        $ti->setMaxLength(80);
 
  551                        $ilToolbar->addInputItem($ti, 
true);
 
  552                        $ilToolbar->addFormButton(
$lng->txt(
"create"), 
"createDirectory");
 
  554                        $ilToolbar->addSeparator();
 
  557                include_once(
"./Services/Form/classes/class.ilFileInputGUI.php");
 
  560                        $fi = 
new ilFileInputGUI($this->lng->txt(
"cont_new_file"), 
"new_file");
 
  562                        $ilToolbar->addInputItem($fi, 
true);
 
  563                        $ilToolbar->addFormButton(
$lng->txt(
"upload"), 
"uploadFile");
 
  566                include_once 
'Services/FileSystem/classes/class.ilUploadFiles.php';
 
  569                        $ilToolbar->addSeparator();
 
  571                        $options[
""] = 
$lng->txt(
"cont_select_from_upload_dir"); 
 
  574                                $file = htmlspecialchars(
$file, ENT_QUOTES, 
"utf-8");
 
  577                        include_once(
"./Services/Form/classes/class.ilSelectInputGUI.php");
 
  580                        $ilToolbar->addInputItem(
$si, 
true);
 
  581                        $ilToolbar->addFormButton(
$lng->txt(
"copy"), 
"uploadFile");
 
  585                include_once(
"./Services/FileSystem/classes/class.ilFileSystemTableGUI.php");
 
  587                        $this->label_enable, $this->file_labels, $this->label_header, $this->commands,
 
  591                        $fs_table->setTitle($this->
getTitle());
 
  593                if (
$_GET[
"resetoffset"] == 1)
 
  595                        $fs_table->resetOffset();
 
  597                $this->tpl->setContent($fs_table->getHTML());
 
  608                $file = $this->main_dir.
"/".$a_file;
 
  610                $this->ctrl->setParameter($this, 
"old_name", basename($a_file));
 
  613                include_once(
"Services/Form/classes/class.ilPropertyFormGUI.php");
 
  618                $ti->setMaxLength(200);
 
  620                $ti->setValue(basename($a_file));
 
  624                $form->addCommandButton(
"renameFile", 
$lng->txt(
"rename"));
 
  625                $form->addCommandButton(
"cancelRename", 
$lng->txt(
"cancel"));
 
  626                $form->setFormAction(
$ilCtrl->getFormAction($this, 
"renameFile"));
 
  630                        $form->setTitle($this->lng->txt(
"cont_rename_dir"));
 
  634                        $form->setTitle($this->lng->txt(
"rename_file"));
 
  637                $this->tpl->setContent($form->getHTML());
 
  648                $new_name = str_replace(
"/", 
"", $new_name);
 
  651                        $this->
ilias->raiseError($this->lng->txt(
"enter_new_name"),$this->ilias->error_obj->MESSAGE);
 
  654                $pi = pathinfo($new_name);
 
  655                $suffix = $pi[
"extension"];
 
  659                        $this->ctrl->redirect($this, 
"listFiles");
 
  663                $dir = (!empty($cur_subdir))
 
  664                        ? $this->main_dir.
"/".$cur_subdir.
"/" 
  665                        : $this->main_dir.
"/";
 
  668                if (is_dir($dir.ilUtil::stripSlashes(
$_GET[
"old_name"])))
 
  670                        rename($dir.ilUtil::stripSlashes(
$_GET[
"old_name"]), $dir.$new_name);
 
  674                        include_once(
"./Services/Utilities/classes/class.ilFileUtils.php");
 
  682                                $this->ctrl->redirect($this, 
"listFiles");
 
  687                if (@is_dir($dir.$new_name))
 
  691                                "new_name" => $new_name));
 
  697                                "new_name" => $new_name));
 
  699                $this->ctrl->redirect($this, 
"listFiles");
 
  707                $this->ctrl->redirect($this, 
"listFiles");
 
  719                $cur_dir = (!empty($cur_subdir))
 
  720                        ? $this->main_dir.
"/".$cur_subdir
 
  724                $new_dir = str_replace(
"/", 
"", $new_dir);
 
  726                if (!empty($new_dir))
 
  729                        if (is_dir($cur_dir.
"/".$new_dir))
 
  739                $this->ctrl->saveParameter($this, 
"cdir");
 
  740                $this->ctrl->redirect($this, 
"listFiles");
 
  752                $cur_dir = (!empty($cur_subdir))
 
  753                        ? $this->main_dir.
"/".$cur_subdir
 
  758                $pi = pathinfo($_FILES[
"new_file"][
"name"]);
 
  759                $suffix = $pi[
"extension"];
 
  763                        $this->ctrl->redirect($this, 
"listFiles");
 
  766                if (is_file($_FILES[
"new_file"][
"tmp_name"]))
 
  769                        $tgt_file = $cur_dir.
"/".$name;
 
  774                elseif (
$_POST[
"uploaded_file"])
 
  776                        include_once 
'Services/FileSystem/classes/class.ilUploadFiles.php';
 
  787                else if (trim($_FILES[
"new_file"][
"name"]) == 
"")
 
  792                if($tgt_file && is_file($tgt_file))
 
  797                        include_once(
"./Services/Utilities/classes/class.ilMimeTypeUtil.php");                                  
 
  800                                $this->ctrl->setParameter($this, 
"upfile", basename($tgt_file));
 
  801                                $url = $this->ctrl->getLinkTarget($this, 
"unzipFile");
 
  802                                $this->ctrl->setParameter($this, 
"upfile", 
"");
 
  804                                include_once 
"Services/UIComponent/Button/classes/class.ilLinkButton.php";
 
  806                                $unzip->setCaption(
"unzip");
 
  807                                $unzip->setUrl(
$url);
 
  808                                $unzip = 
" ".$unzip->render();
 
  814                                array(
"name" => substr($tgt_file, strlen($this->main_dir)+1)));         
 
  817                $this->ctrl->saveParameter($this, 
"cdir");
 
  821                $this->ctrl->redirect($this, 
"listFiles");
 
  831                include_once(
"./Services/Utilities/classes/class.ilConfirmationGUI.php");
 
  833                $cgui->setFormAction(
$ilCtrl->getFormAction($this));
 
  834                $cgui->setHeaderText(
$lng->txt(
"info_delete_sure"));
 
  835                $cgui->setCancel(
$lng->txt(
"cancel"), 
"listFiles");
 
  836                $cgui->setConfirm(
$lng->txt(
"delete"), 
"deleteFile");
 
  838                foreach ($a_files as $i)
 
  840                        $cgui->addItem(
"file[]", $i, $i);
 
  843                $tpl->setContent($cgui->getHTML());             
 
  853                if (!isset(
$_POST[
"file"]))
 
  855                        $this->
ilias->raiseError($this->lng->txt(
"no_checkbox"),$this->ilias->error_obj->MESSAGE);
 
  858                foreach (
$_POST[
"file"] as $post_file)
 
  862                                $this->
ilias->raiseError($this->lng->txt(
"no_checkbox"),$this->ilias->error_obj->MESSAGE);
 
  867                        $cur_dir = (!empty($cur_subdir))
 
  868                                ? $this->main_dir.
"/".$cur_subdir
 
  870                        $pi = pathinfo($post_file);
 
  885                $this->ctrl->saveParameter($this, 
"cdir");
 
  898                $this->ctrl->redirect($this, 
"listFiles");
 
  910                        isset(
$_GET[
"upfile"]))
 
  912                        $a_file = basename(
$_GET[
"upfile"]);
 
  916                $cur_dir = (!empty($cur_subdir))
 
  917                        ? $this->main_dir.
"/".$cur_subdir
 
  919                $a_file = $this->main_dir.
"/".$a_file;
 
  921                if (@is_file($a_file))
 
  923                        include_once(
"./Services/Utilities/classes/class.ilFileUtils.php");
 
  939                        $diff = array_diff($new_files, $cur_files);
 
  940                        $diff_r = array_diff($new_files_r, $cur_files_r);
 
  943                        foreach ($diff_r as $f => 
$d)
 
  946                                if (!is_dir($f) && !$this->
isValidSuffix(strtolower($pi[
"extension"])))
 
  957                                        include_once(
"./Services/Utilities/classes/class.ilFileUtils.php");
 
  958                                        $new_files = array();
 
  960                                        foreach($diff as $new_item)
 
  962                                                if(is_dir($cur_dir.
"/".$new_item))
 
  968                                        if(is_array($new_files[
"path"]))
 
  970                                                foreach($new_files[
"path"] as $idx => 
$path)
 
  972                                                        $path = substr(
$path, strlen($this->main_dir)+1);
 
  973                                                        $diff[] = 
$path.$new_files[
"file"][$idx];                                                       
 
  979                                        array(
"name" => substr(
$file, strlen($this->main_dir)+1),                                               
 
  986                $this->ctrl->saveParameter($this, 
"cdir");
 
  988                $this->ctrl->redirect($this, 
"listFiles");
 
  996                $file = $this->main_dir.
"/".$a_file;
 
 1005                        $this->ctrl->saveParameter($this, 
"cdir");
 
 1006                        $this->ctrl->redirect($this, 
"listFiles");
 
 1017                $ilCtrl->setParameter($this, 
"resetoffset", 1);
 
 1018                $tabs_gui->addTarget(
"cont_list_files",
 
 1019                        $this->ctrl->getLinkTarget($this, 
"listFiles"), 
"listFiles",
 
 1021                $ilCtrl->setParameter($this, 
"resetoffset", 
"");
 
for($col=0; $col< 50; $col++) $d
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.
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.
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
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 moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
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(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file
if(!is_array($argv)) $options