ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules Pages
ilFileSystemGUI Class Reference

File System Explorer GUI class. More...

+ Collaboration diagram for ilFileSystemGUI:

Public Member Functions

 ilFileSystemGUI ($a_main_directory)
 
 setAllowedSuffixes ($a_suffixes)
 Set allowed Suffixes. More...
 
 getAllowedSuffixes ()
 Get allowed Suffixes. More...
 
 setForbiddenSuffixes ($a_suffixes)
 Set forbidden Suffixes. More...
 
 getForbiddenSuffixes ()
 Get Accepted Suffixes. More...
 
 isValidSuffix ($a_suffix)
 Is suffix valid? More...
 
 setAllowDirectories ($a_val)
 Set allow directories. More...
 
 getAllowDirectories ()
 Get allow directories. More...
 
 setPostDirPath ($a_val)
 Set post dir path. More...
 
 getPostDirPath ()
 Get post dir path. More...
 
 setTableId ($a_val)
 Set table id. More...
 
 getTableId ()
 Get table id. More...
 
 setTitle ($a_val)
 Set title. More...
 
 getTitle ()
 Get title. More...
 
 setUseUploadDirectory ($a_val)
 Set use upload directory. More...
 
 getUseUploadDirectory ()
 Get use upload directory. More...
 
 getLastPerformedCommand ()
 Get performed command. More...
 
executeCommand ()
 execute command More...
 
 addCommand (&$a_obj, $a_func, $a_name, $a_single=true, $a_allow_dir=false)
 Add command. More...
 
 clearCommands ()
 Clear commands. More...
 
 labelFile ($a_file, $a_label)
 label a file More...
 
 activateLabels ($a_act, $a_label_header)
 activate file labels More...
 
extCommand ($a_nr)
 call external command More...
 
 setAllowDirectoryCreation ($a_val)
 Set allowed directory creation. More...
 
 getAllowDirectoryCreation ()
 Get allowed directory creation. More...
 
 setAllowFileCreation ($a_val)
 Set allowed file creation. More...
 
 getAllowFileCreation ()
 Get allowed file creation. More...
 
 listFiles ()
 list files More...
 
 renameFileForm ()
 list files More...
 
 renameFile ()
 rename a file More...
 
 cancelRename ()
 cancel renaming a file More...
 
 createDirectory ()
 create directory More...
 
 uploadFile ()
 upload file More...
 
 confirmDeleteFile ()
 Confirm file deletion. More...
 
 deleteFile ()
 delete object file More...
 
 unzipFile ()
 delete object file More...
 
 downloadFile ()
 delete object file More...
 
 getTabs (&$tabs_gui)
 get tabs More...
 

Data Fields

 $ctrl
 

Protected Member Functions

 setPerformedCommand ($command, $pars="")
 Set performed command. More...
 

Protected Attributes

 $use_upload_directory = false
 
 $allowed_suffixes = array()
 
 $forbidden_suffixes = array()
 

Detailed Description

File System Explorer GUI class.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 12 of file class.ilFileSystemGUI.php.

Member Function Documentation

◆ activateLabels()

ilFileSystemGUI::activateLabels (   $a_act,
  $a_label_header 
)

activate file labels

Definition at line 333 of file class.ilFileSystemGUI.php.

Referenced by ilObjFileBasedLMGUI\executeCommand().

334  {
335  $this->label_enable = $a_act;
336  $this->label_header = $a_label_header;
337  }
+ Here is the caller graph for this function:

◆ addCommand()

ilFileSystemGUI::addCommand ( $a_obj,
  $a_func,
  $a_name,
  $a_single = true,
  $a_allow_dir = false 
)

Add command.

Definition at line 300 of file class.ilFileSystemGUI.php.

302  {
303  $i = count($this->commands);
304 
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;
310 
311  //$this->commands[] = $arr;
312  }

◆ cancelRename()

ilFileSystemGUI::cancelRename ( )

cancel renaming a file

Definition at line 634 of file class.ilFileSystemGUI.php.

635  {
636  $this->ctrl->redirect($this, "listFiles");
637  }

◆ clearCommands()

ilFileSystemGUI::clearCommands ( )

Clear commands.

Definition at line 317 of file class.ilFileSystemGUI.php.

318  {
319  $this->commands = array();
320  }

◆ confirmDeleteFile()

ilFileSystemGUI::confirmDeleteFile ( )

Confirm file deletion.

Definition at line 755 of file class.ilFileSystemGUI.php.

References $_POST, $ilCtrl, $lng, $tpl, and ilUtil\sendFailure().

756  {
757  global $ilCtrl, $tpl, $lng;
758 
759  if (!is_array($_POST["file"]) || count($_POST["file"]) == 0)
760  {
761  ilUtil::sendFailure($lng->txt("no_checkbox"), true);
762  $ilCtrl->redirect($this, "listFile");
763  }
764  else
765  {
766  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
767  $cgui = new ilConfirmationGUI();
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");
772 
773  foreach ($_POST["file"] as $i)
774  {
775  $cgui->addItem("file[]", $i, $i);
776  }
777 
778  $tpl->setContent($cgui->getHTML());
779  }
780  }
$_POST['username']
Definition: cron.php:12
global $tpl
Definition: ilias.php:8
global $ilCtrl
Definition: ilias.php:18
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $lng
Definition: privfeed.php:40
Confirmation screen class.
+ Here is the call graph for this function:

◆ createDirectory()

ilFileSystemGUI::createDirectory ( )

create directory

Definition at line 642 of file class.ilFileSystemGUI.php.

References $_GET, $_POST, $lng, ilUtil\makeDir(), ilUtil\sendFailure(), ilUtil\sendSuccess(), setPerformedCommand(), and ilUtil\stripSlashes().

643  {
644  global $lng;
645 
646  // determine directory
647  $cur_subdir = str_replace(".", "", ilUtil::stripSlashes($_GET["cdir"]));
648  $cur_dir = (!empty($cur_subdir))
649  ? $this->main_dir."/".$cur_subdir
650  : $this->main_dir;
651 
652  $new_dir = str_replace(".", "", ilUtil::stripSlashes($_POST["new_dir"]));
653  $new_dir = str_replace("/", "", $new_dir);
654 
655  if (!empty($new_dir))
656  {
657  ilUtil::makeDir($cur_dir."/".$new_dir);
658  if (is_dir($cur_dir."/".$new_dir))
659  {
660  ilUtil::sendSuccess($lng->txt("cont_dir_created"), true);
661  $this->setPerformedCommand("create_dir", array("name" => $new_dir));
662  }
663  }
664  else
665  {
666  ilUtil::sendFailure($lng->txt("cont_enter_a_dir_name"), true);
667  }
668  $this->ctrl->saveParameter($this, "cdir");
669  $this->ctrl->redirect($this, "listFiles");
670  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
$_POST['username']
Definition: cron.php:12
$_GET["client_id"]
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
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 ...
global $lng
Definition: privfeed.php:40
setPerformedCommand($command, $pars="")
Set performed command.
+ Here is the call graph for this function:

◆ deleteFile()

ilFileSystemGUI::deleteFile ( )

delete object file

Definition at line 785 of file class.ilFileSystemGUI.php.

References $_GET, $_POST, $file, $lng, ilUtil\delDir(), ilUtil\sendSuccess(), setPerformedCommand(), and ilUtil\stripSlashes().

786  {
787  global $lng;
788 
789  if (!isset($_POST["file"]))
790  {
791  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
792  }
793 
794  foreach ($_POST["file"] as $post_file)
795  {
796  if (ilUtil::stripSlashes($post_file) == "..")
797  {
798  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
799  break;
800  }
801 
802  $cur_subdir = str_replace(".", "", ilUtil::stripSlashes($_GET["cdir"]));
803  $cur_dir = (!empty($cur_subdir))
804  ? $this->main_dir."/".$cur_subdir
805  : $this->main_dir;
806  $file = $cur_dir."/".ilUtil::stripSlashes($post_file);
807 
808  if (@is_file($file))
809  {
810  unlink($file);
811  }
812 
813  if (@is_dir($file))
814  {
815  $is_dir = true;
817  }
818  }
819 
820  $this->ctrl->saveParameter($this, "cdir");
821  if ($is_dir)
822  {
823  ilUtil::sendSuccess($lng->txt("cont_dir_deleted"), true);
824  $this->setPerformedCommand("delete_dir",
825  array("name" => ilUtil::stripSlashes($post_file)));
826  }
827  else
828  {
829  ilUtil::sendSuccess($lng->txt("cont_file_deleted"), true);
830  $this->setPerformedCommand("delete_file",
831  array("name" => ilUtil::stripSlashes($post_file)));
832  }
833  $this->ctrl->redirect($this, "listFiles");
834  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
print $file
$_POST['username']
Definition: cron.php:12
$_GET["client_id"]
redirection script todo: (a better solution should control the processing via a xml file) ...
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
global $lng
Definition: privfeed.php:40
setPerformedCommand($command, $pars="")
Set performed command.
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
+ Here is the call graph for this function:

◆ downloadFile()

ilFileSystemGUI::downloadFile ( )

delete object file

Definition at line 941 of file class.ilFileSystemGUI.php.

References $_GET, $_POST, $file, $valid, ilUtil\deliverFile(), exit, ilUtil\getDir(), and ilUtil\stripSlashes().

942  {
943  if (!isset($_POST["file"]))
944  {
945  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
946  }
947 
948  if (count($_POST["file"]) > 1)
949  {
950  $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
951  }
952 
953  $cur_subdir = str_replace(".", "", ilUtil::stripSlashes($_GET["cdir"]));
954  $cur_dir = (!empty($cur_subdir))
955  ? $this->main_dir."/".$cur_subdir
956  : $this->main_dir;
957  $file = $cur_dir."/".$_POST["file"][0];
958 
959  // validate against files of current directory
960  $valid = false;
961  foreach(ilUtil::getDir($cur_dir) as $entry)
962  {
963  if($entry["type"] == "file" &&
964  $cur_dir."/".$entry["entry"] == $file)
965  {
966  $valid = true;
967  break;
968  }
969  }
970 
971  if (@is_file($file) && !(@is_dir($file)) && $valid)
972  {
973  ilUtil::deliverFile($file, $_POST["file"][0]);
974  exit;
975  }
976  else
977  {
978  $this->ctrl->saveParameter($this, "cdir");
979  $this->ctrl->redirect($this, "listFiles");
980  }
981  }
print $file
exit
Definition: login.php:54
$_POST['username']
Definition: cron.php:12
$_GET["client_id"]
$valid
static getDir($a_dir, $a_rec=false, $a_sub_dir="")
get directory
redirection script todo: (a better solution should control the processing via a xml 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.
+ Here is the call graph for this function:

◆ executeCommand()

& ilFileSystemGUI::executeCommand ( )

execute command

Definition at line 273 of file class.ilFileSystemGUI.php.

References $cmd, $ret, and extCommand().

274  {
275  $next_class = $this->ctrl->getNextClass($this);
276  $cmd = $this->ctrl->getCmd("listFiles");
277 
278  switch($next_class)
279  {
280 
281  default:
282  if (substr($cmd, 0, 11) == "extCommand_")
283  {
284  $ret =& $this->extCommand(substr($cmd, 11, strlen($cmd) - 11));
285  }
286  else
287  {
288  $ret =& $this->$cmd();
289  }
290  break;
291  }
292 
293  return $ret;
294  }
$cmd
Definition: sahs_server.php:35
& extCommand($a_nr)
call external command
+ Here is the call graph for this function:

◆ extCommand()

& ilFileSystemGUI::extCommand (   $a_nr)

call external command

Definition at line 342 of file class.ilFileSystemGUI.php.

References $_GET, $_POST, $file, and ilUtil\stripSlashes().

Referenced by executeCommand().

343  {
344  if (isset($_POST["file"]))
345  {
346  // remove ".." items
347  foreach ($_POST["file"] as $k => $v)
348  {
349  if ($_POST["file"][$k] == "..")
350  {
351  unset($_POST["file"][$k]);
352  }
353  }
354  }
355  // check if at least one item is select
356  else
357  {
358  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
359  }
360 
361  // check if only one item is select, if command does not allow multiple selection
362  if (count($_POST["file"]) > 1 && $this->commands[$a_nr]["single"])
363  {
364  $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
365  }
366 
367  $cur_subdir = str_replace(".", "", ilUtil::stripSlashes($_GET["cdir"]));
368 
369  // collect files and
370  $files = array();
371  foreach ($_POST["file"] as $k => $v)
372  {
373  $file = (!empty($cur_subdir))
374  ? $this->main_dir."/".$cur_subdir."/".ilUtil::stripSlashes($_POST["file"][$k])
375  : $this->main_dir."/".ilUtil::stripSlashes($_POST["file"][$k]);
376 
377  // check wether selected item is a directory
378  if (@is_dir($file) && !$this->commands[$a_nr]["allow_dir"])
379  {
380  $this->ilias->raiseError($this->lng->txt("select_a_file"),$this->ilias->error_obj->MESSAGE);
381  }
382  $file = (!empty($cur_subdir))
383  ? $cur_subdir."/".ilUtil::stripSlashes($_POST["file"][$k])
384  : ilUtil::stripSlashes($_POST["file"][$k]);
385  $files[] = $file;
386  }
387 
388  if ($this->commands[$a_nr]["single"])
389  {
390  $files = $files[0];
391  }
392 
393  $obj =& $this->commands[$a_nr]["object"];
394  $method = $this->commands[$a_nr]["method"];
395 
396  return $obj->$method($files);
397  }
print $file
$_POST['username']
Definition: cron.php:12
$_GET["client_id"]
redirection script todo: (a better solution should control the processing via a xml file) ...
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAllowDirectories()

ilFileSystemGUI::getAllowDirectories ( )

Get allow directories.

Returns
boolean allow directories

Definition at line 157 of file class.ilFileSystemGUI.php.

Referenced by listFiles(), and unzipFile().

158  {
159  return $this->allow_directories;
160  }
+ Here is the caller graph for this function:

◆ getAllowDirectoryCreation()

ilFileSystemGUI::getAllowDirectoryCreation ( )

Get allowed directory creation.

Definition at line 410 of file class.ilFileSystemGUI.php.

Referenced by listFiles().

411  {
412  return $this->directory_creation;
413  }
+ Here is the caller graph for this function:

◆ getAllowedSuffixes()

ilFileSystemGUI::getAllowedSuffixes ( )

Get allowed Suffixes.

Returns
array allowed Suffixes

Definition at line 93 of file class.ilFileSystemGUI.php.

References $allowed_suffixes.

Referenced by isValidSuffix().

94  {
96  }
+ Here is the caller graph for this function:

◆ getAllowFileCreation()

ilFileSystemGUI::getAllowFileCreation ( )

Get allowed file creation.

Definition at line 426 of file class.ilFileSystemGUI.php.

Referenced by listFiles().

427  {
428  return $this->file_creation;
429  }
+ Here is the caller graph for this function:

◆ getForbiddenSuffixes()

ilFileSystemGUI::getForbiddenSuffixes ( )

Get Accepted Suffixes.

Returns
array forbidden Suffixes

Definition at line 113 of file class.ilFileSystemGUI.php.

References $forbidden_suffixes.

Referenced by isValidSuffix().

114  {
116  }
+ Here is the caller graph for this function:

◆ getLastPerformedCommand()

ilFileSystemGUI::getLastPerformedCommand ( )

Get performed command.

Returns
array command array

Definition at line 263 of file class.ilFileSystemGUI.php.

References $_SESSION, and $ret.

264  {
265  $ret = $_SESSION["fsys"]["lastcomm"];
266  $_SESSION["fsys"]["lastcomm"] = "none";
267  return $ret;
268  }
< a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false">< img src="./images/refresh.png" alt="Reload Image" height="32" width="32" onclick="this.blur()" align="bottom" border="0"/></a >< br/>< strong > Enter Code *if($_SERVER['REQUEST_METHOD']=='POST' &&@ $_POST['do']=='contact') $_SESSION['ctform']['success']

◆ getPostDirPath()

ilFileSystemGUI::getPostDirPath ( )

Get post dir path.

Returns
boolean post dir path

Definition at line 177 of file class.ilFileSystemGUI.php.

Referenced by listFiles().

178  {
179  return $this->post_dir_path;
180  }
+ Here is the caller graph for this function:

◆ getTableId()

ilFileSystemGUI::getTableId ( )

Get table id.

Returns
string table id

Definition at line 197 of file class.ilFileSystemGUI.php.

Referenced by listFiles().

198  {
199  return $this->table_id;
200  }
+ Here is the caller graph for this function:

◆ getTabs()

ilFileSystemGUI::getTabs ( $tabs_gui)

get tabs

Definition at line 986 of file class.ilFileSystemGUI.php.

References $ilCtrl.

987  {
988  global $ilCtrl;
989 
990  $ilCtrl->setParameter($this, "resetoffset", 1);
991  $tabs_gui->addTarget("cont_list_files",
992  $this->ctrl->getLinkTarget($this, "listFiles"), "listFiles",
993  get_class($this));
994  $ilCtrl->setParameter($this, "resetoffset", "");
995  }
global $ilCtrl
Definition: ilias.php:18

◆ getTitle()

ilFileSystemGUI::getTitle ( )

Get title.

Returns
string title

Definition at line 217 of file class.ilFileSystemGUI.php.

Referenced by listFiles().

218  {
219  return $this->title;
220  }
+ Here is the caller graph for this function:

◆ getUseUploadDirectory()

ilFileSystemGUI::getUseUploadDirectory ( )

Get use upload directory.

Returns
bool use upload directory

Definition at line 237 of file class.ilFileSystemGUI.php.

References $use_upload_directory.

Referenced by listFiles().

238  {
240  }
+ Here is the caller graph for this function:

◆ ilFileSystemGUI()

ilFileSystemGUI::ilFileSystemGUI (   $a_main_directory)

Definition at line 29 of file class.ilFileSystemGUI.php.

References $ilCtrl, $lng, $tpl, setAllowDirectories(), setAllowDirectoryCreation(), and setAllowFileCreation().

30  {
31  global $lng, $ilCtrl, $tpl, $ilias;
32 
33  $this->ctrl =& $ilCtrl;
34  $this->lng =& $lng;
35  $this->ilias =& $ilias;
36  $this->tpl =& $tpl;
37  $this->main_dir = $a_main_directory;
38  $this->post_dir_path = false;
39  $this->commands = array(
40  0 => array(
41  "object" => $this,
42  "method" => "downloadFile",
43  "name" => $lng->txt("download"),
44  "int" => true
45  ),
46  1 => array(
47  "object" => $this,
48  "method" => "confirmDeleteFile",
49  "name" => $lng->txt("delete"),
50  "allow_dir" => true,
51  "int" => true
52  ),
53  2 => array(
54  "object" => $this,
55  "method" => "unzipFile",
56  "name" => $lng->txt("unzip"),
57  "int" => true
58  ),
59  3 => array(
60  "object" => $this,
61  "method" => "renameFileForm",
62  "name" => $lng->txt("rename"),
63  "allow_dir" => true,
64  "int" => true
65  ),
66  );
67 
68  $this->file_labels = array();
69  $this->label_enable = false;
70  $this->ctrl->saveParameter($this, "cdir");
71  $lng->loadLanguageModule("content");
72  $this->setAllowDirectories(true);
73  $this->setAllowDirectoryCreation(true);
74  $this->setAllowFileCreation(true);
75 //echo "<br>main_dir:".$this->main_dir.":";
76  }
setAllowDirectories($a_val)
Set allow directories.
global $tpl
Definition: ilias.php:8
global $ilCtrl
Definition: ilias.php:18
redirection script todo: (a better solution should control the processing via a xml file) ...
setAllowDirectoryCreation($a_val)
Set allowed directory creation.
setAllowFileCreation($a_val)
Set allowed file creation.
global $lng
Definition: privfeed.php:40
+ Here is the call graph for this function:

◆ isValidSuffix()

ilFileSystemGUI::isValidSuffix (   $a_suffix)

Is suffix valid?

Parameters
string$a_suffix
Returns
bool

Definition at line 124 of file class.ilFileSystemGUI.php.

References getAllowedSuffixes(), and getForbiddenSuffixes().

Referenced by renameFile(), unzipFile(), and uploadFile().

125  {
126  if (is_array($this->getForbiddenSuffixes()) && in_array($a_suffix, $this->getForbiddenSuffixes()))
127  {
128  return false;
129  }
130  if (is_array($this->getAllowedSuffixes()) && in_array($a_suffix, $this->getAllowedSuffixes()))
131  {
132  return true;
133  }
134  if (!is_array($this->getAllowedSuffixes()) || count($this->getAllowedSuffixes()) == 0)
135  {
136  return true;
137  }
138  return false;
139  }
getForbiddenSuffixes()
Get Accepted Suffixes.
getAllowedSuffixes()
Get allowed Suffixes.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ labelFile()

ilFileSystemGUI::labelFile (   $a_file,
  $a_label 
)

label a file

Definition at line 325 of file class.ilFileSystemGUI.php.

326  {
327  $this->file_labels[$a_file][] = $a_label;
328  }

◆ listFiles()

ilFileSystemGUI::listFiles ( )

list files

Definition at line 434 of file class.ilFileSystemGUI.php.

References $_GET, $file, $ilCtrl, $lng, $options, $si, ilUploadFiles\_getUploadDirectory(), ilUploadFiles\_getUploadFiles(), getAllowDirectories(), getAllowDirectoryCreation(), getAllowFileCreation(), getPostDirPath(), getTableId(), getTitle(), getUseUploadDirectory(), ilTextInputGUI\setMaxLength(), ilFileInputGUI\setSize(), and ilUtil\stripSlashes().

435  {
436  global $ilToolbar, $lng, $ilCtrl;
437 
438 
439  // determine directory
440  // FIXME: I have to call stripSlashes here twice, because I could not
441  // determine where the second layer of slashes is added to the
442  // URL Parameter
443  $cur_subdir = ilUtil::stripSlashes(ilUtil::stripSlashes($_GET["cdir"]));
444  $new_subdir = ilUtil::stripSlashes(ilUtil::stripSlashes($_GET["newdir"]));
445 
446  if($new_subdir == "..")
447  {
448  $cur_subdir = substr($cur_subdir, 0, strrpos($cur_subdir, "/"));
449  }
450  else
451  {
452  if (!empty($new_subdir))
453  {
454  if (!empty($cur_subdir))
455  {
456  $cur_subdir = $cur_subdir."/".$new_subdir;
457  }
458  else
459  {
460  $cur_subdir = $new_subdir;
461  }
462  }
463  }
464 
465  $cur_subdir = str_replace("..", "", $cur_subdir);
466  $cur_dir = (!empty($cur_subdir))
467  ? $this->main_dir."/".$cur_subdir
468  : $this->main_dir;
469 
470  $this->ctrl->setParameter($this, "cdir", $cur_subdir);
471 
472  // toolbar for adding files/directories
473  $ilToolbar->setFormAction($ilCtrl->getFormAction($this), true);
474  include_once("./Services/Form/classes/class.ilTextInputGUI.php");
475 
476  if ($this->getAllowDirectories() && $this->getAllowDirectoryCreation())
477  {
478  $ti = new ilTextInputGUI($this->lng->txt("cont_new_dir"), "new_dir");
479  $ti->setMaxLength(80);
480  $ti->setSize(10);
481  $ilToolbar->addInputItem($ti, true);
482  $ilToolbar->addFormButton($lng->txt("create"), "createDirectory");
483 
484  $ilToolbar->addSeparator();
485  }
486 
487  include_once("./Services/Form/classes/class.ilFileInputGUI.php");
488  if ($this->getAllowFileCreation())
489  {
490  $fi = new ilFileInputGUI($this->lng->txt("cont_new_file"), "new_file");
491  $fi->setSize(10);
492  $ilToolbar->addInputItem($fi, true);
493  $ilToolbar->addFormButton($lng->txt("upload"), "uploadFile");
494  }
495 
496  include_once 'Services/FileSystem/classes/class.ilUploadFiles.php';
498  {
499  $ilToolbar->addSeparator();
501  $options[""] = $lng->txt("cont_select_from_upload_dir");
502  foreach($files as $file)
503  {
504  $file = htmlspecialchars($file, ENT_QUOTES, "utf-8");
505  $options[$file] = $file;
506  }
507  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
508  $si = new ilSelectInputGUI($this->lng->txt("cont_uploaded_file"), "uploaded_file");
509  $si->setOptions($options);
510  $ilToolbar->addInputItem($si, true);
511  $ilToolbar->addFormButton($lng->txt("copy"), "uploadFile");
512  }
513 
514  // load files templates
515  include_once("./Services/FileSystem/classes/class.ilFileSystemTableGUI.php");
516  $fs_table = new ilFileSystemTableGUI($this, "listFiles", $cur_dir, $cur_subdir,
517  $this->label_enable, $this->file_labels, $this->label_header, $this->commands,
518  $this->getPostDirPath(), $this->getTableId());
519  if ($this->getTitle() != "")
520  {
521  $fs_table->setTitle($this->getTitle());
522  }
523  if ($_GET["resetoffset"] == 1)
524  {
525  $fs_table->resetOffset();
526  }
527  $this->tpl->setContent($fs_table->getHTML());
528  }
print $file
This class represents a selection list property in a property form.
getTableId()
Get table id.
$_GET["client_id"]
This class represents a file property in a property form.
getAllowDirectoryCreation()
Get allowed directory creation.
static _getUploadDirectory()
Get the directory with uploaded files.
static _getUploadFiles()
Get a list of readable files in the upload directory.
setSize($a_size)
Set Size.
global $ilCtrl
Definition: ilias.php:18
if(!is_array($argv)) $options
getUseUploadDirectory()
Get use upload directory.
This class represents a text property in a property form.
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
getPostDirPath()
Get post dir path.
global $lng
Definition: privfeed.php:40
getAllowFileCreation()
Get allowed file creation.
TableGUI class for file system.
+ Here is the call graph for this function:

◆ renameFile()

ilFileSystemGUI::renameFile ( )

rename a file

Definition at line 589 of file class.ilFileSystemGUI.php.

References $_GET, $_POST, $lng, isValidSuffix(), ilUtil\renameExecutables(), ilUtil\sendFailure(), ilUtil\sendSuccess(), setPerformedCommand(), and ilUtil\stripSlashes().

590  {
591  global $lng;
592 
593  $new_name = str_replace("..", "", ilUtil::stripSlashes($_POST["new_name"]));
594  $new_name = str_replace("/", "", $new_name);
595  if ($new_name == "")
596  {
597  $this->ilias->raiseError($this->lng->txt("enter_new_name"),$this->ilias->error_obj->MESSAGE);
598  }
599 
600  $pi = pathinfo($new_name);
601  $suffix = $pi["extension"];
602  if ($suffix != "" && !$this->isValidSuffix($suffix))
603  {
604  ilUtil::sendFailure($this->lng->txt("file_no_valid_file_type")." ($suffix)", true);
605  $this->ctrl->redirect($this, "listFiles");
606  }
607 
608  $cur_subdir = str_replace(".", "", ilUtil::stripSlashes($_GET["cdir"]));
609  $dir = (!empty($cur_subdir))
610  ? $this->main_dir."/".$cur_subdir."/"
611  : $this->main_dir."/";
612 
613  rename($dir.ilUtil::stripSlashes($_GET["old_name"]), $dir.$new_name);
614 
615  ilUtil::renameExecutables($this->main_dir);
616  if (@is_dir($dir.$new_name))
617  {
618  ilUtil::sendSuccess($lng->txt("cont_dir_renamed"), true);
619  $this->setPerformedCommand("rename_dir", array("old_name" => $_GET["old_name"],
620  "new_name" => $new_name));
621  }
622  else
623  {
624  ilUtil::sendSuccess($lng->txt("cont_file_renamed"), true);
625  $this->setPerformedCommand("rename_file", array("old_name" => $_GET["old_name"],
626  "new_name" => $new_name));
627  }
628  $this->ctrl->redirect($this, "listFiles");
629  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
$_POST['username']
Definition: cron.php:12
$_GET["client_id"]
redirection script todo: (a better solution should control the processing via a xml file) ...
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
isValidSuffix($a_suffix)
Is suffix valid?
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static renameExecutables($a_dir)
Rename uploaded executables for security reasons.
global $lng
Definition: privfeed.php:40
setPerformedCommand($command, $pars="")
Set performed command.
+ Here is the call graph for this function:

◆ renameFileForm()

ilFileSystemGUI::renameFileForm ( )

list files

Definition at line 533 of file class.ilFileSystemGUI.php.

References $_GET, $_POST, $file, $ilCtrl, $lng, ilTextInputGUI\setMaxLength(), and ilUtil\stripSlashes().

534  {
535  global $lng, $ilCtrl;
536 
537  if (!isset($_POST["file"]))
538  {
539  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
540  }
541 
542  if (count($_POST["file"]) > 1)
543  {
544  $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
545  }
546 
547  if (ilUtil::stripSlashes($_POST["file"][0]) == ".." )
548  {
549  $this->ilias->raiseError($this->lng->txt("select_a_file"),$this->ilias->error_obj->MESSAGE);
550  }
551 
552  $cur_subdir = str_replace(".", "", ilUtil::stripSlashes($_GET["cdir"]));
553  $file = (!empty($cur_subdir))
554  ? $this->main_dir."/".$cur_subdir."/".ilUtil::stripSlashes($_POST["file"][0])
555  : $this->main_dir."/".ilUtil::stripSlashes($_POST["file"][0]);
556 
557  $this->ctrl->setParameter($this, "old_name", ilUtil::stripSlashes($_POST["file"][0]));
558 
559  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
560  $form = new ilPropertyFormGUI();
561 
562  // file/dir name
563  $ti = new ilTextInputGUI($this->lng->txt("name"), "new_name");
564  $ti->setMaxLength(200);
565  $ti->setSize(40);
566  $ti->setValue(ilUtil::stripSlashes($_POST["file"][0]));
567  $form->addItem($ti);
568 
569  // save and cancel commands
570  $form->addCommandButton("renameFile", $lng->txt("rename"));
571  $form->addCommandButton("cancelRename", $lng->txt("cancel"));
572  $form->setFormAction($ilCtrl->getFormAction($this, "renameFile"));
573 
574  if (@is_dir($file))
575  {
576  $form->setTitle($this->lng->txt("cont_rename_dir"));
577  }
578  else
579  {
580  $form->setTitle($this->lng->txt("rename_file"));
581  }
582 
583  $this->tpl->setContent($form->getHTML());
584  }
print $file
$_POST['username']
Definition: cron.php:12
This class represents a property form user interface.
$_GET["client_id"]
global $ilCtrl
Definition: ilias.php:18
This class represents a text property in a property form.
redirection script todo: (a better solution should control the processing via a xml file) ...
setMaxLength($a_maxlength)
Set Max Length.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
global $lng
Definition: privfeed.php:40
+ Here is the call graph for this function:

◆ setAllowDirectories()

ilFileSystemGUI::setAllowDirectories (   $a_val)

Set allow directories.

Parameters
booleanallow directories

Definition at line 147 of file class.ilFileSystemGUI.php.

Referenced by ilFileSystemGUI().

148  {
149  $this->allow_directories = $a_val;
150  }
+ Here is the caller graph for this function:

◆ setAllowDirectoryCreation()

ilFileSystemGUI::setAllowDirectoryCreation (   $a_val)

Set allowed directory creation.

Definition at line 402 of file class.ilFileSystemGUI.php.

Referenced by ilFileSystemGUI().

403  {
404  $this->directory_creation = $a_val;
405  }
+ Here is the caller graph for this function:

◆ setAllowedSuffixes()

ilFileSystemGUI::setAllowedSuffixes (   $a_suffixes)

Set allowed Suffixes.

Parameters
array$a_suffixesallowed Suffixes

Definition at line 83 of file class.ilFileSystemGUI.php.

Referenced by ilObjMediaObjectGUI\executeCommand().

84  {
85  $this->allowed_suffixes = $a_suffixes;
86  }
+ Here is the caller graph for this function:

◆ setAllowFileCreation()

ilFileSystemGUI::setAllowFileCreation (   $a_val)

Set allowed file creation.

Definition at line 418 of file class.ilFileSystemGUI.php.

Referenced by ilFileSystemGUI().

419  {
420  $this->file_creation = $a_val;
421  }
+ Here is the caller graph for this function:

◆ setForbiddenSuffixes()

ilFileSystemGUI::setForbiddenSuffixes (   $a_suffixes)

Set forbidden Suffixes.

Parameters
array$a_suffixesforbidden Suffixes

Definition at line 103 of file class.ilFileSystemGUI.php.

104  {
105  $this->forbidden_suffixes = $a_suffixes;
106  }

◆ setPerformedCommand()

ilFileSystemGUI::setPerformedCommand (   $command,
  $pars = "" 
)
protected

Set performed command.

Parameters
stringcommand
arrayparameter array

Definition at line 248 of file class.ilFileSystemGUI.php.

References $_SESSION.

Referenced by createDirectory(), deleteFile(), renameFile(), unzipFile(), and uploadFile().

249  {
250  if (!is_array($pars))
251  {
252  $pars = array();
253  }
254  $_SESSION["fsys"]["lastcomm"] = array_merge(
255  array("cmd" => $command), $pars);
256  }
< a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false">< img src="./images/refresh.png" alt="Reload Image" height="32" width="32" onclick="this.blur()" align="bottom" border="0"/></a >< br/>< strong > Enter Code *if($_SERVER['REQUEST_METHOD']=='POST' &&@ $_POST['do']=='contact') $_SESSION['ctform']['success']
+ Here is the caller graph for this function:

◆ setPostDirPath()

ilFileSystemGUI::setPostDirPath (   $a_val)

Set post dir path.

Parameters
booleanpost dir path

Definition at line 167 of file class.ilFileSystemGUI.php.

Referenced by ilObjMediaPoolGUI\executeCommand().

168  {
169  $this->post_dir_path = $a_val;
170  }
+ Here is the caller graph for this function:

◆ setTableId()

ilFileSystemGUI::setTableId (   $a_val)

Set table id.

Parameters
stringtable id

Definition at line 187 of file class.ilFileSystemGUI.php.

Referenced by ilObjExerciseGUI\executeCommand().

188  {
189  $this->table_id = $a_val;
190  }
+ Here is the caller graph for this function:

◆ setTitle()

ilFileSystemGUI::setTitle (   $a_val)

Set title.

Parameters
stringtitle

Definition at line 207 of file class.ilFileSystemGUI.php.

Referenced by ilObjExerciseGUI\executeCommand().

208  {
209  $this->title = $a_val;
210  }
+ Here is the caller graph for this function:

◆ setUseUploadDirectory()

ilFileSystemGUI::setUseUploadDirectory (   $a_val)

Set use upload directory.

Parameters
bool$a_valuse upload directory

Definition at line 227 of file class.ilFileSystemGUI.php.

Referenced by ilObjSAHSLearningModuleGUI\executeCommand().

228  {
229  $this->use_upload_directory = $a_val;
230  }
+ Here is the caller graph for this function:

◆ unzipFile()

ilFileSystemGUI::unzipFile ( )

delete object file

Definition at line 839 of file class.ilFileSystemGUI.php.

References $_GET, $_POST, $d, $file, $lng, $path, getAllowDirectories(), ilUtil\getDir(), isValidSuffix(), ilFileUtils\recursive_dirscan(), ilUtil\renameExecutables(), ilUtil\sendFailure(), ilUtil\sendSuccess(), setPerformedCommand(), ilUtil\stripSlashes(), and ilUtil\unzip().

840  {
841  global $lng;
842 
843  if (isset($_GET["upfile"]))
844  {
845  $file = basename($_GET["upfile"]);
846  }
847  else
848  {
849  if (!isset($_POST["file"]))
850  {
851  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
852  }
853 
854  if (count($_POST["file"]) > 1)
855  {
856  $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
857  }
858 
859  $file = basename($_POST["file"][0]);
860  }
861 
862  $cur_subdir = str_replace(".", "", ilUtil::stripSlashes($_GET["cdir"]));
863  $cur_dir = (!empty($cur_subdir))
864  ? $this->main_dir."/".$cur_subdir
865  : $this->main_dir;
866  $file = $cur_dir."/".ilUtil::stripSlashes($file);
867 
868  if (@is_file($file))
869  {
870  include_once("./Services/Utilities/classes/class.ilFileUtils.php");
871  $cur_files = array_keys(ilUtil::getDir($cur_dir));
872  $cur_files_r = iterator_to_array(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($cur_dir)));
873 
874  if ($this->getAllowDirectories())
875  {
876  ilUtil::unzip($file, true);
877  }
878  else
879  {
880  ilUtil::unzip($file, true, true);
881  }
882 
883  $new_files = array_keys(ilUtil::getDir($cur_dir));
884  $new_files_r = iterator_to_array(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($cur_dir)));
885 
886  $diff = array_diff($new_files, $cur_files);
887  $diff_r = array_diff($new_files_r, $cur_files_r);
888 
889  // unlink forbidden file types
890  foreach ($diff_r as $f => $d)
891  {
892  $pi = pathinfo($f);
893  if (!is_dir($f) && !$this->isValidSuffix(strtolower($pi["extension"])))
894  {
895  ilUtil::sendFailure($lng->txt("file_some_invalid_file_types_removed")." (".$pi["extension"].")", true);
896  unlink($f);
897  }
898  }
899 
900  if(sizeof($diff))
901  {
902  if ($this->getAllowDirectories())
903  {
904  include_once("./Services/Utilities/classes/class.ilFileUtils.php");
905  $new_files = array();
906 
907  foreach($diff as $new_item)
908  {
909  if(is_dir($cur_dir."/".$new_item))
910  {
911  ilFileUtils::recursive_dirscan($cur_dir."/".$new_item, $new_files);
912  }
913  }
914 
915  if(is_array($new_files["path"]))
916  {
917  foreach($new_files["path"] as $idx => $path)
918  {
919  $path = substr($path, strlen($this->main_dir)+1);
920  $diff[] = $path.$new_files["file"][$idx];
921  }
922  }
923  }
924 
925  $this->setPerformedCommand("unzip_file",
926  array("name" => substr($file, strlen($this->main_dir)+1),
927  "added" => $diff));
928  }
929  }
930 
931  ilUtil::renameExecutables($this->main_dir);
932 
933  $this->ctrl->saveParameter($this, "cdir");
934  ilUtil::sendSuccess($lng->txt("cont_file_unzipped"), true);
935  $this->ctrl->redirect($this, "listFiles");
936  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
print $file
$_POST['username']
Definition: cron.php:12
$_GET["client_id"]
static unzip($a_file, $overwrite=false, $a_flat=false)
unzip file
static getDir($a_dir, $a_rec=false, $a_sub_dir="")
get directory
redirection script todo: (a better solution should control the processing via a xml file) ...
getAllowDirectories()
Get allow directories.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
isValidSuffix($a_suffix)
Is suffix valid?
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
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.
global $lng
Definition: privfeed.php:40
$path
Definition: index.php:22
setPerformedCommand($command, $pars="")
Set performed command.
+ Here is the call graph for this function:

◆ uploadFile()

ilFileSystemGUI::uploadFile ( )

upload file

Definition at line 675 of file class.ilFileSystemGUI.php.

References $_GET, $_POST, $lng, ilUploadFiles\_checkUploadFile(), ilUploadFiles\_copyUploadFile(), ilLinkButton\getInstance(), ilMimeTypeUtil\getMimeType(), isValidSuffix(), ilUtil\renameExecutables(), ilUtil\sendFailure(), ilUtil\sendSuccess(), setPerformedCommand(), and ilUtil\stripSlashes().

676  {
677  global $lng;
678 
679  // determine directory
680  $cur_subdir = str_replace(".", "", ilUtil::stripSlashes($_GET["cdir"]));
681  $cur_dir = (!empty($cur_subdir))
682  ? $this->main_dir."/".$cur_subdir
683  : $this->main_dir;
684 
685  $tgt_file = null;
686 
687  $pi = pathinfo($_FILES["new_file"]["name"]);
688  $suffix = $pi["extension"];
689  if (!$this->isValidSuffix($suffix))
690  {
691  ilUtil::sendFailure($this->lng->txt("file_no_valid_file_type")." ($suffix)", true);
692  $this->ctrl->redirect($this, "listFiles");
693  }
694 
695  if (is_file($_FILES["new_file"]["tmp_name"]))
696  {
697  $tgt_file = $cur_dir."/".ilUtil::stripSlashes($_FILES["new_file"]["name"]);
698 
699  move_uploaded_file($_FILES["new_file"]["tmp_name"], $tgt_file);
700 
701  }
702  elseif ($_POST["uploaded_file"])
703  {
704  include_once 'Services/FileSystem/classes/class.ilUploadFiles.php';
705 
706  // check if the file is in the ftp directory and readable
707  if (ilUploadFiles::_checkUploadFile($_POST["uploaded_file"]))
708  {
709  $tgt_file = $cur_dir."/".ilUtil::stripSlashes($_POST["uploaded_file"]);
710 
711  // copy uploaded file to data directory
712  ilUploadFiles::_copyUploadFile($_POST["uploaded_file"], $tgt_file);
713  }
714  }
715  else if (trim($_FILES["new_file"]["name"]) == "")
716  {
717  ilUtil::sendFailure($lng->txt("cont_enter_a_file"), true);
718  }
719 
720  if($tgt_file && is_file($tgt_file))
721  {
722  $unzip = null;
723 
724  // extract zip?
725  include_once("./Services/Utilities/classes/class.ilMimeTypeUtil.php");
726  if(ilMimeTypeUtil::getMimeType($tgt_file) == "application/zip")
727  {
728  $this->ctrl->setParameter($this, "upfile", basename($tgt_file));
729  $url = $this->ctrl->getLinkTarget($this, "unzipFile");
730  $this->ctrl->setParameter($this, "upfile", "");
731 
732  include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
733  $unzip = ilLinkButton::getInstance();
734  $unzip->setCaption("unzip");
735  $unzip->setUrl($url);
736  $unzip = " ".$unzip->render();
737  }
738 
739  ilUtil::sendSuccess($lng->txt("cont_file_created").$unzip, true);
740 
741  $this->setPerformedCommand("create_file",
742  array("name" => substr($tgt_file, strlen($this->main_dir)+1)));
743  }
744 
745  $this->ctrl->saveParameter($this, "cdir");
746 
747  ilUtil::renameExecutables($this->main_dir);
748 
749  $this->ctrl->redirect($this, "listFiles");
750  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
$_POST['username']
Definition: cron.php:12
$_GET["client_id"]
static getMimeType($a_file="", $a_filename="", $a_mime="")
Get Mime type.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
isValidSuffix($a_suffix)
Is suffix valid?
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static renameExecutables($a_dir)
Rename uploaded executables for security reasons.
global $lng
Definition: privfeed.php:40
setPerformedCommand($command, $pars="")
Set performed command.
static _checkUploadFile($a_file)
Check if a file exists in the upload directory and is readable.
static _copyUploadFile($a_file, $a_target, $a_raise_errors=true)
copy an uploaded file to the target directory (including virus check)
+ Here is the call graph for this function:

Field Documentation

◆ $allowed_suffixes

ilFileSystemGUI::$allowed_suffixes = array()
protected

Definition at line 21 of file class.ilFileSystemGUI.php.

Referenced by getAllowedSuffixes().

◆ $ctrl

ilFileSystemGUI::$ctrl

Definition at line 14 of file class.ilFileSystemGUI.php.

◆ $forbidden_suffixes

ilFileSystemGUI::$forbidden_suffixes = array()
protected

Definition at line 26 of file class.ilFileSystemGUI.php.

Referenced by getForbiddenSuffixes().

◆ $use_upload_directory

ilFileSystemGUI::$use_upload_directory = false
protected

Definition at line 16 of file class.ilFileSystemGUI.php.

Referenced by getUseUploadDirectory().


The documentation for this class was generated from the following file: