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