1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15:
16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
17:
18: cInclude("includes", "functions.con.php");
19: cInclude("includes", "functions.str.php");
20:
21: if (!(int) $client > 0) {
22:
23: $oPage = new cGuiPage("upl_dirs_overview");
24: $oPage->render();
25: return;
26: }
27:
28: function getUplExpandCollapseButton($item) {
29: global $sess, $PHP_SELF, $frame, $area, $appendparameters;
30: $selflink = "main.php";
31:
32: if (count($item->subitems) > 0) {
33: if ($item->collapsed == true) {
34: $expandlink = $sess->url($selflink . "?area=$area&frame=$frame&appendparameters=$appendparameters&expand=" . $item->id);
35: return ('<a href="' . $expandlink . '" alt="' . i18n('Open category') . '" title="' . i18n('Open category') . '"><img src="' . $item->collapsed_icon . '" border="0" align="middle" width="18"></a>');
36: } else {
37: $collapselink = $sess->url($selflink . "?area=$area&appendparameters=$appendparameters&frame=$frame&collapse=" . $item->id);
38: return ('<a href="' . $collapselink . '" alt="' . i18n('Close category') . '" title="' . i18n('Close category') . '"><img src="' . $item->expanded_icon . '" border="0" align="middle" width="18"></a>');
39: }
40: } else {
41: if ($item->custom["lastitem"]) {
42: return '<img class="vAlignMiddle" src="images/but_lastnode.gif" width="18" height="18">';
43: } else {
44: return '<img class="vAlignMiddle" src="images/grid_collapse.gif" width="18" height="18">';
45: }
46: }
47: }
48:
49:
50:
51:
52:
53:
54:
55: if (!isset($path) && $sess->isRegistered("upl_last_path")) {
56: $path = $upl_last_path;
57: }
58:
59: $appendparameters = $_REQUEST["appendparameters"];
60:
61: if (!isset($action))
62: $action = "";
63:
64: if ($tmp_area == "") {
65: $tmp_area = $area;
66: }
67:
68: $uplexpandedList = unserialize($currentuser->getUserProperty("system", "upl_expandstate"));
69: $upldbfsexpandedList = unserialize($currentuser->getUserProperty("system", "upl_dbfs_expandstate"));
70:
71: if (!is_array($uplexpandedList)) {
72: $uplexpandedList = array();
73: }
74:
75: if (!is_array($upldbfsexpandedList)) {
76: $upldbfsexpandedList = array();
77: }
78:
79: if ($action == "upl_renamedir") {
80: if ($perm->have_perm_area_action("upl", "upl_renamedir")) {
81: uplRenameDirectory($oldname, $newname, $parent);
82: $path = $cfgClient[$client]['upl']['path'] . $parent . $newname . "/";
83: if (in_array($cfgClient[$client]['upl']['path'] . $parent . $oldname . "/", $uplexpandedList)) {
84: $uplexpandedList[] = $cfgClient[$client]['upl']['path'] . $parent . $newname . "/";
85: }
86: }
87: }
88:
89:
90:
91:
92: $dbfs = new cApiDbfsCollection();
93:
94: if ($action == "upl_delete") {
95: if (cApiDbfs::isDbfs($path)) {
96: $dbfs->remove($path . "/.");
97: } else {
98:
99: if (uplHasFiles($path)) {
100: $failedFiles = array();
101: if (is_dir($cfgClient[$client]["upl"]["path"] . $path)) {
102:
103: $directory = @opendir($cfgClient[$client]["upl"]["path"] . $path);
104: if (false !== $directory) {
105: while (false !== ($dir_entry = readdir($directory))) {
106: if ($dir_entry != "." && $dir_entry != "..") {
107: $res = @ unlink($cfgClient[$client]["upl"]["path"] . $path . $dir_entry);
108:
109: if ($res == false) {
110: $failedFiles[] = $dir_entry;
111: }
112: }
113: }
114: }
115: closedir($directory);
116: }
117: }
118:
119: if (count($failedFiles) > 0) {
120: $notification->displayNotification("warning", i18n("Failed to delete the following files:") . "<br><br>" . implode("<br>", $failedFiles));
121: } else {
122: $res = @ rmdir($cfgClient[$client]['upl']['path'] . $path);
123: if ($res == false) {
124: $notification->displayNotification("warning", sprintf(i18n("Failed to remove directory %s"), $path));
125: }
126: }
127: }
128: }
129:
130: $tpl->reset();
131:
132: $file = 'Upload';
133: $pathstring = '';
134:
135: $rootTreeItem = new TreeItem();
136: $rootTreeItem->custom["level"] = 0;
137: $rootTreeItem->name = i18n("Upload directory");
138: $aInvalidDirectories = uplRecursiveDirectoryList($cfgClient[$client]["upl"]["path"], $rootTreeItem, 2);
139: if (count($aInvalidDirectories) > 0) {
140: $sWarningInfo = i18n('The following directories contains invalid characters and were ignored: ');
141: $sSeperator = '<br>';
142: $sFiles = implode(', ', $aInvalidDirectories);
143: $sRenameString = i18n('Please click here in order to rename automatically.');
144: $sRenameHref = $sess->url("main.php?area=$area&frame=$frame&force_rename=true");
145: $sRemameLink = '<a href="' . $sRenameHref . '">' . $sRenameString . '</a>';
146: $sNotificationString = $sWarningInfo . $sSeperator . $sFiles . $sSeperator . $sSeperator . $sRemameLink;
147:
148: $sErrorString = $notification->returnNotification("warning", $sNotificationString, 1);
149: $tpl->set('s', 'WARNING', $sErrorString);
150: } else {
151: $tpl->set('s', 'WARNING', '');
152: }
153:
154:
155: foreach ($uplexpandedList as $key => $value) {
156: $rootTreeItem->markExpanded($value);
157: }
158:
159:
160: if (is_string($collapse)) {
161: $rootTreeItem->markCollapsed($collapse);
162: }
163:
164: if (is_string($expand)) {
165: $rootTreeItem->markExpanded($expand);
166: }
167:
168: $uplexpandedList = array();
169: $rootTreeItem->getExpandedList($uplexpandedList);
170:
171: $currentuser->setUserProperty("system", "upl_expandstate", serialize($uplexpandedList));
172:
173: $objects = array();
174: $rootTreeItem->traverse($objects);
175: unset($objects[0]);
176:
177: if ($appendparameters == "filebrowser") {
178: $mtree = new cGuiTree("b58f0ae3-8d4e-4bb3-a754-5f0628863364");
179: $cattree = conFetchCategoryTree();
180: $marray = array();
181:
182: foreach ($cattree as $key => $catitem) {
183: $no_start = true;
184: $no_online = true;
185: $no_start = !strHasStartArticle($catitem["idcat"], $lang);
186:
187: $no_online = !$catitem["visible"];
188:
189: if ($catitem["visible"] == 1) {
190: if ($catitem["public"] == 0) {
191: if ($no_start || $no_online) {
192:
193: $tmp_img = "folder_on_error_locked.gif";
194: } else {
195:
196: $tmp_img = "folder_on_locked.gif";
197: }
198: } else {
199:
200: if ($no_start || $no_online) {
201:
202: $tmp_img = "folder_on_error.gif";
203: } else {
204:
205: $tmp_img = "folder_on.gif";
206: }
207: }
208: } else {
209:
210: if ($catitem['public'] == 0) {
211:
212: if ($no_start || $no_online) {
213:
214: $tmp_img = "folder_off_error_locked.gif";
215: } else {
216:
217: $tmp_img = "folder_off_locked.gif";
218: }
219: } else {
220:
221: if ($no_start || $no_online) {
222:
223: $tmp_img = "folder_off_error.gif";
224: } else {
225:
226: $tmp_img = "folder_off.gif";
227: }
228: }
229: }
230:
231: $icon = "./images/" . $tmp_img;
232:
233: $idcat = $catitem["idcat"];
234:
235: $name = ' <a href="' . $sess->url("main.php?area=$area&frame=5&idcat=$idcat&appendparameters=$appendparameters") . '" target="right_bottom">' . $catitem["name"] . '</a>';
236: $marray[] = array(
237: "id" => $catitem["idcat"],
238: "name" => $name,
239: "level" => $catitem["level"],
240: "attributes" => array(
241: "icon" => $icon
242: )
243: );
244: }
245:
246: $mtree->setTreeName(i18n("Categories"));
247: $mtree->setIcon("images/grid_folder.gif");
248: $mtree->importTable($marray);
249:
250: $baselink = new cHTMLLink();
251: $baselink->setCLink($area, $frame, "");
252: $baselink->setCustom("appendparameters", $appendparameters);
253:
254: $mtree->setBaseLink($baselink);
255: $mtree->setBackgroundMode(TREEVIEW_BACKGROUND_SHADED);
256: $mtree->setMouseoverMode(cGuiTree::TREEVIEW_MOUSEOVER_NONE);
257: $mtree->setCollapsed($collapsed);
258: $mtree->processParameters();
259:
260: $collapsed = array();
261: $mtree->getCollapsedList($collapsed);
262:
263: $tpl->set('s', 'CATBROWSER', $mtree->render());
264: $tpl->set('s', 'APPENDPARAMETERS', 'url += \'&appendparameters=' . $appendparameters . '\'');
265: } else {
266: $tpl->set('s', 'CATBROWSER', '');
267: $tpl->set('s', 'APPENDPARAMETERS', 'url += \'&appendparameters=' . $appendparameters . '\'');
268: }
269:
270: chdir(cRegistry::getBackendPath());
271:
272: $tpl->set('s', 'SID', $sess->id);
273:
274:
275: $tmp_mstr = '<a id="root" href="javascript:conMultiLink(\'%s\', \'%s\',\'%s\', \'%s\')">%s</a>';
276: $mstr = sprintf($tmp_mstr, 'right_top', $sess->url("main.php?area=$area&frame=3&path=$pathstring&appendparameters=$appendparameters"), 'right_bottom', $sess->url("main.php?area=$area&frame=4&path=$pathstring&appendparameters=$appendparameters"), '<img class="vAlignMiddle" src="images/ordner_oben.gif" align="middle" alt="" border="0"><img src="images/spacer.gif" width="5" border="0">' . $file);
277:
278: $tpl->set('d', 'PATH', $pathstring);
279: $tpl->set('d', 'INDENT', 3);
280: $tpl->set('d', 'DIRNAME', $mstr);
281: $tpl->set('d', 'EDITBUTTON', '');
282: $tpl->set('d', 'DELETEBUTTON', '');
283: $tpl->set('d', 'COLLAPSE', '');
284: $tpl->next();
285:
286: if (is_array($objects)) {
287: foreach ($objects as $a_file) {
288: $file = $a_file->name;
289: $depth = $a_file->custom["level"] - 1;
290: $pathstring = str_replace($cfgClient[$client]['upl']['path'], "", $a_file->id);
291: $a_file->collapsed_icon = "images/grid_expand.gif";
292: $a_file->expanded_icon = "images/grid_collapse.gif";
293: $dlevels[$depth] = $a_file->custom["lastitem"];
294: $imgcollapse = getUplExpandCollapseButton($a_file);
295: $fileurl = rawurlencode($path . $file . '/');
296: $pathurl = rawurlencode($path);
297:
298:
299: $cnt = $depth;
300: $indent = 18;
301:
302: for ($i = 0; $i < $cnt; $i++) {
303: $indent += 18;
304: }
305:
306:
307: $tmp_mstr = '<a href="javascript:conMultiLink(\'%s\', \'%s\', \'%s\', \'%s\')">%s</a>';
308: $mstr = sprintf($tmp_mstr, 'right_bottom', $sess->url("main.php?area=$area&frame=4&path=$pathstring&appendparameters=$appendparameters"), 'right_top', $sess->url("main.php?area=$area&frame=3&path=$pathstring&appendparameters=$appendparameters"), '<img class="vAlignMiddle" src="images/grid_folder.gif" border="0" alt=""><img src="images/spacer.gif" align="middle" width="5" border="0">' . $file);
309:
310: $hasFiles = uplHasFiles($pathstring);
311: $hasSubdirs = uplHasSubdirs($pathstring);
312:
313: if ((!$hasSubdirs) && (!$hasFiles) && $perm->have_perm_area_action($tmp_area, "upl_rmdir")) {
314: $deletebutton = '<a title="' . i18n("Delete directory") . '" href="javascript:void(0)" onclick="event.cancelBubble=true;showConfirmation("' . i18n("Do you really want to delete the following directory:") . '<b>' . $file . '</b>", function() { deleteDirectory("' . $pathstring . '"); });return false;"><img src="' . $cfg['path']['images'] . 'delete.gif" border="0" title="' . i18n("Delete directory") . '" alt="' . i18n("Delete directory") . '"></a>';
315: } else {
316: if ($hasFiles) {
317: $message = i18n("Directory contains files");
318: } else {
319: $message = i18n("Permission denied");
320: }
321:
322: $deletebutton = "<img src=\"" . $cfg["path"]["images"] . "delete_inact.gif\" border=\"0\" alt=\"" . $message . "\" title=\"" . $message . "\">";
323: }
324:
325: $tpl->set('d', 'PATH', $pathstring);
326: $tpl->set('d', 'INDENT', 0);
327:
328: $gline = "";
329:
330: for ($i = 1; $i < $depth; $i++) {
331: if ($dlevels[$i] == false && $i != 0) {
332: $gline .= '<img class="vAlignMiddle" src="images/grid_linedown.gif" width="18">';
333: } else {
334: $gline .= '<img class="vAlignMiddle" src="images/spacer.gif" width="18" height="18">';
335: }
336: }
337:
338: $parent = str_replace($cfgClient[$client]['upl']['path'], "", $a_file->custom["parent"]);
339:
340: $tpl->set('d', 'DIRNAME', $mstr);
341: $tpl->set('d', 'EDITBUTTON', '');
342: $tpl->set('d', 'DELETEBUTTON', $deletebutton);
343:
344: $tpl->set('d', 'COLLAPSE', $gline . $imgcollapse);
345: $tpl->next();
346: }
347: }
348:
349: $tpl->set('d', 'DELETEBUTTON', ' ');
350: $tpl->set('d', 'DIRNAME', '');
351: $tpl->set('d', 'EDITBUTTON', '');
352: $tpl->set('d', 'COLLAPSE', "");
353: $tpl->next();
354:
355:
356:
357:
358: $file = i18n("Database file system");
359: $pathstring = 'dbfs:';
360: $rootTreeItem = new TreeItem();
361: $rootTreeItem->custom["level"] = 0;
362:
363: uplRecursiveDBDirectoryList("", $rootTreeItem, 2, $client);
364:
365:
366: foreach ($upldbfsexpandedList as $key => $value) {
367: $rootTreeItem->markExpanded($value);
368: }
369:
370:
371: if (is_string($collapse)) {
372: $rootTreeItem->markCollapsed($collapse);
373: }
374:
375: if (is_string($expand)) {
376: $rootTreeItem->markExpanded($expand);
377: }
378:
379: $upldbfsexpandedList = array();
380: $rootTreeItem->getExpandedList($upldbfsexpandedList);
381:
382: $currentuser->setUserProperty("system", "upl_dbfs_expandstate", serialize($upldbfsexpandedList));
383:
384: $objects = array();
385: $rootTreeItem->traverse($objects);
386:
387: unset($objects[0]);
388:
389: $tmp_mstr = '<a href="javascript:conMultiLink(\'%s\', \'%s\', \'%s\', \'%s\')">%s</a>';
390: $mstr = sprintf($tmp_mstr, 'right_top', $sess->url("main.php?area=$area&frame=3&path=$pathstring&appendparameters=$appendparameters"), 'right_bottom', $sess->url("main.php?area=$area&frame=4&path=$pathstring&appendparameters=$appendparameters"), '<img class="vAlignMiddle" src="images/ordner_oben.gif" alt="" border="0"><img src="images/spacer.gif" width="5" border="0">' . $file);
391:
392: $tpl->set('d', 'PATH', $pathstring);
393: $tpl->set('d', 'INDENT', 3);
394: $tpl->set('d', 'DIRNAME', $mstr);
395: $tpl->set('d', 'EDITBUTTON', '');
396: $tpl->set('d', 'DELETEBUTTON', '');
397: $tpl->set('d', 'COLLAPSE', '');
398: $tpl->next();
399:
400: $dbfsc = new cApiDbfsCollection();
401:
402: $dlevels = array();
403:
404: if (is_array($objects)) {
405: foreach ($objects as $a_file) {
406: $file = $a_file->name;
407: $depth = $a_file->custom["level"] - 1;
408: $pathstring = $a_file->id;
409: $a_file->collapsed_icon = "images/grid_expand.gif";
410: $a_file->expanded_icon = "images/grid_collapse.gif";
411: $dlevels[$depth] = $a_file->custom["lastitem"];
412: $collapse = getUplExpandCollapseButton($a_file);
413: $fileurl = rawurlencode($path . $file . '/');
414: $pathurl = rawurlencode($path);
415:
416: if ($file == 'tmp') {
417: echo 'tmp2<br>';
418: }
419:
420:
421: $cnt = $depth;
422: $indent = 18;
423:
424: for ($i = 0; $i < $cnt; $i++) {
425:
426: $indent += 18;
427: }
428:
429:
430: $tmp_mstr = '<a href="javascript:conMultiLink(\'%s\', \'%s\', \'%s\', \'%s\')">%s</a>';
431: $mstr = sprintf($tmp_mstr, 'right_bottom', $sess->url("main.php?area=$area&frame=4&path=$pathstring&appendparameters=$appendparameters"), 'right_top', $sess->url("main.php?area=$area&frame=3&path=$pathstring&appendparameters=$appendparameters"), '<img class="vAlignMiddle" src="images/grid_folder.gif" border="0" alt=""><img src="images/spacer.gif" align="middle" width="5" border="0">' . $file);
432:
433: $hasFiles = $dbfsc->hasFiles($pathstring);
434:
435: if (!$hasFiles && $perm->have_perm_area_action($tmp_area, "upl_rmdir")) {
436: $deletebutton = '<a title="' . i18n("Delete directory") . '" href="javascript:void(0)" onclick="event.cancelBubble=true;showConfirmation("' . i18n("Do you really want to delete the following directory:") . '<b>' . $file . '</b>' . '", function() { deleteDirectory("' . $pathstring . '"); });return false;"><img class="vAlignMiddle" src="' . $cfg['path']['images'] . 'delete.gif" border="0" title="' . i18n("Delete directory") . '" alt="' . i18n("Delete directory") . '"></a>';
437: } else {
438: if ($hasFiles) {
439: $message = i18n("Directory contains files");
440: } else {
441: $message = i18n("Permission denied");
442: }
443:
444: $deletebutton = "<img class='vAlignMiddle' src=\"" . $cfg["path"]["images"] . "delete_inact.gif\" border=\"0\" alt=\"" . $message . "\" title=\"" . $message . "\">";
445: }
446:
447: $tpl->set('d', 'PATH', $pathstring);
448: $tpl->set('d', 'INDENT', 0);
449:
450: $gline = "";
451:
452: for ($i = 1; $i < $depth; $i++) {
453: if ($dlevels[$i] == false && $i != 0) {
454: $gline .= '<img class="vAlignMiddle" src="images/grid_linedown.gif" align="middle">';
455: } else {
456: $gline .= '<img class="vAlignMiddle" src="images/spacer.gif" width="18" height="18" align="middle">';
457: }
458: }
459:
460: $parent = str_replace($cfgClient[$client]['upl']['path'], "", $a_file->custom["parent"]);
461: $tpl->set('d', 'DIRNAME', $mstr);
462: $tpl->set('d', 'EDITBUTTON', '');
463: $tpl->set('d', 'DELETEBUTTON', $deletebutton);
464: $tpl->set('d', 'COLLAPSE', $gline . $collapse);
465: $tpl->next();
466: }
467: }
468:
469: $tpl->set('s', 'ID_PATH', $path);
470: chdir(cRegistry::getBackendPath());
471: $tpl->generate($cfg['path']['templates'] . $cfg['templates']['upl_dirs_overview']);
472: