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

Classes

  • cAjaxRequest
  • cAutoload
  • cBackend
  • cEffectiveSetting
  • cGuiScrollListAlltranslations
  • cHTMLValidator
  • cMailer
  • cModuleFileTranslation
  • cModuleHandler
  • cModuleSearch
  • cModuleSynchronizer
  • cModuleTemplateHandler
  • CodeMirror
  • cPasswordRequest
  • cPermission
  • cRegistry
  • cSystemPurge
  • cSystemtest
  • cTinymce4Configuration
  • cTinyMCE4Editor
  • cTinyMCEEditor
  • cWYSIWYGEditor
  • FrontendList
  • HtmlParser
  • TODOBackendList
  • TreeItem
  • UploadList
  • UploadSearchResultList

Functions

  • addArtspec
  • addSortImages
  • backToMainArea
  • buildArticleSelect
  • buildCategorySelect
  • buildCategorySelectRights
  • buildHeapTable
  • buildStackString
  • buildTree
  • buildUserOrGroupPermsFromRequest
  • callPluginStore
  • cApiCatGetLevelNode
  • cApiImageCheckCachedImageValidity
  • cApiImageCheckImageEditingPosibility
  • cApiImageGetCacheFileName
  • cApiImageGetTargetDimensions
  • cApiImageIsAnimGif
  • cApiImgScale
  • cApiImgScaleGetMD5CacheFile
  • cApiImgScaleHQ
  • cApiImgScaleImageMagick
  • cApiImgScaleLQ
  • cApiIsImageMagickAvailable
  • cApiStrCleanURLCharacters
  • cApiStrNormalizeLineEndings
  • cApiStrRecodeString
  • cApiStrReplaceDiacritics
  • cApiStrTrimAfterWord
  • cApiStrTrimHard
  • cApiStrTrimSentence
  • cDeprecated
  • cDie
  • cError
  • checkLangInClients
  • checkPathInformation
  • cInclude
  • compareUrlStrings
  • conChangeTemplateForCat
  • conCopyArticle
  • conCopyArtLang
  • conCopyContainerConf
  • conCopyContent
  • conCopyMetaTags
  • conCopyTemplateConfiguration
  • conCreateLocationString
  • conDeeperCategoriesArray
  • conDeleteart
  • conEditArt
  • conEditFirstTime
  • conFetchCategoryTree
  • conFlagOnOffline
  • conGenerateCode
  • conGenerateCodeForAllArts
  • conGenerateCodeForAllArtsInCategory
  • conGenerateCodeForAllartsUsingLayout
  • conGenerateCodeForAllartsUsingMod
  • conGenerateCodeForAllArtsUsingTemplate
  • conGenerateCodeForArtInAllCategories
  • conGenerateCodeForClient
  • conGenerateKeywords
  • conGetAvailableMetaTagTypes
  • conGetCategoryArticleId
  • conGetCategoryAssignments
  • conGetContainerConfiguration
  • conGetContentFromArticle
  • conGetHtmlTranslationTable
  • conGetMetaValue
  • conGetTemplateConfigurationIdForArticle
  • conGetTemplateConfigurationIdForCategory
  • conGetTopmostCat
  • conGetUsedModules
  • conHtmlentities
  • conHtmlEntityDecode
  • conHtmlSpecialChars
  • conIsLocked
  • conLock
  • conLockBulkEditing
  • conMakeArticleIndex
  • conMakeCatOnline
  • conMakeInlineScript
  • conMakeOnline
  • conMakeOnlineBulkEditing
  • conMakePublic
  • conMakeStart
  • conMoveArticles
  • conPhp54Check
  • conRemoveOldCategoryArticle
  • conSaveContentEntry
  • conSetCodeFlag
  • conSetCodeFlagBulkEditing
  • conSetMetaValue
  • conSyncArticle
  • copyRightsForElement
  • createBulkEditingFunction
  • createRandomName
  • createRightsForElement
  • cWarning
  • dbGetColumns
  • dbGetIndexes
  • dbGetPrimaryKeyName
  • dbTableExists
  • dbUpgradeTable
  • defineIfNotDefined
  • deleteArtspec
  • deleteRightsForElement
  • deleteSystemProperty
  • displayDatetime
  • emptyLogFile
  • endAndLogTiming
  • extractNumber
  • generateDisplayFilePath
  • generateJs
  • getAllClientsAndLanguages
  • getArtLang
  • getArtspec
  • getAvailableContentTypes
  • getCanonicalDay
  • getCanonicalMonth
  • getDirectorySize
  • getEffectiveSetting
  • getEffectiveSettingsByType
  • getEncodingByLanguage
  • getFileContents
  • getFileInformation
  • getFileType
  • getGroupOrUserName
  • getIDForArea
  • getJsHelpContext
  • getLanguageNamesByClient
  • getLanguagesByClient
  • getmicrotime
  • getNamedFrame
  • getParam
  • getParentAreaId
  • getSearchResults
  • getStrExpandCollapseButton
  • getSystemProperties
  • getSystemPropertiesByType
  • getSystemProperty
  • getTemplateSelect
  • getUplExpandCollapseButton
  • htmldecode
  • htmlentities_iso88592
  • humanReadableSize
  • includePlugins
  • insertEmptyStrRow
  • ipMatch
  • isAlphanumeric
  • isArchive
  • isArtInMultipleUse
  • isFunctionDisabled
  • isGroup
  • isIPv4
  • isRunningFromWeb
  • isStartArticle
  • isUtf8
  • isValidMail
  • langActivateDeactivateLanguage
  • langDeleteLanguage
  • langEditLanguage
  • langGetTextDirection
  • langNewLanguage
  • langRenameLanguage
  • layDeleteLayout
  • layEditLayout
  • machineReadableSize
  • mailLogBulkEditingFunctions
  • mailLogDecodeAddresses
  • markSubMenuItem
  • mask
  • modDeleteModule
  • modEditModule
  • phpInfoToHtml
  • plugin_include
  • prCreateURLNameLocationString
  • prDeleteCacheFileContent
  • prGetCacheFileContent
  • prResolvePathViaCategoryNames
  • prResolvePathViaURLNames
  • prWriteCacheFileContent
  • putFileContents
  • recursiveCopy
  • removeFileInformation
  • renderBackendBreadcrumb
  • renderLabel
  • renderSelectProperty
  • renderTextProperty
  • saveGroupRights
  • saveRights
  • scanDirectory
  • scanPlugins
  • sendEncodingHeader
  • set_magic_quotes_gpc
  • setArtspecDefault
  • setArtspecOnline
  • setSystemProperty
  • showTree
  • startTiming
  • statCreateLocationString
  • statDisplayTopChooser
  • statDisplayYearlyTopChooser
  • statGetAvailableMonths
  • statGetAvailableYears
  • statResetStatistic
  • statsArchive
  • statsDisplayInfo
  • statsOverviewAll
  • statsOverviewTop
  • statsOverviewTopYear
  • statsOverviewYear
  • strAssignTemplate
  • strBuildSqlValues
  • strCheckTreeForErrors
  • strCopyCategory
  • strCopyTree
  • strDeeperCategoriesArray
  • strDeleteCategory
  • strHasArticles
  • strHasStartArticle
  • strMakePublic
  • strMakeVisible
  • strMoveCatTargetallowed
  • strMoveDownCategory
  • strMoveSubtree
  • strMoveUpCategory
  • strNewCategory
  • strNewTree
  • strNextBackwards
  • strNextDeeper
  • strNextDeeperAll
  • strNextPost
  • strOrderedPostTreeList
  • strRemakeTreeTable
  • strRenameCategory
  • strRenameCategoryAlias
  • strSortPrePost
  • strSyncCategory
  • systemHavePerm
  • tplAutoFillModules
  • tplBrowseLayoutForContainers
  • tplcfgDuplicate
  • tplDeleteTemplate
  • tplDuplicateTemplate
  • tplEditTemplate
  • tplGetContainerDefault
  • tplGetContainerMode
  • tplGetContainerName
  • tplGetContainerNumbersInLayout
  • tplGetContainerTypes
  • tplGetInUsedData
  • tplIsTemplateInUse
  • tplPreparseLayout
  • tplProcessSendContainerConfiguration
  • updateClientCache
  • updateFileInformation
  • uplCreateFriendlyName
  • uplDirectoryListRecursive
  • uplGetDirectoriesToExclude
  • uplGetFileExtension
  • uplGetFileIcon
  • uplGetFileTypeDescription
  • uplGetThumbnail
  • uplHasFiles
  • uplHasSubdirs
  • uplmkdir
  • uplRecursiveDBDirectoryList
  • uplRecursiveDirectoryList
  • uplRenameDirectory
  • uplSearch
  • uplSyncDirectory
  • uplSyncDirectoryDBFS
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: 
  3: /**
  4:  * This file contains the backend page for displaying files of a directory in upload section.
  5:  *
  6:  * @package          Core
  7:  * @subpackage       Backend
  8:  * @author           Timo Hummel
  9:  * @copyright        four for business AG <www.4fb.de>
 10:  * @license          http://www.contenido.org/license/LIZENZ.txt
 11:  * @link             http://www.4fb.de
 12:  * @link             http://www.contenido.org
 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: cInclude('classes', 'class.cziparchive.php');
 22: 
 23: //cInclude('includes', 'class.ziparchive.php');
 24: 
 25: if (!(int) $client > 0) {
 26:     // if there is no client selected, display empty page
 27:     $oPage = new cGuiPage('upl_files_overview');
 28:     $oPage->render();
 29:     return;
 30: }
 31: 
 32: $page = new cGuiPage('upl_files_overview', '', 0);
 33: 
 34: $appendparameters = $_REQUEST['appendparameters'];
 35: 
 36: // Define local variable file
 37: $file = cSecurity::escapeString($_REQUEST['file']);
 38: $file = str_replace('..', '', $file);
 39: $file = str_replace('/', '', $file);
 40: 
 41: if (!is_array($browserparameters) && ($appendparameters != 'imagebrowser' || $appendparameters != 'filebrowser')) {
 42:     $browserparameters = array();
 43: }
 44: 
 45: if (!$sess->isRegistered('upl_last_path')) {
 46:     // register last path (upl_last_path) in session
 47:     $sess->register('upl_last_path');
 48: } elseif (!isset($path)) {
 49:     // if no path is given the last path is used
 50:     $path = $upl_last_path;
 51: }
 52: 
 53: // if path doesn't exist use root path
 54: // this might happen when the last path is that of another client or deleted outside CONTENIDO
 55: if (!cApiDbfs::isDbfs($path) && !cFileHandler::exists($cfgClient[$client]['upl']['path'] . $path)) {
 56:     $path = '';
 57: }
 58: // remember current path as last path
 59: $upl_last_path = $path;
 60: 
 61: $uploads = new cApiUploadCollection();
 62: 
 63: $dbfs = new cApiDbfsCollection();
 64: 
 65: if (cApiDbfs::isDbfs($path)) {
 66:     $qpath = $path . '/';
 67: } else {
 68:     $qpath = $path;
 69: }
 70: 
 71: if ((is_writable($cfgClient[$client]['upl']['path'] . $path) || cApiDbfs::isDbfs($path)) && (int) $client > 0) {
 72:     $bDirectoryIsWritable = true;
 73: } else {
 74:     $bDirectoryIsWritable = false;
 75: }
 76: 
 77: 
 78: if ($action == 'upl_modify_file') {
 79: 
 80:     $extractFolder = NULL;
 81:     $uplPath = $cfgClient[$client]['upl']['path'];
 82: 
 83:     if (isset($_REQUEST['path']) && $_REQUEST['path'] != NULL) {
 84:         $uplPath .= cSecurity::escapeString($_REQUEST['path']);
 85:     }
 86: 
 87:     if (isset($_REQUEST['efolder']) && $_REQUEST['efolder'] != NULL) {
 88:         $extractFolder = cSecurity::escapeString($_REQUEST['efolder']);
 89:     }
 90: 
 91:     if (isset($_REQUEST['extractZip']) && !isset($_REQUEST['overwrite'])) {
 92:         $zipFile = $uplPath . cSecurity::escapeString($_REQUEST['file']);
 93:         cZipArchive::extract($zipFile, $uplPath, $extractFolder);
 94:     }
 95:     if (isset($_REQUEST['extractZip']) && isset($_REQUEST['overwrite'])) {
 96:         $zipFile = $uplPath . cSecurity::escapeString($_REQUEST['file']);
 97:         cZipArchive::extractOverRide($zipFile, $uplPath, $extractFolder);
 98:     }
 99:     // Did the user upload a new file?
100:     if ($bDirectoryIsWritable == true && count($_FILES) == 1 && ($_FILES['file']['size'] > 0) && ($_FILES['file']['name'] != '')) {
101:         if ($_FILES['file']['tmp_name'] != '') {
102:             $tmp_name = $_FILES['file']['tmp_name'];
103:             $_cecIterator = $_cecRegistry->getIterator('Contenido.Upload.UploadPreprocess');
104: 
105:             if ($_cecIterator->count() > 0) {
106:                 // Copy file to a temporary location
107:                 move_uploaded_file($tmp_name, $backendPath . $cfg['path']['temp'] . $file);
108:                 $tmp_name = $backendPath . $cfg['path']['temp'] . $file;
109: 
110:                 while ($chainEntry = $_cecIterator->next()) {
111:                     if (cApiDbfs::isDbfs($path)) {
112:                         $sPathPrepend = '';
113:                         $sPathApppend = '/';
114:                     } else {
115:                         $sPathPrepend = $cfgClient[$client]['upl']['path'];
116:                         $sPathApppend = '';
117:                     }
118: 
119:                     $modified = $chainEntry->execute($tmp_name, $sPathPrepend . $path . $sPathApppend . uplCreateFriendlyName($_FILES['file']['name']));
120: 
121:                     if ($modified !== false) {
122:                         $tmp_name = $modified;
123:                     }
124:                 }
125:             }
126: 
127:             if (cApiDbfs::isDbfs($path)) {
128:                 $dbfs->writeFromFile($tmp_name, $qpath . $file);
129:                 unlink($_FILES['file']['tmp_name']);
130:             } else {
131:                 unlink($cfgClient[$client]['upl']['path'] . $path . $file);
132: 
133:                 if (is_uploaded_file($tmp_name)) {
134:                     move_uploaded_file($tmp_name, $cfgClient[$client]['upl']['path'] . $path . $file);
135:                 } else {
136:                     rename($tmp_name, $cfgClient[$client]['upl']['path'] . $path . $file);
137:                 }
138:             }
139:         }
140:     }
141: 
142:     $uploads->select("idclient = '$client' AND dirname = '$qpath' AND filename='$file'");
143:     $upload = $uploads->next();
144: 
145:     // $upload->set('description', stripslashes($description));
146:     $upload->store();
147: 
148:     $properties = new cApiPropertyCollection();
149:     $properties->setValue('upload', $qpath . $file, 'file', 'protected', stripslashes($protected));
150: 
151:     $bTimeMng = (isset($_REQUEST['timemgmt']) && strlen($_REQUEST['timemgmt']) > 1);
152:     $properties->setValue('upload', $qpath . $file, 'file', 'timemgmt', ($bTimeMng) ? 1 : 0);
153:     if ($bTimeMng) {
154:         $properties->setValue('upload', $qpath . $file, 'file', 'datestart', cSecurity::escapeString($_REQUEST['datestart']));
155:         $properties->setValue('upload', $qpath . $file, 'file', 'dateend', cSecurity::escapeString($_REQUEST['dateend']));
156:     }
157: 
158:     $author = $auth->auth['uid'];
159:     $created = date('Y-m-d H:i:s');
160: 
161:     $iIdupl = $upload->get('idupl');
162:     if (!empty($iIdupl) && $iIdupl > 0) {
163:         // check for new entry:
164:         $oUploadMeta = new cApiUploadMeta((int) $iIdupl);
165:         if ($oUploadMeta->loadByUploadIdAndLanguageId($iIdupl, $lang)) {
166:             // Update existing entry
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:             // Create new entry
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:         // array of cApiUpload objects to be passed to chain function
186:         $uploadObjects = array();
187: 
188:         // Check if it is in the upload table
189:         foreach ($fdelete as $file) {
190:             $uploads->select("idclient = '$client' AND dirname='$qpath' AND filename='$file'");
191:             if (false !== $item = $uploads->next()) {
192:                 if (cApiDbfs::isDbfs($qpath)) {
193:                     $dbfs->remove($qpath . $file);
194: 
195:                     // call chain once for each deleted file
196:                     $_cecIterator = cRegistry::getCecRegistry()->getIterator('Contenido.Upl_edit.Delete');
197:                     if ($_cecIterator->count() > 0) {
198:                         while (false !== $chainEntry = $_cecIterator->next()) {
199:                             $chainEntry->execute($item->get('idupl'), $qpath, $file);
200:                         }
201:                     }
202:                 } else {
203:                     $uploads->delete($item->get('idupl'));
204:                 }
205: 
206:                 // add current upload object to array in order to be processed
207:                 array_push($uploadObjects, $item);
208:             }
209:         }
210: 
211:         // call chain once for all deleted files
212:         $_cecIterator = cRegistry::getCecRegistry()->getIterator('Contenido.Upl_edit.DeleteBatch');
213:         if ($_cecIterator->count() > 0) {
214:             while (false !== $chainEntry = $_cecIterator->next()) {
215:                 $chainEntry->execute($uploadObjects);
216:             }
217:         }
218:     }
219: }
220: 
221: if ($action == 'upl_delete' && $perm->have_perm_area_action($area, $action) && $bDirectoryIsWritable == true) {
222:     // array of cApiUpload objects to be passed to chain function
223:     $uploadObjects = array();
224: 
225:     $uploads->select("idclient = '$client' AND dirname='$qpath' AND filename='$file'");
226:     // FIXME Code is similar/redundant to cApiUploadCollection->delete(), in
227:     // previous version from UploadCollection->delete() too
228:     if (false !== $item = $uploads->next()) {
229:         if (cApiDbfs::isDbfs($qpath)) {
230:             $dbfs->remove($qpath . $file);
231:         } else {
232:             unlink($cfgClient[$client]['upl']['path'] . $qpath . $file);
233:         }
234: 
235:         // call chain for deleted file
236:         $_cecIterator = cRegistry::getCecRegistry()->getIterator('Contenido.Upl_edit.Delete');
237:         if ($_cecIterator->count() > 0) {
238:             while (false !== $chainEntry = $_cecIterator->next()) {
239:                 $chainEntry->execute($uploads->f('idupl'), $qpath, $file);
240: 
241:                 // add current upload object to array in order to be processed
242:                 array_push($uploadObjects, $item);
243:             }
244:         }
245: 
246:         // call chain once for all deleted files
247:         $_cecIterator = cRegistry::getCecRegistry()->getIterator('Contenido.Upl_edit.DeleteBatch');
248:         if ($_cecIterator->count() > 0) {
249:             while (false !== $chainEntry = $_cecIterator->next()) {
250:                 $chainEntry->execute($uploadObjects);
251:             }
252:         }
253:     }
254: }
255: 
256: if ($action == 'upl_upload' && $bDirectoryIsWritable == true) {
257:     if ($perm->have_perm_area_action($area, 'upl_upload')) {
258:         if (count($_FILES) == 1) {
259:             foreach ($_FILES['file']['name'] as $key => $value) {
260:                 if (cString::isUtf8($_FILES['file']['name'][$key])) {
261:                     $_FILES['file']['name'][$key] = utf8_decode($_FILES['file']['name'][$key]);
262:                 }
263:                 if ($_FILES['file']['tmp_name'][$key] != '') {
264:                     $tmp_name = $_FILES['file']['tmp_name'][$key];
265:                     $_cecIterator = $_cecRegistry->getIterator('Contenido.Upload.UploadPreprocess');
266: 
267:                     if ($_cecIterator->count() > 0) {
268:                         // Copy file to a temporary location
269:                         move_uploaded_file($tmp_name, $backendPath . $cfg['path']['temp'] . $_FILES['file']['name'][$key]);
270:                         $tmp_name = $backendPath . $cfg['path']['temp'] . $_FILES['file']['name'][$key];
271: 
272:                         while ($chainEntry = $_cecIterator->next()) {
273:                             if (cApiDbfs::isDbfs($path)) {
274:                                 $sPathPrepend = '';
275:                                 $sPathApppend = '/';
276:                             } else {
277:                                 $sPathPrepend = $cfgClient[$client]['upl']['path'];
278:                                 $sPathApppend = '';
279:                             }
280: 
281:                             $modified = $chainEntry->execute($tmp_name, $sPathPrepend . $path . $sPathApppend . uplCreateFriendlyName($_FILES['file']['name'][$key]));
282:                             if ($modified !== false) {
283:                                 $tmp_name = $modified;
284:                             }
285:                         }
286:                     }
287: 
288:                     if (cApiDbfs::isDbfs($qpath)) {
289:                         $dbfs->writeFromFile($tmp_name, $qpath . uplCreateFriendlyName($_FILES['file']['name'][$key]));
290:                         unlink($tmp_name);
291:                     } else {
292:                         if (is_uploaded_file($tmp_name)) {
293:                             $final_filename = $cfgClient[$client]['upl']['path'] . $path . uplCreateFriendlyName($_FILES['file']['name'][$key]);
294: 
295:                             move_uploaded_file($tmp_name, $final_filename);
296: 
297:                             $iterator = $_cecRegistry->getIterator('Contenido.Upload.UploadPostprocess');
298:                             while ($chainEntry = $iterator->next()) {
299:                                 $chainEntry->execute($final_filename);
300:                             }
301:                         } else {
302:                             rename($tmp_name, $cfgClient[$client]['upl']['path'] . $path . uplCreateFriendlyName($_FILES['file']['name'][$key]));
303:                         }
304:                     }
305:                 }
306:             }
307:         }
308:     } else {
309:         $page->displayError(i18n("Permission denied"));
310:         $page->render();
311:         die();
312:     }
313: }
314: 
315: if ($action == 'upl_renamefile' && $bDirectoryIsWritable == true) {
316:     $newname = str_replace('/', '', $newname);
317:     rename($cfgClient[$client]['upl']['path'] . $path . $oldname, $cfgClient[$client]['upl']['path'] . $path . $newname);
318: }
319: 
320: /**
321:  *
322:  * @author unknown
323:  */
324: class UploadList extends FrontendList {
325: 
326:     /**
327:      *
328:      * @var string
329:      */
330:     protected $_dark;
331: 
332:     /**
333:      *
334:      * @var int
335:      */
336:     protected $_size;
337: 
338:     /**
339:      * Field converting facility.
340:      *
341:      * @see FrontendList::convert()
342:      * @param int $field
343:      *         Field index
344:      * @param mixed $data
345:      *         Field value
346:      * @return mixed
347:      */
348:     public function convert($field, $data) {
349:         global $path, $appendparameters;
350: 
351:         $cfg = cRegistry::getConfig();
352:         $sess = cRegistry::getSession();
353:         $client = cRegistry::getClientId();
354:         $cfgClient = cRegistry::getClientConfig();
355:         $backendUrl = cRegistry::getBackendUrl();
356: 
357:         if ($field == 4) {
358:             return humanReadableSize($data);
359:         }
360: 
361:         if ($field == 3) {
362:             if ($appendparameters == 'imagebrowser' || $appendparameters == 'filebrowser') {
363:                 // fix for IE11 popup:
364:                 // selecting link with tiny out of popup does not work with Con.getFrame in IE11
365:                 // reverting to the old call solves this problem
366:                 if (cApiDbfs::isDbfs($path . '/' . $data)) {
367:                     $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>';
368:                 } else {
369:                     $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>';
370:                 }
371:             } else {
372:                 $tmp_mstr = '<a onmouseover="this.style.cursor=\'pointer\'" href="javascript:Con.multiLink(\'%s\', \'%s\', \'%s\', \'%s\')">%s</a>';
373:                 $mstr = sprintf($tmp_mstr, 'right_bottom', $sess->url("main.php?area=upl_edit&frame=4&path=$path&file=$data&appendparameters=$appendparameters&startpage=" . cSecurity::toInteger($_REQUEST['startpage']) . "&sortby=" . cSecurity::escapeString($_REQUEST['sortby']) . "&sortmode=" . cSecurity::escapeString($_REQUEST['sortmode']) . "&thumbnailmode=" . cSecurity::escapeString($_REQUEST['thumbnailmode'])), 'right_top', $sess->url("main.php?area=upl&frame=3&path=$path&file=$data"), $data);
374:             }
375:             return $mstr;
376:         }
377: 
378:         if ($field == 5) {
379:             return uplGetFileTypeDescription($data);
380:         }
381: 
382:         if ($field == 2) {
383:             // If this file is an image, try to open
384:             $fileType = strtolower(cFileHandler::getExtension($data));
385:             switch ($fileType) {
386:                 case 'png':
387:                 case 'gif':
388:                 case 'tiff':
389:                 case 'bmp':
390:                 case 'jpeg':
391:                 case 'jpg':
392:                 case 'iff':
393:                 case 'xbm':
394:                 case 'wbmp':
395:                     $frontendURL = cRegistry::getFrontendUrl();
396: 
397:                     $sCacheThumbnail = uplGetThumbnail($data, 150);
398:                     $sCacheName = substr($sCacheThumbnail, strrpos($sCacheThumbnail, '/') + 1, strlen($sCacheThumbnail) - (strrchr($sCacheThumbnail, '/') + 1));
399:                     $sFullPath = $cfgClient[$client]['cache']['path'] . $sCacheName;
400:                     if (cFileHandler::exists($sFullPath)) {
401:                         $aDimensions = getimagesize($sFullPath);
402:                         $iWidth = $aDimensions[0];
403:                         $iHeight = $aDimensions[1];
404:                     } else {
405:                         $iWidth = 0;
406:                         $iHeight = 0;
407:                     }
408: 
409:                     if (cApiDbfs::isDbfs($data)) {
410:                         $href = $frontendURL . 'dbfs.php?file=' . $data;
411:                     } else {
412:                         $href = $frontendURL . $cfgClient[$client]['upload'] . $data;
413:                     }
414:                     $retValue = '<a class="jsZoom" href="' . $href . '">
415:                            <img class="hover" name="smallImage" alt="" src="' . $sCacheThumbnail . '" data-width="' . $iWidth . '" data-height="' . $iHeight . '">
416:                            <img class="preview" name="prevImage" alt="" src="' . $sCacheThumbnail . '">
417:                        </a>';
418:                     return $retValue;
419:                     break;
420:                 default:
421:                     $sCacheThumbnail = uplGetThumbnail($data, 150);
422:                     return '<img class="hover_none" name="smallImage" alt="" src="' . $sCacheThumbnail . '">';
423:             }
424:         }
425: 
426:         return $data;
427:     }
428: 
429:     /**
430:      * @return int $size
431:      */
432:     public function getSize() {
433:         return $this->_size;
434:     }
435: 
436:     /**
437:      * @param int $size
438:      */
439:     public function setSize($size) {
440:         $this->_size = $size;
441:     }
442: 
443: }
444: 
445: uplSyncDirectory($path);
446: 
447: if ($sortby == '') {
448:     $sortby = 3;
449:     $sortmode = 'ASC';
450: }
451: 
452: if ($startpage == '') {
453:     $startpage = 1;
454: }
455: 
456: $thisfile = $sess->url("main.php?idarea=$area&frame=$frame&path=$path&thumbnailmode=$thumbnailmode&appendparameters=$appendparameters");
457: $scrollthisfile = $thisfile . "&sortmode=$sortmode&sortby=$sortby&appendparameters=$appendparameters";
458: 
459: if ($sortby == 3 && $sortmode == 'DESC') {
460:     $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>';
461: } else {
462:     if ($sortby == 3) {
463:         $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>';
464:     } else {
465:         $fnsort = '<a class="gray" href="' . $thisfile . '&sortby=3&sortmode=ASC&startpage=' . $startpage . '">' . i18n("Filename / Description") . '</a>';
466:     }
467: }
468: 
469: if ($sortby == 4 && $sortmode == 'DESC') {
470:     $sizesort = '<a class="gray" href="' . $thisfile . '&sortby=4&sortmode=ASC&startpage=' . $startpage . '">' . i18n("Size") . '<img src="images/sort_down.gif" alt="" border="0"></a>';
471: } else {
472:     if ($sortby == 4) {
473:         $sizesort = '<a class="gray" href="' . $thisfile . '&sortby=4&sortmode=DESC&startpage=' . $startpage . '">' . i18n("Size") . '<img src="images/sort_up.gif" alt="" border="0"></a>';
474:     } else {
475:         $sizesort = '<a class="gray" href="' . $thisfile . '&sortby=4&sortmode=ASC&startpage=' . $startpage . '">' . i18n("Size") . "</a>";
476:     }
477: }
478: 
479: if ($sortby == 5 && $sortmode == 'DESC') {
480:     $typesort = '<a class="gray" href="' . $thisfile . '&sortby=5&sortmode=ASC&startpage=' . $startpage . '">' . i18n("Type") . '<img src="images/sort_down.gif" alt="" border="0"></a>';
481: } else {
482:     if ($sortby == 5) {
483:         $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>';
484:     } else {
485:         $typesort = '<a class="gray" href="' . $thisfile . '&sortby=5&sortmode=ASC&startpage=' . $startpage . '">' . i18n("Type") . "</a>";
486:     }
487: }
488: 
489: // Multiple deletes at top of table
490: if ($perm->have_perm_area_action('upl', 'upl_multidelete') && $bDirectoryIsWritable == true) {
491:     $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;";
492:     $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>';
493: } else {
494:     $sDelete = '';
495: }
496: 
497: if (cApiDbfs::isDbfs($path)) {
498:     $mpath = $path . '/';
499: } else {
500:     $mpath = 'upload/' . $path;
501: }
502: 
503: $sDisplayPath = generateDisplayFilePath($mpath, 85);
504: 
505: $sToolsRow = '<tr>
506:                <th colspan="6" id="cat_navbar">
507:                    <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>
508:                        ' . $sDelete . '
509:                    <div class="toolsRight">
510:                    ' . i18n("Path:") . " " . $sDisplayPath . '
511:                    </div>
512:                </th>
513:            </tr>';
514: $sSpacedRow = '<tr height="10">
515:                    <td colspan="6" class="emptyCell"></td>
516:               </tr>';
517: 
518: // List wraps
519: 
520: $pagerwrap = '<tr>
521:                <th colspan="6" id="cat_navbar">
522:                    <div class="toolsRight">
523:                        <div class="vAlignMiddle">-C-SCROLLLEFT-</div>
524:                        <div class="vAlignMiddle">-C-PAGE-</div>
525:                        <div class="vAlignMiddle">-C-SCROLLRIGHT-</div>
526:                    </div>
527:                    <span class="vAlignMiddle">' . i18n("Files per Page") . ' -C-FILESPERPAGE-</span>
528:                </th>
529:            </tr>';
530: 
531: $startwrap = '<table class="hoverbox generic" cellspacing="0" cellpadding="2" border="0">
532:                ' . $pagerwrap . $sSpacedRow . $sToolsRow . $sSpacedRow . '
533:               <tr>
534:                    <th>' . i18n("Mark") . '</th>
535:                    <th>' . i18n("Preview") . '</th>
536:                    <th width="100%">' . $fnsort . '</th>
537:                    <th>' . $sizesort . '</th>
538:                    <th>' . $typesort . '</th>
539:                    <th>' . i18n("Actions") . '</th>
540:                </tr>';
541: $itemwrap = '<tr>
542:                    <td align="center">%s</td>
543:                    <td align="center">%s</td>
544:                    <td class="vAlignTop nowrap">%s</td>
545:                    <td class="vAlignTop nowrap">%s</td>
546:                    <td class="vAlignTop nowrap">%s</td>
547:                    <td class="vAlignTop nowrap">%s</td>
548:                </tr>';
549: $endwrap = $sSpacedRow . $sToolsRow . $sSpacedRow . $pagerwrap . '</table>';
550: 
551: // Object initializing
552: $list2 = new UploadList($startwrap, $endwrap, $itemwrap);
553: 
554: $uploads = new cApiUploadCollection();
555: 
556: // Fetch data
557: if (substr($path, strlen($path) - 1, 1) != "/") {
558:     if ($path != "") {
559:         $qpath = $path . "/";
560:     } else {
561:         // view the root folder
562:         $qpath = "";
563:     }
564: } else {
565:     $qpath = $path;
566: }
567: 
568: $uploads->select("idclient = '$client' AND dirname = '$qpath'");
569: 
570: $user = new cApiUser($auth->auth['uid']);
571: 
572: if ($thumbnailmode == '') {
573:     $current_mode = $user->getUserProperty('upload_folder_thumbnailmode', md5($path));
574:     if ($current_mode != '') {
575:         $thumbnailmode = $current_mode;
576:     } else {
577:         $thumbnailmode = getEffectiveSetting('backend', 'thumbnailmode', 100);
578:     }
579: }
580: 
581: switch ($thumbnailmode) {
582:     case 10:
583:         $numpics = 10;
584:         break;
585:     case 25:
586:         $numpics = 25;
587:         break;
588:     case 50:
589:         $numpics = 50;
590:         break;
591:     case 100:
592:         $numpics = 100;
593:         break;
594:     case 200:
595:         $numpics = 200;
596:         break;
597:     default:
598:         $thumbnailmode = 100;
599:         $numpics = 15;
600:         break;
601: }
602: 
603: $user->setUserProperty('upload_folder_thumbnailmode', md5($path), $thumbnailmode);
604: 
605: $list2->setResultsPerPage($numpics);
606: 
607: $list2->setSize($thumbnailmode);
608: 
609: $rownum = 0;
610: 
611: $properties = new cApiPropertyCollection();
612: 
613: while ($item = $uploads->next()) {
614: 
615:     // Get name of directory, filename and size of file
616:     $dirname = $item->get('dirname');
617:     $filename = $item->get('filename');
618:     $filesize = $item->get('size');
619: 
620:     // Do not display directories and "filenames" begin with a dot
621:     if (true === cDirHandler::exists($cfgClient[$client]['upl']['path'] . $dirname . $filename) || strpos($filename, ".") === 0) {
622:         continue;
623:     }
624: 
625:     $bAddFile = true;
626: 
627:     if ($appendparameters == 'imagebrowser') {
628:         $restrictvar = 'restrict_' . $appendparameters;
629:         if (array_key_exists($restrictvar, $browserparameters)) {
630:             $fileType = strtolower(cFileHandler::getExtension($filename));
631:             if (count($browserparameters[$restrictvar]) > 0) {
632:                 $bAddFile = false;
633:                 if (in_array($fileType, $browserparameters[$restrictvar])) {
634:                     $bAddFile = true;
635:                 }
636:             }
637:         }
638:     }
639: 
640:     if ($filesize == 0) {
641:         if (cFileHandler::exists($cfgClient[$client]['upl']['path'] . $dirname . $filename)) {
642:             $filesize = filesize($cfgClient[$client]['upl']['path'] . $dirname . $filename);
643:         }
644:     }
645: 
646:     $actions = '';
647: 
648:     $medianame = $properties->getValue('upload', $path . $filename, 'file', 'medianame');
649:     $medianotes = $properties->getValue('upload', $path . $filename, 'file', 'medianotes');
650: 
651:     $todo = new TODOLink('upload', $path . $filename, "File $path$filename", '');
652: 
653:     $proptitle = i18n("Display properties");
654: 
655:     if ($appendparameters == 'imagebrowser' || $appendparameters == 'filebrowser') {
656:         $mstr = '';
657:     } else {
658:         $tmp_mstr = '<a href="javascript:Con.multiLink(\'%s\', \'%s\', \'%s\', \'%s\')">%s</a>';
659:         $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\'">');
660:     }
661: 
662:     $actions = $mstr . $actions;
663: 
664:     $showfilename = $filename;
665: 
666:     $check = new cHTMLCheckbox('fdelete[]', $filename);
667: 
668:     $mark = $check->toHtml(false);
669: 
670:     if ($bAddFile == true) {
671:         // 'bgcolor' is just a placeholder...
672:         $list2->setData($rownum, $mark, $dirname . $filename, $showfilename, $filesize, strtolower(cFileHandler::getExtension($filename)), $todo->render() . $actions);
673:         $rownum++;
674:     }
675: }
676: 
677: if ($rownum == 0) {
678:     header('Location: ' . cRegistry::getBackendUrl() . 'main.php?area=upl_upload&frame=4&path=' . $path . '&contenido=' . $contenido . '&appendparameters=' . $appendparameters);
679: }
680: 
681: if ($sortmode == 'ASC') {
682:     $list2->sort($sortby, SORT_ASC);
683: } else {
684:     $list2->sort($sortby, SORT_DESC);
685: }
686: 
687: if ($startpage < 1) {
688:     $startpage = 1;
689: }
690: 
691: if ($startpage > $list2->getNumPages()) {
692:     $startpage = $list2->getNumPages();
693: }
694: 
695: $list2->setListStart($startpage);
696: 
697: // Create scroller
698: if ($list2->getCurrentPage() > 1) {
699:     $prevpage = '<a href="' . $scrollthisfile . '&startpage=' . ($list2->getCurrentPage() - 1) . '" class="invert_hover">' . i18n("Previous Page") . '</a>';
700: } else {
701:     $prevpage = '&nbsp;';
702: }
703: 
704: if ($list2->getCurrentPage() < $list2->getNumPages()) {
705:     $nextpage = '<a href="' . $scrollthisfile . '&startpage=' . ($list2->getCurrentPage() + 1) . '" class="invert_hover">' . i18n("Next Page") . '</a>';
706: } else {
707:     $nextpage = '&nbsp;';
708: }
709: 
710: // curpage = $list2->getCurrentPage() . " / ". $list2->getNumPages();
711: 
712: if ($list2->getNumPages() > 1) {
713:     $num_pages = $list2->getNumPages();
714: 
715:     $paging_form .= "<script type=\"text/javascript\">
716:        function jumpToPage(select) {
717:            var pagenumber = select.selectedIndex + 1;
718:            url = '" . $sess->url('main.php') . "';
719:            document.location.href = url + '&area=upl&frame=4&appendparameters=$appendparameters&path=$path&sortmode=$sortmode&sortby=$sortby&thumbnailmode=$thumbnailmode&startpage=' + pagenumber;
720:        }
721:    </script>";
722:     $paging_form .= "<select name=\"start_page\" class=\"text_medium\" onChange=\"jumpToPage(this);\">";
723:     for ($i = 1; $i <= $num_pages; $i++) {
724:         if ($i == $startpage) {
725:             $selected = ' selected';
726:         } else {
727:             $selected = '';
728:         }
729:         $paging_form .= "<option value=\"$i\"$selected>$i</option>";
730:     }
731: 
732:     $paging_form .= '</select>';
733: } else {
734:     $paging_form = '1';
735: }
736: $curpage = $paging_form . ' / ' . $list2->getNumPages();
737: 
738: $scroller = $prevpage . $nextpage;
739: $output = $list2->output(true);
740: $output = str_replace('-C-SCROLLLEFT-', $prevpage, $output);
741: $output = str_replace('-C-SCROLLRIGHT-', $nextpage, $output);
742: $output = str_replace('-C-PAGE-', i18n("Page") . ' ' . $curpage, $output);
743: 
744: $select = new cHTMLSelectElement('thumbnailmode');
745: 
746: $values = array(
747:     10 => '10',
748:     25 => '25',
749:     50 => '50',
750:     100 => '100',
751:     200 => '200'
752: );
753: 
754: $select->autoFill($values);
755: 
756: $select->setDefault($thumbnailmode);
757: $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;");
758: 
759: $topbar = $select->render() . '<input class="vAlignMiddle tableElement" type="image" onmouseover="this.style.cursor=\'pointer\'" src="images/submit.gif">';
760: 
761: $output = str_replace('-C-FILESPERPAGE-', $topbar, $output);
762: 
763: $delform = new cHTMLForm('del');
764: $delform->setVar('area', $area);
765: $delform->setVar('action', '');
766: $delform->setVar('startpage', $startpage);
767: $delform->setVar('thumbnailmode', $thumbnailmode);
768: $delform->setVar('sortmode', $sortmode);
769: $delform->setVar('sortby', $sortby);
770: $delform->setVar('appendparameters', $appendparameters);
771: $delform->setVar('path', $path);
772: $delform->setVar('frame', 4);
773: // Table with (preview) images
774: $delform->appendContent($output);
775: 
776: $page->addScript($sess->url('iZoom.js.php'));
777: 
778: if ($bDirectoryIsWritable == false) {
779:     $page->displayError(i18n("Directory not writable") . ' (' . $cfgClient[$client]['upl']['path'] . $path . ')');
780: }
781: 
782: $page->setContent(array(
783:     $delform,
784:     $jsScript
785: ));
786: 
787: $page->render();
788: 
CMS CONTENIDO 4.9.11 API documentation generated by ApiGen 2.8.0