Overview

Packages

  • CONTENIDO
  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentRssCreator
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • mpAutoloaderClassMap
  • None
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SearchSolr
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob
  • Smarty
    • Cacher
    • Compiler
    • Config
    • Debug
    • PluginsBlock
    • PluginsFilter
    • PluginsFunction
    • PluginsInternal
    • PluginsModifier
    • PluginsModifierCompiler
    • PluginsShared
    • Security
    • Template
    • TemplateResources
  • Swift
    • ByteStream
    • CharacterStream
    • Encoder
    • Events
    • KeyCache
    • Mailer
    • Mime
    • Plugins
    • Transport

Classes

  • Swift_FailoverTransport
  • Swift_LoadBalancedTransport
  • Swift_MailTransport
  • Swift_Plugins_Loggers_ArrayLogger
  • Swift_Plugins_Loggers_EchoLogger
  • Swift_SendmailTransport
  • Swift_SmtpTransport
  • Swift_Transport_AbstractSmtpTransport
  • Swift_Transport_Esmtp_Auth_CramMd5Authenticator
  • Swift_Transport_Esmtp_Auth_LoginAuthenticator
  • Swift_Transport_Esmtp_Auth_PlainAuthenticator
  • Swift_Transport_Esmtp_AuthHandler
  • Swift_Transport_EsmtpTransport
  • Swift_Transport_FailoverTransport
  • Swift_Transport_LoadBalancedTransport
  • Swift_Transport_MailTransport
  • Swift_Transport_SendmailTransport
  • Swift_Transport_SimpleMailInvoker
  • Swift_Transport_StreamBuffer

Interfaces

  • Swift_Plugins_Logger
  • Swift_Plugins_Pop_Pop3Exception
  • Swift_Transport
  • Swift_Transport_Esmtp_Authenticator
  • Swift_Transport_EsmtpHandler
  • Swift_Transport_IoBuffer
  • Swift_Transport_MailInvoker
  • Swift_Transport_SmtpAgent
  • Swift_TransportException
  • Overview
  • Package
  • Function
  • Todo
  • Download
  1: <?php
  2: /**
  3:  * This file contains the backend page for displaying files of a directory in upload section.
  4:  *
  5:  * @package          Core
  6:  * @subpackage       Backend
  7:  * @version          SVN Revision $Rev:$
  8:  *
  9:  * @author           Timo Hummel
 10:  * @copyright        four for business AG <www.4fb.de>
 11:  * @license          http://www.contenido.org/license/LIZENZ.txt
 12:  * @link             http://www.4fb.de
 13:  * @link             http://www.contenido.org
 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: //cInclude('includes', 'class.ziparchive.php');
 25: 
 26: if (!(int) $client > 0) {
 27:     // if there is no client selected, display empty page
 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:     // register last path (upl_last_path) in session
 44:     $sess->register('upl_last_path');
 45: } elseif (!isset($path)) {
 46:     // if no path is given the last path is used
 47:     $path = $upl_last_path;
 48: }
 49: // if path doesn't exist use root path
 50: // this might happen when the last path is that of another client or deleted outside CONTENIDO
 51: if (!cApiDbfs::isDbfs($path) && !cFileHandler::exists($cfgClient[$client]['upl']['path'] . $path)) {
 52:     $path = '';
 53: }
 54: // remember current path as last path
 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:     // Did the user upload a new file?
 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:                 // Copy file to a temporary location
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:     // $upload->set('description', stripslashes($description));
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:         // check for new entry:
160:         $oUploadMeta = new cApiUploadMeta((int) $iIdupl);
161:         if ($oUploadMeta->loadByUploadIdAndLanguageId($iIdupl, $lang)) {
162:             // Update existing entry
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:             // Create new entry
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:         // array of cApiUpload objects to be passed to chain function
182:         $uploadObjects = array();
183: 
184:         // Check if it is in the upload table
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:                     // call chain once for each deleted file
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:                 // add current upload object to array in order to be processed
203:                 array_push($uploadObjects, $item);
204:             }
205:         }
206: 
207:         // call chain once for all deleted files
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:     // array of cApiUpload objects to be passed to chain function
219:     $uploadObjects = array();
220: 
221:     $uploads->select("idclient = '$client' AND dirname='$qpath' AND filename='$file'");
222:     // FIXME Code is similar/redundant to cApiUploadCollection->delete(), in
223:     // previous version from UploadCollection->delete() too
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:         // call chain for deleted file
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:                 // add current upload object to array in order to be processed
238:                 array_push($uploadObjects, $item);
239:             }
240:         }
241: 
242:         // call chain once for all deleted files
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:                         // Copy file to a temporary location
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:                 // fix for IE11 popup:
333:                 // selecting link with tiny out of popup does not work with Con.getFrame in IE11
334:                 // reverting to the old call solves this problem
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 alt="" src="' . $backendUrl . $cfg['path']['images'] . 'but_ok.gif" title="' . i18n("Use file") . '">&nbsp;' . $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 alt="" src="' . $backendUrl . $cfg['path']['images'] . 'but_ok.gif" title="' . i18n("Use file") . '">&nbsp;' . $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:             // If this file is an image, try to open
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" alt="" src="' . $sCacheThumbnail . '" data-width="' . $iWidth . '" data-height="' . $iHeight . '">
385:                            <img class="preview" name="prevImage" alt="" src="' . $sCacheThumbnail . '">
386:                        </a>';
387:                     return $retValue;
388:                     break;
389:                 default:
390:                     $sCacheThumbnail = uplGetThumbnail($data, 150);
391:                     return '<img class="hover_none" name="smallImage" alt="" 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" alt="" 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" alt="" 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" alt="" 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" alt="" 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" alt="" 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" alt="" 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: // Multiple deletes at top of table
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: // List wraps
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: // Object initializing
507: $list2 = new UploadList($startwrap, $endwrap, $itemwrap);
508: 
509: $uploads = new cApiUploadCollection();
510: 
511: // Fetch data
512: if (substr($path, strlen($path) - 1, 1) != "/") {
513:     if ($path != "") {
514:         $qpath = $path . "/";
515:     } else {
516:         // view the root folder
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: 
570:     // Get name of directory, filename and size of file
571:     $dirname = $item->get('dirname');
572:     $filename = $item->get('filename');
573:     $filesize = $item->get('size');
574: 
575:     // Do not display directories and "filenames" begin with a dot
576:     if (true === cDirHandler::exists($cfgClient[$client]['upl']['path'] . $dirname . $filename) || strpos($filename, ".") === 0) {
577:         continue;
578:     }
579: 
580:     $bAddFile = true;
581: 
582:     if ($appendparameters == 'imagebrowser') {
583:         $restrictvar = 'restrict_' . $appendparameters;
584:         if (array_key_exists($restrictvar, $browserparameters)) {
585:             $fileType = strtolower(getFileType($filename));
586:             if (count($browserparameters[$restrictvar]) > 0) {
587:                 $bAddFile = false;
588:                 if (in_array($fileType, $browserparameters[$restrictvar])) {
589:                     $bAddFile = true;
590:                 }
591:             }
592:         }
593:     }
594: 
595:     if ($filesize == 0) {
596:         if (cFileHandler::exists($cfgClient[$client]['upl']['path'] . $dirname . $filename)) {
597:             $filesize = filesize($cfgClient[$client]['upl']['path'] . $dirname . $filename);
598:         }
599:     }
600: 
601:     $actions = '';
602: 
603:     $medianame = $properties->getValue('upload', $path . $filename, 'file', 'medianame');
604:     $medianotes = $properties->getValue('upload', $path . $filename, 'file', 'medianotes');
605: 
606:     $todo = new TODOLink('upload', $path . $filename, "File $path$filename", '');
607: 
608:     $proptitle = i18n("Display properties");
609: 
610:     if ($appendparameters == 'imagebrowser' || $appendparameters == 'filebrowser') {
611:         $mstr = '';
612:     } else {
613:         $tmp_mstr = '<a href="javascript:Con.multiLink(\'%s\', \'%s\', \'%s\', \'%s\')">%s</a>';
614:         $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\'">');
615:     }
616: 
617:     $actions = $mstr . $actions;
618: 
619:     $showfilename = $filename;
620: 
621:     $check = new cHTMLCheckbox('fdelete[]', $filename);
622: 
623:     $mark = $check->toHTML(false);
624: 
625:     if ($bAddFile == true) {
626:         // 'bgcolor' is just a placeholder...
627:         $list2->setData($rownum, $mark, $dirname . $filename, $showfilename, $filesize, strtolower(getFileType($filename)), $todo->render() . $actions);
628:         $rownum++;
629:     }
630: }
631: 
632: if ($rownum == 0) {
633:     header('Location: ' . cRegistry::getBackendUrl() . 'main.php?area=upl_upload&frame=4&path=' . $path . '&contenido=' . $contenido . '&appendparameters=' . $appendparameters);
634: }
635: 
636: if ($sortmode == 'ASC') {
637:     $list2->sort($sortby, SORT_ASC);
638: } else {
639:     $list2->sort($sortby, SORT_DESC);
640: }
641: 
642: if ($startpage < 1) {
643:     $startpage = 1;
644: }
645: 
646: if ($startpage > $list2->getNumPages()) {
647:     $startpage = $list2->getNumPages();
648: }
649: 
650: $list2->setListStart($startpage);
651: 
652: // Create scroller
653: if ($list2->getCurrentPage() > 1) {
654:     $prevpage = '<a href="' . $scrollthisfile . '&startpage=' . ($list2->getCurrentPage() - 1) . '" class="invert_hover">' . i18n("Previous Page") . '</a>';
655: } else {
656:     $prevpage = '&nbsp;';
657: }
658: 
659: if ($list2->getCurrentPage() < $list2->getNumPages()) {
660:     $nextpage = '<a href="' . $scrollthisfile . '&startpage=' . ($list2->getCurrentPage() + 1) . '" class="invert_hover">' . i18n("Next Page") . '</a>';
661: } else {
662:     $nextpage = '&nbsp;';
663: }
664: 
665: // curpage = $list2->getCurrentPage() . " / ". $list2->getNumPages();
666: 
667: if ($list2->getNumPages() > 1) {
668:     $num_pages = $list2->getNumPages();
669: 
670:     $paging_form .= "<script type=\"text/javascript\">
671:        function jumpToPage(select) {
672:            var pagenumber = select.selectedIndex + 1;
673:            url = '" . $sess->url('main.php') . "';
674:            document.location.href = url + '&area=upl&frame=4&appendparameters=$appendparameters&path=$path&sortmode=$sortmode&sortby=$sortby&thumbnailmode=$thumbnailmode&startpage=' + pagenumber;
675:        }
676:    </script>";
677:     $paging_form .= "<select name=\"start_page\" class=\"text_medium\" onChange=\"jumpToPage(this);\">";
678:     for ($i = 1; $i <= $num_pages; $i++) {
679:         if ($i == $startpage) {
680:             $selected = ' selected';
681:         } else {
682:             $selected = '';
683:         }
684:         $paging_form .= "<option value=\"$i\"$selected>$i</option>";
685:     }
686: 
687:     $paging_form .= '</select>';
688: } else {
689:     $paging_form = '1';
690: }
691: $curpage = $paging_form . ' / ' . $list2->getNumPages();
692: 
693: $scroller = $prevpage . $nextpage;
694: $output = $list2->output(true);
695: $output = str_replace('-C-SCROLLLEFT-', $prevpage, $output);
696: $output = str_replace('-C-SCROLLRIGHT-', $nextpage, $output);
697: $output = str_replace('-C-PAGE-', i18n("Page") . ' ' . $curpage, $output);
698: 
699: $select = new cHTMLSelectElement('thumbnailmode');
700: 
701: $values = array(
702:     10 => '10',
703:     25 => '25',
704:     50 => '50',
705:     100 => '100',
706:     200 => '200'
707: );
708: 
709: $select->autoFill($values);
710: 
711: $select->setDefault($thumbnailmode);
712: $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;");
713: 
714: $topbar = $select->render() . '<input class="vAlignMiddle tableElement" type="image" onmouseover="this.style.cursor=\'pointer\'" src="images/submit.gif">';
715: 
716: $output = str_replace('-C-FILESPERPAGE-', $topbar, $output);
717: 
718: $delform = new cHTMLForm('del');
719: $delform->setVar('area', $area);
720: $delform->setVar('action', '');
721: $delform->setVar('startpage', $startpage);
722: $delform->setVar('thumbnailmode', $thumbnailmode);
723: $delform->setVar('sortmode', $sortmode);
724: $delform->setVar('sortby', $sortby);
725: $delform->setVar('appendparameters', $appendparameters);
726: $delform->setVar('path', $path);
727: $delform->setVar('frame', 4);
728: // Table with (preview) images
729: $delform->appendContent($output);
730: 
731: $page->addScript($sess->url('iZoom.js.php'));
732: 
733: if ($bDirectoryIsWritable == false) {
734:     $page->displayError(i18n("Directory not writable") . ' (' . $cfgClient[$client]['upl']['path'] . $path . ')');
735: }
736: 
737: $page->setContent(array(
738:     $delform,
739:     $jsScript
740: ));
741: 
742: $page->render();
743: 
CMS CONTENIDO 4.9.7 API documentation generated by ApiGen