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: 29: 30: 31: 32:
33: function getUplExpandCollapseButton($item) {
34: global $sess, $frame, $area, $appendparameters;
35: $selflink = 'main.php';
36:
37: if (count($item->getSubItems()) > 0) {
38: if ($item->isCollapsed() == true) {
39: $expandlink = $sess->url($selflink . "?area=$area&frame=$frame&appendparameters=$appendparameters&expand=" . $item->getId());
40: return ('<a href="' . $expandlink . '" alt="' . i18n('Open category') . '" title="' . i18n('Open category') . '"><img src="' . $item->getCollapsedIcon() . '" alt="" border="0" align="middle" width="18"></a>');
41: } else {
42: $collapselink = $sess->url($selflink . "?area=$area&appendparameters=$appendparameters&frame=$frame&collapse=" . $item->getId());
43: return ('<a href="' . $collapselink . '" alt="' . i18n('Close category') . '" title="' . i18n('Close category') . '"><img src="' . $item->getExpandedIcon() . '" alt="" border="0" align="middle" width="18"></a>');
44: }
45: } else {
46: if ($item->getCustom('lastitem')) {
47: return '<img class="vAlignMiddle" alt="" src="images/but_lastnode.gif" width="18" height="18">';
48: } else {
49: return '<img class="vAlignMiddle" alt="" src="images/grid_collapse.gif" width="18" height="18">';
50: }
51: }
52: }
53:
54:
55:
56:
57: if (!isset($path) && $sess->isRegistered('upl_last_path')) {
58: $path = $upl_last_path;
59: }
60:
61: $appendparameters = $_REQUEST['appendparameters'];
62:
63: if (!isset($action))
64: $action = '';
65:
66: if ($tmp_area == '') {
67: $tmp_area = $area;
68: }
69:
70: $uplexpandedList = unserialize($currentuser->getUserProperty('system', 'upl_expandstate'));
71: $upldbfsexpandedList = unserialize($currentuser->getUserProperty('system', 'upl_dbfs_expandstate'));
72:
73: if (!is_array($uplexpandedList)) {
74: $uplexpandedList = array();
75: }
76:
77: if (!is_array($upldbfsexpandedList)) {
78: $upldbfsexpandedList = array();
79: }
80:
81: $dbfs = new cApiDbfsCollection();
82:
83: if ($action == 'upl_delete') {
84: if (cApiDbfs::isDbfs($path)) {
85: $dbfs->remove($path . '/.');
86: } else {
87:
88: if (uplHasFiles($path)) {
89: $failedFiles = array();
90: if (is_dir($cfgClient[$client]['upl']['path'] . $path)) {
91: if (false !== ($directory = cDirHandler::read($uploadPath))) {
92: foreach ($directory as $dir_entry) {
93: if (cFileHandler::fileNameIsDot($dir_entry) === false) {
94: $res = cFileHandler::remove($cfgClient[$client]['upl']['path'] . $path . $dir_entry);
95:
96: if ($res == false) {
97: $failedFiles[] = $dir_entry;
98: }
99: }
100: }
101: }
102: }
103: }
104:
105: if (count($failedFiles) > 0) {
106: $notification->displayNotification('warning', i18n("Failed to delete the following files:") . '<br><br>' . implode('<br>', $failedFiles));
107: } else {
108: $res = @rmdir($cfgClient[$client]['upl']['path'] . $path);
109: if ($res == false) {
110: $notification->displayNotification('warning', sprintf(i18n("Failed to remove directory %s"), $path));
111: }
112: }
113: }
114: }
115:
116: $tpl->reset();
117:
118:
119: if ($errno === '0703') {
120: $tpl->set('s', 'WARNING', $notification->returnNotification('error', i18n('Directories with special characters and spaces are not allowed.')));
121: }
122:
123:
124:
125: $file = 'Upload';
126: $pathstring = '';
127:
128: $rootTreeItem = new TreeItem();
129: $rootTreeItem->setCustom('level', 0);
130: $rootTreeItem->setName(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);
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->setCollapsed($collapsed);
224: $mtree->processParameters();
225:
226: $collapsed = array();
227: $mtree->getCollapsedList($collapsed);
228:
229: $tpl->set('s', 'CATBROWSER', $mtree->render());
230: $tpl->set('s', 'APPENDPARAMETERS', '\'&appendparameters=' . $appendparameters . '\'');
231: } else {
232: $tpl->set('s', 'CATBROWSER', '');
233: $tpl->set('s', 'APPENDPARAMETERS', '\'&appendparameters=' . $appendparameters . '\'');
234: }
235:
236: chdir(cRegistry::getBackendPath());
237:
238: $idFsPathPrefix = 'fs_';
239:
240:
241: $tmp_mstr = '<a id="root" href="javascript:Con.multiLink(\'%s\', \'%s\',\'%s\', \'%s\')">%s</a>';
242: $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);
243:
244: $tpl->set('d', 'ID_PATH', $idFsPathPrefix . 'root');
245: $tpl->set('d', 'DATA_PATH', $pathstring);
246: $tpl->set('d', 'INDENT', 3);
247: $tpl->set('d', 'DIRNAME', $mstr);
248: $tpl->set('d', 'EDITBUTTON', '');
249: $tpl->set('d', 'DELETEBUTTON', '');
250: $tpl->set('d', 'COLLAPSE', '');
251: $tpl->next();
252:
253: if (is_array($objects)) {
254: foreach ($objects as $a_file) {
255: $file = $a_file->getName();
256: $depth = $a_file->getCustom('level') - 1;
257: $pathstring = str_replace($cfgClient[$client]['upl']['path'], '', $a_file->getId());
258: $a_file->setCollapsedIcon('images/grid_expand.gif');
259: $a_file->setExpandedIcon('images/grid_collapse.gif');
260: $dlevels[$depth] = $a_file->getCustom('lastitem');
261: $imgcollapse = getUplExpandCollapseButton($a_file);
262: $fileurl = rawurlencode($path . $file . '/');
263: $pathurl = rawurlencode($path);
264:
265:
266: $indent = 18 + (($depth - 1) * 18);
267:
268:
269: $tmp_mstr = '<a href="javascript:Con.multiLink(\'%s\', \'%s\', \'%s\', \'%s\')">%s</a>';
270: $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);
271:
272: $hasFiles = uplHasFiles($pathstring);
273: $hasSubdirs = uplHasSubdirs($pathstring);
274:
275: if ((!$hasSubdirs) && (!$hasFiles) && $perm->have_perm_area_action($tmp_area, "upl_rmdir")) {
276:
277:
278:
279:
280:
281:
282:
283:
284:
285:
286:
287: $deletebutton = '
288: <a class="jsDelete" title="' . i18n("Delete directory") . '" href="javascript:void(0)">
289: <img src="' . $cfg['path']['images'] . 'delete.gif" border="0" title="' . i18n("Delete directory") . '" alt="' . i18n("Delete directory") . '">
290: </a>';
291: } else {
292: if ($hasFiles) {
293: $message = i18n("Directory contains files");
294: } else {
295: $message = i18n("Permission denied");
296: }
297: $deletebutton = '<img src="' . $cfg['path']['images'] . 'delete_inact.gif" border="0" alt="' . $message . '" title="' . $message . '">';
298: }
299:
300: $gline = '';
301: for ($i = 1; $i < $depth; $i++) {
302: if ($dlevels[$i] == false && $i != 0) {
303: $gline .= '<img class="vAlignMiddle" alt="" src="images/grid_linedown.gif" width="18">';
304: } else {
305: $gline .= '<img class="vAlignMiddle" alt="" src="images/spacer.gif" width="18" height="18">';
306: }
307: }
308:
309: $parent = str_replace($cfgClient[$client]['upl']['path'], '', $a_file->getCustom('parent'));
310:
311: $idAttrPath = str_replace(array(
312: '/',
313: ':'
314: ), array(
315: '_',
316: ''
317: ), trim($pathstring, '/'));
318: $tpl->set('d', 'ID_PATH', $idFsPathPrefix . $idAttrPath);
319: $tpl->set('d', 'DATA_PATH', $pathstring);
320: $tpl->set('d', 'INDENT', 0);
321: $tpl->set('d', 'DIRNAME', $mstr);
322: $tpl->set('d', 'EDITBUTTON', '');
323: $tpl->set('d', 'DELETEBUTTON', $deletebutton);
324: $tpl->set('d', 'COLLAPSE', $gline . $imgcollapse);
325: $tpl->next();
326: }
327: }
328:
329: $tpl->set('d', 'DELETEBUTTON', ' ');
330: $tpl->set('d', 'DIRNAME', '');
331: $tpl->set('d', 'EDITBUTTON', '');
332: $tpl->set('d', 'COLLAPSE', "");
333: $tpl->next();
334:
335:
336:
337: $idDbfsPathPrefix = 'dbfs_';
338: $file = i18n("Database file system");
339: $pathstring = cApiDbfs::PROTOCOL_DBFS;
340: $rootTreeItem = new TreeItem();
341: $rootTreeItem->setCustom('level', 0);
342:
343: uplRecursiveDBDirectoryList('', $rootTreeItem, 2, $client);
344:
345:
346: foreach ($upldbfsexpandedList as $key => $value) {
347: $rootTreeItem->markExpanded($value);
348: }
349:
350:
351: if (is_string($collapse)) {
352: $rootTreeItem->markCollapsed($collapse);
353: }
354:
355: if (is_string($expand)) {
356: $rootTreeItem->markExpanded($expand);
357: }
358:
359: $upldbfsexpandedList = array();
360: $rootTreeItem->getExpandedList($upldbfsexpandedList);
361:
362: $currentuser->setUserProperty('system', 'upl_dbfs_expandstate', serialize($upldbfsexpandedList));
363:
364: $objects = array();
365: $rootTreeItem->traverse($objects);
366:
367: unset($objects[0]);
368:
369: $tmp_mstr = '<a href="javascript:Con.multiLink(\'%s\', \'%s\', \'%s\', \'%s\')">%s</a>';
370: $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);
371:
372: $tpl->set('d', 'ID_PATH', $idDbfsPathPrefix . 'root');
373: $tpl->set('d', 'DATA_PATH', $pathstring);
374: $tpl->set('d', 'INDENT', 3);
375: $tpl->set('d', 'DIRNAME', $mstr);
376: $tpl->set('d', 'EDITBUTTON', '');
377: $tpl->set('d', 'DELETEBUTTON', '');
378: $tpl->set('d', 'COLLAPSE', '');
379: $tpl->next();
380:
381: $dbfsc = new cApiDbfsCollection();
382:
383: $dlevels = array();
384:
385: if (is_array($objects)) {
386: foreach ($objects as $a_file) {
387: $file = $a_file->getName();
388: $depth = $a_file->getCustom('level') - 1;
389: $pathstring = $a_file->getId();
390: $a_file->setCollapsedIcon('images/grid_expand.gif');
391: $a_file->setExpandedIcon('images/grid_collapse.gif');
392: $dlevels[$depth] = $a_file->getCustom('lastitem');
393: $collapse = getUplExpandCollapseButton($a_file);
394: $fileurl = rawurlencode($path . $file . '/');
395: $pathurl = rawurlencode($path);
396:
397: if ($file == 'tmp') {
398: echo 'tmp2<br>';
399: }
400:
401:
402: $indent = 18 + (($depth - 1) * 18);
403:
404:
405: $tmp_mstr = '<a href="javascript:Con.multiLink(\'%s\', \'%s\', \'%s\', \'%s\')">%s</a>';
406: $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);
407:
408: $hasFiles = $dbfsc->hasFiles($pathstring);
409:
410: if (!$hasFiles && $perm->have_perm_area_action($tmp_area, 'upl_rmdir')) {
411:
412:
413:
414:
415:
416:
417:
418:
419:
420:
421:
422:
423: $deletebutton = '
424: <a class="jsDelete" title="' . i18n("Delete directory") . '" href="javascript:void(0)">
425: <img class="vAlignMiddle" src="' . $cfg['path']['images'] . 'delete.gif" border="0" title="' . i18n("Delete directory") . '" alt="' . i18n("Delete directory") . '">
426: </a>';
427: } else {
428: if ($hasFiles) {
429: $message = i18n("Directory contains files");
430: } else {
431: $message = i18n("Permission denied");
432: }
433: $deletebutton = '<img class="vAlignMiddle" alt="" src="' . $cfg['path']['images'] . 'delete_inact.gif" border="0" alt="' . $message . '" title="' . $message . '">';
434: }
435:
436: $gline = '';
437: for ($i = 1; $i < $depth; $i++) {
438: if ($dlevels[$i] == false && $i != 0) {
439: $gline .= '<img class="vAlignMiddle" src="images/grid_linedown.gif" alt="" align="middle">';
440: } else {
441: $gline .= '<img class="vAlignMiddle" src="images/spacer.gif" width="18" height="18" alt="" align="middle">';
442: }
443: }
444:
445: $parent = str_replace($cfgClient[$client]['upl']['path'], '', $a_file->getCustom('parent'));
446:
447: $idAttrPath = str_replace(array(
448: '/',
449: ':'
450: ), array(
451: '_',
452: ''
453: ), trim($pathstring, '/'));
454: $tpl->set('d', 'ID_PATH', $idDbfsPathPrefix . $idAttrPath);
455: $tpl->set('d', 'DATA_PATH', $pathstring);
456: $tpl->set('d', 'INDENT', 0);
457: $tpl->set('d', 'DIRNAME', $mstr);
458: $tpl->set('d', 'EDITBUTTON', '');
459: $tpl->set('d', 'DELETEBUTTON', $deletebutton);
460: $tpl->set('d', 'COLLAPSE', $gline . $collapse);
461: $tpl->next();
462: }
463: }
464:
465: $pathPrefix = (cApiDbfs::isDbfs($path)) ? $idDbfsPathPrefix : $idFsPathPrefix;
466: $idAttrPath = str_replace(array(
467: '/',
468: ':'
469: ), array(
470: '_',
471: ''
472: ), trim($path, '/'));
473: $tpl->set('s', 'ID_PATH', $pathPrefix . $idAttrPath);
474: $tpl->set('s', 'DELETE_MSG', i18n("Do you really want to delete the following directory:") . '<b>{path}</b>');
475:
476: chdir(cRegistry::getBackendPath());
477:
478: $tpl->generate($cfg['path']['templates'] . $cfg['templates']['upl_dirs_overview']);
479: