ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilFileSystemGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
13{
14 var $ctrl;
15
16 protected $use_upload_directory = false;
17
21 protected $allowed_suffixes = array();
22
26 protected $forbidden_suffixes = array();
27
28
29 function ilFileSystemGUI($a_main_directory)
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 "single" => true
46 ),
47 1 => array(
48 "object" => $this,
49 "method" => "confirmDeleteFile",
50 "name" => $lng->txt("delete"),
51 "allow_dir" => true,
52 "int" => true
53 ),
54 2 => array(
55 "object" => $this,
56 "method" => "unzipFile",
57 "name" => $lng->txt("unzip"),
58 "int" => true,
59 "single" => true
60 ),
61 3 => array(
62 "object" => $this,
63 "method" => "renameFileForm",
64 "name" => $lng->txt("rename"),
65 "allow_dir" => true,
66 "int" => true,
67 "single" => true
68 ),
69 );
70
71 $this->file_labels = array();
72 $this->label_enable = false;
73 $this->ctrl->saveParameter($this, "cdir");
74 $lng->loadLanguageModule("content");
75 $this->setAllowDirectories(true);
76 $this->setAllowDirectoryCreation(true);
77 $this->setAllowFileCreation(true);
78//echo "<br>main_dir:".$this->main_dir.":";
79 }
80
86 function setAllowedSuffixes($a_suffixes)
87 {
88 $this->allowed_suffixes = $a_suffixes;
89 }
90
97 {
99 }
100
106 function setForbiddenSuffixes($a_suffixes)
107 {
108 $this->forbidden_suffixes = $a_suffixes;
109 }
110
117 {
119 }
120
127 function isValidSuffix($a_suffix)
128 {
129 if (is_array($this->getForbiddenSuffixes()) && in_array($a_suffix, $this->getForbiddenSuffixes()))
130 {
131 return false;
132 }
133 if (is_array($this->getAllowedSuffixes()) && in_array($a_suffix, $this->getAllowedSuffixes()))
134 {
135 return true;
136 }
137 if (!is_array($this->getAllowedSuffixes()) || count($this->getAllowedSuffixes()) == 0)
138 {
139 return true;
140 }
141 return false;
142 }
143
144
150 function setAllowDirectories($a_val)
151 {
152 $this->allow_directories = $a_val;
153 }
154
161 {
162 return $this->allow_directories;
163 }
164
170 function setPostDirPath($a_val)
171 {
172 $this->post_dir_path = $a_val;
173 }
174
180 function getPostDirPath()
181 {
182 return $this->post_dir_path;
183 }
184
190 function setTableId($a_val)
191 {
192 $this->table_id = $a_val;
193 }
194
200 function getTableId()
201 {
202 return $this->table_id;
203 }
204
210 function setTitle($a_val)
211 {
212 $this->title = $a_val;
213 }
214
220 function getTitle()
221 {
222 return $this->title;
223 }
224
230 function setUseUploadDirectory($a_val)
231 {
232 $this->use_upload_directory = $a_val;
233 }
234
241 {
243 }
244
251 protected function setPerformedCommand($command, $pars = "")
252 {
253 if (!is_array($pars))
254 {
255 $pars = array();
256 }
257 $_SESSION["fsys"]["lastcomm"] = array_merge(
258 array("cmd" => $command), $pars);
259 }
260
266 public function getLastPerformedCommand()
267 {
268 $ret = $_SESSION["fsys"]["lastcomm"];
269 $_SESSION["fsys"]["lastcomm"] = "none";
270 return $ret;
271 }
272
276 function &executeCommand()
277 {
278 $next_class = $this->ctrl->getNextClass($this);
279 $cmd = $this->ctrl->getCmd("listFiles");
280
281 switch($next_class)
282 {
283
284 default:
285 if (substr($cmd, 0, 11) == "extCommand_")
286 {
287 $ret =& $this->extCommand(substr($cmd, 11, strlen($cmd) - 11));
288 }
289 else
290 {
291 $ret =& $this->$cmd();
292 }
293 break;
294 }
295
296 return $ret;
297 }
298
299
303 function addCommand(&$a_obj, $a_func, $a_name, $a_single = true,
304 $a_allow_dir = false)
305 {
306 $i = count($this->commands);
307
308 $this->commands[$i]["object"] =& $a_obj;
309 $this->commands[$i]["method"] = $a_func;
310 $this->commands[$i]["name"] = $a_name;
311 $this->commands[$i]["single"] = $a_single;
312 $this->commands[$i]["allow_dir"] = $a_allow_dir;
313
314 //$this->commands[] = $arr;
315 }
316
320 function clearCommands()
321 {
322 $this->commands = array();
323 }
324
328 function labelFile($a_file, $a_label)
329 {
330 $this->file_labels[$a_file][] = $a_label;
331 }
332
336 function activateLabels($a_act, $a_label_header)
337 {
338 $this->label_enable = $a_act;
339 $this->label_header = $a_label_header;
340 }
341
342
343
344 protected function parseCurrentDirectory()
345 {
346 // determine directory
347 // FIXME: I have to call stripSlashes here twice, because I could not
348 // determine where the second layer of slashes is added to the
349 // URL Parameter
350 $cur_subdir = ilUtil::stripSlashes(ilUtil::stripSlashes($_GET["cdir"]));
351 $new_subdir = ilUtil::stripSlashes(ilUtil::stripSlashes($_GET["newdir"]));
352
353 if($new_subdir == "..")
354 {
355 $cur_subdir = substr($cur_subdir, 0, strrpos($cur_subdir, "/"));
356 }
357 else
358 {
359 if (!empty($new_subdir))
360 {
361 if (!empty($cur_subdir))
362 {
363 $cur_subdir = $cur_subdir."/".$new_subdir;
364 }
365 else
366 {
367 $cur_subdir = $new_subdir;
368 }
369 }
370 }
371
372 $cur_subdir = str_replace("..", "", $cur_subdir);
373 $cur_dir = (!empty($cur_subdir))
374 ? $this->main_dir."/".$cur_subdir
375 : $this->main_dir;
376
377 return array("dir"=>$cur_dir, "subdir"=>$cur_subdir);
378 }
379
380 protected function getFileList($a_dir, $a_subdir = null)
381 {
382 $items = array();
383
384 $entries = (is_dir($a_dir))
385 ? ilUtil::getDir($a_dir)
386 : array(array("type" => "dir", "entry" => ".."));
387
388 $items = array();
389 foreach ($entries as $e)
390 {
391 if(($e["entry"] == ".") ||
392 ($e["entry"] == ".." && empty($a_subdir)))
393 {
394 continue;
395 }
396
397 $cfile = (!empty($a_subdir))
398 ? $a_subdir."/".$e["entry"]
399 : $e["entry"];
400
401 $items[] = array(
402 "file" => $cfile,
403 "entry" => $e["entry"],
404 "type" => $e["type"],
405 "size" => $e["size"],
406 "hash" => md5($e["entry"])
407 );
408 }
409
410 return $items;
411 }
412
413 protected function getIncomingFiles()
414 {
415 $sel_files = $hashes = array();
416 if (isset($_POST["file"]))
417 {
418 $hashes = $_POST["file"];
419 }
420 else if(isset($_GET["fhsh"]))
421 {
422 $hashes = array($_GET["fhsh"]);
423 }
424
425 if(sizeof($hashes))
426 {
427 $dir = $this->parseCurrentDirectory();
428 $all_files = $this->getFileList($dir["dir"], $dir["subdir"]);
429 foreach($hashes as $hash)
430 {
431 foreach($all_files as $file)
432 {
433 if($file["hash"] == $hash)
434 {
435 $sel_files[] = $this->getPostDirPath()
436 ? $file["file"]
437 : $file["entry"];
438 break;
439 }
440 }
441 }
442 }
443
444 return $sel_files;
445 }
446
450 function extCommand($a_nr)
451 {
452 $selected = $this->getIncomingFiles();
453
454 if(!count($selected))
455 {
456 ilUtil::sendFailure($this->lng->txt("no_checkbox"), true);
457 $this->ctrl->redirect($this, "listFiles");
458 }
459
460 // check if only one item is select, if command does not allow multiple selection
461 if (count($selected) > 1 && $this->commands[$a_nr]["single"])
462 {
463 ilUtil::sendFailure($this->lng->txt("cont_select_max_one_item"), true);
464 $this->ctrl->redirect($this, "listFiles");
465 }
466
467 $cur_subdir = str_replace(".", "", ilUtil::stripSlashes($_GET["cdir"]));
468
469 // collect files and
470 $files = array();
471 foreach ($selected as $file)
472 {
474 $file = (!empty($cur_subdir))
475 ? $cur_subdir."/".$file
476 : $file;
477
478 // check wether selected item is a directory
479 if (@is_dir($this->main_dir."/".$file) &&
480 !$this->commands[$a_nr]["allow_dir"])
481 {
482 ilUtil::sendFailure($this->lng->txt("select_a_file"), true);
483 $this->ctrl->redirect($this, "listFiles");
484 }
485
486 $files[] = $file;
487 }
488
489 if ($this->commands[$a_nr]["single"])
490 {
491 $files = array_shift($files);
492 }
493
494 $obj = $this->commands[$a_nr]["object"];
495 $method = $this->commands[$a_nr]["method"];
496
497 return $obj->$method($files);
498 }
499
503 public function setAllowDirectoryCreation($a_val)
504 {
505 $this->directory_creation = $a_val;
506 }
507
512 {
513 return $this->directory_creation;
514 }
515
519 public function setAllowFileCreation($a_val)
520 {
521 $this->file_creation = $a_val;
522 }
523
527 public function getAllowFileCreation()
528 {
529 return $this->file_creation;
530 }
531
535 function listFiles()
536 {
537 global $ilToolbar, $lng, $ilCtrl;
538
539 $dir = $this->parseCurrentDirectory();
540
541 $this->ctrl->setParameter($this, "cdir", $dir["subdir"]);
542
543 // toolbar for adding files/directories
544 $ilToolbar->setFormAction($ilCtrl->getFormAction($this), true);
545 include_once("./Services/Form/classes/class.ilTextInputGUI.php");
546
547 if ($this->getAllowDirectories() && $this->getAllowDirectoryCreation())
548 {
549 $ti = new ilTextInputGUI($this->lng->txt("cont_new_dir"), "new_dir");
550 $ti->setMaxLength(80);
551 $ti->setSize(10);
552 $ilToolbar->addInputItem($ti, true);
553 $ilToolbar->addFormButton($lng->txt("create"), "createDirectory");
554
555 $ilToolbar->addSeparator();
556 }
557
558 include_once("./Services/Form/classes/class.ilFileInputGUI.php");
559 if ($this->getAllowFileCreation())
560 {
561 $fi = new ilFileInputGUI($this->lng->txt("cont_new_file"), "new_file");
562 $fi->setSize(10);
563 $ilToolbar->addInputItem($fi, true);
564 $ilToolbar->addFormButton($lng->txt("upload"), "uploadFile");
565 }
566
567 include_once 'Services/FileSystem/classes/class.ilUploadFiles.php';
569 {
570 $ilToolbar->addSeparator();
572 $options[""] = $lng->txt("cont_select_from_upload_dir");
573 foreach($files as $file)
574 {
575 $file = htmlspecialchars($file, ENT_QUOTES, "utf-8");
577 }
578 include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
579 $si = new ilSelectInputGUI($this->lng->txt("cont_uploaded_file"), "uploaded_file");
580 $si->setOptions($options);
581 $ilToolbar->addInputItem($si, true);
582 $ilToolbar->addFormButton($lng->txt("copy"), "uploadFile");
583 }
584
585 // load files templates
586 include_once("./Services/FileSystem/classes/class.ilFileSystemTableGUI.php");
587 $fs_table = new ilFileSystemTableGUI($this, "listFiles", $dir["dir"], $dir["subdir"],
588 $this->label_enable, $this->file_labels, $this->label_header, $this->commands,
589 $this->getPostDirPath(), $this->getTableId());
590 if ($this->getTitle() != "")
591 {
592 $fs_table->setTitle($this->getTitle());
593 }
594 if ($_GET["resetoffset"] == 1)
595 {
596 $fs_table->resetOffset();
597 }
598 $this->tpl->setContent($fs_table->getHTML());
599 }
600
604 function renameFileForm($a_file)
605 {
606 global $lng, $ilCtrl;
607
608 $cur_subdir = str_replace(".", "", ilUtil::stripSlashes($_GET["cdir"]));
609 $file = $this->main_dir."/".$a_file;
610
611 $this->ctrl->setParameter($this, "old_name", basename($a_file));
612 $this->ctrl->setParameter($this, "cdir", ilUtil::stripSlashes($_GET["cdir"]));
613
614 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
615 $form = new ilPropertyFormGUI();
616
617 // file/dir name
618 $ti = new ilTextInputGUI($this->lng->txt("name"), "new_name");
619 $ti->setMaxLength(200);
620 $ti->setSize(40);
621 $ti->setValue(basename($a_file));
622 $form->addItem($ti);
623
624 // save and cancel commands
625 $form->addCommandButton("renameFile", $lng->txt("rename"));
626 $form->addCommandButton("cancelRename", $lng->txt("cancel"));
627 $form->setFormAction($ilCtrl->getFormAction($this, "renameFile"));
628
629 if (@is_dir($file))
630 {
631 $form->setTitle($this->lng->txt("cont_rename_dir"));
632 }
633 else
634 {
635 $form->setTitle($this->lng->txt("rename_file"));
636 }
637
638 $this->tpl->setContent($form->getHTML());
639 }
640
644 function renameFile()
645 {
646 global $lng;
647
648 $new_name = str_replace("..", "", ilUtil::stripSlashes($_POST["new_name"]));
649 $new_name = str_replace("/", "", $new_name);
650 if ($new_name == "")
651 {
652 $this->ilias->raiseError($this->lng->txt("enter_new_name"),$this->ilias->error_obj->MESSAGE);
653 }
654
655 $pi = pathinfo($new_name);
656 $suffix = $pi["extension"];
657 if ($suffix != "" && !$this->isValidSuffix($suffix))
658 {
659 ilUtil::sendFailure($this->lng->txt("file_no_valid_file_type")." ($suffix)", true);
660 $this->ctrl->redirect($this, "listFiles");
661 }
662
663 $cur_subdir = str_replace(".", "", ilUtil::stripSlashes($_GET["cdir"]));
664 $dir = (!empty($cur_subdir))
665 ? $this->main_dir."/".$cur_subdir."/"
666 : $this->main_dir."/";
667
668
669 if (is_dir($dir.ilUtil::stripSlashes($_GET["old_name"])))
670 {
671 rename($dir.ilUtil::stripSlashes($_GET["old_name"]), $dir.$new_name);
672 }
673 else
674 {
675 include_once("./Services/Utilities/classes/class.ilFileUtils.php");
676
677 try
678 {
679 ilFileUtils::rename($dir . ilUtil::stripSlashes($_GET["old_name"]), $dir . $new_name);
680 } catch (ilException $e)
681 {
682 ilUtil::sendFailure($e->getMessage(), true);
683 $this->ctrl->redirect($this, "listFiles");
684 }
685 }
686
687 ilUtil::renameExecutables($this->main_dir);
688 if (@is_dir($dir.$new_name))
689 {
690 ilUtil::sendSuccess($lng->txt("cont_dir_renamed"), true);
691 $this->setPerformedCommand("rename_dir", array("old_name" => $_GET["old_name"],
692 "new_name" => $new_name));
693 }
694 else
695 {
696 ilUtil::sendSuccess($lng->txt("cont_file_renamed"), true);
697 $this->setPerformedCommand("rename_file", array("old_name" => $_GET["old_name"],
698 "new_name" => $new_name));
699 }
700 $this->ctrl->redirect($this, "listFiles");
701 }
702
706 function cancelRename()
707 {
708 $this->ctrl->redirect($this, "listFiles");
709 }
710
715 {
716 global $lng;
717
718 // determine directory
719 $cur_subdir = str_replace(".", "", ilUtil::stripSlashes($_GET["cdir"]));
720 $cur_dir = (!empty($cur_subdir))
721 ? $this->main_dir."/".$cur_subdir
722 : $this->main_dir;
723
724 $new_dir = str_replace(".", "", ilUtil::stripSlashes($_POST["new_dir"]));
725 $new_dir = str_replace("/", "", $new_dir);
726
727 if (!empty($new_dir))
728 {
729 ilUtil::makeDir($cur_dir."/".$new_dir);
730 if (is_dir($cur_dir."/".$new_dir))
731 {
732 ilUtil::sendSuccess($lng->txt("cont_dir_created"), true);
733 $this->setPerformedCommand("create_dir", array("name" => $new_dir));
734 }
735 }
736 else
737 {
738 ilUtil::sendFailure($lng->txt("cont_enter_a_dir_name"), true);
739 }
740 $this->ctrl->saveParameter($this, "cdir");
741 $this->ctrl->redirect($this, "listFiles");
742 }
743
747 function uploadFile()
748 {
749 global $lng;
750
751 // determine directory
752 $cur_subdir = str_replace(".", "", ilUtil::stripSlashes($_GET["cdir"]));
753 $cur_dir = (!empty($cur_subdir))
754 ? $this->main_dir."/".$cur_subdir
755 : $this->main_dir;
756
757 $tgt_file = null;
758
759 $pi = pathinfo($_FILES["new_file"]["name"]);
760 $suffix = $pi["extension"];
761 if (!$this->isValidSuffix($suffix))
762 {
763 ilUtil::sendFailure($this->lng->txt("file_no_valid_file_type")." ($suffix)", true);
764 $this->ctrl->redirect($this, "listFiles");
765 }
766
767 if (is_file($_FILES["new_file"]["tmp_name"]))
768 {
769 $name = ilUtil::stripSlashes($_FILES["new_file"]["name"]);
770 $tgt_file = $cur_dir."/".$name;
771
772 ilUtil::moveUploadedFile($_FILES["new_file"]["tmp_name"], $name, $tgt_file);
773
774 }
775 elseif ($_POST["uploaded_file"])
776 {
777 include_once 'Services/FileSystem/classes/class.ilUploadFiles.php';
778
779 // check if the file is in the ftp directory and readable
780 if (ilUploadFiles::_checkUploadFile($_POST["uploaded_file"]))
781 {
782 $tgt_file = $cur_dir."/".ilUtil::stripSlashes($_POST["uploaded_file"]);
783
784 // copy uploaded file to data directory
785 ilUploadFiles::_copyUploadFile($_POST["uploaded_file"], $tgt_file);
786 }
787 }
788 else if (trim($_FILES["new_file"]["name"]) == "")
789 {
790 ilUtil::sendFailure($lng->txt("cont_enter_a_file"), true);
791 }
792
793 if($tgt_file && is_file($tgt_file))
794 {
795 $unzip = null;
796
797 // extract zip?
798 include_once("./Services/Utilities/classes/class.ilMimeTypeUtil.php");
799 if(ilMimeTypeUtil::getMimeType($tgt_file) == "application/zip")
800 {
801 $this->ctrl->setParameter($this, "upfile", basename($tgt_file));
802 $url = $this->ctrl->getLinkTarget($this, "unzipFile");
803 $this->ctrl->setParameter($this, "upfile", "");
804
805 include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
806 $unzip = ilLinkButton::getInstance();
807 $unzip->setCaption("unzip");
808 $unzip->setUrl($url);
809 $unzip = " ".$unzip->render();
810 }
811
812 ilUtil::sendSuccess($lng->txt("cont_file_created").$unzip, true);
813
814 $this->setPerformedCommand("create_file",
815 array("name" => substr($tgt_file, strlen($this->main_dir)+1)));
816 }
817
818 $this->ctrl->saveParameter($this, "cdir");
819
820 ilUtil::renameExecutables($this->main_dir);
821
822 $this->ctrl->redirect($this, "listFiles");
823 }
824
828 function confirmDeleteFile(array $a_files)
829 {
830 global $ilCtrl, $tpl, $lng;
831
832 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
833 $cgui = new ilConfirmationGUI();
834 $cgui->setFormAction($ilCtrl->getFormAction($this));
835 $cgui->setHeaderText($lng->txt("info_delete_sure"));
836 $cgui->setCancel($lng->txt("cancel"), "listFiles");
837 $cgui->setConfirm($lng->txt("delete"), "deleteFile");
838
839 foreach ($a_files as $i)
840 {
841 $cgui->addItem("file[]", $i, $i);
842 }
843
844 $tpl->setContent($cgui->getHTML());
845 }
846
850 function deleteFile()
851 {
852 global $lng;
853
854 if (!isset($_POST["file"]))
855 {
856 $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
857 }
858
859 foreach ($_POST["file"] as $post_file)
860 {
861 if (ilUtil::stripSlashes($post_file) == "..")
862 {
863 $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
864 break;
865 }
866
867 $cur_subdir = str_replace(".", "", ilUtil::stripSlashes($_GET["cdir"]));
868 $cur_dir = (!empty($cur_subdir))
869 ? $this->main_dir."/".$cur_subdir
870 : $this->main_dir;
871 $pi = pathinfo($post_file);
872 $file = $cur_dir."/".ilUtil::stripSlashes($pi["basename"]);
873
874 if (@is_file($file))
875 {
876 unlink($file);
877 }
878
879 if (@is_dir($file))
880 {
881 $is_dir = true;
883 }
884 }
885
886 $this->ctrl->saveParameter($this, "cdir");
887 if ($is_dir)
888 {
889 ilUtil::sendSuccess($lng->txt("cont_dir_deleted"), true);
890 $this->setPerformedCommand("delete_dir",
891 array("name" => ilUtil::stripSlashes($post_file)));
892 }
893 else
894 {
895 ilUtil::sendSuccess($lng->txt("cont_file_deleted"), true);
896 $this->setPerformedCommand("delete_file",
897 array("name" => ilUtil::stripSlashes($post_file)));
898 }
899 $this->ctrl->redirect($this, "listFiles");
900 }
901
905 function unzipFile($a_file = null)
906 {
907 global $lng;
908
909 // #17470 - direct unzip call (after upload)
910 if(!$a_file &&
911 isset($_GET["upfile"]))
912 {
913 $a_file = basename($_GET["upfile"]);
914 }
915
916 $cur_subdir = str_replace(".", "", ilUtil::stripSlashes($_GET["cdir"]));
917 $cur_dir = (!empty($cur_subdir))
918 ? $this->main_dir."/".$cur_subdir
919 : $this->main_dir;
920 $a_file = $this->main_dir."/".$a_file;
921
922 if (@is_file($a_file))
923 {
924 include_once("./Services/Utilities/classes/class.ilFileUtils.php");
925 $cur_files = array_keys(ilUtil::getDir($cur_dir));
926 $cur_files_r = iterator_to_array(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($cur_dir)));
927
928 if ($this->getAllowDirectories())
929 {
930 ilUtil::unzip($a_file, true);
931 }
932 else
933 {
934 ilUtil::unzip($a_file, true, true);
935 }
936
937 $new_files = array_keys(ilUtil::getDir($cur_dir));
938 $new_files_r = iterator_to_array(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($cur_dir)));
939
940 $diff = array_diff($new_files, $cur_files);
941 $diff_r = array_diff($new_files_r, $cur_files_r);
942
943 // unlink forbidden file types
944 foreach ($diff_r as $f => $d)
945 {
946 $pi = pathinfo($f);
947 if (!is_dir($f) && !$this->isValidSuffix(strtolower($pi["extension"])))
948 {
949 ilUtil::sendFailure($lng->txt("file_some_invalid_file_types_removed")." (".$pi["extension"].")", true);
950 unlink($f);
951 }
952 }
953
954 if(sizeof($diff))
955 {
956 if ($this->getAllowDirectories())
957 {
958 include_once("./Services/Utilities/classes/class.ilFileUtils.php");
959 $new_files = array();
960
961 foreach($diff as $new_item)
962 {
963 if(is_dir($cur_dir."/".$new_item))
964 {
965 ilFileUtils::recursive_dirscan($cur_dir."/".$new_item, $new_files);
966 }
967 }
968
969 if(is_array($new_files["path"]))
970 {
971 foreach($new_files["path"] as $idx => $path)
972 {
973 $path = substr($path, strlen($this->main_dir)+1);
974 $diff[] = $path.$new_files["file"][$idx];
975 }
976 }
977 }
978
979 $this->setPerformedCommand("unzip_file",
980 array("name" => substr($file, strlen($this->main_dir)+1),
981 "added" => $diff));
982 }
983 }
984
985 ilUtil::renameExecutables($this->main_dir);
986
987 $this->ctrl->saveParameter($this, "cdir");
988 ilUtil::sendSuccess($lng->txt("cont_file_unzipped"), true);
989 $this->ctrl->redirect($this, "listFiles");
990 }
991
995 function downloadFile($a_file)
996 {
997 $file = $this->main_dir."/".$a_file;
998
999 if (@is_file($file) && !(@is_dir($file)))
1000 {
1001 ilUtil::deliverFile($file, basename($a_file));
1002 exit;
1003 }
1004 else
1005 {
1006 $this->ctrl->saveParameter($this, "cdir");
1007 $this->ctrl->redirect($this, "listFiles");
1008 }
1009 }
1010
1014 function getTabs(&$tabs_gui)
1015 {
1016 global $ilCtrl;
1017
1018 $ilCtrl->setParameter($this, "resetoffset", 1);
1019 $tabs_gui->addTarget("cont_list_files",
1020 $this->ctrl->getLinkTarget($this, "listFiles"), "listFiles",
1021 get_class($this));
1022 $ilCtrl->setParameter($this, "resetoffset", "");
1023 }
1024
1025}
1026?>
print $file
global $tpl
Definition: ilias.php:8
$_GET["client_id"]
$_SESSION["AccountId"]
Confirmation screen class.
Base class for ILIAS Exception handling.
This class represents a file property in a property form.
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.
isValidSuffix($a_suffix)
Is suffix valid?
deleteFile()
delete object file
cancelRename()
cancel renaming a file
extCommand($a_nr)
call external command
& executeCommand()
execute 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)
getLastPerformedCommand()
Get performed command.
unzipFile($a_file=null)
delete object file
ilFileSystemGUI($a_main_directory)
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.
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 getInstance()
Factory.
static getMimeType($a_file='', $a_filename='', $a_mime='')
This class represents a property form user interface.
This class represents a selection list property in a property form.
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.
if(!file_exists(getcwd().'/ilias.ini.php')) if(isset( $_GET["client_id"]))
registration confirmation script for ilias
Definition: confirmReg.php:20
$_POST['username']
Definition: cron.php:12
global $ilCtrl
Definition: ilias.php:18
exit
Definition: login.php:54
redirection script todo: (a better solution should control the processing via a xml file)
global $lng
Definition: privfeed.php:40
$cmd
Definition: sahs_server.php:35
$url
Definition: shib_logout.php:72
$path
Definition: index.php:22
if(!is_array($argv)) $options