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: $backendPath = cRegistry::getBackendPath();
19:
20: cInclude('includes', 'api/functions.frontend.list.php');
21: cInclude('includes', 'functions.file.php');
22: cInclude('classes', 'class.cziparchive.php');
23:
24:
25:
26: if (!(int) $client > 0) {
27:
28: $oPage = new cGuiPage('upl_files_overview');
29: $oPage->render();
30: return;
31: }
32:
33: $page = new cGuiPage('upl_files_overview', '', 0);
34:
35: $appendparameters = $_REQUEST['appendparameters'];
36: $file = $_REQUEST['file'];
37:
38: if (!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: if (!cApiDbfs::isDbfs($path) && !cFileHandler::exists($cfgClient[$client]['upl']['path'] . $path)) {
52: $path = '';
53: }
54:
55: $upl_last_path = $path;
56:
57: $uploads = new cApiUploadCollection();
58:
59: $dbfs = new cApiDbfsCollection();
60:
61: if (cApiDbfs::isDbfs($path)) {
62: $qpath = $path . '/';
63: } else {
64: $qpath = $path;
65: }
66:
67: if ((is_writable($cfgClient[$client]['upl']['path'] . $path) || cApiDbfs::isDbfs($path)) && (int) $client > 0) {
68: $bDirectoryIsWritable = true;
69: } else {
70: $bDirectoryIsWritable = false;
71: }
72:
73:
74: if ($action == 'upl_modify_file') {
75:
76: $extractFolder = NULL;
77: $uplPath = $cfgClient[$client]['upl']['path'];
78:
79: if (isset($_REQUEST['path']) && $_REQUEST['path'] != NULL) {
80: $uplPath .= $_REQUEST['path'];
81: }
82:
83: if (isset($_REQUEST['efolder']) && $_REQUEST['efolder'] != NULL) {
84: $extractFolder = $_REQUEST['efolder'];
85: }
86:
87: if (isset($_REQUEST['extractZip']) && !isset($_REQUEST['overwrite'])) {
88: $zipFile = $uplPath . $_REQUEST['file'];
89: cZipArchive::extract($zipFile, $uplPath, $extractFolder);
90: }
91: if (isset($_REQUEST['extractZip']) && isset($_REQUEST['overwrite'])) {
92: $zipFile = $uplPath . $_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: $sPathApppend = '/';
110: } else {
111: $sPathPrepend = $cfgClient[$client]['upl']['path'];
112: $sPathApppend = '';
113: }
114:
115: $modified = $chainEntry->execute($tmp_name, $sPathPrepend . $path . $sPathApppend . 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 = '$qpath' AND filename='$file'");
139: $upload = $uploads->next();
140:
141:
142: $upload->store();
143:
144: $properties = new cApiPropertyCollection();
145: $properties->setValue('upload', $qpath . $file, 'file', 'protected', stripslashes($protected));
146:
147: $bTimeMng = (isset($_REQUEST['timemgmt']) && strlen($_REQUEST['timemgmt']) > 1);
148: $properties->setValue('upload', $qpath . $file, 'file', 'timemgmt', ($bTimeMng) ? 1 : 0);
149: if ($bTimeMng) {
150: $properties->setValue('upload', $qpath . $file, 'file', 'datestart', $_REQUEST['datestart']);
151: $properties->setValue('upload', $qpath . $file, 'file', 'dateend', $_REQUEST['dateend']);
152: }
153:
154: $author = $auth->auth['uid'];
155: $created = date('Y-m-d H:i:s');
156:
157: $iIdupl = $upload->get('idupl');
158: if (!empty($iIdupl) && $iIdupl > 0) {
159:
160: $oUploadMeta = new cApiUploadMeta((int) $iIdupl);
161: if ($oUploadMeta->loadByUploadIdAndLanguageId($iIdupl, $lang)) {
162:
163: $oUploadMeta->set('medianame', $medianame);
164: $oUploadMeta->set('description', $description);
165: $oUploadMeta->set('keywords', $keywords);
166: $oUploadMeta->set('internal_notice', $medianotes);
167: $oUploadMeta->set('copyright', $copyright);
168: $oUploadMeta->set('modified', $created);
169: $oUploadMeta->set('modifiedby', $author);
170: $oUploadMeta->store();
171: } else {
172:
173: $oUploadMetaColl = new cApiUploadMetaCollection();
174: $oUploadMeta = $oUploadMetaColl->create($iIdupl, $lang, $medianame, $description, $keywords, $medianotes, $copyright, $author, $created, $created, $author);
175: }
176: }
177: }
178:
179: if ($action == 'upl_multidelete' && $perm->have_perm_area_action($area, $action) && $bDirectoryIsWritable == true) {
180: if (is_array($fdelete)) {
181:
182: $uploadObjects = array();
183:
184:
185: foreach ($fdelete as $file) {
186: $uploads->select("idclient = '$client' AND dirname='$qpath' AND filename='$file'");
187: if (false !== $item = $uploads->next()) {
188: if (cApiDbfs::isDbfs($qpath)) {
189: $dbfs->remove($qpath . $file);
190:
191:
192: $_cecIterator = cRegistry::getCecRegistry()->getIterator('Contenido.Upl_edit.Delete');
193: if ($_cecIterator->count() > 0) {
194: while (false !== $chainEntry = $_cecIterator->next()) {
195: $chainEntry->execute($item->get('idupl'), $qpath, $file);
196: }
197: }
198: } else {
199: $uploads->delete($item->get('idupl'));
200: }
201:
202:
203: array_push($uploadObjects, $item);
204: }
205: }
206:
207:
208: $_cecIterator = cRegistry::getCecRegistry()->getIterator('Contenido.Upl_edit.DeleteBatch');
209: if ($_cecIterator->count() > 0) {
210: while (false !== $chainEntry = $_cecIterator->next()) {
211: $chainEntry->execute($uploadObjects);
212: }
213: }
214: }
215: }
216:
217: if ($action == 'upl_delete' && $perm->have_perm_area_action($area, $action) && $bDirectoryIsWritable == true) {
218:
219: $uploadObjects = array();
220:
221: $uploads->select("idclient = '$client' AND dirname='$qpath' AND filename='$file'");
222:
223:
224: if (false !== $item = $uploads->next()) {
225: if (cApiDbfs::isDbfs($qpath)) {
226: $dbfs->remove($qpath . $file);
227: } else {
228: unlink($cfgClient[$client]['upl']['path'] . $qpath . $file);
229: }
230:
231:
232: $_cecIterator = cRegistry::getCecRegistry()->getIterator('Contenido.Upl_edit.Delete');
233: if ($_cecIterator->count() > 0) {
234: while (false !== $chainEntry = $_cecIterator->next()) {
235: $chainEntry->execute($uploads->f('idupl'), $qpath, $file);
236:
237:
238: array_push($uploadObjects, $item);
239: }
240: }
241:
242:
243: $_cecIterator = cRegistry::getCecRegistry()->getIterator('Contenido.Upl_edit.DeleteBatch');
244: if ($_cecIterator->count() > 0) {
245: while (false !== $chainEntry = $_cecIterator->next()) {
246: $chainEntry->execute($uploadObjects);
247: }
248: }
249: }
250: }
251:
252: if ($action == 'upl_upload' && $bDirectoryIsWritable == true) {
253: if ($perm->have_perm_area_action($area, 'upl_upload')) {
254: if (count($_FILES) == 1) {
255: foreach ($_FILES['file']['name'] as $key => $value) {
256: if (isUtf8($_FILES['file']['name'][$key])) {
257: $_FILES['file']['name'][$key] = utf8_decode($_FILES['file']['name'][$key]);
258: }
259: if ($_FILES['file']['tmp_name'][$key] != '') {
260: $tmp_name = $_FILES['file']['tmp_name'][$key];
261: $_cecIterator = $_cecRegistry->getIterator('Contenido.Upload.UploadPreprocess');
262:
263: if ($_cecIterator->count() > 0) {
264:
265: move_uploaded_file($tmp_name, $backendPath . $cfg['path']['temp'] . $_FILES['file']['name'][$key]);
266: $tmp_name = $backendPath . $cfg['path']['temp'] . $_FILES['file']['name'][$key];
267:
268: while ($chainEntry = $_cecIterator->next()) {
269: if (cApiDbfs::isDbfs($path)) {
270: $sPathPrepend = '';
271: $sPathApppend = '/';
272: } else {
273: $sPathPrepend = $cfgClient[$client]['upl']['path'];
274: $sPathApppend = '';
275: }
276:
277: $modified = $chainEntry->execute($tmp_name, $sPathPrepend . $path . $sPathApppend . uplCreateFriendlyName($_FILES['file']['name'][$key]));
278: if ($modified !== false) {
279: $tmp_name = $modified;
280: }
281: }
282: }
283:
284: if (cApiDbfs::isDbfs($qpath)) {
285: $dbfs->writeFromFile($tmp_name, $qpath . uplCreateFriendlyName($_FILES['file']['name'][$key]));
286: unlink($tmp_name);
287: } else {
288: if (is_uploaded_file($tmp_name)) {
289: $final_filename = $cfgClient[$client]['upl']['path'] . $path . uplCreateFriendlyName($_FILES['file']['name'][$key]);
290:
291: move_uploaded_file($tmp_name, $final_filename);
292:
293: $iterator = $_cecRegistry->getIterator('Contenido.Upload.UploadPostprocess');
294: while ($chainEntry = $iterator->next()) {
295: $chainEntry->execute($final_filename);
296: }
297: } else {
298: rename($tmp_name, $cfgClient[$client]['upl']['path'] . $path . uplCreateFriendlyName($_FILES['file']['name'][$key]));
299: }
300: }
301: }
302: }
303: }
304: } else {
305: $page->displayError(i18n("Permission denied"));
306: $page->render();
307: die();
308: }
309: }
310:
311: if ($action == 'upl_renamefile' && $bDirectoryIsWritable == true) {
312: $newname = str_replace('/', '', $newname);
313: rename($cfgClient[$client]['upl']['path'] . $path . $oldname, $cfgClient[$client]['upl']['path'] . $path . $newname);
314: }
315:
316: class UploadList extends FrontendList {
317:
318: var $dark;
319: var $size;
320:
321: function convert($field, $data) {
322: global $cfg, $path, $sess, $cfgClient, $client, $appendparameters;
323:
324: $backendUrl = cRegistry::getBackendUrl();
325:
326: if ($field == 4) {
327: return humanReadableSize($data);
328: }
329:
330: if ($field == 3) {
331: if ($appendparameters == 'imagebrowser' || $appendparameters == 'filebrowser') {
332:
333:
334:
335: if (cApiDbfs::isDbfs($path . '/' . $data)) {
336: $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 src="' . $backendUrl . $cfg['path']['images'] . 'but_ok.gif" title="' . i18n("Use file") . '"> ' . $data . '</a>';
337: } else {
338: $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 src="' . $backendUrl . $cfg['path']['images'] . 'but_ok.gif" title="' . i18n("Use file") . '"> ' . $data . '</a>';
339: }
340: } else {
341: $tmp_mstr = '<a onmouseover="this.style.cursor=\'pointer\'" href="javascript:Con.multiLink(\'%s\', \'%s\', \'%s\', \'%s\')">%s</a>';
342: $mstr = sprintf($tmp_mstr, 'right_bottom', $sess->url("main.php?area=upl_edit&frame=4&path=$path&file=$data&appendparameters=$appendparameters&startpage=" . $_REQUEST['startpage'] . "&sortby=" . $_REQUEST['sortby'] . "&sortmode=" . $_REQUEST['sortmode'] . "&thumbnailmode=" . $_REQUEST['thumbnailmode']), 'right_top', $sess->url("main.php?area=upl&frame=3&path=$path&file=$data"), $data);
343: }
344: return $mstr;
345: }
346:
347: if ($field == 5) {
348: return uplGetFileTypeDescription($data);
349: }
350:
351: if ($field == 2) {
352:
353: $fileType = strtolower(getFileType($data));
354: switch ($fileType) {
355: case 'png':
356: case 'gif':
357: case 'tiff':
358: case 'bmp':
359: case 'jpeg':
360: case 'jpg':
361: case 'iff':
362: case 'xbm':
363: case 'wbmp':
364: $frontendURL = cRegistry::getFrontendUrl();
365:
366: $sCacheThumbnail = uplGetThumbnail($data, 150);
367: $sCacheName = substr($sCacheThumbnail, strrpos($sCacheThumbnail, '/') + 1, strlen($sCacheThumbnail) - (strrchr($sCacheThumbnail, '/') + 1));
368: $sFullPath = $cfgClient[$client]['cache']['path'] . $sCacheName;
369: if (cFileHandler::exists($sFullPath)) {
370: $aDimensions = getimagesize($sFullPath);
371: $iWidth = $aDimensions[0];
372: $iHeight = $aDimensions[1];
373: } else {
374: $iWidth = 0;
375: $iHeight = 0;
376: }
377:
378: if (cApiDbfs::isDbfs($data)) {
379: $href = $frontendURL . 'dbfs.php?file=' . $data;
380: } else {
381: $href = $frontendURL . $cfgClient[$client]['upload'] . $data;
382: }
383: $retValue = '<a class="jsZoom" href="' . $href . '">
384: <img class="hover" name="smallImage" src="' . $sCacheThumbnail . '" data-width="' . $iWidth . '" data-height="' . $iHeight . '">
385: <img class="preview" name="prevImage" src="' . $sCacheThumbnail . '">
386: </a>';
387: return $retValue;
388: break;
389: default:
390: $sCacheThumbnail = uplGetThumbnail($data, 150);
391: return '<img class="hover_none" name="smallImage" src="' . $sCacheThumbnail . '">';
392: }
393: }
394:
395: return $data;
396: }
397:
398: }
399:
400: uplSyncDirectory($path);
401:
402: if ($sortby == '') {
403: $sortby = 3;
404: $sortmode = 'ASC';
405: }
406:
407: if ($startpage == '') {
408: $startpage = 1;
409: }
410:
411: $thisfile = $sess->url("main.php?idarea=$area&frame=$frame&path=$path&thumbnailmode=$thumbnailmode&appendparameters=$appendparameters");
412: $scrollthisfile = $thisfile . "&sortmode=$sortmode&sortby=$sortby&appendparameters=$appendparameters";
413:
414: if ($sortby == 3 && $sortmode == 'DESC') {
415: $fnsort = '<a class="gray" href="' . $thisfile . '&sortby=3&sortmode=ASC&startpage=' . $startpage . '">' . i18n("Filename / Description") . '<img src="images/sort_down.gif" border="0"></a>';
416: } else {
417: if ($sortby == 3) {
418: $fnsort = '<a class="gray" href="' . $thisfile . '&sortby=3&sortmode=DESC&startpage=' . $startpage . '">' . i18n("Filename / Description") . '<img src="images/sort_up.gif" border="0"></a>';
419: } else {
420: $fnsort = '<a class="gray" href="' . $thisfile . '&sortby=3&sortmode=ASC&startpage=' . $startpage . '">' . i18n("Filename / Description") . '</a>';
421: }
422: }
423:
424: if ($sortby == 4 && $sortmode == 'DESC') {
425: $sizesort = '<a class="gray" href="' . $thisfile . '&sortby=4&sortmode=ASC&startpage=' . $startpage . '">' . i18n("Size") . '<img src="images/sort_down.gif" border="0"></a>';
426: } else {
427: if ($sortby == 4) {
428: $sizesort = '<a class="gray" href="' . $thisfile . '&sortby=4&sortmode=DESC&startpage=' . $startpage . '">' . i18n("Size") . '<img src="images/sort_up.gif" border="0"></a>';
429: } else {
430: $sizesort = '<a class="gray" href="' . $thisfile . '&sortby=4&sortmode=ASC&startpage=' . $startpage . '">' . i18n("Size") . "</a>";
431: }
432: }
433:
434: if ($sortby == 5 && $sortmode == 'DESC') {
435: $typesort = '<a class="gray" href="' . $thisfile . '&sortby=5&sortmode=ASC&startpage=' . $startpage . '">' . i18n("Type") . '<img src="images/sort_down.gif" border="0"></a>';
436: } else {
437: if ($sortby == 5) {
438: $typesort = '<a class="gray" class="gray" href="' . $thisfile . '&sortby=5&sortmode=DESC&startpage=' . $startpage . '">' . i18n("Type") . '<img src="images/sort_up.gif" border="0"></a>';
439: } else {
440: $typesort = '<a class="gray" href="' . $thisfile . '&sortby=5&sortmode=ASC&startpage=' . $startpage . '">' . i18n("Type") . "</a>";
441: }
442: }
443:
444:
445: if ($perm->have_perm_area_action('upl', 'upl_multidelete') && $bDirectoryIsWritable == true) {
446: $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;";
447: $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>';
448: } else {
449: $sDelete = '';
450: }
451:
452: if (cApiDbfs::isDbfs($path)) {
453: $mpath = $path . '/';
454: } else {
455: $mpath = 'upload/' . $path;
456: }
457:
458: $sDisplayPath = generateDisplayFilePath($mpath, 85);
459:
460: $sToolsRow = '<tr>
461: <th colspan="6" id="cat_navbar">
462: <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>
463: ' . $sDelete . '
464: <div class="toolsRight">
465: ' . i18n("Path:") . " " . $sDisplayPath . '
466: </div>
467: </th>
468: </tr>';
469: $sSpacedRow = '<tr height="10">
470: <td colspan="6" class="emptyCell"></td>
471: </tr>';
472:
473:
474:
475: $pagerwrap = '<tr>
476: <th colspan="6" id="cat_navbar">
477: <div class="toolsRight">
478: <div class="vAlignMiddle">-C-SCROLLLEFT-</div>
479: <div class="vAlignMiddle">-C-PAGE-</div>
480: <div class="vAlignMiddle">-C-SCROLLRIGHT-</div>
481: </div>
482: <span class="vAlignMiddle">' . i18n("Files per Page") . ' -C-FILESPERPAGE-</span>
483: </th>
484: </tr>';
485:
486: $startwrap = '<table class="hoverbox generic" cellspacing="0" cellpadding="2" border="0">
487: ' . $pagerwrap . $sSpacedRow . $sToolsRow . $sSpacedRow . '
488: <tr>
489: <th>' . i18n("Mark") . '</th>
490: <th>' . i18n("Preview") . '</th>
491: <th width="100%">' . $fnsort . '</th>
492: <th>' . $sizesort . '</th>
493: <th>' . $typesort . '</th>
494: <th>' . i18n("Actions") . '</th>
495: </tr>';
496: $itemwrap = '<tr>
497: <td align="center">%s</td>
498: <td align="center">%s</td>
499: <td class="vAlignTop nowrap">%s</td>
500: <td class="vAlignTop nowrap">%s</td>
501: <td class="vAlignTop nowrap">%s</td>
502: <td class="vAlignTop nowrap">%s</td>
503: </tr>';
504: $endwrap = $sSpacedRow . $sToolsRow . $sSpacedRow . $pagerwrap . '</table>';
505:
506:
507: $list2 = new UploadList($startwrap, $endwrap, $itemwrap);
508:
509: $uploads = new cApiUploadCollection();
510:
511:
512: if (substr($path, strlen($path) - 1, 1) != "/") {
513: if ($path != "") {
514: $qpath = $path . "/";
515: } else {
516:
517: $qpath = "";
518: }
519: } else {
520: $qpath = $path;
521: }
522:
523: $uploads->select("idclient = '$client' AND dirname = '$qpath'");
524:
525: $user = new cApiUser($auth->auth['uid']);
526:
527: if ($thumbnailmode == '') {
528: $current_mode = $user->getUserProperty('upload_folder_thumbnailmode', md5($path));
529: if ($current_mode != '') {
530: $thumbnailmode = $current_mode;
531: } else {
532: $thumbnailmode = getEffectiveSetting('backend', 'thumbnailmode', 100);
533: }
534: }
535:
536: switch ($thumbnailmode) {
537: case 10:
538: $numpics = 10;
539: break;
540: case 25:
541: $numpics = 25;
542: break;
543: case 50:
544: $numpics = 50;
545: break;
546: case 100:
547: $numpics = 100;
548: break;
549: case 200:
550: $numpics = 200;
551: break;
552: default:
553: $thumbnailmode = 100;
554: $numpics = 15;
555: break;
556: }
557:
558: $user->setUserProperty('upload_folder_thumbnailmode', md5($path), $thumbnailmode);
559:
560: $list2->setResultsPerPage($numpics);
561:
562: $list2->size = $thumbnailmode;
563:
564: $rownum = 0;
565:
566: $properties = new cApiPropertyCollection();
567:
568: while ($item = $uploads->next()) {
569: $filename = $item->get('filename');
570:
571: if (strpos($filename, ".") === 0) {
572: continue;
573: }
574:
575: $bAddFile = true;
576:
577: if ($appendparameters == 'imagebrowser') {
578: $restrictvar = 'restrict_' . $appendparameters;
579: if (array_key_exists($restrictvar, $browserparameters)) {
580: $fileType = strtolower(getFileType($filename));
581: if (count($browserparameters[$restrictvar]) > 0) {
582: $bAddFile = false;
583: if (in_array($fileType, $browserparameters[$restrictvar])) {
584: $bAddFile = true;
585: }
586: }
587: }
588: }
589:
590: $dirname = $item->get('dirname');
591: $filesize = $item->get('size');
592:
593: if ($filesize == 0) {
594: if (cFileHandler::exists($cfgClient[$client]['upl']['path'] . $dirname . $filename)) {
595: $filesize = filesize($cfgClient[$client]['upl']['path'] . $dirname . $filename);
596: }
597: }
598:
599: $actions = '';
600:
601: $medianame = $properties->getValue('upload', $path . $filename, 'file', 'medianame');
602: $medianotes = $properties->getValue('upload', $path . $filename, 'file', 'medianotes');
603:
604: $todo = new TODOLink('upload', $path . $filename, "File $path$filename", '');
605:
606: $proptitle = i18n("Display properties");
607:
608: if ($appendparameters == 'imagebrowser' || $appendparameters == 'filebrowser') {
609: $mstr = '';
610: } else {
611: $tmp_mstr = '<a href="javascript:Con.multiLink(\'%s\', \'%s\', \'%s\', \'%s\')">%s</a>';
612: $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\'">');
613: }
614:
615: $actions = $mstr . $actions;
616:
617: $showfilename = $filename;
618:
619: $check = new cHTMLCheckbox('fdelete[]', $filename);
620:
621: $mark = $check->toHTML(false);
622:
623: if ($bAddFile == true) {
624:
625: $list2->setData($rownum, $mark, $dirname . $filename, $showfilename, $filesize, strtolower(getFileType($filename)), $todo->render() . $actions);
626: $rownum++;
627: }
628: }
629:
630: if ($rownum == 0) {
631:
632: header('Location: ' . cRegistry::getBackendUrl() . 'main.php?area=upl_upload&frame=4&path=' . $path . '&contenido=' . $contenido . '&appendparameters=' . $appendparameters);
633: }
634:
635: if ($sortmode == 'ASC') {
636: $list2->sort($sortby, SORT_ASC);
637: } else {
638: $list2->sort($sortby, SORT_DESC);
639: }
640:
641: if ($startpage < 1) {
642: $startpage = 1;
643: }
644:
645: if ($startpage > $list2->getNumPages()) {
646: $startpage = $list2->getNumPages();
647: }
648:
649: $list2->setListStart($startpage);
650:
651:
652: if ($list2->getCurrentPage() > 1) {
653: $prevpage = '<a href="' . $scrollthisfile . '&startpage=' . ($list2->getCurrentPage() - 1) . '" class="invert_hover">' . i18n("Previous Page") . '</a>';
654: } else {
655: $prevpage = ' ';
656: }
657:
658: if ($list2->getCurrentPage() < $list2->getNumPages()) {
659: $nextpage = '<a href="' . $scrollthisfile . '&startpage=' . ($list2->getCurrentPage() + 1) . '" class="invert_hover">' . i18n("Next Page") . '</a>';
660: } else {
661: $nextpage = ' ';
662: }
663:
664:
665:
666: if ($list2->getNumPages() > 1) {
667: $num_pages = $list2->getNumPages();
668:
669: $paging_form .= "<script type=\"text/javascript\">
670: function jumpToPage(select) {
671: var pagenumber = select.selectedIndex + 1;
672: url = '" . $sess->url('main.php') . "';
673: document.location.href = url + '&area=upl&frame=4&appendparameters=$appendparameters&path=$path&sortmode=$sortmode&sortby=$sortby&thumbnailmode=$thumbnailmode&startpage=' + pagenumber;
674: }
675: </script>";
676: $paging_form .= "<select name=\"start_page\" class=\"text_medium\" onChange=\"jumpToPage(this);\">";
677: for ($i = 1; $i <= $num_pages; $i++) {
678: if ($i == $startpage) {
679: $selected = ' selected';
680: } else {
681: $selected = '';
682: }
683: $paging_form .= "<option value=\"$i\"$selected>$i</option>";
684: }
685:
686: $paging_form .= '</select>';
687: } else {
688: $paging_form = '1';
689: }
690: $curpage = $paging_form . ' / ' . $list2->getNumPages();
691:
692: $scroller = $prevpage . $nextpage;
693: $output = $list2->output(true);
694: $output = str_replace('-C-SCROLLLEFT-', $prevpage, $output);
695: $output = str_replace('-C-SCROLLRIGHT-', $nextpage, $output);
696: $output = str_replace('-C-PAGE-', i18n("Page") . ' ' . $curpage, $output);
697:
698: $select = new cHTMLSelectElement('thumbnailmode');
699:
700: $values = array(
701: 10 => '10',
702: 25 => '25',
703: 50 => '50',
704: 100 => '100',
705: 200 => '200'
706: );
707:
708: $select->autoFill($values);
709:
710: $select->setDefault($thumbnailmode);
711: $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;");
712:
713: $topbar = $select->render() . '<input class="vAlignMiddle tableElement" type="image" onmouseover="this.style.cursor=\'pointer\'" src="images/submit.gif">';
714:
715: $output = str_replace('-C-FILESPERPAGE-', $topbar, $output);
716:
717: $delform = new cHTMLForm('del');
718: $delform->setVar('area', $area);
719: $delform->setVar('action', '');
720: $delform->setVar('startpage', $startpage);
721: $delform->setVar('thumbnailmode', $thumbnailmode);
722: $delform->setVar('sortmode', $sortmode);
723: $delform->setVar('sortby', $sortby);
724: $delform->setVar('appendparameters', $appendparameters);
725: $delform->setVar('path', $path);
726: $delform->setVar('frame', 4);
727:
728: $delform->appendContent($output);
729:
730: $page->addScript($sess->url('iZoom.js.php'));
731:
732: if ($bDirectoryIsWritable == false) {
733: $page->displayError(i18n("Directory not writable") . ' (' . $cfgClient[$client]['upl']['path'] . $path . ')');
734: }
735:
736: $jsScript = new cHTMLScript();
737: $jsScript->setAttribute('type', 'text/javascript');
738:
739: $jsCode = '
740: (function(Con, $) {
741: $(function() {
742: var $body = $("body");
743:
744: // Handler for clicked image anchors
745: $body.delegate("a.jsZoom", "click", function() {
746: iZoom($(this).attr("href"));
747: return false;
748: });
749:
750: // Handler for mouseover/mouseout on images
751: $body.delegate("a.jsZoom img.hover", "mouseover", function() {
752: correctPosition(this, $(this).attr("data-width"), $(this).attr("data-height"));
753: });
754: $body.delegate("a.jsZoom img.hover", "mouseout", function() {
755: if (typeof(previewHideIe6) == "function") {
756: previewHideIe6(this);
757: };
758: });
759: });
760: })(Con, Con.$);
761: ';
762: $jsScript->setContent($jsCode);
763:
764: $page->setContent(array(
765: $delform,
766: $jsScript
767: ));
768:
769: $page->render();
770: