1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13:
14:
15: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
16:
17: $backendPath = cRegistry::getBackendPath();
18:
19: cInclude('includes', 'api/functions.frontend.list.php');
20: cInclude('includes', 'functions.file.php');
21:
22: $page = new cGuiPage('upl_files_overview', '', 0);
23:
24:
25: if ((int) $client < 1) {
26: $page->displayCriticalError(i18n("No Client selected"));
27: $page->render();
28: return;
29: }
30:
31: $appendparameters = isset($_REQUEST['appendparameters']) ? $_REQUEST['appendparameters'] : '';
32: $file = isset($_REQUEST['file']) ? basename(cSecurity::escapeString($_REQUEST['file'])) : '';
33: $startpage = isset($_REQUEST['startpage']) ? cSecurity::toInteger($_REQUEST['startpage']) : 1;
34: $sortby = isset($_REQUEST['sortby']) ? cSecurity::escapeString($_REQUEST['sortby']) : '';
35: $sortmode = isset($_REQUEST['sortmode']) ? cSecurity::escapeString($_REQUEST['sortmode']) : '';
36: $thumbnailmode = isset($_REQUEST['thumbnailmode']) ? cSecurity::escapeString($_REQUEST['thumbnailmode']) : '';
37:
38: if ((empty($browserparameters) || !is_array($browserparameters)) && ($appendparameters != 'imagebrowser' || $appendparameters != 'filebrowser')) {
39: $browserparameters = array();
40: }
41:
42: if (!$sess->isRegistered('upl_last_path')) {
43:
44: $sess->register('upl_last_path');
45: } elseif (!isset($path)) {
46:
47: $path = $upl_last_path;
48: }
49:
50:
51:
52: if (empty($path) || (!cApiDbfs::isDbfs($path) && !cFileHandler::exists($cfgClient[$client]['upl']['path'] . $path))) {
53: $path = '';
54: }
55:
56: $upl_last_path = $path;
57:
58: $uploads = new cApiUploadCollection();
59:
60: $dbfs = new cApiDbfsCollection();
61:
62: if (cApiDbfs::isDbfs($path)) {
63: $qpath = $path . '/';
64: } else {
65: $qpath = $path;
66: }
67:
68: if ((is_writable($cfgClient[$client]['upl']['path'] . $path) || cApiDbfs::isDbfs($path)) && (int) $client > 0) {
69: $bDirectoryIsWritable = true;
70: } else {
71: $bDirectoryIsWritable = false;
72: }
73:
74: if ($action === 'upl_modify_file' && !empty($file)) {
75:
76: $extractFolder = NULL;
77: $uplPath = $cfgClient[$client]['upl']['path'];
78:
79: if (isset($_REQUEST['path']) && $_REQUEST['path'] != NULL) {
80: $uplPath .= cSecurity::escapeString($_REQUEST['path']);
81: }
82:
83: if (isset($_REQUEST['efolder']) && $_REQUEST['efolder'] != NULL) {
84: $extractFolder = cSecurity::escapeString($_REQUEST['efolder']);
85: }
86:
87: if (isset($_REQUEST['extractZip']) && !isset($_REQUEST['overwrite'])) {
88: $zipFile = $uplPath . cSecurity::escapeString($_REQUEST['file']);
89: cZipArchive::extract($zipFile, $uplPath, $extractFolder);
90: }
91: if (isset($_REQUEST['extractZip']) && isset($_REQUEST['overwrite'])) {
92: $zipFile = $uplPath . cSecurity::escapeString($_REQUEST['file']);
93: cZipArchive::extractOverRide($zipFile, $uplPath, $extractFolder);
94: }
95:
96: if ($bDirectoryIsWritable == true && count($_FILES) == 1 && ($_FILES['file']['size'] > 0) && ($_FILES['file']['name'] != '')) {
97: if ($_FILES['file']['tmp_name'] != '') {
98: $tmp_name = $_FILES['file']['tmp_name'];
99: $_cecIterator = $_cecRegistry->getIterator('Contenido.Upload.UploadPreprocess');
100:
101: if ($_cecIterator->count() > 0) {
102:
103: move_uploaded_file($tmp_name, $backendPath . $cfg['path']['temp'] . $file);
104: $tmp_name = $backendPath . $cfg['path']['temp'] . $file;
105:
106: while ($chainEntry = $_cecIterator->next()) {
107: if (cApiDbfs::isDbfs($path)) {
108: $sPathPrepend = '';
109: $sPathAppend = '/';
110: } else {
111: $sPathPrepend = $cfgClient[$client]['upl']['path'];
112: $sPathAppend = '';
113: }
114:
115: $modified = $chainEntry->execute($tmp_name, $sPathPrepend . $path . $sPathAppend . uplCreateFriendlyName($_FILES['file']['name']));
116:
117: if ($modified !== false) {
118: $tmp_name = $modified;
119: }
120: }
121: }
122:
123: if (cApiDbfs::isDbfs($path)) {
124: $dbfs->writeFromFile($tmp_name, $qpath . $file);
125: unlink($_FILES['file']['tmp_name']);
126: } else {
127: unlink($cfgClient[$client]['upl']['path'] . $path . $file);
128:
129: if (is_uploaded_file($tmp_name)) {
130: move_uploaded_file($tmp_name, $cfgClient[$client]['upl']['path'] . $path . $file);
131: } else {
132: rename($tmp_name, $cfgClient[$client]['upl']['path'] . $path . $file);
133: }
134: }
135: }
136: }
137:
138: $uploads->select("idclient = '$client' AND dirname='" . $uploads->escape($qpath) . "' AND filename='" . $uploads->escape($file) . "'");
139: $upload = $uploads->next();
140: if ($upload) {
141:
142: $upload->store();
143: }
144:
145: $protected = !empty($_REQUEST['protected']) && $_REQUEST['protected'] === '1' ? '1' : '';
146: $properties = new cApiPropertyCollection();
147: $properties->setValue('upload', $qpath . $file, 'file', 'protected', $protected);
148:
149: $timeMgmt = !empty($_REQUEST['timemgmt']) && $_REQUEST['timemgmt'] === '1' ? '1' : '';
150: $properties->setValue('upload', $qpath . $file, 'file', 'timemgmt', $timeMgmt);
151: if ($timeMgmt) {
152: $dateStart = !empty($_REQUEST['datestart']) ? cSecurity::escapeString($_REQUEST['datestart']) : '';
153: $dateEnd = !empty($_REQUEST['dateend']) ? cSecurity::escapeString($_REQUEST['dateend']) : '';
154: $properties->setValue('upload', $qpath . $file, 'file', 'datestart', $dateStart);
155: $properties->setValue('upload', $qpath . $file, 'file', 'dateend', $dateEnd);
156: }
157:
158: $author = $auth->auth['uid'];
159: $created = date('Y-m-d H:i:s');
160:
161: $iIdupl = is_object($upload) ? $upload->get('idupl') : 0;
162: if (!empty($iIdupl) && $iIdupl > 0) {
163:
164: $oUploadMeta = new cApiUploadMeta((int) $iIdupl);
165: if ($oUploadMeta->loadByUploadIdAndLanguageId($iIdupl, $lang)) {
166:
167: $oUploadMeta->set('medianame', $medianame);
168: $oUploadMeta->set('description', $description);
169: $oUploadMeta->set('keywords', $keywords);
170: $oUploadMeta->set('internal_notice', $medianotes);
171: $oUploadMeta->set('copyright', $copyright);
172: $oUploadMeta->set('modified', $created);
173: $oUploadMeta->set('modifiedby', $author);
174: $oUploadMeta->store();
175: } else {
176:
177: $oUploadMetaColl = new cApiUploadMetaCollection();
178: $oUploadMeta = $oUploadMetaColl->create($iIdupl, $lang, $medianame, $description, $keywords, $medianotes, $copyright, $author, $created, $created, $author);
179: }
180: }
181: }
182:
183: if ($action === 'upl_multidelete' && $perm->have_perm_area_action($area, $action) && $bDirectoryIsWritable === true) {
184: if (is_array($fdelete)) {
185:
186: $uploadObjects = array();
187:
188:
189: foreach ($fdelete as $fileNameToDelete) {
190: $fileNameToDelete = basename(cSecurity::escapeString($fileNameToDelete));
191: $uploads->select("idclient = '$client' AND dirname='" . $uploads->escape($qpath) . "' AND filename='" . $uploads->escape($fileNameToDelete) . "'");
192: if (false !== $item = $uploads->next()) {
193: if (cApiDbfs::isDbfs($qpath)) {
194: $dbfs->remove($qpath . $fileNameToDelete);
195:
196:
197: $_cecIterator = cRegistry::getCecRegistry()->getIterator('Contenido.Upl_edit.Delete');
198: if ($_cecIterator->count() > 0) {
199: while (false !== $chainEntry = $_cecIterator->next()) {
200: $chainEntry->execute($item->get('idupl'), $qpath, $fileNameToDelete);
201: }
202: }
203: } else {
204: $uploads->delete($item->get('idupl'));
205: }
206:
207:
208: array_push($uploadObjects, $item);
209: }
210: }
211:
212:
213: $_cecIterator = cRegistry::getCecRegistry()->getIterator('Contenido.Upl_edit.DeleteBatch');
214: if ($_cecIterator->count() > 0) {
215: while (false !== $chainEntry = $_cecIterator->next()) {
216: $chainEntry->execute($uploadObjects);
217: }
218: }
219: }
220: }
221:
222: if ($action === 'upl_delete' && !empty($file) && $perm->have_perm_area_action($area, $action) && $bDirectoryIsWritable === true) {
223:
224: $uploadObjects = array();
225:
226: $uploads->select("idclient = '$client' AND dirname='" . $uploads->escape($qpath) . "' AND filename='" . $uploads->escape($file) . "'");
227:
228:
229: if (false !== $item = $uploads->next()) {
230: if (cApiDbfs::isDbfs($qpath)) {
231: $dbfs->remove($qpath . $file);
232: } else {
233: unlink($cfgClient[$client]['upl']['path'] . $qpath . $file);
234: }
235:
236:
237: $_cecIterator = cRegistry::getCecRegistry()->getIterator('Contenido.Upl_edit.Delete');
238: if ($_cecIterator->count() > 0) {
239: while (false !== $chainEntry = $_cecIterator->next()) {
240: $chainEntry->execute($uploads->f('idupl'), $qpath, $file);
241:
242:
243: array_push($uploadObjects, $item);
244: }
245: }
246:
247:
248: $_cecIterator = cRegistry::getCecRegistry()->getIterator('Contenido.Upl_edit.DeleteBatch');
249: if ($_cecIterator->count() > 0) {
250: while (false !== $chainEntry = $_cecIterator->next()) {
251: $chainEntry->execute($uploadObjects);
252: }
253: }
254: }
255: }
256:
257: if ($action === 'upl_upload' && $bDirectoryIsWritable === true) {
258: if ($perm->have_perm_area_action($area, 'upl_upload')) {
259: if (count($_FILES) == 1) {
260: foreach ($_FILES['file']['name'] as $key => $value) {
261: if ($_FILES['file']['tmp_name'][$key] != '') {
262: $tmp_name = $_FILES['file']['tmp_name'][$key];
263: $_cecIterator = $_cecRegistry->getIterator('Contenido.Upload.UploadPreprocess');
264:
265: if ($_cecIterator->count() > 0) {
266:
267: move_uploaded_file($tmp_name, $backendPath . $cfg['path']['temp'] . $_FILES['file']['name'][$key]);
268: $tmp_name = $backendPath . $cfg['path']['temp'] . $_FILES['file']['name'][$key];
269:
270: while (false !== $chainEntry = $_cecIterator->next()) {
271: if (cApiDbfs::isDbfs($path)) {
272: $sPathPrepend = '';
273: $sPathAppend = '/';
274: } else {
275: $sPathPrepend = $cfgClient[$client]['upl']['path'];
276: $sPathAppend = '';
277: }
278:
279: $modified = $chainEntry->execute($tmp_name, $sPathPrepend . $path . $sPathAppend . uplCreateFriendlyName($_FILES['file']['name'][$key]));
280: if ($modified !== false) {
281: $tmp_name = $modified;
282: }
283: }
284: }
285:
286: if (cApiDbfs::isDbfs($qpath)) {
287: $dbfs->writeFromFile($tmp_name, $qpath . uplCreateFriendlyName($_FILES['file']['name'][$key]));
288: unlink($tmp_name);
289: } else {
290: if (is_uploaded_file($tmp_name)) {
291: $final_filename = $cfgClient[$client]['upl']['path'] . $path . uplCreateFriendlyName($_FILES['file']['name'][$key]);
292:
293: move_uploaded_file($tmp_name, $final_filename);
294:
295: $iterator = $_cecRegistry->getIterator('Contenido.Upload.UploadPostprocess');
296: while ($chainEntry = $iterator->next()) {
297: $chainEntry->execute($final_filename);
298: }
299: } else {
300: rename($tmp_name, $cfgClient[$client]['upl']['path'] . $path . uplCreateFriendlyName($_FILES['file']['name'][$key]));
301: }
302: }
303: }
304: }
305: }
306: } else {
307: $page->displayError(i18n("Permission denied"));
308: $page->render();
309: die();
310: }
311: }
312:
313: if ($action === 'upl_renamefile' && $bDirectoryIsWritable === true) {
314: $oldname = basename(cSecurity::escapeString($oldname));
315: $newname = basename(cSecurity::escapeString($newname));
316: rename($cfgClient[$client]['upl']['path'] . $path . $oldname, $cfgClient[$client]['upl']['path'] . $path . $newname);
317: }
318:
319: 320: 321: 322:
323: class UploadList extends FrontendList {
324:
325: 326: 327: 328:
329: protected $_dark;
330:
331: 332: 333: 334:
335: protected $_size;
336:
337: 338: 339:
340: protected $_data_count = 0;
341:
342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357:
358: public function convert($field, $data) {
359: global $path, $appendparameters, $startpage, $sortby, $sortmode, $thumbnailmode;
360:
361: $cfg = cRegistry::getConfig();
362: $sess = cRegistry::getSession();
363: $client = cRegistry::getClientId();
364: $cfgClient = cRegistry::getClientConfig();
365: $backendUrl = cRegistry::getBackendUrl();
366:
367: if ($field == 4) {
368: return humanReadableSize($data);
369: }
370:
371: if ($field == 3) {
372: if ($appendparameters == 'imagebrowser' || $appendparameters == 'filebrowser') {
373:
374:
375:
376: if (cApiDbfs::isDbfs($path . '/' . $data)) {
377: $mstr = '<a href="javascript://" onclick="parent.parent.frames[\'left\'].frames[\'left_top\'].document.getElementById(\'selectedfile\').value= \'' . $cfgClient[$client]['htmlpath']['frontend'] . 'dbfs.php?file=' . $path . '/' . $data . '\'; window.returnValue=\'' . $cfgClient[$client]['htmlpath']['frontend'] . 'dbfs.php?file=' . $path . '/' . $data . '\'; window.close();"><img alt="" src="' . $backendUrl . $cfg['path']['images'] . 'but_ok.gif" title="' . i18n("Use file") . '"> ' . $data . '</a>';
378: } else {
379: $mstr = '<a href="javascript://" onclick="parent.parent.frames[\'left\'].frames[\'left_top\'].document.getElementById(\'selectedfile\').value= \'' . $cfgClient[$client]['htmlpath']['frontend'] . $cfgClient[$client]['upl']['frontendpath'] . $path . $data . '\'; window.returnValue=\'' . $cfgClient[$client]['htmlpath']['frontend'] . $cfgClient[$client]['upl']['frontendpath'] . $path . $data . '\'; window.close();"><img alt="" src="' . $backendUrl . $cfg['path']['images'] . 'but_ok.gif" title="' . i18n("Use file") . '"> ' . $data . '</a>';
380: }
381: } else {
382: $tmp_mstr = '<a onmouseover="this.style.cursor=\'pointer\'" href="javascript:Con.multiLink(\'%s\', \'%s\', \'%s\', \'%s\')">%s</a>';
383: $mstr = sprintf($tmp_mstr, 'right_bottom', $sess->url("main.php?area=upl_edit&frame=4&path=$path&file=$data&appendparameters=$appendparameters&startpage=" . $startpage . "&sortby=" . $sortby . "&sortmode=" . $sortmode . "&thumbnailmode=" . $thumbnailmode), 'right_top', $sess->url("main.php?area=upl&frame=3&path=$path&file=$data"), $data);
384: }
385: return $mstr;
386: }
387:
388: if ($field == 5) {
389: return uplGetFileTypeDescription($data);
390: }
391:
392: if ($field == 2) {
393:
394: $fileType = cString::toLowerCase(cFileHandler::getExtension($data));
395: switch ($fileType) {
396: case 'png':
397: case 'gif':
398: case 'tiff':
399: case 'bmp':
400: case 'jpeg':
401: case 'jpg':
402: case 'iff':
403: case 'xbm':
404: case 'wbmp':
405: $frontendURL = cRegistry::getFrontendUrl();
406:
407: $sCacheThumbnail = uplGetThumbnail($data, 150);
408: $sCacheName = basename($sCacheThumbnail);
409: $sFullPath = $cfgClient[$client]['cache']['path'] . $sCacheName;
410: if (cFileHandler::isFile($sFullPath)) {
411: $aDimensions = getimagesize($sFullPath);
412: $iWidth = $aDimensions[0];
413: $iHeight = $aDimensions[1];
414: } else {
415: $iWidth = 0;
416: $iHeight = 0;
417: }
418:
419: if (cApiDbfs::isDbfs($data)) {
420: $href = $frontendURL . 'dbfs.php?file=' . $data;
421: } else {
422: $href = $frontendURL . $cfgClient[$client]['upload'] . $data;
423: }
424: $retValue = '<a class="jsZoom" href="' . $href . '">
425: <img class="hover" name="smallImage" alt="" src="' . $sCacheThumbnail . '" data-width="' . $iWidth . '" data-height="' . $iHeight . '">
426: <img class="preview" name="prevImage" alt="" src="' . $sCacheThumbnail . '">
427: </a>';
428: return $retValue;
429: break;
430: default:
431: $sCacheThumbnail = uplGetThumbnail($data, 150);
432: return '<img class="hover_none" name="smallImage" alt="" src="' . $sCacheThumbnail . '">';
433: }
434: }
435:
436: return $data;
437: }
438:
439: 440: 441:
442: public function getSize() {
443: return $this->_size;
444: }
445:
446: 447: 448:
449: public function setSize($size) {
450: $this->_size = $size;
451: }
452:
453: 454: 455: 456:
457: public function setDataCount($totalUploadsCount) {
458: $this->_data_count = $totalUploadsCount;
459: }
460:
461: 462: 463: 464: 465:
466: public function getNumPages() {
467: if ($this->_data_count > 0) {
468: return ceil($this->_data_count / $this->_resultsPerPage);
469: }
470:
471: return parent::getNumPages();
472: }
473:
474: 475: 476: 477: 478: 479: 480: 481: 482: 483: 484: 485:
486: public function output($return = false) {
487:
488: if ($this->_data_count === 0) {
489: return parent::output($return);
490: }
491:
492:
493:
494: $output = $this->_startwrap;
495:
496: $count = count($this->_data);
497:
498: for ($i = 1; $i <= $count; $i++) {
499: if (is_array($this->_data[$i - 1])) {
500: $items = "";
501: foreach ($this->_data[$i - 1] as $key => $value) {
502: $items .= ", '" . addslashes($this->convert($key, $value)) . "'";
503: }
504:
505: $execute = '$output .= sprintf($this->_itemwrap ' . $items . ');';
506: eval($execute);
507: }
508: }
509:
510: $output .= $this->_endwrap;
511:
512: $output = stripslashes($output);
513:
514: if ($return == true) {
515: return $output;
516: } else {
517: echo $output;
518: }
519: }
520:
521: }
522:
523: uplSyncDirectory($path);
524:
525: if ($sortby == '') {
526: $sortby = 3;
527: $sortmode = 'ASC';
528: }
529:
530: if ($startpage == '') {
531: $startpage = 1;
532: }
533:
534: $thisfile = $sess->url("main.php?idarea=$area&frame=$frame&path=$path&thumbnailmode=$thumbnailmode&appendparameters=$appendparameters");
535: $scrollthisfile = $thisfile . "&sortmode=$sortmode&sortby=$sortby&appendparameters=$appendparameters";
536:
537: if ($sortby == 3 && $sortmode == 'DESC') {
538: $fnsort = '<a class="gray" href="' . $thisfile . '&sortby=3&sortmode=ASC&startpage=' . $startpage . '">' . i18n("Filename / Description") . '<img src="images/sort_down.gif" alt="" border="0"></a>';
539: } else {
540: if ($sortby == 3) {
541: $fnsort = '<a class="gray" href="' . $thisfile . '&sortby=3&sortmode=DESC&startpage=' . $startpage . '">' . i18n("Filename / Description") . '<img src="images/sort_up.gif" alt="" border="0"></a>';
542: } else {
543: $fnsort = '<a class="gray" href="' . $thisfile . '&sortby=3&sortmode=ASC&startpage=' . $startpage . '">' . i18n("Filename / Description") . '</a>';
544: }
545: }
546:
547: if ($sortby == 4 && $sortmode == 'DESC') {
548: $sizesort = '<a class="gray" href="' . $thisfile . '&sortby=4&sortmode=ASC&startpage=' . $startpage . '">' . i18n("Size") . '<img src="images/sort_down.gif" alt="" border="0"></a>';
549: } else {
550: if ($sortby == 4) {
551: $sizesort = '<a class="gray" href="' . $thisfile . '&sortby=4&sortmode=DESC&startpage=' . $startpage . '">' . i18n("Size") . '<img src="images/sort_up.gif" alt="" border="0"></a>';
552: } else {
553: $sizesort = '<a class="gray" href="' . $thisfile . '&sortby=4&sortmode=ASC&startpage=' . $startpage . '">' . i18n("Size") . "</a>";
554: }
555: }
556:
557: if ($sortby == 5 && $sortmode == 'DESC') {
558: $typesort = '<a class="gray" href="' . $thisfile . '&sortby=5&sortmode=ASC&startpage=' . $startpage . '">' . i18n("Type") . '<img src="images/sort_down.gif" alt="" border="0"></a>';
559: } else {
560: if ($sortby == 5) {
561: $typesort = '<a class="gray" class="gray" href="' . $thisfile . '&sortby=5&sortmode=DESC&startpage=' . $startpage . '">' . i18n("Type") . '<img src="images/sort_up.gif" alt="" border="0"></a>';
562: } else {
563: $typesort = '<a class="gray" href="' . $thisfile . '&sortby=5&sortmode=ASC&startpage=' . $startpage . '">' . i18n("Type") . "</a>";
564: }
565: }
566:
567:
568: if ($perm->have_perm_area_action('upl', 'upl_multidelete') && $bDirectoryIsWritable == true) {
569: $sConfirmation = "Con.showConfirmation('" . i18n('Are you sure you want to delete the selected files?') . "', function() { document.del.action.value = \'upl_multidelete\'; document.del.submit(); });return false;";
570: $sDelete = '<a class="tableElement vAlignMiddle" href="javascript:void(0)" onclick="' . $sConfirmation . '"><img class="tableElement vAlignMiddle" src="images/delete.gif" title="' . i18n("Delete selected files") . '" alt="' . i18n("Delete selected files") . '" onmouseover="this.style.cursor=\'pointer\'"><span class="tableElement">' . i18n("Delete selected files") . '</span></a>';
571: } else {
572: $sDelete = '';
573: }
574:
575: if (cApiDbfs::isDbfs($path)) {
576: $mpath = $path . '/';
577: } else {
578: $mpath = 'upload/' . $path;
579: }
580:
581: $sDisplayPath = generateDisplayFilePath($mpath, 85);
582:
583: $sToolsRow = '<tr>
584: <th colspan="6" id="cat_navbar">
585: <a class="tableElement vAlignMiddle" href="javascript:invertSelection();"><img class="tableElement vAlignMiddle" src="images/but_invert_selection.gif" title="' . i18n("Flip Selection") . '" alt="' . i18n("Flip Selection") . '" onmouseover="this.style.cursor=\'pointer\'"> ' . i18n("Flip Selection") . '</a>
586: ' . $sDelete . '
587: <div class="toolsRight">
588: ' . i18n("Path:") . " " . $sDisplayPath . '
589: </div>
590: </th>
591: </tr>';
592: $sSpacedRow = '<tr height="10">
593: <td colspan="6" class="emptyCell"></td>
594: </tr>';
595:
596:
597:
598: $pagerwrap = '<tr>
599: <th colspan="6" id="cat_navbar">
600: <div class="toolsRight">
601: <div class="vAlignMiddle">-C-SCROLLLEFT-</div>
602: <div class="vAlignMiddle">-C-PAGE-</div>
603: <div class="vAlignMiddle">-C-SCROLLRIGHT-</div>
604: </div>
605: <span class="vAlignMiddle">' . i18n("Files per Page") . ' -C-FILESPERPAGE-</span>
606: </th>
607: </tr>';
608:
609: $startwrap = '<table class="hoverbox generic" cellspacing="0" cellpadding="2" border="0">
610: ' . $pagerwrap . $sSpacedRow . $sToolsRow . $sSpacedRow . '
611: <tr>
612: <th>' . i18n("Mark") . '</th>
613: <th>' . i18n("Preview") . '</th>
614: <th width="100%">' . $fnsort . '</th>
615: <th>' . $sizesort . '</th>
616: <th>' . $typesort . '</th>
617: <th>' . i18n("Actions") . '</th>
618: </tr>';
619: $itemwrap = '<tr>
620: <td align="center">%s</td>
621: <td align="center">%s</td>
622: <td class="vAlignTop nowrap">%s</td>
623: <td class="vAlignTop nowrap">%s</td>
624: <td class="vAlignTop nowrap">%s</td>
625: <td class="vAlignTop nowrap">%s</td>
626: </tr>';
627: $endwrap = $sSpacedRow . $sToolsRow . $sSpacedRow . $pagerwrap . '</table>';
628:
629:
630: $list2 = new UploadList($startwrap, $endwrap, $itemwrap);
631:
632: $uploads = new cApiUploadCollection();
633:
634:
635: if (cString::getPartOfString($path, cString::getStringLength($path) - 1, 1) != "/") {
636: if ($path != "") {
637: $qpath = $path . "/";
638: } else {
639:
640: $qpath = "";
641: }
642: } else {
643: $qpath = $path;
644: }
645:
646: $uploads->select("idclient = '$client' AND dirname = '$qpath'");
647:
648: $user = new cApiUser($auth->auth['uid']);
649:
650: if ($thumbnailmode == '') {
651: $current_mode = $user->getUserProperty('upload_folder_thumbnailmode', md5($path));
652: if ($current_mode != '') {
653: $thumbnailmode = $current_mode;
654: } else {
655: $thumbnailmode = getEffectiveSetting('backend', 'thumbnailmode', 100);
656: }
657: }
658:
659: switch ($thumbnailmode) {
660: case 10:
661: $numpics = 10;
662: break;
663: case 25:
664: $numpics = 25;
665: break;
666: case 50:
667: $numpics = 50;
668: break;
669: case 100:
670: $numpics = 100;
671: break;
672: case 200:
673: $numpics = 200;
674: break;
675: default:
676: $thumbnailmode = 100;
677: $numpics = 15;
678: break;
679: }
680:
681: $user->setUserProperty('upload_folder_thumbnailmode', md5($path), $thumbnailmode);
682:
683: $list2->setResultsPerPage($numpics);
684: $list2->setSize($thumbnailmode);
685:
686: $totalUploadsCount = $uploads->count();
687: $list2->setDataCount($totalUploadsCount);
688:
689: if ($startpage > $list2->getNumPages()) {
690: $startpage = $list2->getNumPages();
691: }
692:
693: if ($startpage < 1) {
694: $startpage = 1;
695: }
696:
697: $uploads->resetQuery();
698: $uploads->select("idclient = '$client' AND dirname = '$qpath'", '', '', $numpics * ($startpage - 1) . ", " . $numpics);
699:
700: $rownum = 0;
701:
702: $properties = new cApiPropertyCollection();
703:
704: while ($item = $uploads->next()) {
705:
706:
707: $dirname = $item->get('dirname');
708: $filename = $item->get('filename');
709: $filesize = $item->get('size');
710:
711:
712: if (true === cDirHandler::exists($cfgClient[$client]['upl']['path'] . $dirname . $filename) || cString::findFirstPos($filename, ".") === 0) {
713: continue;
714: }
715:
716: $bAddFile = true;
717:
718: if ($appendparameters == 'imagebrowser') {
719: $restrictvar = 'restrict_' . $appendparameters;
720: if (array_key_exists($restrictvar, $browserparameters)) {
721: $fileType = cString::toLowerCase(cFileHandler::getExtension($filename));
722: if (count($browserparameters[$restrictvar]) > 0) {
723: $bAddFile = false;
724: if (in_array($fileType, $browserparameters[$restrictvar])) {
725: $bAddFile = true;
726: }
727: }
728: }
729: }
730:
731: if ($filesize == 0) {
732: if (cFileHandler::exists($cfgClient[$client]['upl']['path'] . $dirname . $filename)) {
733: $filesize = filesize($cfgClient[$client]['upl']['path'] . $dirname . $filename);
734: }
735: }
736:
737: $actions = '';
738:
739: $medianame = $properties->getValue('upload', $path . $filename, 'file', 'medianame');
740: $medianotes = $properties->getValue('upload', $path . $filename, 'file', 'medianotes');
741:
742: $todo = new TODOLink('upload', $path . $filename, "File $path$filename", '');
743:
744: $proptitle = i18n("Display properties");
745:
746: if ($appendparameters == 'imagebrowser' || $appendparameters == 'filebrowser') {
747: $mstr = '';
748: } else {
749: $tmp_mstr = '<a href="javascript:Con.multiLink(\'%s\', \'%s\', \'%s\', \'%s\')">%s</a>';
750: $mstr = sprintf($tmp_mstr, 'right_bottom', $sess->url("main.php?area=upl_edit&frame=4&path=$path&file=$filename&startpage=$startpage&sortby=$sortby&sortmode=$sortmode&thumbnailmode=$thumbnailmode"), 'right_top', $sess->url("main.php?area=upl&frame=3&path=$path&file=$filename"), '<img class="vAlignMiddle tableElement" alt="' . $proptitle . '" title="' . $proptitle . '" src="images/but_art_conf2.gif" onmouseover="this.style.cursor=\'pointer\'">');
751: }
752:
753: $actions = $mstr . $actions;
754:
755: $showfilename = $filename;
756:
757: $check = new cHTMLCheckbox('fdelete[]', $filename);
758:
759: $mark = $check->toHtml(false);
760:
761: if ($bAddFile == true) {
762:
763: $list2->setData($rownum, $mark, $dirname . $filename, $showfilename, $filesize, cString::toLowerCase(cFileHandler::getExtension($filename)), $todo->render() . $actions);
764: $rownum++;
765: }
766: }
767:
768: if ($rownum == 0) {
769: header('Location: ' . cRegistry::getBackendUrl() . 'main.php?area=upl_upload&frame=4&path=' . $path . '&contenido=' . $contenido . '&appendparameters=' . $appendparameters);
770: }
771:
772: if ($sortmode == 'ASC') {
773: $list2->sort($sortby, SORT_ASC);
774: } else {
775: $list2->sort($sortby, SORT_DESC);
776: }
777:
778: $list2->setListStart($startpage);
779:
780:
781: if ($list2->getCurrentPage() > 1) {
782: $prevpage = '<a href="' . $scrollthisfile . '&startpage=' . ($list2->getCurrentPage() - 1) . '" class="invert_hover">' . i18n("Previous Page") . '</a>';
783: } else {
784: $prevpage = ' ';
785: }
786:
787: if ($list2->getCurrentPage() < $list2->getNumPages()) {
788: $nextpage = '<a href="' . $scrollthisfile . '&startpage=' . ($list2->getCurrentPage() + 1) . '" class="invert_hover">' . i18n("Next Page") . '</a>';
789: } else {
790: $nextpage = ' ';
791: }
792:
793:
794:
795: if ($list2->getNumPages() > 1) {
796: $num_pages = $list2->getNumPages();
797:
798: $paging_form .= "<script type=\"text/javascript\">
799: function jumpToPage(select) {
800: var pagenumber = select.selectedIndex + 1;
801: url = '" . $sess->url('main.php') . "';
802: document.location.href = url + '&area=upl&frame=4&appendparameters=$appendparameters&path=$path&sortmode=$sortmode&sortby=$sortby&thumbnailmode=$thumbnailmode&startpage=' + pagenumber;
803: }
804: </script>";
805: $paging_form .= "<select name=\"start_page\" class=\"text_medium\" onChange=\"jumpToPage(this);\">";
806: for ($i = 1; $i <= $num_pages; $i++) {
807: if ($i == $startpage) {
808: $selected = ' selected';
809: } else {
810: $selected = '';
811: }
812: $paging_form .= "<option value=\"$i\"$selected>$i</option>";
813: }
814:
815: $paging_form .= '</select>';
816: } else {
817: $paging_form = '1';
818: }
819: $curpage = $paging_form . ' / ' . $list2->getNumPages();
820:
821: $scroller = $prevpage . $nextpage;
822: $output = $list2->output(true);
823: $output = str_replace('-C-SCROLLLEFT-', $prevpage, $output);
824: $output = str_replace('-C-SCROLLRIGHT-', $nextpage, $output);
825: $output = str_replace('-C-PAGE-', i18n("Page") . ' ' . $curpage, $output);
826:
827: $select = new cHTMLSelectElement('thumbnailmode');
828:
829: $values = array(
830: 10 => '10',
831: 25 => '25',
832: 50 => '50',
833: 100 => '100',
834: 200 => '200'
835: );
836:
837: $select->autoFill($values);
838:
839: $select->setDefault($thumbnailmode);
840: $select->setEvent('change', "if (document.del.thumbnailmode[0] != 'undefined') document.del.thumbnailmode[0].value = this.value; if (document.del.thumbnailmode[1] != 'undefined') document.del.thumbnailmode[1].value = this.value; if (document.del.thumbnailmode[2] != 'undefined') document.del.thumbnailmode[2].value = this.value;");
841:
842: $topbar = $select->render() . '<input class="vAlignMiddle tableElement" type="image" onmouseover="this.style.cursor=\'pointer\'" src="images/submit.gif">';
843:
844: $output = str_replace('-C-FILESPERPAGE-', $topbar, $output);
845:
846: $delform = new cHTMLForm('del');
847: $delform->setVar('area', $area);
848: $delform->setVar('action', '');
849: $delform->setVar('startpage', $startpage);
850: $delform->setVar('thumbnailmode', $thumbnailmode);
851: $delform->setVar('sortmode', $sortmode);
852: $delform->setVar('sortby', $sortby);
853: $delform->setVar('appendparameters', $appendparameters);
854: $delform->setVar('path', $path);
855: $delform->setVar('frame', 4);
856:
857: $delform->appendContent($output);
858:
859: $page->addScript($sess->url('iZoom.js.php'));
860:
861: if ($bDirectoryIsWritable == false) {
862: $page->displayError(i18n("Directory not writable") . ' (' . $cfgClient[$client]['upl']['path'] . $path . ')');
863: }
864:
865: $page->setContent(array(
866: $delform
867: ));
868:
869: $page->render();
870: