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